@getpara/core-sdk 3.5.0 → 3.5.1
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 +67 -35
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/errors.js +12 -0
- package/dist/esm/ParaCore.js +68 -36
- package/dist/esm/constants.js +1 -1
- package/dist/esm/errors.js +11 -0
- package/dist/types/ParaCore.d.ts +1 -0
- package/dist/types/errors.d.ts +13 -0
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -124,6 +124,24 @@ if (typeof global !== "undefined") {
|
|
|
124
124
|
self.global = self.global || self;
|
|
125
125
|
}
|
|
126
126
|
const { pki, jsbn } = import_node_forge.default;
|
|
127
|
+
const DEFAULT_SIGNING_RESULT_ERROR_MESSAGE = "Signing failed before a signature was produced.";
|
|
128
|
+
function getPendingTransactionId(signRes) {
|
|
129
|
+
return typeof signRes.pendingTransactionId === "string" && signRes.pendingTransactionId.length > 0 ? signRes.pendingTransactionId : void 0;
|
|
130
|
+
}
|
|
131
|
+
function requireSuccessfulSignatureResult(signRes) {
|
|
132
|
+
if (typeof signRes.signature === "string" && signRes.signature.length > 0) {
|
|
133
|
+
return { signature: signRes.signature };
|
|
134
|
+
}
|
|
135
|
+
throw new import_errors.SigningResultError(
|
|
136
|
+
typeof signRes.message === "string" && signRes.message.length > 0 ? signRes.message : DEFAULT_SIGNING_RESULT_ERROR_MESSAGE,
|
|
137
|
+
{
|
|
138
|
+
code: signRes.code,
|
|
139
|
+
status: signRes.status,
|
|
140
|
+
responseURL: signRes.responseURL,
|
|
141
|
+
data: signRes.data
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
127
145
|
const _ParaCore = class _ParaCore {
|
|
128
146
|
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
129
147
|
__privateAdd(this, _ParaCore_instances);
|
|
@@ -2417,6 +2435,14 @@ const _ParaCore = class _ParaCore {
|
|
|
2417
2435
|
return result.url;
|
|
2418
2436
|
});
|
|
2419
2437
|
}
|
|
2438
|
+
getDeniedSignatureResultWithUrl(pendingTransactionId) {
|
|
2439
|
+
return __async(this, null, function* () {
|
|
2440
|
+
return {
|
|
2441
|
+
pendingTransactionId,
|
|
2442
|
+
transactionReviewUrl: yield this.getTransactionReviewUrl(pendingTransactionId)
|
|
2443
|
+
};
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2420
2446
|
getOnRampTransactionUrl(_0) {
|
|
2421
2447
|
return __async(this, arguments, function* ({
|
|
2422
2448
|
purchaseId
|
|
@@ -2479,11 +2505,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2479
2505
|
);
|
|
2480
2506
|
let timeStart = Date.now();
|
|
2481
2507
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
effectiveTimeoutMs
|
|
2486
|
-
);
|
|
2508
|
+
let pendingTransactionId = getPendingTransactionId(signRes);
|
|
2509
|
+
if (pendingTransactionId) {
|
|
2510
|
+
const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
|
|
2487
2511
|
if (onTransactionReviewUrl) {
|
|
2488
2512
|
onTransactionReviewUrl(reviewUrl);
|
|
2489
2513
|
} else {
|
|
@@ -2492,8 +2516,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2492
2516
|
});
|
|
2493
2517
|
}
|
|
2494
2518
|
} else {
|
|
2495
|
-
|
|
2496
|
-
|
|
2519
|
+
const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
|
|
2520
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes2);
|
|
2521
|
+
return successfulSignRes2;
|
|
2497
2522
|
}
|
|
2498
2523
|
while (true) {
|
|
2499
2524
|
if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
|
|
@@ -2507,15 +2532,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2507
2532
|
"tx.review.poll",
|
|
2508
2533
|
(span) => __async(this, null, function* () {
|
|
2509
2534
|
var _a;
|
|
2510
|
-
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId,
|
|
2535
|
+
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2511
2536
|
span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
|
|
2512
2537
|
return res;
|
|
2513
2538
|
}),
|
|
2514
|
-
{ "pending_transaction.id":
|
|
2539
|
+
{ "pending_transaction.id": pendingTransactionId }
|
|
2515
2540
|
);
|
|
2516
2541
|
} catch (e) {
|
|
2517
2542
|
const error = new import_errors.TransactionReviewDenied();
|
|
2518
|
-
(0, import_utils2.dispatchEvent)(
|
|
2543
|
+
(0, import_utils2.dispatchEvent)(
|
|
2544
|
+
import_types.ParaEvent.SIGN_MESSAGE_EVENT,
|
|
2545
|
+
yield this.getDeniedSignatureResultWithUrl(pendingTransactionId),
|
|
2546
|
+
error.message
|
|
2547
|
+
);
|
|
2519
2548
|
throw error;
|
|
2520
2549
|
}
|
|
2521
2550
|
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
@@ -2530,16 +2559,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2530
2559
|
break;
|
|
2531
2560
|
}
|
|
2532
2561
|
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
);
|
|
2538
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2562
|
+
pendingTransactionId = getPendingTransactionId(signRes);
|
|
2563
|
+
if (pendingTransactionId) {
|
|
2564
|
+
const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
|
|
2565
|
+
const error = new import_errors.TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
|
|
2566
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, deniedSignRes, error.message);
|
|
2539
2567
|
throw error;
|
|
2540
2568
|
}
|
|
2541
|
-
|
|
2542
|
-
|
|
2569
|
+
const successfulSignRes = requireSuccessfulSignatureResult(signRes);
|
|
2570
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes);
|
|
2571
|
+
return successfulSignRes;
|
|
2543
2572
|
});
|
|
2544
2573
|
}
|
|
2545
2574
|
signMessageInner(_0) {
|
|
@@ -2618,19 +2647,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2618
2647
|
);
|
|
2619
2648
|
let timeStart = Date.now();
|
|
2620
2649
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
effectiveTimeoutMs
|
|
2625
|
-
);
|
|
2650
|
+
let pendingTransactionId = getPendingTransactionId(signRes);
|
|
2651
|
+
if (pendingTransactionId) {
|
|
2652
|
+
const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
|
|
2626
2653
|
if (onTransactionReviewUrl) {
|
|
2627
2654
|
onTransactionReviewUrl(reviewUrl);
|
|
2628
2655
|
} else {
|
|
2629
2656
|
yield this.platformUtils.openPopup(reviewUrl, { type: import_types.PopupType.SIGN_TRANSACTION_REVIEW });
|
|
2630
2657
|
}
|
|
2631
2658
|
} else {
|
|
2632
|
-
|
|
2633
|
-
|
|
2659
|
+
const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
|
|
2660
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes2);
|
|
2661
|
+
return successfulSignRes2;
|
|
2634
2662
|
}
|
|
2635
2663
|
while (true) {
|
|
2636
2664
|
if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
|
|
@@ -2638,7 +2666,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2638
2666
|
break;
|
|
2639
2667
|
}
|
|
2640
2668
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2641
|
-
const pendingTxId =
|
|
2669
|
+
const pendingTxId = pendingTransactionId;
|
|
2642
2670
|
let pendingTransaction;
|
|
2643
2671
|
try {
|
|
2644
2672
|
pendingTransaction = yield (0, import_tracer.wrapWithSpan)(
|
|
@@ -2653,7 +2681,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2653
2681
|
);
|
|
2654
2682
|
} catch (e) {
|
|
2655
2683
|
const error = new import_errors.TransactionReviewDenied();
|
|
2656
|
-
(0, import_utils2.dispatchEvent)(
|
|
2684
|
+
(0, import_utils2.dispatchEvent)(
|
|
2685
|
+
import_types.ParaEvent.SIGN_TRANSACTION_EVENT,
|
|
2686
|
+
yield this.getDeniedSignatureResultWithUrl(pendingTxId),
|
|
2687
|
+
error.message
|
|
2688
|
+
);
|
|
2657
2689
|
throw error;
|
|
2658
2690
|
}
|
|
2659
2691
|
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
@@ -2677,16 +2709,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2677
2709
|
break;
|
|
2678
2710
|
}
|
|
2679
2711
|
}
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
);
|
|
2685
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2712
|
+
pendingTransactionId = getPendingTransactionId(signRes);
|
|
2713
|
+
if (pendingTransactionId) {
|
|
2714
|
+
const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
|
|
2715
|
+
const error = new import_errors.TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
|
|
2716
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, deniedSignRes, error.message);
|
|
2686
2717
|
throw error;
|
|
2687
2718
|
}
|
|
2688
|
-
|
|
2689
|
-
|
|
2719
|
+
const successfulSignRes = requireSuccessfulSignatureResult(signRes);
|
|
2720
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes);
|
|
2721
|
+
return successfulSignRes;
|
|
2690
2722
|
});
|
|
2691
2723
|
}
|
|
2692
2724
|
isProviderModalDisabled() {
|
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 = "3.5.
|
|
49
|
+
const PARA_CORE_VERSION = "3.5.1";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
package/dist/cjs/errors.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var errors_exports = {};
|
|
19
19
|
__export(errors_exports, {
|
|
20
20
|
PartnerConfigError: () => PartnerConfigError,
|
|
21
|
+
SigningResultError: () => SigningResultError,
|
|
21
22
|
TransactionReviewDenied: () => TransactionReviewDenied,
|
|
22
23
|
TransactionReviewError: () => TransactionReviewError,
|
|
23
24
|
TransactionReviewTimeout: () => TransactionReviewTimeout
|
|
@@ -44,6 +45,16 @@ class TransactionReviewTimeout extends Error {
|
|
|
44
45
|
this.pendingTransactionId = pendingTransactionId;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
class SigningResultError extends Error {
|
|
49
|
+
constructor(message, options = {}) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "SigningResultError";
|
|
52
|
+
this.code = options.code;
|
|
53
|
+
this.status = options.status;
|
|
54
|
+
this.responseURL = options.responseURL;
|
|
55
|
+
this.data = options.data;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
class PartnerConfigError extends Error {
|
|
48
59
|
constructor(code, message, detail) {
|
|
49
60
|
super(message);
|
|
@@ -55,6 +66,7 @@ class PartnerConfigError extends Error {
|
|
|
55
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
67
|
0 && (module.exports = {
|
|
57
68
|
PartnerConfigError,
|
|
69
|
+
SigningResultError,
|
|
58
70
|
TransactionReviewDenied,
|
|
59
71
|
TransactionReviewError,
|
|
60
72
|
TransactionReviewTimeout
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
import { waitForAuthStateChange } from "./utils/stateListener.js";
|
|
55
55
|
import { warnOnce } from "./utils/deprecation.js";
|
|
56
56
|
import { assertConfigAllowed } from "./utils/partnerConfigGating.js";
|
|
57
|
-
import { TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
|
|
57
|
+
import { SigningResultError, TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
|
|
58
58
|
import * as constants from "./constants.js";
|
|
59
59
|
import { EnclaveClient } from "./shares/enclave.js";
|
|
60
60
|
import { AuthService } from "./services/AuthService.js";
|
|
@@ -69,6 +69,24 @@ import { wrapWithSpan } from "./telemetry/tracer.js";
|
|
|
69
69
|
import { setCurrentUserId } from "./telemetry/uxStateSpanProcessor.js";
|
|
70
70
|
import { initTelemetry } from "./telemetry/init.js";
|
|
71
71
|
import { recordActionOnSpan } from "./telemetry/uxAction.js";
|
|
72
|
+
const DEFAULT_SIGNING_RESULT_ERROR_MESSAGE = "Signing failed before a signature was produced.";
|
|
73
|
+
function getPendingTransactionId(signRes) {
|
|
74
|
+
return typeof signRes.pendingTransactionId === "string" && signRes.pendingTransactionId.length > 0 ? signRes.pendingTransactionId : void 0;
|
|
75
|
+
}
|
|
76
|
+
function requireSuccessfulSignatureResult(signRes) {
|
|
77
|
+
if (typeof signRes.signature === "string" && signRes.signature.length > 0) {
|
|
78
|
+
return { signature: signRes.signature };
|
|
79
|
+
}
|
|
80
|
+
throw new SigningResultError(
|
|
81
|
+
typeof signRes.message === "string" && signRes.message.length > 0 ? signRes.message : DEFAULT_SIGNING_RESULT_ERROR_MESSAGE,
|
|
82
|
+
{
|
|
83
|
+
code: signRes.code,
|
|
84
|
+
status: signRes.status,
|
|
85
|
+
responseURL: signRes.responseURL,
|
|
86
|
+
data: signRes.data
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
72
90
|
const _ParaCore = class _ParaCore {
|
|
73
91
|
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
74
92
|
__privateAdd(this, _ParaCore_instances);
|
|
@@ -2362,6 +2380,14 @@ const _ParaCore = class _ParaCore {
|
|
|
2362
2380
|
return result.url;
|
|
2363
2381
|
});
|
|
2364
2382
|
}
|
|
2383
|
+
getDeniedSignatureResultWithUrl(pendingTransactionId) {
|
|
2384
|
+
return __async(this, null, function* () {
|
|
2385
|
+
return {
|
|
2386
|
+
pendingTransactionId,
|
|
2387
|
+
transactionReviewUrl: yield this.getTransactionReviewUrl(pendingTransactionId)
|
|
2388
|
+
};
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2365
2391
|
getOnRampTransactionUrl(_0) {
|
|
2366
2392
|
return __async(this, arguments, function* ({
|
|
2367
2393
|
purchaseId
|
|
@@ -2424,11 +2450,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2424
2450
|
);
|
|
2425
2451
|
let timeStart = Date.now();
|
|
2426
2452
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
effectiveTimeoutMs
|
|
2431
|
-
);
|
|
2453
|
+
let pendingTransactionId = getPendingTransactionId(signRes);
|
|
2454
|
+
if (pendingTransactionId) {
|
|
2455
|
+
const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
|
|
2432
2456
|
if (onTransactionReviewUrl) {
|
|
2433
2457
|
onTransactionReviewUrl(reviewUrl);
|
|
2434
2458
|
} else {
|
|
@@ -2437,8 +2461,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2437
2461
|
});
|
|
2438
2462
|
}
|
|
2439
2463
|
} else {
|
|
2440
|
-
|
|
2441
|
-
|
|
2464
|
+
const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
|
|
2465
|
+
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes2);
|
|
2466
|
+
return successfulSignRes2;
|
|
2442
2467
|
}
|
|
2443
2468
|
while (true) {
|
|
2444
2469
|
if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
|
|
@@ -2452,15 +2477,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2452
2477
|
"tx.review.poll",
|
|
2453
2478
|
(span) => __async(this, null, function* () {
|
|
2454
2479
|
var _a;
|
|
2455
|
-
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId,
|
|
2480
|
+
const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2456
2481
|
span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
|
|
2457
2482
|
return res;
|
|
2458
2483
|
}),
|
|
2459
|
-
{ "pending_transaction.id":
|
|
2484
|
+
{ "pending_transaction.id": pendingTransactionId }
|
|
2460
2485
|
);
|
|
2461
2486
|
} catch (e) {
|
|
2462
2487
|
const error = new TransactionReviewDenied();
|
|
2463
|
-
dispatchEvent(
|
|
2488
|
+
dispatchEvent(
|
|
2489
|
+
ParaEvent.SIGN_MESSAGE_EVENT,
|
|
2490
|
+
yield this.getDeniedSignatureResultWithUrl(pendingTransactionId),
|
|
2491
|
+
error.message
|
|
2492
|
+
);
|
|
2464
2493
|
throw error;
|
|
2465
2494
|
}
|
|
2466
2495
|
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
@@ -2475,16 +2504,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2475
2504
|
break;
|
|
2476
2505
|
}
|
|
2477
2506
|
}
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
);
|
|
2483
|
-
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2507
|
+
pendingTransactionId = getPendingTransactionId(signRes);
|
|
2508
|
+
if (pendingTransactionId) {
|
|
2509
|
+
const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
|
|
2510
|
+
const error = new TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
|
|
2511
|
+
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, deniedSignRes, error.message);
|
|
2484
2512
|
throw error;
|
|
2485
2513
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2514
|
+
const successfulSignRes = requireSuccessfulSignatureResult(signRes);
|
|
2515
|
+
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes);
|
|
2516
|
+
return successfulSignRes;
|
|
2488
2517
|
});
|
|
2489
2518
|
}
|
|
2490
2519
|
signMessageInner(_0) {
|
|
@@ -2563,19 +2592,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2563
2592
|
);
|
|
2564
2593
|
let timeStart = Date.now();
|
|
2565
2594
|
const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
effectiveTimeoutMs
|
|
2570
|
-
);
|
|
2595
|
+
let pendingTransactionId = getPendingTransactionId(signRes);
|
|
2596
|
+
if (pendingTransactionId) {
|
|
2597
|
+
const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
|
|
2571
2598
|
if (onTransactionReviewUrl) {
|
|
2572
2599
|
onTransactionReviewUrl(reviewUrl);
|
|
2573
2600
|
} else {
|
|
2574
2601
|
yield this.platformUtils.openPopup(reviewUrl, { type: PopupType.SIGN_TRANSACTION_REVIEW });
|
|
2575
2602
|
}
|
|
2576
2603
|
} else {
|
|
2577
|
-
|
|
2578
|
-
|
|
2604
|
+
const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
|
|
2605
|
+
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes2);
|
|
2606
|
+
return successfulSignRes2;
|
|
2579
2607
|
}
|
|
2580
2608
|
while (true) {
|
|
2581
2609
|
if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
|
|
@@ -2583,7 +2611,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2583
2611
|
break;
|
|
2584
2612
|
}
|
|
2585
2613
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2586
|
-
const pendingTxId =
|
|
2614
|
+
const pendingTxId = pendingTransactionId;
|
|
2587
2615
|
let pendingTransaction;
|
|
2588
2616
|
try {
|
|
2589
2617
|
pendingTransaction = yield wrapWithSpan(
|
|
@@ -2598,7 +2626,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2598
2626
|
);
|
|
2599
2627
|
} catch (e) {
|
|
2600
2628
|
const error = new TransactionReviewDenied();
|
|
2601
|
-
dispatchEvent(
|
|
2629
|
+
dispatchEvent(
|
|
2630
|
+
ParaEvent.SIGN_TRANSACTION_EVENT,
|
|
2631
|
+
yield this.getDeniedSignatureResultWithUrl(pendingTxId),
|
|
2632
|
+
error.message
|
|
2633
|
+
);
|
|
2602
2634
|
throw error;
|
|
2603
2635
|
}
|
|
2604
2636
|
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
@@ -2622,16 +2654,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2622
2654
|
break;
|
|
2623
2655
|
}
|
|
2624
2656
|
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
);
|
|
2630
|
-
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2657
|
+
pendingTransactionId = getPendingTransactionId(signRes);
|
|
2658
|
+
if (pendingTransactionId) {
|
|
2659
|
+
const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
|
|
2660
|
+
const error = new TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
|
|
2661
|
+
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, deniedSignRes, error.message);
|
|
2631
2662
|
throw error;
|
|
2632
2663
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2664
|
+
const successfulSignRes = requireSuccessfulSignatureResult(signRes);
|
|
2665
|
+
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes);
|
|
2666
|
+
return successfulSignRes;
|
|
2635
2667
|
});
|
|
2636
2668
|
}
|
|
2637
2669
|
isProviderModalDisabled() {
|
package/dist/esm/constants.js
CHANGED
package/dist/esm/errors.js
CHANGED
|
@@ -20,6 +20,16 @@ class TransactionReviewTimeout extends Error {
|
|
|
20
20
|
this.pendingTransactionId = pendingTransactionId;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
class SigningResultError extends Error {
|
|
24
|
+
constructor(message, options = {}) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "SigningResultError";
|
|
27
|
+
this.code = options.code;
|
|
28
|
+
this.status = options.status;
|
|
29
|
+
this.responseURL = options.responseURL;
|
|
30
|
+
this.data = options.data;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
23
33
|
class PartnerConfigError extends Error {
|
|
24
34
|
constructor(code, message, detail) {
|
|
25
35
|
super(message);
|
|
@@ -30,6 +40,7 @@ class PartnerConfigError extends Error {
|
|
|
30
40
|
}
|
|
31
41
|
export {
|
|
32
42
|
PartnerConfigError,
|
|
43
|
+
SigningResultError,
|
|
33
44
|
TransactionReviewDenied,
|
|
34
45
|
TransactionReviewError,
|
|
35
46
|
TransactionReviewTimeout
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -844,6 +844,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
844
844
|
walletScheme?: TWalletScheme;
|
|
845
845
|
}): Promise<any>;
|
|
846
846
|
private getTransactionReviewUrl;
|
|
847
|
+
private getDeniedSignatureResultWithUrl;
|
|
847
848
|
private getOnRampTransactionUrl;
|
|
848
849
|
getWalletBalance(params: GetWalletBalanceParams): Promise<string>;
|
|
849
850
|
/**
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -10,6 +10,19 @@ export declare class TransactionReviewTimeout extends Error {
|
|
|
10
10
|
transactionReviewUrl: string;
|
|
11
11
|
constructor(transactionReviewUrl: string, pendingTransactionId: string);
|
|
12
12
|
}
|
|
13
|
+
export interface SigningResultErrorOptions {
|
|
14
|
+
code?: string;
|
|
15
|
+
status?: number;
|
|
16
|
+
responseURL?: string;
|
|
17
|
+
data?: object;
|
|
18
|
+
}
|
|
19
|
+
export declare class SigningResultError extends Error {
|
|
20
|
+
readonly code?: string;
|
|
21
|
+
readonly status?: number;
|
|
22
|
+
readonly responseURL?: string;
|
|
23
|
+
readonly data?: object;
|
|
24
|
+
constructor(message: string, options?: SigningResultErrorOptions);
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
27
|
* Discriminant for a `PartnerConfigError`. Each code corresponds to a specific
|
|
15
28
|
* partner-config check that rejected an SDK call. Stable string values are
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1",
|
|
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": "3.5.
|
|
8
|
+
"@getpara/user-management-client": "3.5.1",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"@opentelemetry/api": "^1.9.1",
|
|
11
11
|
"@opentelemetry/context-zone": "^2.7.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist",
|
|
42
42
|
"package.json"
|
|
43
43
|
],
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "362fc377edf3cca5f743679498ff4908921c8468",
|
|
45
45
|
"main": "dist/cjs/index.js",
|
|
46
46
|
"module": "dist/esm/index.js",
|
|
47
47
|
"scripts": {
|