@getpara/core-sdk 1.6.0 → 1.7.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.
- package/dist/cjs/index.js +67 -26
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +67 -26
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/ParaCore.d.ts +8 -3
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/types/params.d.ts +8 -1
- package/dist/types/types/wallet.d.ts +3 -0
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -1104,13 +1104,14 @@ var TransactionReviewTimeout = class extends Error {
|
|
|
1104
1104
|
};
|
|
1105
1105
|
|
|
1106
1106
|
// src/constants.ts
|
|
1107
|
-
var PARA_CORE_VERSION = '1.
|
|
1107
|
+
var PARA_CORE_VERSION = '1.7.0';
|
|
1108
1108
|
var PREFIX = "@CAPSULE/";
|
|
1109
1109
|
var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
1110
1110
|
var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
1111
1111
|
var LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
|
|
1112
1112
|
var LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
|
|
1113
1113
|
var LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
|
|
1114
|
+
var LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = `${PREFIX}externalWalletUserId`;
|
|
1114
1115
|
var LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
|
|
1115
1116
|
var LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
|
|
1116
1117
|
var LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
|
|
@@ -1413,16 +1414,23 @@ var _ParaCore = class _ParaCore {
|
|
|
1413
1414
|
setupListeners.bind(this)();
|
|
1414
1415
|
}
|
|
1415
1416
|
get isEmail() {
|
|
1416
|
-
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
|
|
1417
|
+
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1417
1418
|
}
|
|
1418
1419
|
get isPhone() {
|
|
1419
|
-
return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId;
|
|
1420
|
+
return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1420
1421
|
}
|
|
1421
1422
|
get isFarcaster() {
|
|
1422
|
-
return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId;
|
|
1423
|
+
return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1423
1424
|
}
|
|
1424
1425
|
get isTelegram() {
|
|
1425
|
-
return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername;
|
|
1426
|
+
return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.externalWalletWithParaAuth;
|
|
1427
|
+
}
|
|
1428
|
+
get externalWalletWithParaAuth() {
|
|
1429
|
+
const externalWallets = Object.values(this.externalWallets);
|
|
1430
|
+
return externalWallets.find((w) => w.isExternalWithParaAuth);
|
|
1431
|
+
}
|
|
1432
|
+
get isExternalWalletAuth() {
|
|
1433
|
+
return !!this.externalWalletWithParaAuth && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
|
|
1426
1434
|
}
|
|
1427
1435
|
get currentWalletIdsArray() {
|
|
1428
1436
|
return this.supportedWalletTypes.reduce((acc, { type }) => {
|
|
@@ -1530,7 +1538,11 @@ var _ParaCore = class _ParaCore {
|
|
|
1530
1538
|
));
|
|
1531
1539
|
}
|
|
1532
1540
|
isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
|
|
1541
|
+
var _a;
|
|
1533
1542
|
let error;
|
|
1543
|
+
if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
|
|
1544
|
+
return true;
|
|
1545
|
+
}
|
|
1534
1546
|
if (!this.wallets[walletId]) {
|
|
1535
1547
|
error = `wallet with id ${walletId} does not exist`;
|
|
1536
1548
|
} else {
|
|
@@ -1543,8 +1555,8 @@ var _ParaCore = class _ParaCore {
|
|
|
1543
1555
|
} else if (!this.isWalletSupported(wallet)) {
|
|
1544
1556
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
|
|
1545
1557
|
} else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
|
|
1546
|
-
var
|
|
1547
|
-
return (_b = (
|
|
1558
|
+
var _a2, _b;
|
|
1559
|
+
return (_b = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b.includes(walletId);
|
|
1548
1560
|
}))) {
|
|
1549
1561
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
|
|
1550
1562
|
} else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
|
|
@@ -1611,7 +1623,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1611
1623
|
}
|
|
1612
1624
|
constructPortalUrl(_0) {
|
|
1613
1625
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
1614
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1626
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1615
1627
|
const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
|
|
1616
1628
|
let path;
|
|
1617
1629
|
switch (type) {
|
|
@@ -1663,7 +1675,10 @@ var _ParaCore = class _ParaCore {
|
|
|
1663
1675
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
1664
1676
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
|
|
1665
1677
|
supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
|
|
1666
|
-
}, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {})
|
|
1678
|
+
}, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}), opts.authType === "externalWallet" ? {
|
|
1679
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
1680
|
+
externalWalletAddress: (_n = this.externalWalletWithParaAuth) == null ? void 0 : _n.id
|
|
1681
|
+
} : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
|
|
1667
1682
|
encryptionKey: opts.loginEncryptionPublicKey,
|
|
1668
1683
|
newDeviceSessionLookupId: opts.newDeviceSessionId,
|
|
1669
1684
|
newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
|
|
@@ -1817,7 +1832,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1817
1832
|
* @param externalType - Type of external wallet to set.
|
|
1818
1833
|
*/
|
|
1819
1834
|
setExternalWallet(_0) {
|
|
1820
|
-
return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
|
|
1835
|
+
return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
|
|
1821
1836
|
this.externalWallets = {
|
|
1822
1837
|
[address]: {
|
|
1823
1838
|
id: address,
|
|
@@ -1825,6 +1840,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1825
1840
|
type,
|
|
1826
1841
|
name: provider,
|
|
1827
1842
|
isExternal: true,
|
|
1843
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
1828
1844
|
signer: ""
|
|
1829
1845
|
}
|
|
1830
1846
|
};
|
|
@@ -2012,18 +2028,18 @@ var _ParaCore = class _ParaCore {
|
|
|
2012
2028
|
return wallet;
|
|
2013
2029
|
}
|
|
2014
2030
|
findWallet(idOrAddress, overrideType, filter = {}) {
|
|
2015
|
-
var
|
|
2016
|
-
if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
2031
|
+
var _a, _c, _d;
|
|
2032
|
+
if (!this.isExternalWalletAuth && !idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
2017
2033
|
return Object.values(this.externalWallets)[0];
|
|
2018
2034
|
}
|
|
2019
|
-
if (this.externalWallets[idOrAddress]) {
|
|
2035
|
+
if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
|
|
2020
2036
|
return this.externalWallets[idOrAddress];
|
|
2021
2037
|
}
|
|
2022
2038
|
try {
|
|
2023
2039
|
const walletId = this.findWalletId(idOrAddress, filter);
|
|
2024
2040
|
if (walletId && !!this.wallets[walletId]) {
|
|
2025
|
-
const
|
|
2026
|
-
const type = (
|
|
2041
|
+
const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
|
|
2042
|
+
const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
|
|
2027
2043
|
return __spreadProps(__spreadValues({}, wallet), {
|
|
2028
2044
|
type: import_user_management_client5.WalletType[type]
|
|
2029
2045
|
});
|
|
@@ -2307,7 +2323,8 @@ var _ParaCore = class _ParaCore {
|
|
|
2307
2323
|
externalAddress: wallet.address,
|
|
2308
2324
|
type: wallet.type,
|
|
2309
2325
|
externalWalletProvider: wallet.provider,
|
|
2310
|
-
|
|
2326
|
+
// If the wallet isn't using full Para auth we want to track the login here
|
|
2327
|
+
shouldTrackUser: !wallet.withFullParaAuth
|
|
2311
2328
|
});
|
|
2312
2329
|
yield this.setExternalWallet(wallet);
|
|
2313
2330
|
yield this.setUserId(res.userId);
|
|
@@ -2315,10 +2332,10 @@ var _ParaCore = class _ParaCore {
|
|
|
2315
2332
|
});
|
|
2316
2333
|
}
|
|
2317
2334
|
/**
|
|
2318
|
-
* Returns whether or not the user is connected with an external wallet.
|
|
2335
|
+
* Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
|
|
2319
2336
|
*/
|
|
2320
2337
|
isUsingExternalWallet() {
|
|
2321
|
-
return !!Object.keys(this.externalWallets).length;
|
|
2338
|
+
return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
|
|
2322
2339
|
}
|
|
2323
2340
|
/**
|
|
2324
2341
|
* Passes the email code obtained from the user for verification.
|
|
@@ -2340,7 +2357,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2340
2357
|
cosmosSigner
|
|
2341
2358
|
}) {
|
|
2342
2359
|
yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
|
|
2343
|
-
return this.getSetUpBiometricsURL();
|
|
2360
|
+
return this.getSetUpBiometricsURL({ authType: "externalWallet" });
|
|
2344
2361
|
});
|
|
2345
2362
|
}
|
|
2346
2363
|
/**
|
|
@@ -2594,15 +2611,20 @@ var _ParaCore = class _ParaCore {
|
|
|
2594
2611
|
*/
|
|
2595
2612
|
getUserBiometricLocationHints() {
|
|
2596
2613
|
return __async(this, null, function* () {
|
|
2597
|
-
|
|
2598
|
-
|
|
2614
|
+
var _a;
|
|
2615
|
+
if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
|
|
2616
|
+
throw new Error(
|
|
2617
|
+
"one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
|
|
2618
|
+
);
|
|
2599
2619
|
}
|
|
2600
2620
|
return yield this.ctx.client.getBiometricLocationHints({
|
|
2601
2621
|
email: this.email,
|
|
2602
2622
|
phone: this.phone,
|
|
2603
2623
|
countryCode: this.countryCode,
|
|
2604
2624
|
farcasterUsername: this.farcasterUsername,
|
|
2605
|
-
telegramUserId: this.telegramUserId
|
|
2625
|
+
telegramUserId: this.telegramUserId,
|
|
2626
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
2627
|
+
externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
|
|
2606
2628
|
});
|
|
2607
2629
|
});
|
|
2608
2630
|
}
|
|
@@ -2714,7 +2736,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2714
2736
|
waitForAccountCreation() {
|
|
2715
2737
|
return __async(this, arguments, function* ({ popupWindow } = {}) {
|
|
2716
2738
|
yield this.touchSession();
|
|
2717
|
-
this.
|
|
2739
|
+
if (!this.isExternalWalletAuth) {
|
|
2740
|
+
this.externalWallets = {};
|
|
2741
|
+
}
|
|
2718
2742
|
this.isAwaitingAccountCreation = true;
|
|
2719
2743
|
while (this.isAwaitingAccountCreation) {
|
|
2720
2744
|
try {
|
|
@@ -2882,7 +2906,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2882
2906
|
skipSessionRefresh = false
|
|
2883
2907
|
} = {}) {
|
|
2884
2908
|
var _a;
|
|
2885
|
-
this.
|
|
2909
|
+
if (!this.isExternalWalletAuth) {
|
|
2910
|
+
this.externalWallets = {};
|
|
2911
|
+
}
|
|
2886
2912
|
this.isAwaitingLogin = true;
|
|
2887
2913
|
while (this.isAwaitingLogin) {
|
|
2888
2914
|
try {
|
|
@@ -3808,13 +3834,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3808
3834
|
}
|
|
3809
3835
|
/**
|
|
3810
3836
|
* Serialize the current session for import by another Para instance.
|
|
3837
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
3811
3838
|
* @returns {string} the serialized session
|
|
3812
3839
|
*/
|
|
3813
|
-
exportSession() {
|
|
3840
|
+
exportSession({ excludeSigners } = {}) {
|
|
3814
3841
|
const sessionInfo = {
|
|
3815
3842
|
email: this.email,
|
|
3816
3843
|
userId: this.userId,
|
|
3817
|
-
wallets: this.wallets,
|
|
3844
|
+
wallets: structuredClone(this.wallets),
|
|
3818
3845
|
currentWalletIds: this.currentWalletIds,
|
|
3819
3846
|
sessionCookie: this.sessionCookie,
|
|
3820
3847
|
phone: this.phone,
|
|
@@ -3823,6 +3850,11 @@ var _ParaCore = class _ParaCore {
|
|
|
3823
3850
|
farcasterUsername: this.farcasterUsername,
|
|
3824
3851
|
externalWallets: this.externalWallets
|
|
3825
3852
|
};
|
|
3853
|
+
if (excludeSigners) {
|
|
3854
|
+
for (const wallet of Object.values(sessionInfo.wallets)) {
|
|
3855
|
+
delete wallet.signer;
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3826
3858
|
return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
|
|
3827
3859
|
}
|
|
3828
3860
|
/**
|
|
@@ -3946,6 +3978,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3946
3978
|
}),
|
|
3947
3979
|
{}
|
|
3948
3980
|
);
|
|
3981
|
+
const redactedExternalWallets = Object.keys(this.externalWallets).reduce(
|
|
3982
|
+
(acc, walletId) => __spreadProps(__spreadValues({}, acc), {
|
|
3983
|
+
[walletId]: __spreadProps(__spreadValues({}, this.externalWallets[walletId]), {
|
|
3984
|
+
signer: this.externalWallets[walletId].signer ? "[REDACTED]" : void 0
|
|
3985
|
+
})
|
|
3986
|
+
}),
|
|
3987
|
+
{}
|
|
3988
|
+
);
|
|
3949
3989
|
const obj = {
|
|
3950
3990
|
supportedWalletTypes: this.supportedWalletTypes,
|
|
3951
3991
|
cosmosPrefix: this.cosmosPrefix,
|
|
@@ -3958,6 +3998,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3958
3998
|
pregenIds: this.pregenIds,
|
|
3959
3999
|
currentWalletIds: this.currentWalletIds,
|
|
3960
4000
|
wallets: redactedWallets,
|
|
4001
|
+
externalWallets: redactedExternalWallets,
|
|
3961
4002
|
loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
|
|
3962
4003
|
ctx: {
|
|
3963
4004
|
apiKey: this.ctx.apiKey,
|
package/dist/cjs/index.js.br
CHANGED
|
Binary file
|
package/dist/cjs/index.js.gz
CHANGED
|
Binary file
|
package/dist/esm/index.js
CHANGED
|
@@ -1021,13 +1021,14 @@ var TransactionReviewTimeout = class extends Error {
|
|
|
1021
1021
|
};
|
|
1022
1022
|
|
|
1023
1023
|
// src/constants.ts
|
|
1024
|
-
var PARA_CORE_VERSION = '1.
|
|
1024
|
+
var PARA_CORE_VERSION = '1.7.0';
|
|
1025
1025
|
var PREFIX = "@CAPSULE/";
|
|
1026
1026
|
var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
1027
1027
|
var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
1028
1028
|
var LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
|
|
1029
1029
|
var LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
|
|
1030
1030
|
var LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
|
|
1031
|
+
var LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = `${PREFIX}externalWalletUserId`;
|
|
1031
1032
|
var LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
|
|
1032
1033
|
var LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
|
|
1033
1034
|
var LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
|
|
@@ -1330,16 +1331,23 @@ var _ParaCore = class _ParaCore {
|
|
|
1330
1331
|
setupListeners.bind(this)();
|
|
1331
1332
|
}
|
|
1332
1333
|
get isEmail() {
|
|
1333
|
-
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
|
|
1334
|
+
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1334
1335
|
}
|
|
1335
1336
|
get isPhone() {
|
|
1336
|
-
return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId;
|
|
1337
|
+
return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1337
1338
|
}
|
|
1338
1339
|
get isFarcaster() {
|
|
1339
|
-
return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId;
|
|
1340
|
+
return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
1340
1341
|
}
|
|
1341
1342
|
get isTelegram() {
|
|
1342
|
-
return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername;
|
|
1343
|
+
return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.externalWalletWithParaAuth;
|
|
1344
|
+
}
|
|
1345
|
+
get externalWalletWithParaAuth() {
|
|
1346
|
+
const externalWallets = Object.values(this.externalWallets);
|
|
1347
|
+
return externalWallets.find((w) => w.isExternalWithParaAuth);
|
|
1348
|
+
}
|
|
1349
|
+
get isExternalWalletAuth() {
|
|
1350
|
+
return !!this.externalWalletWithParaAuth && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
|
|
1343
1351
|
}
|
|
1344
1352
|
get currentWalletIdsArray() {
|
|
1345
1353
|
return this.supportedWalletTypes.reduce((acc, { type }) => {
|
|
@@ -1447,7 +1455,11 @@ var _ParaCore = class _ParaCore {
|
|
|
1447
1455
|
));
|
|
1448
1456
|
}
|
|
1449
1457
|
isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
|
|
1458
|
+
var _a;
|
|
1450
1459
|
let error;
|
|
1460
|
+
if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
|
|
1461
|
+
return true;
|
|
1462
|
+
}
|
|
1451
1463
|
if (!this.wallets[walletId]) {
|
|
1452
1464
|
error = `wallet with id ${walletId} does not exist`;
|
|
1453
1465
|
} else {
|
|
@@ -1460,8 +1472,8 @@ var _ParaCore = class _ParaCore {
|
|
|
1460
1472
|
} else if (!this.isWalletSupported(wallet)) {
|
|
1461
1473
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
|
|
1462
1474
|
} else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
|
|
1463
|
-
var
|
|
1464
|
-
return (_b = (
|
|
1475
|
+
var _a2, _b;
|
|
1476
|
+
return (_b = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b.includes(walletId);
|
|
1465
1477
|
}))) {
|
|
1466
1478
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
|
|
1467
1479
|
} else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
|
|
@@ -1528,7 +1540,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1528
1540
|
}
|
|
1529
1541
|
constructPortalUrl(_0) {
|
|
1530
1542
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
1531
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1543
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1532
1544
|
const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
|
|
1533
1545
|
let path;
|
|
1534
1546
|
switch (type) {
|
|
@@ -1580,7 +1592,10 @@ var _ParaCore = class _ParaCore {
|
|
|
1580
1592
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
1581
1593
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
|
|
1582
1594
|
supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
|
|
1583
|
-
}, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {})
|
|
1595
|
+
}, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}), opts.authType === "externalWallet" ? {
|
|
1596
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
1597
|
+
externalWalletAddress: (_n = this.externalWalletWithParaAuth) == null ? void 0 : _n.id
|
|
1598
|
+
} : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
|
|
1584
1599
|
encryptionKey: opts.loginEncryptionPublicKey,
|
|
1585
1600
|
newDeviceSessionLookupId: opts.newDeviceSessionId,
|
|
1586
1601
|
newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
|
|
@@ -1734,7 +1749,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1734
1749
|
* @param externalType - Type of external wallet to set.
|
|
1735
1750
|
*/
|
|
1736
1751
|
setExternalWallet(_0) {
|
|
1737
|
-
return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
|
|
1752
|
+
return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
|
|
1738
1753
|
this.externalWallets = {
|
|
1739
1754
|
[address]: {
|
|
1740
1755
|
id: address,
|
|
@@ -1742,6 +1757,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1742
1757
|
type,
|
|
1743
1758
|
name: provider,
|
|
1744
1759
|
isExternal: true,
|
|
1760
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
1745
1761
|
signer: ""
|
|
1746
1762
|
}
|
|
1747
1763
|
};
|
|
@@ -1929,18 +1945,18 @@ var _ParaCore = class _ParaCore {
|
|
|
1929
1945
|
return wallet;
|
|
1930
1946
|
}
|
|
1931
1947
|
findWallet(idOrAddress, overrideType, filter = {}) {
|
|
1932
|
-
var
|
|
1933
|
-
if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
1948
|
+
var _a, _c, _d;
|
|
1949
|
+
if (!this.isExternalWalletAuth && !idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
1934
1950
|
return Object.values(this.externalWallets)[0];
|
|
1935
1951
|
}
|
|
1936
|
-
if (this.externalWallets[idOrAddress]) {
|
|
1952
|
+
if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
|
|
1937
1953
|
return this.externalWallets[idOrAddress];
|
|
1938
1954
|
}
|
|
1939
1955
|
try {
|
|
1940
1956
|
const walletId = this.findWalletId(idOrAddress, filter);
|
|
1941
1957
|
if (walletId && !!this.wallets[walletId]) {
|
|
1942
|
-
const
|
|
1943
|
-
const type = (
|
|
1958
|
+
const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
|
|
1959
|
+
const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
|
|
1944
1960
|
return __spreadProps(__spreadValues({}, wallet), {
|
|
1945
1961
|
type: WalletType2[type]
|
|
1946
1962
|
});
|
|
@@ -2224,7 +2240,8 @@ var _ParaCore = class _ParaCore {
|
|
|
2224
2240
|
externalAddress: wallet.address,
|
|
2225
2241
|
type: wallet.type,
|
|
2226
2242
|
externalWalletProvider: wallet.provider,
|
|
2227
|
-
|
|
2243
|
+
// If the wallet isn't using full Para auth we want to track the login here
|
|
2244
|
+
shouldTrackUser: !wallet.withFullParaAuth
|
|
2228
2245
|
});
|
|
2229
2246
|
yield this.setExternalWallet(wallet);
|
|
2230
2247
|
yield this.setUserId(res.userId);
|
|
@@ -2232,10 +2249,10 @@ var _ParaCore = class _ParaCore {
|
|
|
2232
2249
|
});
|
|
2233
2250
|
}
|
|
2234
2251
|
/**
|
|
2235
|
-
* Returns whether or not the user is connected with an external wallet.
|
|
2252
|
+
* Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
|
|
2236
2253
|
*/
|
|
2237
2254
|
isUsingExternalWallet() {
|
|
2238
|
-
return !!Object.keys(this.externalWallets).length;
|
|
2255
|
+
return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
|
|
2239
2256
|
}
|
|
2240
2257
|
/**
|
|
2241
2258
|
* Passes the email code obtained from the user for verification.
|
|
@@ -2257,7 +2274,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2257
2274
|
cosmosSigner
|
|
2258
2275
|
}) {
|
|
2259
2276
|
yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
|
|
2260
|
-
return this.getSetUpBiometricsURL();
|
|
2277
|
+
return this.getSetUpBiometricsURL({ authType: "externalWallet" });
|
|
2261
2278
|
});
|
|
2262
2279
|
}
|
|
2263
2280
|
/**
|
|
@@ -2511,15 +2528,20 @@ var _ParaCore = class _ParaCore {
|
|
|
2511
2528
|
*/
|
|
2512
2529
|
getUserBiometricLocationHints() {
|
|
2513
2530
|
return __async(this, null, function* () {
|
|
2514
|
-
|
|
2515
|
-
|
|
2531
|
+
var _a;
|
|
2532
|
+
if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
|
|
2533
|
+
throw new Error(
|
|
2534
|
+
"one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
|
|
2535
|
+
);
|
|
2516
2536
|
}
|
|
2517
2537
|
return yield this.ctx.client.getBiometricLocationHints({
|
|
2518
2538
|
email: this.email,
|
|
2519
2539
|
phone: this.phone,
|
|
2520
2540
|
countryCode: this.countryCode,
|
|
2521
2541
|
farcasterUsername: this.farcasterUsername,
|
|
2522
|
-
telegramUserId: this.telegramUserId
|
|
2542
|
+
telegramUserId: this.telegramUserId,
|
|
2543
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
2544
|
+
externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
|
|
2523
2545
|
});
|
|
2524
2546
|
});
|
|
2525
2547
|
}
|
|
@@ -2631,7 +2653,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2631
2653
|
waitForAccountCreation() {
|
|
2632
2654
|
return __async(this, arguments, function* ({ popupWindow } = {}) {
|
|
2633
2655
|
yield this.touchSession();
|
|
2634
|
-
this.
|
|
2656
|
+
if (!this.isExternalWalletAuth) {
|
|
2657
|
+
this.externalWallets = {};
|
|
2658
|
+
}
|
|
2635
2659
|
this.isAwaitingAccountCreation = true;
|
|
2636
2660
|
while (this.isAwaitingAccountCreation) {
|
|
2637
2661
|
try {
|
|
@@ -2799,7 +2823,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2799
2823
|
skipSessionRefresh = false
|
|
2800
2824
|
} = {}) {
|
|
2801
2825
|
var _a;
|
|
2802
|
-
this.
|
|
2826
|
+
if (!this.isExternalWalletAuth) {
|
|
2827
|
+
this.externalWallets = {};
|
|
2828
|
+
}
|
|
2803
2829
|
this.isAwaitingLogin = true;
|
|
2804
2830
|
while (this.isAwaitingLogin) {
|
|
2805
2831
|
try {
|
|
@@ -3725,13 +3751,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3725
3751
|
}
|
|
3726
3752
|
/**
|
|
3727
3753
|
* Serialize the current session for import by another Para instance.
|
|
3754
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
3728
3755
|
* @returns {string} the serialized session
|
|
3729
3756
|
*/
|
|
3730
|
-
exportSession() {
|
|
3757
|
+
exportSession({ excludeSigners } = {}) {
|
|
3731
3758
|
const sessionInfo = {
|
|
3732
3759
|
email: this.email,
|
|
3733
3760
|
userId: this.userId,
|
|
3734
|
-
wallets: this.wallets,
|
|
3761
|
+
wallets: structuredClone(this.wallets),
|
|
3735
3762
|
currentWalletIds: this.currentWalletIds,
|
|
3736
3763
|
sessionCookie: this.sessionCookie,
|
|
3737
3764
|
phone: this.phone,
|
|
@@ -3740,6 +3767,11 @@ var _ParaCore = class _ParaCore {
|
|
|
3740
3767
|
farcasterUsername: this.farcasterUsername,
|
|
3741
3768
|
externalWallets: this.externalWallets
|
|
3742
3769
|
};
|
|
3770
|
+
if (excludeSigners) {
|
|
3771
|
+
for (const wallet of Object.values(sessionInfo.wallets)) {
|
|
3772
|
+
delete wallet.signer;
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3743
3775
|
return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
|
|
3744
3776
|
}
|
|
3745
3777
|
/**
|
|
@@ -3863,6 +3895,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3863
3895
|
}),
|
|
3864
3896
|
{}
|
|
3865
3897
|
);
|
|
3898
|
+
const redactedExternalWallets = Object.keys(this.externalWallets).reduce(
|
|
3899
|
+
(acc, walletId) => __spreadProps(__spreadValues({}, acc), {
|
|
3900
|
+
[walletId]: __spreadProps(__spreadValues({}, this.externalWallets[walletId]), {
|
|
3901
|
+
signer: this.externalWallets[walletId].signer ? "[REDACTED]" : void 0
|
|
3902
|
+
})
|
|
3903
|
+
}),
|
|
3904
|
+
{}
|
|
3905
|
+
);
|
|
3866
3906
|
const obj = {
|
|
3867
3907
|
supportedWalletTypes: this.supportedWalletTypes,
|
|
3868
3908
|
cosmosPrefix: this.cosmosPrefix,
|
|
@@ -3875,6 +3915,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3875
3915
|
pregenIds: this.pregenIds,
|
|
3876
3916
|
currentWalletIds: this.currentWalletIds,
|
|
3877
3917
|
wallets: redactedWallets,
|
|
3918
|
+
externalWallets: redactedExternalWallets,
|
|
3878
3919
|
loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
|
|
3879
3920
|
ctx: {
|
|
3880
3921
|
apiKey: this.ctx.apiKey,
|
package/dist/esm/index.js.br
CHANGED
|
Binary file
|
package/dist/esm/index.js.gz
CHANGED
|
Binary file
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare abstract class ParaCore {
|
|
|
22
22
|
get isPhone(): boolean;
|
|
23
23
|
get isFarcaster(): boolean;
|
|
24
24
|
get isTelegram(): boolean;
|
|
25
|
+
get externalWalletWithParaAuth(): Wallet | undefined;
|
|
26
|
+
get isExternalWalletAuth(): boolean;
|
|
25
27
|
/**
|
|
26
28
|
* 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.
|
|
27
29
|
*/
|
|
@@ -214,7 +216,7 @@ export declare abstract class ParaCore {
|
|
|
214
216
|
* @param externalAddress - External wallet address to set.
|
|
215
217
|
* @param externalType - Type of external wallet to set.
|
|
216
218
|
*/
|
|
217
|
-
setExternalWallet({ address, type, provider, addressBech32 }: ExternalWalletInfo): Promise<void>;
|
|
219
|
+
setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth }: ExternalWalletInfo): Promise<void>;
|
|
218
220
|
/**
|
|
219
221
|
* Sets the user id associated with the `ParaCore` instance.
|
|
220
222
|
* @param userId - User id to set.
|
|
@@ -391,7 +393,7 @@ export declare abstract class ParaCore {
|
|
|
391
393
|
*/
|
|
392
394
|
externalWalletLogin(wallet: ExternalWalletInfo): Promise<ExternalWalletLoginRes>;
|
|
393
395
|
/**
|
|
394
|
-
* Returns whether or not the user is connected with an external wallet.
|
|
396
|
+
* Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
|
|
395
397
|
*/
|
|
396
398
|
protected isUsingExternalWallet(): boolean;
|
|
397
399
|
/**
|
|
@@ -912,9 +914,12 @@ export declare abstract class ParaCore {
|
|
|
912
914
|
keepSessionAlive(): Promise<boolean>;
|
|
913
915
|
/**
|
|
914
916
|
* Serialize the current session for import by another Para instance.
|
|
917
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
915
918
|
* @returns {string} the serialized session
|
|
916
919
|
*/
|
|
917
|
-
exportSession(
|
|
920
|
+
exportSession({ excludeSigners }?: {
|
|
921
|
+
excludeSigners?: boolean;
|
|
922
|
+
}): string;
|
|
918
923
|
/**
|
|
919
924
|
* Imports a session serialized by another Para instance.
|
|
920
925
|
* @param {string} serializedInstanceBase64 the serialized session
|
|
@@ -5,6 +5,7 @@ export declare const LOCAL_STORAGE_PHONE: string;
|
|
|
5
5
|
export declare const LOCAL_STORAGE_COUNTRY_CODE: string;
|
|
6
6
|
export declare const LOCAL_STORAGE_FARCASTER_USERNAME: string;
|
|
7
7
|
export declare const LOCAL_STORAGE_TELEGRAM_USER_ID: string;
|
|
8
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: string;
|
|
8
9
|
export declare const LOCAL_STORAGE_USER_ID: string;
|
|
9
10
|
export declare const LOCAL_STORAGE_ED25519_WALLETS: string;
|
|
10
11
|
export declare const LOCAL_STORAGE_WALLETS: string;
|
|
@@ -7,7 +7,14 @@ export type ExternalWalletInfo = {
|
|
|
7
7
|
type: ExternalWalletType;
|
|
8
8
|
provider?: string;
|
|
9
9
|
addressBech32?: string;
|
|
10
|
-
|
|
10
|
+
ensName?: string | null;
|
|
11
|
+
ensAvatar?: string | null;
|
|
12
|
+
withFullParaAuth?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type VerifyExternalWallet = {
|
|
15
|
+
signedMessage: string;
|
|
16
|
+
cosmosPublicKeyHex?: string;
|
|
17
|
+
cosmosSigner?: string;
|
|
11
18
|
};
|
|
12
19
|
export type PortalUrlOptions = {
|
|
13
20
|
params?: Record<string, string | undefined | null>;
|
|
@@ -20,6 +20,9 @@ export interface Wallet {
|
|
|
20
20
|
lastUsedPartner?: PartnerEntity;
|
|
21
21
|
lastUsedPartnerId?: string;
|
|
22
22
|
isExternal?: boolean;
|
|
23
|
+
ensName?: string | null;
|
|
24
|
+
ensAvatar?: string | null;
|
|
25
|
+
isExternalWithParaAuth?: boolean;
|
|
23
26
|
}
|
|
24
27
|
/** @deprecated */
|
|
25
28
|
export declare enum PregenIdentifierType {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@celo/utils": "^8.0.0",
|
|
11
11
|
"@cosmjs/encoding": "^0.32.4",
|
|
12
|
-
"@getpara/user-management-client": "1.
|
|
12
|
+
"@getpara/user-management-client": "1.7.0",
|
|
13
13
|
"@noble/hashes": "^1.5.0",
|
|
14
14
|
"base64url": "^3.0.1",
|
|
15
15
|
"ethereumjs-util": "7.1.5",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"require": "./dist/cjs/index.js"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "241b03ee3d3502af3b8d702dabd615b266da10ae"
|
|
44
44
|
}
|