@portal-hq/web 3.2.0 → 3.2.2
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/lib/commonjs/index.js +12 -1
- package/lib/commonjs/mpc/index.js +37 -1
- package/lib/esm/index.js +11 -0
- package/lib/esm/mpc/index.js +38 -2
- package/package.json +2 -2
- package/src/index.ts +11 -0
- package/src/mpc/index.ts +46 -2
package/lib/commonjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.GetTransactionsOrder = exports.BackupMethods = exports.MpcStatuses = exports.MpcErrorCodes = exports.MpcError = void 0;
|
|
15
|
+
exports.PortalCurve = exports.GetTransactionsOrder = exports.BackupMethods = exports.MpcStatuses = exports.MpcErrorCodes = exports.MpcError = void 0;
|
|
16
16
|
const web3_js_1 = require("@solana/web3.js");
|
|
17
17
|
const mpc_1 = __importDefault(require("./mpc"));
|
|
18
18
|
const provider_1 = __importDefault(require("./provider"));
|
|
@@ -393,6 +393,12 @@ class Portal {
|
|
|
393
393
|
}));
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
|
+
rawSign(curve, param) {
|
|
397
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
+
const response = yield this.mpc.rawSign(curve, param);
|
|
399
|
+
return response;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
396
402
|
sendSol({ chainId, to, lamports, }) {
|
|
397
403
|
var _a;
|
|
398
404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -591,4 +597,9 @@ var GetTransactionsOrder;
|
|
|
591
597
|
GetTransactionsOrder["ASC"] = "asc";
|
|
592
598
|
GetTransactionsOrder["DESC"] = "desc";
|
|
593
599
|
})(GetTransactionsOrder = exports.GetTransactionsOrder || (exports.GetTransactionsOrder = {}));
|
|
600
|
+
var PortalCurve;
|
|
601
|
+
(function (PortalCurve) {
|
|
602
|
+
PortalCurve["ED25519"] = "ED25519";
|
|
603
|
+
PortalCurve["SECP256K1"] = "SECP256K1";
|
|
604
|
+
})(PortalCurve = exports.PortalCurve || (exports.PortalCurve = {}));
|
|
594
605
|
exports.default = Portal;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MpcErrorCodes = exports.MpcError = void 0;
|
|
13
13
|
const errors_1 = require("./errors");
|
|
14
14
|
const index_1 = require("../index");
|
|
15
|
-
const WEB_SDK_VERSION = '3.2.
|
|
15
|
+
const WEB_SDK_VERSION = '3.2.2';
|
|
16
16
|
class Mpc {
|
|
17
17
|
constructor({ portal }) {
|
|
18
18
|
this.configureIframe = () => {
|
|
@@ -284,6 +284,42 @@ class Mpc {
|
|
|
284
284
|
});
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
+
rawSign(curve, param) {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
const handleRawSign = (event) => {
|
|
291
|
+
const { type, data: result } = event.data;
|
|
292
|
+
const { origin } = event;
|
|
293
|
+
// ignore any broadcast postMessages
|
|
294
|
+
if (origin !== this.getOrigin()) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (type === 'portal:mpc:rawSignError') {
|
|
298
|
+
// Remove the event listeners
|
|
299
|
+
window.removeEventListener('message', handleRawSign);
|
|
300
|
+
// Reject the promise with the error
|
|
301
|
+
return reject(new errors_1.PortalMpcError(result));
|
|
302
|
+
}
|
|
303
|
+
else if (type === 'portal:mpc:rawSignResult') {
|
|
304
|
+
// Remove the event listeners
|
|
305
|
+
window.removeEventListener('message', handleRawSign);
|
|
306
|
+
// Resolve the promise with the result
|
|
307
|
+
resolve(result);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
// Bind the function to the message event
|
|
311
|
+
window.addEventListener('message', handleRawSign);
|
|
312
|
+
// Send the request to the iframe
|
|
313
|
+
this.postMessage({
|
|
314
|
+
type: 'portal:mpc:rawSign',
|
|
315
|
+
data: {
|
|
316
|
+
curve,
|
|
317
|
+
param,
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
287
323
|
sign(data, progress = () => {
|
|
288
324
|
// Noop
|
|
289
325
|
}) {
|
package/lib/esm/index.js
CHANGED
|
@@ -387,6 +387,12 @@ class Portal {
|
|
|
387
387
|
}));
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
|
+
rawSign(curve, param) {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
392
|
+
const response = yield this.mpc.rawSign(curve, param);
|
|
393
|
+
return response;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
390
396
|
sendSol({ chainId, to, lamports, }) {
|
|
391
397
|
var _a;
|
|
392
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -583,4 +589,9 @@ export var GetTransactionsOrder;
|
|
|
583
589
|
GetTransactionsOrder["ASC"] = "asc";
|
|
584
590
|
GetTransactionsOrder["DESC"] = "desc";
|
|
585
591
|
})(GetTransactionsOrder || (GetTransactionsOrder = {}));
|
|
592
|
+
export var PortalCurve;
|
|
593
|
+
(function (PortalCurve) {
|
|
594
|
+
PortalCurve["ED25519"] = "ED25519";
|
|
595
|
+
PortalCurve["SECP256K1"] = "SECP256K1";
|
|
596
|
+
})(PortalCurve || (PortalCurve = {}));
|
|
586
597
|
export default Portal;
|
package/lib/esm/mpc/index.js
CHANGED
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { PortalMpcError } from './errors';
|
|
11
|
-
import { BackupMethods } from '../index';
|
|
12
|
-
const WEB_SDK_VERSION = '3.2.
|
|
11
|
+
import { BackupMethods, } from '../index';
|
|
12
|
+
const WEB_SDK_VERSION = '3.2.2';
|
|
13
13
|
class Mpc {
|
|
14
14
|
constructor({ portal }) {
|
|
15
15
|
this.configureIframe = () => {
|
|
@@ -281,6 +281,42 @@ class Mpc {
|
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
|
+
rawSign(curve, param) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
return new Promise((resolve, reject) => {
|
|
287
|
+
const handleRawSign = (event) => {
|
|
288
|
+
const { type, data: result } = event.data;
|
|
289
|
+
const { origin } = event;
|
|
290
|
+
// ignore any broadcast postMessages
|
|
291
|
+
if (origin !== this.getOrigin()) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (type === 'portal:mpc:rawSignError') {
|
|
295
|
+
// Remove the event listeners
|
|
296
|
+
window.removeEventListener('message', handleRawSign);
|
|
297
|
+
// Reject the promise with the error
|
|
298
|
+
return reject(new PortalMpcError(result));
|
|
299
|
+
}
|
|
300
|
+
else if (type === 'portal:mpc:rawSignResult') {
|
|
301
|
+
// Remove the event listeners
|
|
302
|
+
window.removeEventListener('message', handleRawSign);
|
|
303
|
+
// Resolve the promise with the result
|
|
304
|
+
resolve(result);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
// Bind the function to the message event
|
|
308
|
+
window.addEventListener('message', handleRawSign);
|
|
309
|
+
// Send the request to the iframe
|
|
310
|
+
this.postMessage({
|
|
311
|
+
type: 'portal:mpc:rawSign',
|
|
312
|
+
data: {
|
|
313
|
+
curve,
|
|
314
|
+
param,
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
284
320
|
sign(data, progress = () => {
|
|
285
321
|
// Noop
|
|
286
322
|
}) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Portal MPC Support for Web",
|
|
4
4
|
"author": "Portal Labs, Inc.",
|
|
5
5
|
"homepage": "https://portalhq.io/",
|
|
6
|
-
"version": "3.2.
|
|
6
|
+
"version": "3.2.2",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "lib/commonjs/index",
|
|
9
9
|
"module": "lib/esm/index",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ts-loader": "^9.4.3",
|
|
44
44
|
"ts-node": "^10.9.1",
|
|
45
45
|
"typescript": "^4.8.4",
|
|
46
|
-
"webpack": "^5.
|
|
46
|
+
"webpack": "^5.94.0",
|
|
47
47
|
"webpack-cli": "^5.1.4"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
package/src/index.ts
CHANGED
|
@@ -491,6 +491,12 @@ class Portal {
|
|
|
491
491
|
})) as Promise<string>
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
public async rawSign(curve: PortalCurve, param: string): Promise<string> {
|
|
495
|
+
const response = await this.mpc.rawSign(curve, param)
|
|
496
|
+
|
|
497
|
+
return response
|
|
498
|
+
}
|
|
499
|
+
|
|
494
500
|
public async sendSol({
|
|
495
501
|
chainId,
|
|
496
502
|
to,
|
|
@@ -766,4 +772,9 @@ export enum GetTransactionsOrder {
|
|
|
766
772
|
DESC = 'desc',
|
|
767
773
|
}
|
|
768
774
|
|
|
775
|
+
export enum PortalCurve {
|
|
776
|
+
ED25519 = 'ED25519',
|
|
777
|
+
SECP256K1 = 'SECP256K1',
|
|
778
|
+
}
|
|
779
|
+
|
|
769
780
|
export default Portal
|
package/src/mpc/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { PortalMpcError } from './errors'
|
|
2
2
|
|
|
3
|
-
import Portal, {
|
|
3
|
+
import Portal, {
|
|
4
|
+
BackupMethods,
|
|
5
|
+
GetTransactionsOrder,
|
|
6
|
+
PortalCurve,
|
|
7
|
+
} from '../index'
|
|
4
8
|
import type {
|
|
5
9
|
BackupArgs,
|
|
6
10
|
BackupResponse,
|
|
@@ -26,7 +30,7 @@ import type {
|
|
|
26
30
|
EjectResult,
|
|
27
31
|
} from '../../types'
|
|
28
32
|
|
|
29
|
-
const WEB_SDK_VERSION = '3.2.
|
|
33
|
+
const WEB_SDK_VERSION = '3.2.2'
|
|
30
34
|
|
|
31
35
|
class Mpc {
|
|
32
36
|
public iframe?: HTMLIFrameElement
|
|
@@ -339,6 +343,46 @@ class Mpc {
|
|
|
339
343
|
})
|
|
340
344
|
}
|
|
341
345
|
|
|
346
|
+
public async rawSign(curve: PortalCurve, param: string): Promise<string> {
|
|
347
|
+
return new Promise((resolve, reject) => {
|
|
348
|
+
const handleRawSign = (event: MessageEvent<WorkerResult>) => {
|
|
349
|
+
const { type, data: result } = event.data
|
|
350
|
+
const { origin } = event
|
|
351
|
+
|
|
352
|
+
// ignore any broadcast postMessages
|
|
353
|
+
if (origin !== this.getOrigin()) {
|
|
354
|
+
return
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (type === 'portal:mpc:rawSignError') {
|
|
358
|
+
// Remove the event listeners
|
|
359
|
+
window.removeEventListener('message', handleRawSign)
|
|
360
|
+
|
|
361
|
+
// Reject the promise with the error
|
|
362
|
+
return reject(new PortalMpcError(result as PortalError))
|
|
363
|
+
} else if (type === 'portal:mpc:rawSignResult') {
|
|
364
|
+
// Remove the event listeners
|
|
365
|
+
window.removeEventListener('message', handleRawSign)
|
|
366
|
+
|
|
367
|
+
// Resolve the promise with the result
|
|
368
|
+
resolve(result as string)
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Bind the function to the message event
|
|
373
|
+
window.addEventListener('message', handleRawSign)
|
|
374
|
+
|
|
375
|
+
// Send the request to the iframe
|
|
376
|
+
this.postMessage({
|
|
377
|
+
type: 'portal:mpc:rawSign',
|
|
378
|
+
data: {
|
|
379
|
+
curve,
|
|
380
|
+
param,
|
|
381
|
+
},
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
|
|
342
386
|
public async sign(
|
|
343
387
|
data: SignArgs,
|
|
344
388
|
progress: ProgressCallback = () => {
|