@getpara/core-sdk 2.0.0-alpha.64 → 2.0.0-alpha.65
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 +133 -18
- package/dist/cjs/constants.js +1 -4
- package/dist/cjs/transmission/transmissionUtils.js +4 -3
- package/dist/cjs/types/coreApi.js +2 -1
- package/dist/cjs/types/popup.js +1 -0
- package/dist/cjs/utils/window.js +1 -1
- package/dist/esm/ParaCore.js +133 -18
- package/dist/esm/constants.js +1 -3
- package/dist/esm/transmission/transmissionUtils.js +4 -3
- package/dist/esm/types/coreApi.js +2 -1
- package/dist/esm/types/popup.js +1 -0
- package/dist/esm/utils/window.js +1 -1
- package/dist/types/ParaCore.d.ts +5 -4
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/coreApi.d.ts +11 -1
- package/dist/types/types/methods.d.ts +1 -1
- package/dist/types/types/popup.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +1 -0
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -116,7 +116,7 @@ const _ParaCore = class _ParaCore {
|
|
|
116
116
|
__privateAdd(this, _ParaCore_instances);
|
|
117
117
|
this.popupWindow = null;
|
|
118
118
|
__privateAdd(this, _authInfo);
|
|
119
|
-
|
|
119
|
+
this.isSwitchingWallets = false;
|
|
120
120
|
this.isNativePasskey = false;
|
|
121
121
|
this.isReady = false;
|
|
122
122
|
this.accountLinkInProgress = void 0;
|
|
@@ -776,7 +776,8 @@ const _ParaCore = class _ParaCore {
|
|
|
776
776
|
isTelegramLogin,
|
|
777
777
|
isFarcasterLogin,
|
|
778
778
|
isAddNewCredential,
|
|
779
|
-
isSwitchWallets
|
|
779
|
+
isSwitchWallets,
|
|
780
|
+
isExportPrivateKey
|
|
780
781
|
] = [
|
|
781
782
|
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
782
783
|
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
|
|
@@ -786,7 +787,8 @@ const _ParaCore = class _ParaCore {
|
|
|
786
787
|
["telegramLogin", "telegramLoginVerify"].includes(type),
|
|
787
788
|
type === "loginFarcaster",
|
|
788
789
|
type === "addNewCredential",
|
|
789
|
-
type === "switchWallets"
|
|
790
|
+
type === "switchWallets",
|
|
791
|
+
type === "exportPrivateKey"
|
|
790
792
|
];
|
|
791
793
|
if (isOAuth && !opts.oAuthMethod) {
|
|
792
794
|
throw new Error("oAuthMethod is required for oAuth portal URLs");
|
|
@@ -795,7 +797,7 @@ const _ParaCore = class _ParaCore {
|
|
|
795
797
|
this.assertIsAuthSet();
|
|
796
798
|
}
|
|
797
799
|
let sessionId = opts.sessionId;
|
|
798
|
-
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin) && !sessionId) {
|
|
800
|
+
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin || isExportPrivateKey) && !sessionId) {
|
|
799
801
|
const session = yield this.touchSession(true);
|
|
800
802
|
sessionId = session.sessionId;
|
|
801
803
|
}
|
|
@@ -869,6 +871,10 @@ const _ParaCore = class _ParaCore {
|
|
|
869
871
|
path = "/auth/add-new-credential";
|
|
870
872
|
break;
|
|
871
873
|
}
|
|
874
|
+
case "exportPrivateKey": {
|
|
875
|
+
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
872
878
|
default: {
|
|
873
879
|
throw new Error(`invalid URL type ${type}`);
|
|
874
880
|
}
|
|
@@ -901,12 +907,12 @@ const _ParaCore = class _ParaCore {
|
|
|
901
907
|
portalTextColor: this.portalTextColor,
|
|
902
908
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
903
909
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
904
|
-
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets) ? __spreadProps(__spreadValues({
|
|
910
|
+
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
905
911
|
authInfo: JSON.stringify(this.authInfo)
|
|
906
912
|
}, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
907
913
|
pfpUrl: this.authInfo.pfpUrl,
|
|
908
914
|
displayName: this.authInfo.displayName
|
|
909
|
-
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
|
|
915
|
+
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
|
|
910
916
|
sessionId: thisDevice.sessionId,
|
|
911
917
|
encryptionKey: thisDevice.encryptionKey
|
|
912
918
|
}, opts.newDevice ? {
|
|
@@ -1837,7 +1843,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1837
1843
|
if (this.externalWalletConnectionType === "VERIFICATION") {
|
|
1838
1844
|
return isSessionActive;
|
|
1839
1845
|
}
|
|
1840
|
-
if (this.
|
|
1846
|
+
if (this.isSwitchingWallets) {
|
|
1841
1847
|
return isSessionActive;
|
|
1842
1848
|
}
|
|
1843
1849
|
return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
|
|
@@ -3513,6 +3519,40 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3513
3519
|
this.setUserId(userId);
|
|
3514
3520
|
});
|
|
3515
3521
|
}
|
|
3522
|
+
exportPrivateKey() {
|
|
3523
|
+
return __async(this, arguments, function* (args = {}) {
|
|
3524
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
3525
|
+
if (!(args == null ? void 0 : args.walletId)) {
|
|
3526
|
+
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
|
|
3527
|
+
}
|
|
3528
|
+
const wallet = this.wallets[walletId];
|
|
3529
|
+
if (this.externalWallets[walletId]) {
|
|
3530
|
+
throw new Error("Cannot export private key for an external wallet");
|
|
3531
|
+
}
|
|
3532
|
+
if (!wallet || !wallet.signer) {
|
|
3533
|
+
throw new Error("Wallet not found with id: " + walletId);
|
|
3534
|
+
}
|
|
3535
|
+
if (wallet.scheme !== "DKLS") {
|
|
3536
|
+
throw new Error("Cannot export private key for a Solana wallet");
|
|
3537
|
+
}
|
|
3538
|
+
if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
|
|
3539
|
+
throw new Error("Cannot export private key for a pregenerated wallet");
|
|
3540
|
+
}
|
|
3541
|
+
if (args.shouldOpenPopup) {
|
|
3542
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
|
|
3543
|
+
}
|
|
3544
|
+
const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
|
|
3545
|
+
pathId: walletId
|
|
3546
|
+
});
|
|
3547
|
+
if (args.shouldOpenPopup) {
|
|
3548
|
+
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
3549
|
+
}
|
|
3550
|
+
return {
|
|
3551
|
+
url: exportPrivateKeyUrl,
|
|
3552
|
+
popupWindow: this.popupWindow
|
|
3553
|
+
};
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3516
3556
|
};
|
|
3517
3557
|
_authInfo = new WeakMap();
|
|
3518
3558
|
_ParaCore_instances = new WeakSet();
|
|
@@ -3669,17 +3709,42 @@ waitForLoginProcess_fn = function() {
|
|
|
3669
3709
|
skipSessionRefresh = false,
|
|
3670
3710
|
isSwitchingWallets = false
|
|
3671
3711
|
} = {}) {
|
|
3712
|
+
this.devLog("[waitForLoginProcess] Starting", {
|
|
3713
|
+
isSwitchingWallets,
|
|
3714
|
+
skipSessionRefresh,
|
|
3715
|
+
isExternalWalletAuth: this.isExternalWalletAuth
|
|
3716
|
+
});
|
|
3672
3717
|
const startedAt = Date.now();
|
|
3718
|
+
let originalCurrentWalletIdsHash;
|
|
3719
|
+
if (isSwitchingWallets) {
|
|
3720
|
+
this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
|
|
3721
|
+
this.isSwitchingWallets = true;
|
|
3722
|
+
const session = yield this.touchSession();
|
|
3723
|
+
originalCurrentWalletIdsHash = session.currentWalletIdsHash;
|
|
3724
|
+
this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
|
|
3725
|
+
}
|
|
3673
3726
|
return new Promise((resolve, reject) => {
|
|
3674
3727
|
(() => __async(this, null, function* () {
|
|
3675
3728
|
var _a;
|
|
3676
3729
|
if (!this.isExternalWalletAuth && !isSwitchingWallets) {
|
|
3730
|
+
this.devLog("[waitForLoginProcess] Clearing external wallets");
|
|
3677
3731
|
this.externalWallets = {};
|
|
3678
3732
|
}
|
|
3733
|
+
let pollCount = 0;
|
|
3679
3734
|
while (true) {
|
|
3735
|
+
pollCount++;
|
|
3736
|
+
this.devLog("[waitForLoginProcess] Poll iteration", {
|
|
3737
|
+
pollCount,
|
|
3738
|
+
elapsedMs: Date.now() - startedAt
|
|
3739
|
+
});
|
|
3680
3740
|
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
3741
|
+
this.devLog("[waitForLoginProcess] Canceled or timed out", {
|
|
3742
|
+
wasCanceled: isCanceled(),
|
|
3743
|
+
timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
|
|
3744
|
+
elapsedMs: Date.now() - startedAt
|
|
3745
|
+
});
|
|
3681
3746
|
if (isSwitchingWallets) {
|
|
3682
|
-
this.
|
|
3747
|
+
this.isSwitchingWallets = false;
|
|
3683
3748
|
} else {
|
|
3684
3749
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
3685
3750
|
}
|
|
@@ -3688,58 +3753,108 @@ waitForLoginProcess_fn = function() {
|
|
|
3688
3753
|
}
|
|
3689
3754
|
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
3690
3755
|
try {
|
|
3756
|
+
this.devLog("[waitForLoginProcess] Touching session");
|
|
3691
3757
|
let session = yield this.touchSession();
|
|
3692
|
-
|
|
3758
|
+
this.devLog("[waitForLoginProcess] Session state", {
|
|
3759
|
+
isAuthenticated: session.isAuthenticated,
|
|
3760
|
+
currentWalletIdsHash: session.currentWalletIdsHash,
|
|
3761
|
+
needsWallet: session.needsWallet
|
|
3762
|
+
});
|
|
3763
|
+
const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
|
|
3764
|
+
this.devLog("[waitForLoginProcess] Should continue polling", {
|
|
3765
|
+
shouldContinuePolling,
|
|
3766
|
+
isSwitchingWallets,
|
|
3767
|
+
originalCurrentWalletIdsHash,
|
|
3768
|
+
sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
|
|
3769
|
+
isAuthenticated: session.isAuthenticated
|
|
3770
|
+
});
|
|
3693
3771
|
if (shouldContinuePolling) {
|
|
3694
3772
|
onPoll == null ? void 0 : onPoll();
|
|
3695
3773
|
continue;
|
|
3696
3774
|
}
|
|
3775
|
+
this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
|
|
3697
3776
|
session = yield this.userSetupAfterLogin();
|
|
3698
3777
|
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
3778
|
+
this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
|
|
3699
3779
|
if (isSwitchingWallets) {
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3780
|
+
const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
|
|
3781
|
+
this.devLog("[waitForLoginProcess] Wallet switching check", {
|
|
3782
|
+
isWalletSwitchingComplete,
|
|
3783
|
+
originalHash: originalCurrentWalletIdsHash,
|
|
3784
|
+
sessionHash: session.currentWalletIdsHash
|
|
3785
|
+
});
|
|
3786
|
+
if (!isWalletSwitchingComplete) {
|
|
3707
3787
|
onPoll == null ? void 0 : onPoll();
|
|
3708
3788
|
continue;
|
|
3709
3789
|
}
|
|
3710
3790
|
} else if (!needsWallet) {
|
|
3791
|
+
this.devLog("[waitForLoginProcess] Checking wallet IDs", {
|
|
3792
|
+
currentWalletIdsArrayLength: this.currentWalletIdsArray.length
|
|
3793
|
+
});
|
|
3711
3794
|
if (this.currentWalletIdsArray.length === 0) {
|
|
3795
|
+
this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
|
|
3712
3796
|
onPoll == null ? void 0 : onPoll();
|
|
3713
3797
|
continue;
|
|
3714
3798
|
}
|
|
3715
3799
|
}
|
|
3800
|
+
this.devLog("[waitForLoginProcess] Getting transmission key shares");
|
|
3716
3801
|
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3802
|
+
this.devLog("[waitForLoginProcess] Transmission shares received", {
|
|
3803
|
+
shareCount: tempSharesRes.data.temporaryShares.length,
|
|
3804
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3805
|
+
walletId: s.walletId,
|
|
3806
|
+
walletScheme: s.walletScheme
|
|
3807
|
+
}))
|
|
3808
|
+
});
|
|
3717
3809
|
let hasSharesForCurrentWallets;
|
|
3718
3810
|
if (!isSwitchingWallets) {
|
|
3811
|
+
this.devLog("[waitForLoginProcess] Fetching wallets");
|
|
3719
3812
|
const fetchedWallets = yield this.fetchWallets();
|
|
3813
|
+
this.devLog("[waitForLoginProcess] Wallets fetched", {
|
|
3814
|
+
walletCount: fetchedWallets.length,
|
|
3815
|
+
wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
|
|
3816
|
+
});
|
|
3720
3817
|
hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
|
|
3721
3818
|
} else {
|
|
3722
3819
|
hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
|
|
3723
3820
|
return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
|
|
3724
3821
|
});
|
|
3725
3822
|
}
|
|
3823
|
+
this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
|
|
3824
|
+
hasSharesForCurrentWallets,
|
|
3825
|
+
currentWalletIdsCount: this.currentWalletIdsArray.length,
|
|
3826
|
+
shareCount: tempSharesRes.data.temporaryShares.length
|
|
3827
|
+
});
|
|
3726
3828
|
if (hasSharesForCurrentWallets) {
|
|
3829
|
+
this.devLog("[waitForLoginProcess] Setting up after login");
|
|
3727
3830
|
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3831
|
+
this.devLog("[waitForLoginProcess] Setup after login complete");
|
|
3832
|
+
this.devLog("[waitForLoginProcess] Claiming pregen wallets");
|
|
3728
3833
|
yield this.claimPregenWallets();
|
|
3834
|
+
this.devLog("[waitForLoginProcess] Pregen wallets claimed");
|
|
3729
3835
|
const resp = {
|
|
3730
3836
|
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3731
3837
|
partnerId: session.partnerId
|
|
3732
3838
|
};
|
|
3839
|
+
this.devLog("[waitForLoginProcess] Login process complete", {
|
|
3840
|
+
needsWallet: resp.needsWallet,
|
|
3841
|
+
partnerId: resp.partnerId,
|
|
3842
|
+
walletCount: Object.values(this.wallets).length,
|
|
3843
|
+
isSwitchingWallets
|
|
3844
|
+
});
|
|
3733
3845
|
if (isSwitchingWallets) {
|
|
3734
|
-
this.
|
|
3846
|
+
this.devLog("[waitForLoginProcess] Clearing wallet switching state");
|
|
3847
|
+
this.isSwitchingWallets = false;
|
|
3735
3848
|
} else {
|
|
3849
|
+
this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
|
|
3736
3850
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
|
|
3737
3851
|
}
|
|
3738
3852
|
return resolve(resp);
|
|
3739
3853
|
}
|
|
3854
|
+
this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
|
|
3740
3855
|
onPoll == null ? void 0 : onPoll();
|
|
3741
3856
|
} catch (err) {
|
|
3742
|
-
console.error(err);
|
|
3857
|
+
console.error("[waitForLoginProcess] Error during polling iteration", err);
|
|
3743
3858
|
onPoll == null ? void 0 : onPoll();
|
|
3744
3859
|
}
|
|
3745
3860
|
}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -20,7 +20,6 @@ __export(constants_exports, {
|
|
|
20
20
|
ACCOUNT_LINK_CONFLICT: () => ACCOUNT_LINK_CONFLICT,
|
|
21
21
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID: () => EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
22
22
|
LOCAL_STORAGE_AUTH_INFO: () => LOCAL_STORAGE_AUTH_INFO,
|
|
23
|
-
LOCAL_STORAGE_AUTH_METHOD: () => LOCAL_STORAGE_AUTH_METHOD,
|
|
24
23
|
LOCAL_STORAGE_COUNTRY_CODE: () => LOCAL_STORAGE_COUNTRY_CODE,
|
|
25
24
|
LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
26
25
|
LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -44,7 +43,7 @@ __export(constants_exports, {
|
|
|
44
43
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
45
44
|
});
|
|
46
45
|
module.exports = __toCommonJS(constants_exports);
|
|
47
|
-
const PARA_CORE_VERSION = "2.0.0-alpha.
|
|
46
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.65";
|
|
48
47
|
const PREFIX = "@CAPSULE/";
|
|
49
48
|
const PARA_PREFIX = "@PARA/";
|
|
50
49
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -62,7 +61,6 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
|
|
|
62
61
|
const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
63
62
|
const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
|
|
64
63
|
const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
|
|
65
|
-
const LOCAL_STORAGE_AUTH_METHOD = `${PREFIX}authMethod`;
|
|
66
64
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
67
65
|
const POLLING_INTERVAL_MS = 2e3;
|
|
68
66
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
@@ -74,7 +72,6 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
|
|
74
72
|
ACCOUNT_LINK_CONFLICT,
|
|
75
73
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
76
74
|
LOCAL_STORAGE_AUTH_INFO,
|
|
77
|
-
LOCAL_STORAGE_AUTH_METHOD,
|
|
78
75
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
79
76
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
80
77
|
LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -54,15 +54,16 @@ module.exports = __toCommonJS(transmissionUtils_exports);
|
|
|
54
54
|
var import_ecies = require("@celo/utils/lib/ecies.js");
|
|
55
55
|
var import_buffer = require("buffer");
|
|
56
56
|
var eutil = __toESM(require("@ethereumjs/util"));
|
|
57
|
-
var import_crypto = require("crypto");
|
|
58
57
|
function upload(message, userManagementClient) {
|
|
59
58
|
return __async(this, null, function* () {
|
|
60
59
|
let secret;
|
|
61
60
|
let publicKeyUint8Array;
|
|
62
61
|
while (true) {
|
|
63
62
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const privateKeyUint8Array = new Uint8Array(32);
|
|
64
|
+
crypto.getRandomValues(privateKeyUint8Array);
|
|
65
|
+
secret = import_buffer.Buffer.from(privateKeyUint8Array).toString("hex");
|
|
66
|
+
publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
|
|
66
67
|
break;
|
|
67
68
|
} catch (e) {
|
|
68
69
|
continue;
|
package/dist/cjs/types/popup.js
CHANGED
|
@@ -27,6 +27,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
|
|
|
27
27
|
PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
|
|
28
28
|
PopupType2["OAUTH"] = "OAUTH";
|
|
29
29
|
PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
|
|
30
|
+
PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
|
|
30
31
|
return PopupType2;
|
|
31
32
|
})(PopupType || {});
|
|
32
33
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/utils/window.js
CHANGED
|
@@ -29,7 +29,7 @@ function isPortal(ctx, env) {
|
|
|
29
29
|
if (!isOnPortalDomain) return false;
|
|
30
30
|
const isInIframe = window.parent !== window && !window.opener;
|
|
31
31
|
const isInPopup = window.opener && window.parent === window;
|
|
32
|
-
const isDirectAccess =
|
|
32
|
+
const isDirectAccess = window.parent === window && !window.opener;
|
|
33
33
|
return isInIframe || isInPopup || isDirectAccess;
|
|
34
34
|
}
|
|
35
35
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -82,7 +82,7 @@ const _ParaCore = class _ParaCore {
|
|
|
82
82
|
__privateAdd(this, _ParaCore_instances);
|
|
83
83
|
this.popupWindow = null;
|
|
84
84
|
__privateAdd(this, _authInfo);
|
|
85
|
-
|
|
85
|
+
this.isSwitchingWallets = false;
|
|
86
86
|
this.isNativePasskey = false;
|
|
87
87
|
this.isReady = false;
|
|
88
88
|
this.accountLinkInProgress = void 0;
|
|
@@ -742,7 +742,8 @@ const _ParaCore = class _ParaCore {
|
|
|
742
742
|
isTelegramLogin,
|
|
743
743
|
isFarcasterLogin,
|
|
744
744
|
isAddNewCredential,
|
|
745
|
-
isSwitchWallets
|
|
745
|
+
isSwitchWallets,
|
|
746
|
+
isExportPrivateKey
|
|
746
747
|
] = [
|
|
747
748
|
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
748
749
|
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
|
|
@@ -752,7 +753,8 @@ const _ParaCore = class _ParaCore {
|
|
|
752
753
|
["telegramLogin", "telegramLoginVerify"].includes(type),
|
|
753
754
|
type === "loginFarcaster",
|
|
754
755
|
type === "addNewCredential",
|
|
755
|
-
type === "switchWallets"
|
|
756
|
+
type === "switchWallets",
|
|
757
|
+
type === "exportPrivateKey"
|
|
756
758
|
];
|
|
757
759
|
if (isOAuth && !opts.oAuthMethod) {
|
|
758
760
|
throw new Error("oAuthMethod is required for oAuth portal URLs");
|
|
@@ -761,7 +763,7 @@ const _ParaCore = class _ParaCore {
|
|
|
761
763
|
this.assertIsAuthSet();
|
|
762
764
|
}
|
|
763
765
|
let sessionId = opts.sessionId;
|
|
764
|
-
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin) && !sessionId) {
|
|
766
|
+
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin || isExportPrivateKey) && !sessionId) {
|
|
765
767
|
const session = yield this.touchSession(true);
|
|
766
768
|
sessionId = session.sessionId;
|
|
767
769
|
}
|
|
@@ -835,6 +837,10 @@ const _ParaCore = class _ParaCore {
|
|
|
835
837
|
path = "/auth/add-new-credential";
|
|
836
838
|
break;
|
|
837
839
|
}
|
|
840
|
+
case "exportPrivateKey": {
|
|
841
|
+
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
838
844
|
default: {
|
|
839
845
|
throw new Error(`invalid URL type ${type}`);
|
|
840
846
|
}
|
|
@@ -867,12 +873,12 @@ const _ParaCore = class _ParaCore {
|
|
|
867
873
|
portalTextColor: this.portalTextColor,
|
|
868
874
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
869
875
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
870
|
-
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets) ? __spreadProps(__spreadValues({
|
|
876
|
+
}, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
871
877
|
authInfo: JSON.stringify(this.authInfo)
|
|
872
878
|
}, isPhone(this.authInfo.auth) ? splitPhoneNumber(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
873
879
|
pfpUrl: this.authInfo.pfpUrl,
|
|
874
880
|
displayName: this.authInfo.displayName
|
|
875
|
-
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
|
|
881
|
+
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
|
|
876
882
|
sessionId: thisDevice.sessionId,
|
|
877
883
|
encryptionKey: thisDevice.encryptionKey
|
|
878
884
|
}, opts.newDevice ? {
|
|
@@ -1803,7 +1809,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1803
1809
|
if (this.externalWalletConnectionType === "VERIFICATION") {
|
|
1804
1810
|
return isSessionActive;
|
|
1805
1811
|
}
|
|
1806
|
-
if (this.
|
|
1812
|
+
if (this.isSwitchingWallets) {
|
|
1807
1813
|
return isSessionActive;
|
|
1808
1814
|
}
|
|
1809
1815
|
return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
|
|
@@ -3479,6 +3485,40 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3479
3485
|
this.setUserId(userId);
|
|
3480
3486
|
});
|
|
3481
3487
|
}
|
|
3488
|
+
exportPrivateKey() {
|
|
3489
|
+
return __async(this, arguments, function* (args = {}) {
|
|
3490
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
3491
|
+
if (!(args == null ? void 0 : args.walletId)) {
|
|
3492
|
+
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
|
|
3493
|
+
}
|
|
3494
|
+
const wallet = this.wallets[walletId];
|
|
3495
|
+
if (this.externalWallets[walletId]) {
|
|
3496
|
+
throw new Error("Cannot export private key for an external wallet");
|
|
3497
|
+
}
|
|
3498
|
+
if (!wallet || !wallet.signer) {
|
|
3499
|
+
throw new Error("Wallet not found with id: " + walletId);
|
|
3500
|
+
}
|
|
3501
|
+
if (wallet.scheme !== "DKLS") {
|
|
3502
|
+
throw new Error("Cannot export private key for a Solana wallet");
|
|
3503
|
+
}
|
|
3504
|
+
if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
|
|
3505
|
+
throw new Error("Cannot export private key for a pregenerated wallet");
|
|
3506
|
+
}
|
|
3507
|
+
if (args.shouldOpenPopup) {
|
|
3508
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: PopupType.EXPORT_PRIVATE_KEY });
|
|
3509
|
+
}
|
|
3510
|
+
const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
|
|
3511
|
+
pathId: walletId
|
|
3512
|
+
});
|
|
3513
|
+
if (args.shouldOpenPopup) {
|
|
3514
|
+
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
3515
|
+
}
|
|
3516
|
+
return {
|
|
3517
|
+
url: exportPrivateKeyUrl,
|
|
3518
|
+
popupWindow: this.popupWindow
|
|
3519
|
+
};
|
|
3520
|
+
});
|
|
3521
|
+
}
|
|
3482
3522
|
};
|
|
3483
3523
|
_authInfo = new WeakMap();
|
|
3484
3524
|
_ParaCore_instances = new WeakSet();
|
|
@@ -3635,17 +3675,42 @@ waitForLoginProcess_fn = function() {
|
|
|
3635
3675
|
skipSessionRefresh = false,
|
|
3636
3676
|
isSwitchingWallets = false
|
|
3637
3677
|
} = {}) {
|
|
3678
|
+
this.devLog("[waitForLoginProcess] Starting", {
|
|
3679
|
+
isSwitchingWallets,
|
|
3680
|
+
skipSessionRefresh,
|
|
3681
|
+
isExternalWalletAuth: this.isExternalWalletAuth
|
|
3682
|
+
});
|
|
3638
3683
|
const startedAt = Date.now();
|
|
3684
|
+
let originalCurrentWalletIdsHash;
|
|
3685
|
+
if (isSwitchingWallets) {
|
|
3686
|
+
this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
|
|
3687
|
+
this.isSwitchingWallets = true;
|
|
3688
|
+
const session = yield this.touchSession();
|
|
3689
|
+
originalCurrentWalletIdsHash = session.currentWalletIdsHash;
|
|
3690
|
+
this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
|
|
3691
|
+
}
|
|
3639
3692
|
return new Promise((resolve, reject) => {
|
|
3640
3693
|
(() => __async(this, null, function* () {
|
|
3641
3694
|
var _a;
|
|
3642
3695
|
if (!this.isExternalWalletAuth && !isSwitchingWallets) {
|
|
3696
|
+
this.devLog("[waitForLoginProcess] Clearing external wallets");
|
|
3643
3697
|
this.externalWallets = {};
|
|
3644
3698
|
}
|
|
3699
|
+
let pollCount = 0;
|
|
3645
3700
|
while (true) {
|
|
3701
|
+
pollCount++;
|
|
3702
|
+
this.devLog("[waitForLoginProcess] Poll iteration", {
|
|
3703
|
+
pollCount,
|
|
3704
|
+
elapsedMs: Date.now() - startedAt
|
|
3705
|
+
});
|
|
3646
3706
|
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
3707
|
+
this.devLog("[waitForLoginProcess] Canceled or timed out", {
|
|
3708
|
+
wasCanceled: isCanceled(),
|
|
3709
|
+
timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
|
|
3710
|
+
elapsedMs: Date.now() - startedAt
|
|
3711
|
+
});
|
|
3647
3712
|
if (isSwitchingWallets) {
|
|
3648
|
-
this.
|
|
3713
|
+
this.isSwitchingWallets = false;
|
|
3649
3714
|
} else {
|
|
3650
3715
|
dispatchEvent(ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
3651
3716
|
}
|
|
@@ -3654,58 +3719,108 @@ waitForLoginProcess_fn = function() {
|
|
|
3654
3719
|
}
|
|
3655
3720
|
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
3656
3721
|
try {
|
|
3722
|
+
this.devLog("[waitForLoginProcess] Touching session");
|
|
3657
3723
|
let session = yield this.touchSession();
|
|
3658
|
-
|
|
3724
|
+
this.devLog("[waitForLoginProcess] Session state", {
|
|
3725
|
+
isAuthenticated: session.isAuthenticated,
|
|
3726
|
+
currentWalletIdsHash: session.currentWalletIdsHash,
|
|
3727
|
+
needsWallet: session.needsWallet
|
|
3728
|
+
});
|
|
3729
|
+
const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
|
|
3730
|
+
this.devLog("[waitForLoginProcess] Should continue polling", {
|
|
3731
|
+
shouldContinuePolling,
|
|
3732
|
+
isSwitchingWallets,
|
|
3733
|
+
originalCurrentWalletIdsHash,
|
|
3734
|
+
sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
|
|
3735
|
+
isAuthenticated: session.isAuthenticated
|
|
3736
|
+
});
|
|
3659
3737
|
if (shouldContinuePolling) {
|
|
3660
3738
|
onPoll == null ? void 0 : onPoll();
|
|
3661
3739
|
continue;
|
|
3662
3740
|
}
|
|
3741
|
+
this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
|
|
3663
3742
|
session = yield this.userSetupAfterLogin();
|
|
3664
3743
|
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
3744
|
+
this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
|
|
3665
3745
|
if (isSwitchingWallets) {
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3746
|
+
const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
|
|
3747
|
+
this.devLog("[waitForLoginProcess] Wallet switching check", {
|
|
3748
|
+
isWalletSwitchingComplete,
|
|
3749
|
+
originalHash: originalCurrentWalletIdsHash,
|
|
3750
|
+
sessionHash: session.currentWalletIdsHash
|
|
3751
|
+
});
|
|
3752
|
+
if (!isWalletSwitchingComplete) {
|
|
3673
3753
|
onPoll == null ? void 0 : onPoll();
|
|
3674
3754
|
continue;
|
|
3675
3755
|
}
|
|
3676
3756
|
} else if (!needsWallet) {
|
|
3757
|
+
this.devLog("[waitForLoginProcess] Checking wallet IDs", {
|
|
3758
|
+
currentWalletIdsArrayLength: this.currentWalletIdsArray.length
|
|
3759
|
+
});
|
|
3677
3760
|
if (this.currentWalletIdsArray.length === 0) {
|
|
3761
|
+
this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
|
|
3678
3762
|
onPoll == null ? void 0 : onPoll();
|
|
3679
3763
|
continue;
|
|
3680
3764
|
}
|
|
3681
3765
|
}
|
|
3766
|
+
this.devLog("[waitForLoginProcess] Getting transmission key shares");
|
|
3682
3767
|
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3768
|
+
this.devLog("[waitForLoginProcess] Transmission shares received", {
|
|
3769
|
+
shareCount: tempSharesRes.data.temporaryShares.length,
|
|
3770
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3771
|
+
walletId: s.walletId,
|
|
3772
|
+
walletScheme: s.walletScheme
|
|
3773
|
+
}))
|
|
3774
|
+
});
|
|
3683
3775
|
let hasSharesForCurrentWallets;
|
|
3684
3776
|
if (!isSwitchingWallets) {
|
|
3777
|
+
this.devLog("[waitForLoginProcess] Fetching wallets");
|
|
3685
3778
|
const fetchedWallets = yield this.fetchWallets();
|
|
3779
|
+
this.devLog("[waitForLoginProcess] Wallets fetched", {
|
|
3780
|
+
walletCount: fetchedWallets.length,
|
|
3781
|
+
wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
|
|
3782
|
+
});
|
|
3686
3783
|
hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
|
|
3687
3784
|
} else {
|
|
3688
3785
|
hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
|
|
3689
3786
|
return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
|
|
3690
3787
|
});
|
|
3691
3788
|
}
|
|
3789
|
+
this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
|
|
3790
|
+
hasSharesForCurrentWallets,
|
|
3791
|
+
currentWalletIdsCount: this.currentWalletIdsArray.length,
|
|
3792
|
+
shareCount: tempSharesRes.data.temporaryShares.length
|
|
3793
|
+
});
|
|
3692
3794
|
if (hasSharesForCurrentWallets) {
|
|
3795
|
+
this.devLog("[waitForLoginProcess] Setting up after login");
|
|
3693
3796
|
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3797
|
+
this.devLog("[waitForLoginProcess] Setup after login complete");
|
|
3798
|
+
this.devLog("[waitForLoginProcess] Claiming pregen wallets");
|
|
3694
3799
|
yield this.claimPregenWallets();
|
|
3800
|
+
this.devLog("[waitForLoginProcess] Pregen wallets claimed");
|
|
3695
3801
|
const resp = {
|
|
3696
3802
|
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3697
3803
|
partnerId: session.partnerId
|
|
3698
3804
|
};
|
|
3805
|
+
this.devLog("[waitForLoginProcess] Login process complete", {
|
|
3806
|
+
needsWallet: resp.needsWallet,
|
|
3807
|
+
partnerId: resp.partnerId,
|
|
3808
|
+
walletCount: Object.values(this.wallets).length,
|
|
3809
|
+
isSwitchingWallets
|
|
3810
|
+
});
|
|
3699
3811
|
if (isSwitchingWallets) {
|
|
3700
|
-
this.
|
|
3812
|
+
this.devLog("[waitForLoginProcess] Clearing wallet switching state");
|
|
3813
|
+
this.isSwitchingWallets = false;
|
|
3701
3814
|
} else {
|
|
3815
|
+
this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
|
|
3702
3816
|
dispatchEvent(ParaEvent.LOGIN_EVENT, resp);
|
|
3703
3817
|
}
|
|
3704
3818
|
return resolve(resp);
|
|
3705
3819
|
}
|
|
3820
|
+
this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
|
|
3706
3821
|
onPoll == null ? void 0 : onPoll();
|
|
3707
3822
|
} catch (err) {
|
|
3708
|
-
console.error(err);
|
|
3823
|
+
console.error("[waitForLoginProcess] Error during polling iteration", err);
|
|
3709
3824
|
onPoll == null ? void 0 : onPoll();
|
|
3710
3825
|
}
|
|
3711
3826
|
}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk-W5CT3TVS.js";
|
|
2
|
-
const PARA_CORE_VERSION = "2.0.0-alpha.
|
|
2
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.65";
|
|
3
3
|
const PREFIX = "@CAPSULE/";
|
|
4
4
|
const PARA_PREFIX = "@PARA/";
|
|
5
5
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -17,7 +17,6 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
|
|
|
17
17
|
const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
18
18
|
const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
|
|
19
19
|
const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
|
|
20
|
-
const LOCAL_STORAGE_AUTH_METHOD = `${PREFIX}authMethod`;
|
|
21
20
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
22
21
|
const POLLING_INTERVAL_MS = 2e3;
|
|
23
22
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
@@ -28,7 +27,6 @@ export {
|
|
|
28
27
|
ACCOUNT_LINK_CONFLICT,
|
|
29
28
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
30
29
|
LOCAL_STORAGE_AUTH_INFO,
|
|
31
|
-
LOCAL_STORAGE_AUTH_METHOD,
|
|
32
30
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
33
31
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
34
32
|
LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -4,15 +4,16 @@ import {
|
|
|
4
4
|
import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
|
|
5
5
|
import { Buffer } from "buffer";
|
|
6
6
|
import * as eutil from "@ethereumjs/util";
|
|
7
|
-
import { randomBytes } from "crypto";
|
|
8
7
|
function upload(message, userManagementClient) {
|
|
9
8
|
return __async(this, null, function* () {
|
|
10
9
|
let secret;
|
|
11
10
|
let publicKeyUint8Array;
|
|
12
11
|
while (true) {
|
|
13
12
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const privateKeyUint8Array = new Uint8Array(32);
|
|
14
|
+
crypto.getRandomValues(privateKeyUint8Array);
|
|
15
|
+
secret = Buffer.from(privateKeyUint8Array).toString("hex");
|
|
16
|
+
publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
|
|
16
17
|
break;
|
|
17
18
|
} catch (e) {
|
|
18
19
|
continue;
|
package/dist/esm/types/popup.js
CHANGED
|
@@ -6,6 +6,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
|
|
|
6
6
|
PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
|
|
7
7
|
PopupType2["OAUTH"] = "OAUTH";
|
|
8
8
|
PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
|
|
9
|
+
PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
|
|
9
10
|
return PopupType2;
|
|
10
11
|
})(PopupType || {});
|
|
11
12
|
export {
|
package/dist/esm/utils/window.js
CHANGED
|
@@ -8,7 +8,7 @@ function isPortal(ctx, env) {
|
|
|
8
8
|
if (!isOnPortalDomain) return false;
|
|
9
9
|
const isInIframe = window.parent !== window && !window.opener;
|
|
10
10
|
const isInPopup = window.opener && window.parent === window;
|
|
11
|
-
const isDirectAccess =
|
|
11
|
+
const isDirectAccess = window.parent === window && !window.opener;
|
|
12
12
|
return isInIframe || isInPopup || isDirectAccess;
|
|
13
13
|
}
|
|
14
14
|
export {
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
|
-
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } from './types/index.js';
|
|
3
|
+
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, AvailableWallet } from './types/index.js';
|
|
4
4
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
5
5
|
export declare abstract class ParaCore implements CoreInterface {
|
|
6
6
|
#private;
|
|
7
7
|
popupWindow: Window | null;
|
|
8
8
|
static version?: string;
|
|
9
9
|
ctx: Ctx;
|
|
10
|
-
protected
|
|
10
|
+
protected isSwitchingWallets: boolean;
|
|
11
11
|
protected isNativePasskey: boolean;
|
|
12
12
|
protected isPartnerOptional?: boolean;
|
|
13
13
|
protected setModalError(_error?: string): void;
|
|
@@ -352,7 +352,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
352
352
|
*/
|
|
353
353
|
findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
|
|
354
354
|
findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
|
|
355
|
-
get availableWallets():
|
|
355
|
+
get availableWallets(): AvailableWallet[];
|
|
356
356
|
/**
|
|
357
357
|
* Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
|
|
358
358
|
* @param {string} type the wallet type to filter by.
|
|
@@ -719,7 +719,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
719
719
|
* Doesn't work for all types of logging.
|
|
720
720
|
**/
|
|
721
721
|
toString(): string;
|
|
722
|
-
protected devLog(...s:
|
|
722
|
+
protected devLog(...s: any[]): void;
|
|
723
723
|
protected getNewCredentialAndUrl({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
|
|
724
724
|
credentialId: string;
|
|
725
725
|
url?: string;
|
|
@@ -749,4 +749,5 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
749
749
|
refetch?: boolean;
|
|
750
750
|
}): Promise<import("@getpara/user-management-client").ProfileBalance>;
|
|
751
751
|
protected sendLoginCode(): Promise<void>;
|
|
752
|
+
exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
|
|
752
753
|
}
|
|
@@ -16,7 +16,6 @@ export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletI
|
|
|
16
16
|
export declare const LOCAL_STORAGE_SESSION_COOKIE = "@CAPSULE/sessionCookie";
|
|
17
17
|
export declare const LOCAL_STORAGE_ENCLAVE_JWT = "@CAPSULE/enclaveJwt";
|
|
18
18
|
export declare const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = "@CAPSULE/enclaveRefreshJwt";
|
|
19
|
-
export declare const LOCAL_STORAGE_AUTH_METHOD = "@CAPSULE/authMethod";
|
|
20
19
|
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
|
|
21
20
|
export declare const POLLING_INTERVAL_MS = 2000;
|
|
22
21
|
export declare const SHORT_POLLING_INTERVAL_MS = 1000;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParaCore } from './ParaCore.js';
|
|
2
2
|
export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type TAuthMethod, AuthMethodStatus, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TNetwork, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, type TOnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAssets, type OnRampPurchase, type OnRampAssetInfo, type ProviderAssetInfo, OnRampMethod, type Theme, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, type AssetMetadata, type AssetMetadataIndexed, type AssetValue, type BalancesConfig, type WalletBalance, type ProfileBalance, type OfframpDepositRequest, RecoveryStatus, ThemeMode, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, } from '@getpara/user-management-client';
|
|
3
|
-
export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
|
|
3
|
+
export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type AvailableWallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
|
|
4
4
|
export * from './types/coreApi.js';
|
|
5
5
|
export * from './types/events.js';
|
|
6
6
|
export * from './types/config.js';
|
|
@@ -3,7 +3,7 @@ import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, Wi
|
|
|
3
3
|
import { ParaCore } from '../ParaCore.js';
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './auth.js';
|
|
6
|
-
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential"];
|
|
6
|
+
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential", "exportPrivateKey"];
|
|
7
7
|
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
|
|
8
8
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
9
9
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
@@ -488,6 +488,16 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
488
488
|
params: Pick<NewCredentialUrlParams, 'authMethod'>;
|
|
489
489
|
response: Promise<string>;
|
|
490
490
|
};
|
|
491
|
+
exportPrivateKey: {
|
|
492
|
+
params: {
|
|
493
|
+
walletId?: string;
|
|
494
|
+
shouldOpenPopup?: boolean;
|
|
495
|
+
} | undefined;
|
|
496
|
+
response: {
|
|
497
|
+
popupWindow?: Window;
|
|
498
|
+
url: string;
|
|
499
|
+
};
|
|
500
|
+
};
|
|
491
501
|
};
|
|
492
502
|
export type InternalMethods = {
|
|
493
503
|
linkAccount: {
|
|
@@ -12,7 +12,7 @@ export type VerifyExternalWalletV1 = {
|
|
|
12
12
|
cosmosPublicKeyHex?: string;
|
|
13
13
|
cosmosSigner?: string;
|
|
14
14
|
};
|
|
15
|
-
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential';
|
|
15
|
+
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey';
|
|
16
16
|
export type PortalUrlOptions = {
|
|
17
17
|
params?: Record<string, string | undefined | null>;
|
|
18
18
|
isForNewDevice?: boolean;
|
|
@@ -26,6 +26,7 @@ export interface Wallet extends Omit<IWalletEntity, 'createdAt' | 'updatedAt' |
|
|
|
26
26
|
ensName?: string | null;
|
|
27
27
|
ensAvatar?: string | null;
|
|
28
28
|
}
|
|
29
|
+
export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>;
|
|
29
30
|
/** @deprecated */
|
|
30
31
|
export declare enum PregenIdentifierType {
|
|
31
32
|
EMAIL = "EMAIL",
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.65",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@celo/utils": "^8.0.2",
|
|
6
6
|
"@cosmjs/encoding": "^0.32.4",
|
|
7
7
|
"@ethereumjs/util": "^9.1.0",
|
|
8
|
-
"@getpara/user-management-client": "2.0.0-alpha.
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.65",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"base64url": "^3.0.1",
|
|
11
11
|
"libphonenumber-js": "^1.11.7",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist",
|
|
28
28
|
"package.json"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "9945ab14944c22851eb81c5bbb831b23bf7eaf2a",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|