@getpara/core-sdk 2.16.0 → 2.18.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/ParaCore.js +69 -27
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/cryptography/utils.js +2 -2
- package/dist/cjs/services/ExternalWalletService.js +57 -28
- package/dist/cjs/services/PortalUrlService.js +3 -0
- package/dist/cjs/state/actors/waitForExternalWalletProviders.js +1 -5
- package/dist/cjs/types/coreApi.js +1 -0
- package/dist/esm/ParaCore.js +69 -27
- package/dist/esm/constants.js +1 -1
- package/dist/esm/cryptography/utils.js +2 -2
- package/dist/esm/services/ExternalWalletService.js +57 -28
- package/dist/esm/services/PortalUrlService.js +3 -0
- package/dist/esm/state/actors/waitForExternalWalletProviders.js +1 -5
- package/dist/esm/types/coreApi.js +1 -0
- package/dist/types/ParaCore.d.ts +11 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/types/PollingServiceTypes.d.ts +9 -0
- package/dist/types/types/coreApi.d.ts +10 -1
- package/package.json +5 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -207,6 +207,7 @@ const _ParaCore = class _ParaCore {
|
|
|
207
207
|
methodName,
|
|
208
208
|
sdkType: this.platformUtils.sdkType,
|
|
209
209
|
userId: this.userId,
|
|
210
|
+
sdkVersion: _ParaCore.version,
|
|
210
211
|
error: {
|
|
211
212
|
name: err.name,
|
|
212
213
|
message: err.message
|
|
@@ -403,9 +404,8 @@ const _ParaCore = class _ParaCore {
|
|
|
403
404
|
}
|
|
404
405
|
if (!opts) opts = {};
|
|
405
406
|
__privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
|
|
406
|
-
|
|
407
|
-
if (env
|
|
408
|
-
isE2E = true;
|
|
407
|
+
const isE2E = env === "E2E" || envOrApiKey === "E2E";
|
|
408
|
+
if (isE2E && env !== import_types.Environment.SANDBOX) {
|
|
409
409
|
env = import_types.Environment.SANDBOX;
|
|
410
410
|
}
|
|
411
411
|
this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
|
|
@@ -496,22 +496,20 @@ const _ParaCore = class _ParaCore {
|
|
|
496
496
|
this.initializeFromStorage();
|
|
497
497
|
import_utils2.setupListeners.bind(this)();
|
|
498
498
|
(0, import_utils2.autoBind)(this);
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
]);
|
|
514
|
-
}
|
|
499
|
+
this.wrapMethodsWithErrorTracking([
|
|
500
|
+
"signUpOrLogIn",
|
|
501
|
+
"verifyNewAccount",
|
|
502
|
+
"waitForLogin",
|
|
503
|
+
"waitForSignup",
|
|
504
|
+
"waitForWalletCreation",
|
|
505
|
+
"verifyOAuth",
|
|
506
|
+
"verifyTelegram",
|
|
507
|
+
"verifyFarcaster",
|
|
508
|
+
"createPregenWallet",
|
|
509
|
+
"claimPregenWallets",
|
|
510
|
+
"signMessage",
|
|
511
|
+
"signTransaction"
|
|
512
|
+
]);
|
|
515
513
|
__privateGet(this, _stateManager).start();
|
|
516
514
|
}
|
|
517
515
|
setModalError(_error) {
|
|
@@ -2143,7 +2141,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2143
2141
|
cosmosSignDocBase64,
|
|
2144
2142
|
isCanceled = () => false,
|
|
2145
2143
|
onCancel,
|
|
2146
|
-
onPoll
|
|
2144
|
+
onPoll,
|
|
2145
|
+
onTransactionReviewUrl
|
|
2147
2146
|
}) {
|
|
2148
2147
|
var _a;
|
|
2149
2148
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
@@ -2156,10 +2155,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2156
2155
|
let timeStart = Date.now();
|
|
2157
2156
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2158
2157
|
if (signRes.pendingTransactionId) {
|
|
2159
|
-
yield this.
|
|
2160
|
-
|
|
2161
|
-
|
|
2158
|
+
const reviewUrl = yield this.getTransactionReviewUrl(
|
|
2159
|
+
signRes.pendingTransactionId,
|
|
2160
|
+
effectiveTimeoutMs
|
|
2162
2161
|
);
|
|
2162
|
+
if (onTransactionReviewUrl) {
|
|
2163
|
+
onTransactionReviewUrl(reviewUrl);
|
|
2164
|
+
} else {
|
|
2165
|
+
yield this.platformUtils.openPopup(reviewUrl, {
|
|
2166
|
+
type: cosmosSignDocBase64 ? import_types.PopupType.SIGN_TRANSACTION_REVIEW : import_types.PopupType.SIGN_MESSAGE_REVIEW
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2163
2169
|
} else {
|
|
2164
2170
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2165
2171
|
return signRes;
|
|
@@ -2249,7 +2255,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2249
2255
|
timeoutMs = 3e4,
|
|
2250
2256
|
isCanceled = () => false,
|
|
2251
2257
|
onCancel,
|
|
2252
|
-
onPoll
|
|
2258
|
+
onPoll,
|
|
2259
|
+
onTransactionReviewUrl
|
|
2253
2260
|
}) {
|
|
2254
2261
|
var _a;
|
|
2255
2262
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
@@ -2271,10 +2278,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2271
2278
|
let timeStart = Date.now();
|
|
2272
2279
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2273
2280
|
if (signRes.pendingTransactionId) {
|
|
2274
|
-
yield this.
|
|
2275
|
-
|
|
2276
|
-
|
|
2281
|
+
const reviewUrl = yield this.getTransactionReviewUrl(
|
|
2282
|
+
signRes.pendingTransactionId,
|
|
2283
|
+
effectiveTimeoutMs
|
|
2277
2284
|
);
|
|
2285
|
+
if (onTransactionReviewUrl) {
|
|
2286
|
+
onTransactionReviewUrl(reviewUrl);
|
|
2287
|
+
} else {
|
|
2288
|
+
yield this.platformUtils.openPopup(reviewUrl, { type: import_types.PopupType.SIGN_TRANSACTION_REVIEW });
|
|
2289
|
+
}
|
|
2278
2290
|
} else {
|
|
2279
2291
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2280
2292
|
return signRes;
|
|
@@ -2370,10 +2382,14 @@ const _ParaCore = class _ParaCore {
|
|
|
2370
2382
|
}
|
|
2371
2383
|
/**
|
|
2372
2384
|
* Serialize the current session for import by another Para instance.
|
|
2385
|
+
* @deprecated Use {@link waitAndExportSession} instead, which awaits auth settlement before exporting.
|
|
2373
2386
|
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2374
2387
|
* @returns {string} the serialized session
|
|
2375
2388
|
*/
|
|
2376
2389
|
exportSession({ excludeSigners = false } = {}) {
|
|
2390
|
+
if (__privateGet(this, _stateManager).getSnapshot().authStatePhase !== "authenticated") {
|
|
2391
|
+
throw new Error("Cannot export session: user is not authenticated.");
|
|
2392
|
+
}
|
|
2377
2393
|
const sessionInfo = {
|
|
2378
2394
|
authInfo: __privateGet(this, _authService).authInfo,
|
|
2379
2395
|
userId: this.userId,
|
|
@@ -2389,6 +2405,32 @@ const _ParaCore = class _ParaCore {
|
|
|
2389
2405
|
}
|
|
2390
2406
|
return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
|
|
2391
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Awaits auth settlement, then serializes the current session for import by another Para instance.
|
|
2410
|
+
* Unlike {@link exportSession}, this method waits for the auth state machine to reach the
|
|
2411
|
+
* `authenticated` phase before reading state, ensuring the exported data is up-to-date.
|
|
2412
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2413
|
+
* @returns {Promise<string>} the serialized session
|
|
2414
|
+
*/
|
|
2415
|
+
waitAndExportSession() {
|
|
2416
|
+
return __async(this, arguments, function* (params = {}) {
|
|
2417
|
+
yield (0, import_stateListener.waitForAuthStateChange)({
|
|
2418
|
+
stateManager: __privateGet(this, _stateManager),
|
|
2419
|
+
resolvePhases: [{ phase: "authenticated", onPhase: () => void 0 }],
|
|
2420
|
+
rejectPhases: [
|
|
2421
|
+
{
|
|
2422
|
+
phase: "unauthenticated",
|
|
2423
|
+
onPhase: () => new Error("No active session to export.")
|
|
2424
|
+
},
|
|
2425
|
+
{
|
|
2426
|
+
phase: "guest_mode",
|
|
2427
|
+
onPhase: () => new Error("Cannot export session in guest mode.")
|
|
2428
|
+
}
|
|
2429
|
+
]
|
|
2430
|
+
});
|
|
2431
|
+
return this.exportSession(params);
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2392
2434
|
/**
|
|
2393
2435
|
* Imports a session serialized by another Para instance.
|
|
2394
2436
|
* @param {string} serializedInstanceBase64 the serialized session
|
package/dist/cjs/constants.js
CHANGED
|
@@ -46,7 +46,7 @@ __export(constants_exports, {
|
|
|
46
46
|
TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(constants_exports);
|
|
49
|
-
const PARA_CORE_VERSION = "2.
|
|
49
|
+
const PARA_CORE_VERSION = "2.18.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -116,7 +116,7 @@ function encryptPrivateKey(keyPair, key) {
|
|
|
116
116
|
const ciphertext = yield window.crypto.subtle.encrypt(
|
|
117
117
|
{ name: "AES-GCM", iv: CONSTANT_IV_AES },
|
|
118
118
|
cryptoKey,
|
|
119
|
-
encodedPlaintext
|
|
119
|
+
encodedPlaintext.buffer
|
|
120
120
|
);
|
|
121
121
|
return Buffer.from(ciphertext).toString("base64");
|
|
122
122
|
});
|
|
@@ -299,7 +299,7 @@ function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
|
|
|
299
299
|
const ciphertext = yield window.crypto.subtle.encrypt(
|
|
300
300
|
{ name: "AES-GCM", iv: CONSTANT_IV_AES },
|
|
301
301
|
cryptoKey,
|
|
302
|
-
encodedPlaintext
|
|
302
|
+
encodedPlaintext.buffer
|
|
303
303
|
);
|
|
304
304
|
return Buffer.from(ciphertext).toString("base64");
|
|
305
305
|
});
|
|
@@ -67,7 +67,7 @@ module.exports = __toCommonJS(ExternalWalletService_exports);
|
|
|
67
67
|
var import_events = require("../types/events.js");
|
|
68
68
|
var import_constants = require("../constants.js");
|
|
69
69
|
var import_utils = require("../utils/index.js");
|
|
70
|
-
var _stateManager, _authService, _walletService, _paraCoreInterface, _externalWallets, _watchedProviders, _onWalletDisconnected;
|
|
70
|
+
var _stateManager, _authService, _walletService, _paraCoreInterface, _externalWallets, _watchedProviders, _validateConnectionDeferred, _onWalletDisconnected;
|
|
71
71
|
class ExternalWalletService {
|
|
72
72
|
constructor(paraCore) {
|
|
73
73
|
__privateAdd(this, _stateManager);
|
|
@@ -95,30 +95,11 @@ class ExternalWalletService {
|
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
97
|
for (let i = 0; i < 20; i++) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const loadingResults = yield Promise.all(
|
|
107
|
-
neededProviderInterfaces.map((_0) => __async(this, [_0], function* ({ type, interface: providerInterface }) {
|
|
108
|
-
try {
|
|
109
|
-
const providerAddresses = yield providerInterface.getAddress();
|
|
110
|
-
const storedAddressesForType = Object.values(this.externalWallets).filter((wallet) => wallet.type === type).map((wallet) => Object.keys(this.externalWallets).find((addr) => this.externalWallets[addr] === wallet)).filter(Boolean);
|
|
111
|
-
const allAddressesAvailable = storedAddressesForType.every((addr) => providerAddresses.includes(addr));
|
|
112
|
-
return allAddressesAvailable;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.warn(`Error checking provider ${type}:`, error);
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}))
|
|
118
|
-
);
|
|
119
|
-
if (loadingResults.every((result) => result === true)) {
|
|
120
|
-
neededProviderInterfaces.forEach(({ type, interface: providerInterface }) => {
|
|
121
|
-
if (!__privateGet(this, _watchedProviders).has(type)) {
|
|
98
|
+
const allRegistered = Array.from(storedWalletTypes).every((type) => !!this.externalWalletProviderInterfaces[type]);
|
|
99
|
+
if (allRegistered) {
|
|
100
|
+
Array.from(storedWalletTypes).forEach((type) => {
|
|
101
|
+
const providerInterface = this.externalWalletProviderInterfaces[type];
|
|
102
|
+
if (providerInterface && !__privateGet(this, _watchedProviders).has(type)) {
|
|
122
103
|
__privateGet(this, _watchedProviders).add(type);
|
|
123
104
|
providerInterface.watchDisconnection(() => __async(this, null, function* () {
|
|
124
105
|
yield __privateGet(this, _onWalletDisconnected).call(this);
|
|
@@ -128,6 +109,7 @@ class ExternalWalletService {
|
|
|
128
109
|
}));
|
|
129
110
|
}
|
|
130
111
|
});
|
|
112
|
+
__privateGet(this, _validateConnectionDeferred).call(this);
|
|
131
113
|
return true;
|
|
132
114
|
}
|
|
133
115
|
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -138,7 +120,8 @@ class ExternalWalletService {
|
|
|
138
120
|
if (__privateGet(this, _stateManager).getSnapshot().authStatePhase === "switching_external_wallet") {
|
|
139
121
|
return;
|
|
140
122
|
}
|
|
141
|
-
|
|
123
|
+
const connectionType = this.externalWalletConnectionType;
|
|
124
|
+
if (connectionType === "NONE") {
|
|
142
125
|
return;
|
|
143
126
|
}
|
|
144
127
|
const connectedAddresses = (yield Promise.all(
|
|
@@ -146,6 +129,9 @@ class ExternalWalletService {
|
|
|
146
129
|
return yield providerInterface.getAddress();
|
|
147
130
|
}))
|
|
148
131
|
)).filter((a) => !!a);
|
|
132
|
+
if (connectedAddresses.length === 0) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
149
135
|
const storedExternalWalletAddresses = Object.keys(this.externalWallets);
|
|
150
136
|
const someConnectedHaveStoredWallets = connectedAddresses.some(
|
|
151
137
|
(connectedAddress) => connectedAddress && this.externalWallets[connectedAddress]
|
|
@@ -214,11 +200,53 @@ class ExternalWalletService {
|
|
|
214
200
|
}
|
|
215
201
|
__privateGet(this, _stateManager).send({ type: "SWITCH_EXTERNAL_WALLET", data: params });
|
|
216
202
|
});
|
|
203
|
+
/**
|
|
204
|
+
* Poll until the wallet adapter connects, then validate the address matches a stored wallet.
|
|
205
|
+
* If the adapter doesn't connect within the timeout, or connects with the wrong address, log out.
|
|
206
|
+
*/
|
|
207
|
+
__privateAdd(this, _validateConnectionDeferred, () => {
|
|
208
|
+
const POLL_INTERVAL_MS = 500;
|
|
209
|
+
const TIMEOUT_MS = 1e4;
|
|
210
|
+
const startedAt = Date.now();
|
|
211
|
+
const poll = () => __async(this, null, function* () {
|
|
212
|
+
if (this.externalWalletConnectionType === "NONE") {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const connectedAddresses = (yield Promise.all(
|
|
216
|
+
Object.values(this.externalWalletProviderInterfaces).map((providerInterface) => __async(this, null, function* () {
|
|
217
|
+
return yield providerInterface.getAddress();
|
|
218
|
+
}))
|
|
219
|
+
)).filter((a) => !!a);
|
|
220
|
+
if (connectedAddresses.length === 0) {
|
|
221
|
+
if (Date.now() - startedAt >= TIMEOUT_MS) {
|
|
222
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
setTimeout(() => void poll(), POLL_INTERVAL_MS);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const someMatchesStored = connectedAddresses.some((addr) => addr && this.externalWallets[addr]);
|
|
229
|
+
if (!someMatchesStored) {
|
|
230
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
setTimeout(() => void poll(), POLL_INTERVAL_MS);
|
|
234
|
+
});
|
|
217
235
|
__privateAdd(this, _onWalletDisconnected, () => __async(this, null, function* () {
|
|
218
|
-
|
|
236
|
+
const connectionType = this.externalWalletConnectionType;
|
|
237
|
+
if (connectionType === "NONE") {
|
|
219
238
|
return;
|
|
220
239
|
}
|
|
221
|
-
yield
|
|
240
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
241
|
+
const connectedAddresses = (yield Promise.all(
|
|
242
|
+
Object.values(this.externalWalletProviderInterfaces).map((providerInterface) => __async(this, null, function* () {
|
|
243
|
+
return yield providerInterface.getAddress();
|
|
244
|
+
}))
|
|
245
|
+
)).filter((a) => !!a);
|
|
246
|
+
const someStillConnected = connectedAddresses.some((addr) => addr && this.externalWallets[addr]);
|
|
247
|
+
if (!someStillConnected) {
|
|
248
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
249
|
+
}
|
|
222
250
|
}));
|
|
223
251
|
/**
|
|
224
252
|
* Function to perform connecting an external wallet
|
|
@@ -379,6 +407,7 @@ _walletService = new WeakMap();
|
|
|
379
407
|
_paraCoreInterface = new WeakMap();
|
|
380
408
|
_externalWallets = new WeakMap();
|
|
381
409
|
_watchedProviders = new WeakMap();
|
|
410
|
+
_validateConnectionDeferred = new WeakMap();
|
|
382
411
|
_onWalletDisconnected = new WeakMap();
|
|
383
412
|
// Annotate the CommonJS export names for ESM import in node:
|
|
384
413
|
0 && (module.exports = {
|
|
@@ -105,6 +105,9 @@ class PortalUrlService {
|
|
|
105
105
|
* @returns - portal URL
|
|
106
106
|
*/
|
|
107
107
|
this.getPortalURL = (isLegacy) => __async(this, null, function* () {
|
|
108
|
+
if (__privateGet(this, _paraCoreInterface).ctx.isE2E) {
|
|
109
|
+
return (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
110
|
+
}
|
|
108
111
|
return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
109
112
|
});
|
|
110
113
|
this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
|
|
@@ -42,11 +42,7 @@ __export(waitForExternalWalletProviders_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(waitForExternalWalletProviders_exports);
|
|
43
43
|
var import_xstate = require("xstate");
|
|
44
44
|
const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => (0, import_xstate.fromPromise)(() => __async(void 0, null, function* () {
|
|
45
|
-
|
|
46
|
-
if (!resp) {
|
|
47
|
-
yield stateMachineInterface.logout();
|
|
48
|
-
}
|
|
49
|
-
return resp;
|
|
45
|
+
return yield stateMachineInterface.externalWalletService.waitForProvidersLoading();
|
|
50
46
|
}));
|
|
51
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
48
|
0 && (module.exports = {
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -149,6 +149,7 @@ const _ParaCore = class _ParaCore {
|
|
|
149
149
|
methodName,
|
|
150
150
|
sdkType: this.platformUtils.sdkType,
|
|
151
151
|
userId: this.userId,
|
|
152
|
+
sdkVersion: _ParaCore.version,
|
|
152
153
|
error: {
|
|
153
154
|
name: err.name,
|
|
154
155
|
message: err.message
|
|
@@ -345,9 +346,8 @@ const _ParaCore = class _ParaCore {
|
|
|
345
346
|
}
|
|
346
347
|
if (!opts) opts = {};
|
|
347
348
|
__privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
|
|
348
|
-
|
|
349
|
-
if (env
|
|
350
|
-
isE2E = true;
|
|
349
|
+
const isE2E = env === "E2E" || envOrApiKey === "E2E";
|
|
350
|
+
if (isE2E && env !== Environment.SANDBOX) {
|
|
351
351
|
env = Environment.SANDBOX;
|
|
352
352
|
}
|
|
353
353
|
this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
|
|
@@ -438,22 +438,20 @@ const _ParaCore = class _ParaCore {
|
|
|
438
438
|
this.initializeFromStorage();
|
|
439
439
|
setupListeners.bind(this)();
|
|
440
440
|
autoBind(this);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
]);
|
|
456
|
-
}
|
|
441
|
+
this.wrapMethodsWithErrorTracking([
|
|
442
|
+
"signUpOrLogIn",
|
|
443
|
+
"verifyNewAccount",
|
|
444
|
+
"waitForLogin",
|
|
445
|
+
"waitForSignup",
|
|
446
|
+
"waitForWalletCreation",
|
|
447
|
+
"verifyOAuth",
|
|
448
|
+
"verifyTelegram",
|
|
449
|
+
"verifyFarcaster",
|
|
450
|
+
"createPregenWallet",
|
|
451
|
+
"claimPregenWallets",
|
|
452
|
+
"signMessage",
|
|
453
|
+
"signTransaction"
|
|
454
|
+
]);
|
|
457
455
|
__privateGet(this, _stateManager).start();
|
|
458
456
|
}
|
|
459
457
|
setModalError(_error) {
|
|
@@ -2085,7 +2083,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2085
2083
|
cosmosSignDocBase64,
|
|
2086
2084
|
isCanceled = () => false,
|
|
2087
2085
|
onCancel,
|
|
2088
|
-
onPoll
|
|
2086
|
+
onPoll,
|
|
2087
|
+
onTransactionReviewUrl
|
|
2089
2088
|
}) {
|
|
2090
2089
|
var _a;
|
|
2091
2090
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
@@ -2098,10 +2097,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2098
2097
|
let timeStart = Date.now();
|
|
2099
2098
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2100
2099
|
if (signRes.pendingTransactionId) {
|
|
2101
|
-
yield this.
|
|
2102
|
-
|
|
2103
|
-
|
|
2100
|
+
const reviewUrl = yield this.getTransactionReviewUrl(
|
|
2101
|
+
signRes.pendingTransactionId,
|
|
2102
|
+
effectiveTimeoutMs
|
|
2104
2103
|
);
|
|
2104
|
+
if (onTransactionReviewUrl) {
|
|
2105
|
+
onTransactionReviewUrl(reviewUrl);
|
|
2106
|
+
} else {
|
|
2107
|
+
yield this.platformUtils.openPopup(reviewUrl, {
|
|
2108
|
+
type: cosmosSignDocBase64 ? PopupType.SIGN_TRANSACTION_REVIEW : PopupType.SIGN_MESSAGE_REVIEW
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2105
2111
|
} else {
|
|
2106
2112
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2107
2113
|
return signRes;
|
|
@@ -2191,7 +2197,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2191
2197
|
timeoutMs = 3e4,
|
|
2192
2198
|
isCanceled = () => false,
|
|
2193
2199
|
onCancel,
|
|
2194
|
-
onPoll
|
|
2200
|
+
onPoll,
|
|
2201
|
+
onTransactionReviewUrl
|
|
2195
2202
|
}) {
|
|
2196
2203
|
var _a;
|
|
2197
2204
|
__privateGet(this, _walletService).assertIsValidWalletId(walletId);
|
|
@@ -2213,10 +2220,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2213
2220
|
let timeStart = Date.now();
|
|
2214
2221
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2215
2222
|
if (signRes.pendingTransactionId) {
|
|
2216
|
-
yield this.
|
|
2217
|
-
|
|
2218
|
-
|
|
2223
|
+
const reviewUrl = yield this.getTransactionReviewUrl(
|
|
2224
|
+
signRes.pendingTransactionId,
|
|
2225
|
+
effectiveTimeoutMs
|
|
2219
2226
|
);
|
|
2227
|
+
if (onTransactionReviewUrl) {
|
|
2228
|
+
onTransactionReviewUrl(reviewUrl);
|
|
2229
|
+
} else {
|
|
2230
|
+
yield this.platformUtils.openPopup(reviewUrl, { type: PopupType.SIGN_TRANSACTION_REVIEW });
|
|
2231
|
+
}
|
|
2220
2232
|
} else {
|
|
2221
2233
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2222
2234
|
return signRes;
|
|
@@ -2312,10 +2324,14 @@ const _ParaCore = class _ParaCore {
|
|
|
2312
2324
|
}
|
|
2313
2325
|
/**
|
|
2314
2326
|
* Serialize the current session for import by another Para instance.
|
|
2327
|
+
* @deprecated Use {@link waitAndExportSession} instead, which awaits auth settlement before exporting.
|
|
2315
2328
|
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2316
2329
|
* @returns {string} the serialized session
|
|
2317
2330
|
*/
|
|
2318
2331
|
exportSession({ excludeSigners = false } = {}) {
|
|
2332
|
+
if (__privateGet(this, _stateManager).getSnapshot().authStatePhase !== "authenticated") {
|
|
2333
|
+
throw new Error("Cannot export session: user is not authenticated.");
|
|
2334
|
+
}
|
|
2319
2335
|
const sessionInfo = {
|
|
2320
2336
|
authInfo: __privateGet(this, _authService).authInfo,
|
|
2321
2337
|
userId: this.userId,
|
|
@@ -2331,6 +2347,32 @@ const _ParaCore = class _ParaCore {
|
|
|
2331
2347
|
}
|
|
2332
2348
|
return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
|
|
2333
2349
|
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Awaits auth settlement, then serializes the current session for import by another Para instance.
|
|
2352
|
+
* Unlike {@link exportSession}, this method waits for the auth state machine to reach the
|
|
2353
|
+
* `authenticated` phase before reading state, ensuring the exported data is up-to-date.
|
|
2354
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2355
|
+
* @returns {Promise<string>} the serialized session
|
|
2356
|
+
*/
|
|
2357
|
+
waitAndExportSession() {
|
|
2358
|
+
return __async(this, arguments, function* (params = {}) {
|
|
2359
|
+
yield waitForAuthStateChange({
|
|
2360
|
+
stateManager: __privateGet(this, _stateManager),
|
|
2361
|
+
resolvePhases: [{ phase: "authenticated", onPhase: () => void 0 }],
|
|
2362
|
+
rejectPhases: [
|
|
2363
|
+
{
|
|
2364
|
+
phase: "unauthenticated",
|
|
2365
|
+
onPhase: () => new Error("No active session to export.")
|
|
2366
|
+
},
|
|
2367
|
+
{
|
|
2368
|
+
phase: "guest_mode",
|
|
2369
|
+
onPhase: () => new Error("Cannot export session in guest mode.")
|
|
2370
|
+
}
|
|
2371
|
+
]
|
|
2372
|
+
});
|
|
2373
|
+
return this.exportSession(params);
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2334
2376
|
/**
|
|
2335
2377
|
* Imports a session serialized by another Para instance.
|
|
2336
2378
|
* @param {string} serializedInstanceBase64 the serialized session
|
package/dist/esm/constants.js
CHANGED
|
@@ -49,7 +49,7 @@ function encryptPrivateKey(keyPair, key) {
|
|
|
49
49
|
const ciphertext = yield window.crypto.subtle.encrypt(
|
|
50
50
|
{ name: "AES-GCM", iv: CONSTANT_IV_AES },
|
|
51
51
|
cryptoKey,
|
|
52
|
-
encodedPlaintext
|
|
52
|
+
encodedPlaintext.buffer
|
|
53
53
|
);
|
|
54
54
|
return Buffer.from(ciphertext).toString("base64");
|
|
55
55
|
});
|
|
@@ -232,7 +232,7 @@ function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
|
|
|
232
232
|
const ciphertext = yield window.crypto.subtle.encrypt(
|
|
233
233
|
{ name: "AES-GCM", iv: CONSTANT_IV_AES },
|
|
234
234
|
cryptoKey,
|
|
235
|
-
encodedPlaintext
|
|
235
|
+
encodedPlaintext.buffer
|
|
236
236
|
);
|
|
237
237
|
return Buffer.from(ciphertext).toString("base64");
|
|
238
238
|
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
__spreadProps,
|
|
7
7
|
__spreadValues
|
|
8
8
|
} from "../chunk-7B52C2XE.js";
|
|
9
|
-
var _stateManager, _authService, _walletService, _paraCoreInterface, _externalWallets, _watchedProviders, _onWalletDisconnected;
|
|
9
|
+
var _stateManager, _authService, _walletService, _paraCoreInterface, _externalWallets, _watchedProviders, _validateConnectionDeferred, _onWalletDisconnected;
|
|
10
10
|
import { ParaEvent } from "../types/events.js";
|
|
11
11
|
import { LOCAL_STORAGE_EXTERNAL_WALLETS } from "../constants.js";
|
|
12
12
|
import { dispatchEvent } from "../utils/index.js";
|
|
@@ -37,30 +37,11 @@ class ExternalWalletService {
|
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
39
|
for (let i = 0; i < 20; i++) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const loadingResults = yield Promise.all(
|
|
49
|
-
neededProviderInterfaces.map((_0) => __async(this, [_0], function* ({ type, interface: providerInterface }) {
|
|
50
|
-
try {
|
|
51
|
-
const providerAddresses = yield providerInterface.getAddress();
|
|
52
|
-
const storedAddressesForType = Object.values(this.externalWallets).filter((wallet) => wallet.type === type).map((wallet) => Object.keys(this.externalWallets).find((addr) => this.externalWallets[addr] === wallet)).filter(Boolean);
|
|
53
|
-
const allAddressesAvailable = storedAddressesForType.every((addr) => providerAddresses.includes(addr));
|
|
54
|
-
return allAddressesAvailable;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.warn(`Error checking provider ${type}:`, error);
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}))
|
|
60
|
-
);
|
|
61
|
-
if (loadingResults.every((result) => result === true)) {
|
|
62
|
-
neededProviderInterfaces.forEach(({ type, interface: providerInterface }) => {
|
|
63
|
-
if (!__privateGet(this, _watchedProviders).has(type)) {
|
|
40
|
+
const allRegistered = Array.from(storedWalletTypes).every((type) => !!this.externalWalletProviderInterfaces[type]);
|
|
41
|
+
if (allRegistered) {
|
|
42
|
+
Array.from(storedWalletTypes).forEach((type) => {
|
|
43
|
+
const providerInterface = this.externalWalletProviderInterfaces[type];
|
|
44
|
+
if (providerInterface && !__privateGet(this, _watchedProviders).has(type)) {
|
|
64
45
|
__privateGet(this, _watchedProviders).add(type);
|
|
65
46
|
providerInterface.watchDisconnection(() => __async(this, null, function* () {
|
|
66
47
|
yield __privateGet(this, _onWalletDisconnected).call(this);
|
|
@@ -70,6 +51,7 @@ class ExternalWalletService {
|
|
|
70
51
|
}));
|
|
71
52
|
}
|
|
72
53
|
});
|
|
54
|
+
__privateGet(this, _validateConnectionDeferred).call(this);
|
|
73
55
|
return true;
|
|
74
56
|
}
|
|
75
57
|
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -80,7 +62,8 @@ class ExternalWalletService {
|
|
|
80
62
|
if (__privateGet(this, _stateManager).getSnapshot().authStatePhase === "switching_external_wallet") {
|
|
81
63
|
return;
|
|
82
64
|
}
|
|
83
|
-
|
|
65
|
+
const connectionType = this.externalWalletConnectionType;
|
|
66
|
+
if (connectionType === "NONE") {
|
|
84
67
|
return;
|
|
85
68
|
}
|
|
86
69
|
const connectedAddresses = (yield Promise.all(
|
|
@@ -88,6 +71,9 @@ class ExternalWalletService {
|
|
|
88
71
|
return yield providerInterface.getAddress();
|
|
89
72
|
}))
|
|
90
73
|
)).filter((a) => !!a);
|
|
74
|
+
if (connectedAddresses.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
91
77
|
const storedExternalWalletAddresses = Object.keys(this.externalWallets);
|
|
92
78
|
const someConnectedHaveStoredWallets = connectedAddresses.some(
|
|
93
79
|
(connectedAddress) => connectedAddress && this.externalWallets[connectedAddress]
|
|
@@ -156,11 +142,53 @@ class ExternalWalletService {
|
|
|
156
142
|
}
|
|
157
143
|
__privateGet(this, _stateManager).send({ type: "SWITCH_EXTERNAL_WALLET", data: params });
|
|
158
144
|
});
|
|
145
|
+
/**
|
|
146
|
+
* Poll until the wallet adapter connects, then validate the address matches a stored wallet.
|
|
147
|
+
* If the adapter doesn't connect within the timeout, or connects with the wrong address, log out.
|
|
148
|
+
*/
|
|
149
|
+
__privateAdd(this, _validateConnectionDeferred, () => {
|
|
150
|
+
const POLL_INTERVAL_MS = 500;
|
|
151
|
+
const TIMEOUT_MS = 1e4;
|
|
152
|
+
const startedAt = Date.now();
|
|
153
|
+
const poll = () => __async(this, null, function* () {
|
|
154
|
+
if (this.externalWalletConnectionType === "NONE") {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const connectedAddresses = (yield Promise.all(
|
|
158
|
+
Object.values(this.externalWalletProviderInterfaces).map((providerInterface) => __async(this, null, function* () {
|
|
159
|
+
return yield providerInterface.getAddress();
|
|
160
|
+
}))
|
|
161
|
+
)).filter((a) => !!a);
|
|
162
|
+
if (connectedAddresses.length === 0) {
|
|
163
|
+
if (Date.now() - startedAt >= TIMEOUT_MS) {
|
|
164
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
setTimeout(() => void poll(), POLL_INTERVAL_MS);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const someMatchesStored = connectedAddresses.some((addr) => addr && this.externalWallets[addr]);
|
|
171
|
+
if (!someMatchesStored) {
|
|
172
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
setTimeout(() => void poll(), POLL_INTERVAL_MS);
|
|
176
|
+
});
|
|
159
177
|
__privateAdd(this, _onWalletDisconnected, () => __async(this, null, function* () {
|
|
160
|
-
|
|
178
|
+
const connectionType = this.externalWalletConnectionType;
|
|
179
|
+
if (connectionType === "NONE") {
|
|
161
180
|
return;
|
|
162
181
|
}
|
|
163
|
-
yield
|
|
182
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
183
|
+
const connectedAddresses = (yield Promise.all(
|
|
184
|
+
Object.values(this.externalWalletProviderInterfaces).map((providerInterface) => __async(this, null, function* () {
|
|
185
|
+
return yield providerInterface.getAddress();
|
|
186
|
+
}))
|
|
187
|
+
)).filter((a) => !!a);
|
|
188
|
+
const someStillConnected = connectedAddresses.some((addr) => addr && this.externalWallets[addr]);
|
|
189
|
+
if (!someStillConnected) {
|
|
190
|
+
yield __privateGet(this, _paraCoreInterface).logout();
|
|
191
|
+
}
|
|
164
192
|
}));
|
|
165
193
|
/**
|
|
166
194
|
* Function to perform connecting an external wallet
|
|
@@ -321,6 +349,7 @@ _walletService = new WeakMap();
|
|
|
321
349
|
_paraCoreInterface = new WeakMap();
|
|
322
350
|
_externalWallets = new WeakMap();
|
|
323
351
|
_watchedProviders = new WeakMap();
|
|
352
|
+
_validateConnectionDeferred = new WeakMap();
|
|
324
353
|
_onWalletDisconnected = new WeakMap();
|
|
325
354
|
export {
|
|
326
355
|
ExternalWalletService
|
|
@@ -47,6 +47,9 @@ class PortalUrlService {
|
|
|
47
47
|
* @returns - portal URL
|
|
48
48
|
*/
|
|
49
49
|
this.getPortalURL = (isLegacy) => __async(this, null, function* () {
|
|
50
|
+
if (__privateGet(this, _paraCoreInterface).ctx.isE2E) {
|
|
51
|
+
return getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
52
|
+
}
|
|
50
53
|
return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
|
|
51
54
|
});
|
|
52
55
|
this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
|
|
@@ -3,11 +3,7 @@ import {
|
|
|
3
3
|
} from "../../chunk-7B52C2XE.js";
|
|
4
4
|
import { fromPromise } from "xstate";
|
|
5
5
|
const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => fromPromise(() => __async(void 0, null, function* () {
|
|
6
|
-
|
|
7
|
-
if (!resp) {
|
|
8
|
-
yield stateMachineInterface.logout();
|
|
9
|
-
}
|
|
10
|
-
return resp;
|
|
6
|
+
return yield stateMachineInterface.externalWalletService.waitForProvidersLoading();
|
|
11
7
|
}));
|
|
12
8
|
export {
|
|
13
9
|
createWaitForExternalWalletProvidersActor
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -735,7 +735,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
735
735
|
* @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds. Extended to a minimum of 5 minutes when the transaction requires approval.
|
|
736
736
|
* @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
|
|
737
737
|
**/
|
|
738
|
-
signMessage({ walletId, messageBase64, timeoutMs, cosmosSignDocBase64, isCanceled, onCancel, onPoll, }: CoreMethodParams<'signMessage'>): CoreMethodResponse<'signMessage'>;
|
|
738
|
+
signMessage({ walletId, messageBase64, timeoutMs, cosmosSignDocBase64, isCanceled, onCancel, onPoll, onTransactionReviewUrl, }: CoreMethodParams<'signMessage'>): CoreMethodResponse<'signMessage'>;
|
|
739
739
|
private signMessageInner;
|
|
740
740
|
/**
|
|
741
741
|
* Signs a transaction.
|
|
@@ -745,7 +745,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
745
745
|
* @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
|
|
746
746
|
* @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds. Extended to a minimum of 5 minutes when the transaction requires approval.
|
|
747
747
|
**/
|
|
748
|
-
signTransaction({ walletId, rlpEncodedTxBase64, chainId, timeoutMs, isCanceled, onCancel, onPoll, }: CoreMethodParams<'signTransaction'>): CoreMethodResponse<'signTransaction'>;
|
|
748
|
+
signTransaction({ walletId, rlpEncodedTxBase64, chainId, timeoutMs, isCanceled, onCancel, onPoll, onTransactionReviewUrl, }: CoreMethodParams<'signTransaction'>): CoreMethodResponse<'signTransaction'>;
|
|
749
749
|
protected isProviderModalDisabled(): boolean;
|
|
750
750
|
/**
|
|
751
751
|
* Starts a on-ramp or off-ramp transaction and returns the Para Portal link for the user to finalize and complete it.
|
|
@@ -762,10 +762,19 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
762
762
|
keepSessionAlive(): Promise<boolean>;
|
|
763
763
|
/**
|
|
764
764
|
* Serialize the current session for import by another Para instance.
|
|
765
|
+
* @deprecated Use {@link waitAndExportSession} instead, which awaits auth settlement before exporting.
|
|
765
766
|
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
766
767
|
* @returns {string} the serialized session
|
|
767
768
|
*/
|
|
768
769
|
exportSession({ excludeSigners }?: CoreMethodParams<'exportSession'>): CoreMethodResponse<'exportSession'>;
|
|
770
|
+
/**
|
|
771
|
+
* Awaits auth settlement, then serializes the current session for import by another Para instance.
|
|
772
|
+
* Unlike {@link exportSession}, this method waits for the auth state machine to reach the
|
|
773
|
+
* `authenticated` phase before reading state, ensuring the exported data is up-to-date.
|
|
774
|
+
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
775
|
+
* @returns {Promise<string>} the serialized session
|
|
776
|
+
*/
|
|
777
|
+
waitAndExportSession(params?: CoreMethodParams<'waitAndExportSession'>): CoreMethodResponse<'waitAndExportSession'>;
|
|
769
778
|
/**
|
|
770
779
|
* Imports a session serialized by another Para instance.
|
|
771
780
|
* @param {string} serializedInstanceBase64 the serialized session
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParaCore } from './ParaCore.js';
|
|
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, type WalletWithMetadata, 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, formatAssetQuantity, formatCurrency, type EstimateTransactionOpts, type EstimateTransactionResult, type BroadcastTransactionOpts, type BroadcastTransactionResult, } from '@getpara/user-management-client';
|
|
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, type WalletWithMetadata, 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, formatAssetQuantity, formatCurrency, type EstimateTransactionOpts, type EstimateTransactionResult, type BroadcastTransactionOpts, type BroadcastTransactionResult, type PendingTransactionEntity, type SerializedDecodedTx, type SerializedTxData, type GetPendingTransactionResponse, } from '@getpara/user-management-client';
|
|
3
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 AccountLinkInProgress, AccountLinkError, type InternalInterface, type Verify2faParams, type Verify2faResponse, type StorageType, type TelegramParams, } from './types/index.js';
|
|
4
4
|
export * from './types/coreApi.js';
|
|
5
5
|
export * from './types/events.js';
|
|
@@ -17,6 +17,15 @@ export type PollingCallbacks = {
|
|
|
17
17
|
* Signal to cancel the polling.
|
|
18
18
|
*/
|
|
19
19
|
isCanceled?: () => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback fired when a transaction requires user review. Receives the portal URL
|
|
22
|
+
* that must be opened for the user to approve or deny the transaction.
|
|
23
|
+
*
|
|
24
|
+
* On web this is handled automatically via a popup. On React Native, provide this
|
|
25
|
+
* callback to open the URL in an in-app browser (e.g. `expo-web-browser`).
|
|
26
|
+
* If not provided, the SDK falls back to `openPopup` (which throws on React Native).
|
|
27
|
+
*/
|
|
28
|
+
onTransactionReviewUrl?: (url: string) => void;
|
|
20
29
|
};
|
|
21
30
|
export interface PollingConfig<T> extends PollingCallbacks {
|
|
22
31
|
init?: () => Promise<void>;
|
|
@@ -4,7 +4,7 @@ import { ParaCore } from '../ParaCore.js';
|
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './accountLinking.js';
|
|
6
6
|
import type { WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, WaitForWalletCreationResponse, GetOAuthUrlParams, AddCredentialParams, LoginExternalWalletParams, LoginExternalWalletResponse, ResendVerificationCodeParams, SignUpOrLogInParams, SignUpOrLogInResponse, VerifyOAuthProcessParams, VerifyExternalWalletParams, VerifyExternalWalletResponse, VerifyFarcasterParams, VerifyTelegramParams, ClaimPregenWalletsParams, ClaimPregenWalletsResponse, CreateGuestWalletsResponse, CreatePregenWalletParams, CreatePregenWalletPerTypeParams, CreatePregenWalletPerTypeResponse, CreatePregenWalletResponse, CreateWalletParams, CreateWalletPerTypeParams, CreateWalletPerTypeResponse, CreateWalletResponse, DistributeNewWalletShareParams, GetPregenWalletsParams, GetPregenWalletsResponse, GetWalletBalanceParams, HasPregenWalletParams, PollingCallbacks, RefreshShareParams, RefreshShareResponse, UpdatePregenWalletIdentifierParams, BaseVerifyExternalWalletParams, AuthenticateWithEmailOrPhoneParams, AuthenticateWithEmailOrPhoneResponse, AuthenticateWithOAuthParams, AuthenticateWithOAuthResponse } from '../services/types';
|
|
7
|
-
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", "authenticateWithEmailOrPhone", "authenticateWithOAuth"];
|
|
7
|
+
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", "waitAndExportSession", "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", "authenticateWithEmailOrPhone", "authenticateWithOAuth"];
|
|
8
8
|
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
|
|
9
9
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
10
10
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
@@ -227,6 +227,15 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
227
227
|
response: string;
|
|
228
228
|
sync: true;
|
|
229
229
|
};
|
|
230
|
+
waitAndExportSession: {
|
|
231
|
+
params: {
|
|
232
|
+
/**
|
|
233
|
+
* Whether to exclude the wallet signers from the exported session.
|
|
234
|
+
*/
|
|
235
|
+
excludeSigners?: boolean;
|
|
236
|
+
};
|
|
237
|
+
response: string;
|
|
238
|
+
};
|
|
230
239
|
importSession: {
|
|
231
240
|
params: string;
|
|
232
241
|
response: void;
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
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.
|
|
8
|
+
"@getpara/user-management-client": "2.18.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
|
+
"axios": "^1.8.4",
|
|
10
11
|
"base64url": "^3.0.1",
|
|
12
|
+
"elliptic": "^6.6.1",
|
|
11
13
|
"libphonenumber-js": "^1.11.7",
|
|
12
14
|
"node-forge": "^1.3.1",
|
|
13
15
|
"uuid": "^11.1.0",
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"dist",
|
|
29
31
|
"package.json"
|
|
30
32
|
],
|
|
31
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "4481f6f4e108e682d14c74d4433696141c47fc58",
|
|
32
34
|
"main": "dist/cjs/index.js",
|
|
33
35
|
"module": "dist/esm/index.js",
|
|
34
36
|
"scripts": {
|