@multiversx/sdk-web-wallet-cross-window-provider 0.1.3 → 0.3.0-alpha.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/out/CrossWindowProvider/CrossWindowProvider.d.ts +11 -9
- package/out/CrossWindowProvider/CrossWindowProvider.js +48 -16
- package/out/CrossWindowProvider/CrossWindowProvider.js.map +1 -1
- package/out/CrossWindowProvider/PopupConsent/PopupConsent.d.ts +8 -11
- package/out/CrossWindowProvider/PopupConsent/PopupConsent.js +52 -76
- package/out/CrossWindowProvider/PopupConsent/PopupConsent.js.map +1 -1
- package/out/CrossWindowProvider/PopupConsent/constants.d.ts +1 -0
- package/out/CrossWindowProvider/PopupConsent/constants.js +5 -0
- package/out/CrossWindowProvider/PopupConsent/constants.js.map +1 -0
- package/out/CrossWindowProvider/PopupConsent/getStyles.js +13 -14
- package/out/CrossWindowProvider/PopupConsent/getStyles.js.map +1 -1
- package/out/CrossWindowProvider/tests/Cancel.test.js +6 -7
- package/out/CrossWindowProvider/tests/Cancel.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Init.test.js +0 -2
- package/out/CrossWindowProvider/tests/Init.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Login.test.js +1 -3
- package/out/CrossWindowProvider/tests/Login.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Logout.test.js +2 -4
- package/out/CrossWindowProvider/tests/Logout.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/SignMessage.test.js +1 -3
- package/out/CrossWindowProvider/tests/SignMessage.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/SignTransaction.test.js +1 -3
- package/out/CrossWindowProvider/tests/SignTransaction.test.js.map +1 -1
- package/out/IFrameManager/IFrameProviderContentWindow.d.ts +27 -0
- package/out/IFrameManager/IFrameProviderContentWindow.js +150 -0
- package/out/IFrameManager/IFrameProviderContentWindow.js.map +1 -0
- package/out/IFrameManager/IframeManager.d.ts +18 -0
- package/out/IFrameManager/IframeManager.js +98 -0
- package/out/IFrameManager/IframeManager.js.map +1 -0
- package/out/IFrameManager/iframeManager.styles.d.ts +6 -0
- package/out/IFrameManager/iframeManager.styles.js +78 -0
- package/out/IFrameManager/iframeManager.styles.js.map +1 -0
- package/out/IFrameProvider/IframeProvider.d.ts +11 -0
- package/out/IFrameProvider/IframeProvider.js +70 -0
- package/out/IFrameProvider/IframeProvider.js.map +1 -0
- package/out/WindowManager/WindowManager.d.ts +3 -3
- package/out/WindowManager/WindowManager.js +29 -22
- package/out/WindowManager/WindowManager.js.map +1 -1
- package/out/WindowManager/tests/windowManager.test.js +11 -12
- package/out/WindowManager/tests/windowManager.test.js.map +1 -1
- package/out/constants/index.d.ts +2 -0
- package/out/constants/index.js +6 -0
- package/out/constants/index.js.map +1 -0
- package/out/test-utils/index.d.ts +0 -1
- package/out/test-utils/index.js +0 -1
- package/out/test-utils/index.js.map +1 -1
- package/package.json +2 -3
- package/out/test-utils/mockWindowManager.d.ts +0 -2
- package/out/test-utils/mockWindowManager.js +0 -11
- package/out/test-utils/mockWindowManager.js.map +0 -1
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const test_utils_1 = require("../../test-utils");
|
|
13
|
-
const WindowManager_1 = require("../../WindowManager/WindowManager");
|
|
14
13
|
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
15
14
|
describe('CrossWindowProvider', () => {
|
|
16
15
|
let crossWindowProvider;
|
|
@@ -18,14 +17,13 @@ describe('CrossWindowProvider', () => {
|
|
|
18
17
|
let windowOpenSpy;
|
|
19
18
|
beforeEach(() => {
|
|
20
19
|
walletWindowMock = (0, test_utils_1.getWalletWindowMock)();
|
|
21
|
-
|
|
20
|
+
CrossWindowProvider_1.CrossWindowProvider.getInstance().getWindowManager().postMessage = jest
|
|
22
21
|
.fn()
|
|
23
22
|
.mockImplementation(() => true);
|
|
24
|
-
|
|
23
|
+
CrossWindowProvider_1.CrossWindowProvider.getInstance().getWindowManager().closeConnection = jest
|
|
25
24
|
.fn()
|
|
26
25
|
.mockImplementation(() => true);
|
|
27
26
|
crossWindowProvider = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
28
|
-
(0, test_utils_1.mockWindoManager)();
|
|
29
27
|
windowOpenSpy = jest.spyOn(window, 'open');
|
|
30
28
|
windowOpenSpy.mockImplementation(() => walletWindowMock);
|
|
31
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logout.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/Logout.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Logout.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/Logout.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAA6E;AAC7E,gEAA6D;AAE7D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,mBAAwC,CAAC;IAC7C,IAAI,gBAAsC,CAAC;IAC3C,IAAI,aAA+B,CAAC;IAEpC,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,IAAA,gCAAmB,GAAE,CAAC;QACzC,yCAAmB,CAAC,WAAW,EAAE,CAAC,gBAAgB,EAAE,CAAC,WAAW,GAAG,IAAI;aACpE,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAElC,yCAAmB,CAAC,WAAW,EAAE,CAAC,gBAAgB,EAAE,CAAC,eAAe,GAAG,IAAI;aACxE,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAElC,mBAAmB,GAAG,yCAAmB,CAAC,WAAW,EAAE,CAAC;QACxD,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAS,EAAE;QAC9C,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACjC,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const out_1 = require("@multiversx/sdk-core/out");
|
|
13
13
|
const test_utils_1 = require("../../test-utils");
|
|
14
|
-
const WindowManager_1 = require("../../WindowManager/WindowManager");
|
|
15
14
|
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
16
15
|
describe('CrossWindowProvider Login', () => {
|
|
17
16
|
let crossWindowProvider;
|
|
@@ -19,7 +18,7 @@ describe('CrossWindowProvider Login', () => {
|
|
|
19
18
|
let windowOpenSpy;
|
|
20
19
|
beforeEach(() => {
|
|
21
20
|
walletWindowMock = (0, test_utils_1.getWalletWindowMock)();
|
|
22
|
-
|
|
21
|
+
CrossWindowProvider_1.CrossWindowProvider.getInstance().getWindowManager().postMessage = jest
|
|
23
22
|
.fn()
|
|
24
23
|
.mockImplementation(() => ({
|
|
25
24
|
payload: {
|
|
@@ -30,7 +29,6 @@ describe('CrossWindowProvider Login', () => {
|
|
|
30
29
|
}
|
|
31
30
|
}));
|
|
32
31
|
crossWindowProvider = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
33
|
-
(0, test_utils_1.mockWindoManager)();
|
|
34
32
|
windowOpenSpy = jest.spyOn(window, 'open');
|
|
35
33
|
windowOpenSpy.mockImplementation(() => walletWindowMock);
|
|
36
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignMessage.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/SignMessage.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"SignMessage.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/SignMessage.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA2D;AAC3D,iDAA6E;AAC7E,gEAA6D;AAE7D,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,mBAAwC,CAAC;IAC7C,IAAI,gBAAsC,CAAC;IAC3C,IAAI,aAA+B,CAAC;IAEpC,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,IAAA,gCAAmB,GAAE,CAAC;QACzC,yCAAmB,CAAC,WAAW,EAAE,CAAC,gBAAgB,EAAE,CAAC,WAAW,GAAG,IAAI;aACpE,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;YACzB,OAAO,EAAE;gBACP,IAAI,EAAE;oBACJ,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;iBACxD;aACF;SACF,CAAC,CAAC,CAAC;QAEN,mBAAmB,GAAG,yCAAmB,CAAC,WAAW,EAAE,CAAC;QACxD,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAS,EAAE;QAC/C,MAAM,WAAW,GAAG,IAAI,qBAAe,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1E,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC9C,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAElE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const test_utils_1 = require("../../test-utils");
|
|
13
|
-
const WindowManager_1 = require("../../WindowManager/WindowManager");
|
|
14
13
|
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
15
14
|
describe('CrossWindowProvider Login', () => {
|
|
16
15
|
let crossWindowProvider;
|
|
@@ -24,13 +23,12 @@ describe('CrossWindowProvider Login', () => {
|
|
|
24
23
|
receiverUsername: 'receiver',
|
|
25
24
|
senderUsername: 'sender'
|
|
26
25
|
});
|
|
27
|
-
|
|
26
|
+
CrossWindowProvider_1.CrossWindowProvider.getInstance().getWindowManager().postMessage = jest
|
|
28
27
|
.fn()
|
|
29
28
|
.mockImplementation(() => ({
|
|
30
29
|
payload: { data: [mockTransaction.toPlainObject()] }
|
|
31
30
|
}));
|
|
32
31
|
crossWindowProvider = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
33
|
-
(0, test_utils_1.mockWindoManager)();
|
|
34
32
|
windowOpenSpy = jest.spyOn(window, 'open');
|
|
35
33
|
windowOpenSpy.mockImplementation(() => walletWindowMock);
|
|
36
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransaction.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/SignTransaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"SignTransaction.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/SignTransaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,iDAI0B;AAC1B,gEAA6D;AAE7D,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,mBAAwC,CAAC;IAC7C,IAAI,gBAAsC,CAAC;IAC3C,IAAI,aAA+B,CAAC;IAEpC,IAAI,eAA4B,CAAC;IAEjC,UAAU,CAAC,GAAG,EAAE;QACd,gBAAgB,GAAG,IAAA,gCAAmB,GAAE,CAAC;QACzC,eAAe,GAAG,IAAA,kCAAqB,EAAC;YACtC,IAAI,EAAE,MAAM;YACZ,gBAAgB,EAAE,UAAU;YAC5B,cAAc,EAAE,QAAQ;SACzB,CAAC,CAAC;QAEH,yCAAmB,CAAC,WAAW,EAAE,CAAC,gBAAgB,EAAE,CAAC,WAAW,GAAG,IAAI;aACpE,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;YACzB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC,EAAE;SACrD,CAAC,CAAC,CAAC;QAEN,mBAAmB,GAAG,yCAAmB,CAAC,WAAW,EAAE,CAAC;QACxD,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAS,EAAE;QACnD,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC9C,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QAEjC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class IFrameProviderContentWindow {
|
|
2
|
+
iframe: HTMLIFrameElement;
|
|
3
|
+
contentWindow: Window | null;
|
|
4
|
+
walletAddress: string;
|
|
5
|
+
private readonly container;
|
|
6
|
+
private readonly header;
|
|
7
|
+
private readonly body;
|
|
8
|
+
private readonly onClose;
|
|
9
|
+
constructor(props: {
|
|
10
|
+
id: string;
|
|
11
|
+
url: string;
|
|
12
|
+
anchor?: HTMLElement;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
});
|
|
15
|
+
private buildWindow;
|
|
16
|
+
private getHeaderButtons;
|
|
17
|
+
private setupWindow;
|
|
18
|
+
getContainer(): HTMLDivElement;
|
|
19
|
+
getIframe(): HTMLIFrameElement;
|
|
20
|
+
getContentWindow(): Window | null;
|
|
21
|
+
setUrl(url: string): void;
|
|
22
|
+
remove(): void;
|
|
23
|
+
setWalletVisible(visible: boolean): void;
|
|
24
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject): void;
|
|
25
|
+
private setupResizable;
|
|
26
|
+
private setupDraggable;
|
|
27
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IFrameProviderContentWindow = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const iframeManager_styles_1 = require("./iframeManager.styles");
|
|
6
|
+
class IFrameProviderContentWindow {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9
|
+
this.walletAddress = '';
|
|
10
|
+
this.onClose = undefined;
|
|
11
|
+
const { id, url, anchor, onClose } = props;
|
|
12
|
+
this.onClose = onClose;
|
|
13
|
+
this.container = (_a = constants_1.safeDocument.createElement) === null || _a === void 0 ? void 0 : _a.call(constants_1.safeDocument, 'div');
|
|
14
|
+
this.header = (_b = constants_1.safeDocument.createElement) === null || _b === void 0 ? void 0 : _b.call(constants_1.safeDocument, 'div');
|
|
15
|
+
this.body = (_c = constants_1.safeDocument.createElement) === null || _c === void 0 ? void 0 : _c.call(constants_1.safeDocument, 'div');
|
|
16
|
+
this.iframe = (_d = constants_1.safeDocument.createElement) === null || _d === void 0 ? void 0 : _d.call(constants_1.safeDocument, 'iframe');
|
|
17
|
+
this.buildWindow(id, url);
|
|
18
|
+
this.contentWindow = this.iframe.contentWindow;
|
|
19
|
+
this.setupWindow();
|
|
20
|
+
if (anchor) {
|
|
21
|
+
anchor.appendChild(this.container);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
(_f = (_e = constants_1.safeDocument.body) === null || _e === void 0 ? void 0 : _e.appendChild) === null || _f === void 0 ? void 0 : _f.call(_e, this.container);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
buildWindow(id, url) {
|
|
28
|
+
this.container.setAttribute('data-draggable', 'true');
|
|
29
|
+
this.container.setAttribute('data-resizable', 'true');
|
|
30
|
+
this.header.setAttribute('data-drag-handle', 'true');
|
|
31
|
+
this.container.style.cssText = iframeManager_styles_1.containerStyle;
|
|
32
|
+
this.header.style.cssText = iframeManager_styles_1.headerStyle;
|
|
33
|
+
this.body.style.cssText = iframeManager_styles_1.bodyStyle;
|
|
34
|
+
const { collapsibleButton, closeWalletButton } = this.getHeaderButtons();
|
|
35
|
+
this.header.appendChild(closeWalletButton);
|
|
36
|
+
this.header.appendChild(collapsibleButton);
|
|
37
|
+
this.container.appendChild(this.header);
|
|
38
|
+
this.container.appendChild(this.body);
|
|
39
|
+
this.iframe.id = id;
|
|
40
|
+
this.iframe.src = url;
|
|
41
|
+
this.iframe.style.cssText = iframeManager_styles_1.iframeStyle;
|
|
42
|
+
this.body.appendChild(this.iframe);
|
|
43
|
+
}
|
|
44
|
+
getHeaderButtons() {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const title = (_a = constants_1.safeDocument.createElement) === null || _a === void 0 ? void 0 : _a.call(constants_1.safeDocument, 'span');
|
|
47
|
+
title.innerText = 'Wallet';
|
|
48
|
+
this.header.appendChild(title);
|
|
49
|
+
const collapsibleButton = (_b = constants_1.safeDocument.createElement) === null || _b === void 0 ? void 0 : _b.call(constants_1.safeDocument, 'span');
|
|
50
|
+
collapsibleButton.id = 'iframe-toggle-button';
|
|
51
|
+
collapsibleButton.innerText = '+';
|
|
52
|
+
collapsibleButton.style.cssText = iframeManager_styles_1.collapsibleButtonStyle;
|
|
53
|
+
collapsibleButton.onclick = () => {
|
|
54
|
+
this.body.style.visibility =
|
|
55
|
+
this.body.style.visibility === 'hidden' ? 'visible' : 'hidden';
|
|
56
|
+
this.container.style.height =
|
|
57
|
+
this.body.style.visibility === 'hidden' ? '50px' : '600px';
|
|
58
|
+
collapsibleButton.innerText =
|
|
59
|
+
this.body.style.visibility === 'hidden' ? '+' : '-';
|
|
60
|
+
this.container.style.setProperty('resize', this.body.style.visibility === 'hidden' ? 'none' : 'both');
|
|
61
|
+
};
|
|
62
|
+
const closeWalletButton = (_c = constants_1.safeDocument.createElement) === null || _c === void 0 ? void 0 : _c.call(constants_1.safeDocument, 'span');
|
|
63
|
+
closeWalletButton.id = 'iframe-close-button';
|
|
64
|
+
closeWalletButton.innerText = '✖';
|
|
65
|
+
closeWalletButton.style.cssText = iframeManager_styles_1.closeWalletButtonStyle;
|
|
66
|
+
closeWalletButton.onclick = () => {
|
|
67
|
+
var _a;
|
|
68
|
+
this.container.remove();
|
|
69
|
+
(_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
70
|
+
};
|
|
71
|
+
return { collapsibleButton, closeWalletButton };
|
|
72
|
+
}
|
|
73
|
+
setupWindow() {
|
|
74
|
+
this.iframe.onload = () => {
|
|
75
|
+
this.contentWindow = this.iframe.contentWindow;
|
|
76
|
+
const event = new CustomEvent('iframeWindowReady', {
|
|
77
|
+
detail: this.iframe
|
|
78
|
+
});
|
|
79
|
+
this.iframe.dispatchEvent(event);
|
|
80
|
+
};
|
|
81
|
+
this.setupResizable();
|
|
82
|
+
this.setupDraggable();
|
|
83
|
+
}
|
|
84
|
+
getContainer() {
|
|
85
|
+
return this.container;
|
|
86
|
+
}
|
|
87
|
+
getIframe() {
|
|
88
|
+
return this.iframe;
|
|
89
|
+
}
|
|
90
|
+
getContentWindow() {
|
|
91
|
+
return this.contentWindow;
|
|
92
|
+
}
|
|
93
|
+
setUrl(url) {
|
|
94
|
+
this.iframe.setAttribute('src', url);
|
|
95
|
+
}
|
|
96
|
+
remove() {
|
|
97
|
+
this.container.remove();
|
|
98
|
+
}
|
|
99
|
+
setWalletVisible(visible) {
|
|
100
|
+
this.container.style.visibility = visible ? 'visible' : 'hidden';
|
|
101
|
+
}
|
|
102
|
+
addEventListener(type, listener) {
|
|
103
|
+
this.iframe.addEventListener(type, listener);
|
|
104
|
+
}
|
|
105
|
+
setupResizable() {
|
|
106
|
+
this.container.style.setProperty('resize', 'both');
|
|
107
|
+
this.container.style.setProperty('overflow', 'hidden');
|
|
108
|
+
}
|
|
109
|
+
setupDraggable() {
|
|
110
|
+
this.container.ondragstart = () => {
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
this.header.onmousedown = (event) => {
|
|
114
|
+
var _a;
|
|
115
|
+
const shiftX = event.clientX - this.container.getBoundingClientRect().left;
|
|
116
|
+
const shiftY = event.clientY - this.container.getBoundingClientRect().top;
|
|
117
|
+
// moves the window at (pageX, pageY) coordinates
|
|
118
|
+
// taking initial shifts into account
|
|
119
|
+
const moveAt = (pageX, pageY) => {
|
|
120
|
+
this.container.style.left = pageX - shiftX + 'px';
|
|
121
|
+
this.container.style.top = pageY - shiftY + 'px';
|
|
122
|
+
};
|
|
123
|
+
this.container.style.position = 'absolute';
|
|
124
|
+
this.container.style.zIndex = '1000';
|
|
125
|
+
moveAt(event.pageX, event.pageY);
|
|
126
|
+
const onMouseMove = (ev) => {
|
|
127
|
+
var _a;
|
|
128
|
+
moveAt(ev.pageX, ev.pageY);
|
|
129
|
+
(_a = constants_1.safeWindow.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
130
|
+
};
|
|
131
|
+
// move the container on mousemove
|
|
132
|
+
(_a = constants_1.safeDocument.addEventListener) === null || _a === void 0 ? void 0 : _a.call(constants_1.safeDocument, 'mousemove', onMouseMove);
|
|
133
|
+
// drop the container, remove unneeded handlers
|
|
134
|
+
this.container.onmouseup = () => {
|
|
135
|
+
var _a;
|
|
136
|
+
(_a = constants_1.safeDocument.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(constants_1.safeDocument, 'mousemove', onMouseMove);
|
|
137
|
+
this.container.onmouseup = null;
|
|
138
|
+
};
|
|
139
|
+
// drop the header, remove unneeded handlers
|
|
140
|
+
this.header.onmouseup = () => {
|
|
141
|
+
var _a;
|
|
142
|
+
(_a = constants_1.safeDocument.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(constants_1.safeDocument, 'mousemove', onMouseMove);
|
|
143
|
+
this.header.removeEventListener('mouseup', onMouseMove);
|
|
144
|
+
this.header.onmouseup = null;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.IFrameProviderContentWindow = IFrameProviderContentWindow;
|
|
150
|
+
//# sourceMappingURL=IFrameProviderContentWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFrameProviderContentWindow.js","sourceRoot":"","sources":["../../src/IFrameManager/IFrameProviderContentWindow.ts"],"names":[],"mappings":";;;AAAA,4CAAwD;AACxD,iEAOgC;AAEhC,MAAa,2BAA2B;IAWtC,YAAmB,KAKlB;;QAbM,kBAAa,GAAG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AAG,IAAI,CAAC;YAClC,CAAC,CAAC;YAEF,4CAA4C;YAC5C,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;;gBAC3B,MAAA,wBAAY,CAAC,mBAAmB,yEAAG,WAAW,EAAE,WAAW,CAAC,CAAC;gBAC7D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;YAC/B,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF;AA5LD,kEA4LC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CrossWindowProviderRequestEnums } from '@multiversx/sdk-dapp-utils/out/enums/crossWindowProviderEnums';
|
|
2
|
+
import { PostMessageParamsType, PostMessageReturnType } from '@multiversx/sdk-dapp-utils/out/types/crossWindowProviderTypes';
|
|
3
|
+
import { WindowManager } from '../WindowManager';
|
|
4
|
+
import { IFrameProviderContentWindow } from './IFrameProviderContentWindow';
|
|
5
|
+
export declare class IframeManager extends WindowManager {
|
|
6
|
+
private floatingWalletComponent;
|
|
7
|
+
private readonly onClose;
|
|
8
|
+
constructor(props?: {
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
});
|
|
11
|
+
get floatingWallet(): IFrameProviderContentWindow | null;
|
|
12
|
+
postMessage<T extends CrossWindowProviderRequestEnums>({ type, payload }: PostMessageParamsType<T>): Promise<PostMessageReturnType<T>>;
|
|
13
|
+
closeConnection(): Promise<boolean>;
|
|
14
|
+
isWalletOpened(): boolean;
|
|
15
|
+
closeWalletWindow(): void;
|
|
16
|
+
setWalletWindow(): Promise<void>;
|
|
17
|
+
setWalletVisible(visible: boolean): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IframeManager = void 0;
|
|
13
|
+
const crossWindowProviderConstants_1 = require("@multiversx/sdk-dapp-utils/out/constants/crossWindowProviderConstants");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const WindowManager_1 = require("../WindowManager");
|
|
16
|
+
const IFrameProviderContentWindow_1 = require("./IFrameProviderContentWindow");
|
|
17
|
+
class IframeManager extends WindowManager_1.WindowManager {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super();
|
|
20
|
+
this.floatingWalletComponent = null;
|
|
21
|
+
this.onClose = undefined;
|
|
22
|
+
this.onClose = props === null || props === void 0 ? void 0 : props.onClose;
|
|
23
|
+
}
|
|
24
|
+
get floatingWallet() {
|
|
25
|
+
return this.floatingWalletComponent;
|
|
26
|
+
}
|
|
27
|
+
postMessage({ type, payload }) {
|
|
28
|
+
var _a;
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
yield this.handshake(type);
|
|
31
|
+
(_a = this.walletWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
32
|
+
type,
|
|
33
|
+
payload
|
|
34
|
+
}, this.walletUrl);
|
|
35
|
+
const data = yield this.listenOnce(crossWindowProviderConstants_1.responseTypeMap[type]);
|
|
36
|
+
return data;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
closeConnection() {
|
|
40
|
+
const _super = Object.create(null, {
|
|
41
|
+
closeConnection: { get: () => super.closeConnection }
|
|
42
|
+
});
|
|
43
|
+
var _a;
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const result = yield _super.closeConnection.call(this);
|
|
46
|
+
(_a = this.floatingWalletComponent) === null || _a === void 0 ? void 0 : _a.remove();
|
|
47
|
+
this.walletWindow = null;
|
|
48
|
+
return result;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
isWalletOpened() {
|
|
52
|
+
return Boolean(this.walletWindow);
|
|
53
|
+
}
|
|
54
|
+
closeWalletWindow() {
|
|
55
|
+
var _a;
|
|
56
|
+
if (!this.walletWindow) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
(_a = this.floatingWallet) === null || _a === void 0 ? void 0 : _a.setWalletVisible(false);
|
|
60
|
+
}
|
|
61
|
+
setWalletWindow() {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (this.walletWindow) {
|
|
65
|
+
(_a = this.floatingWallet) === null || _a === void 0 ? void 0 : _a.setWalletVisible(true);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const anchor = (_b = constants_1.safeDocument.getElementById) === null || _b === void 0 ? void 0 : _b.call(constants_1.safeDocument, 'root');
|
|
69
|
+
this.floatingWalletComponent = new IFrameProviderContentWindow_1.IFrameProviderContentWindow({
|
|
70
|
+
id: 'floating-wallet',
|
|
71
|
+
anchor,
|
|
72
|
+
url: this.walletUrl,
|
|
73
|
+
onClose: () => {
|
|
74
|
+
var _a;
|
|
75
|
+
this.closeConnection();
|
|
76
|
+
(_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
this.floatingWalletComponent.walletAddress = this.walletUrl;
|
|
80
|
+
const iframe = yield new Promise((resolve) => {
|
|
81
|
+
var _a;
|
|
82
|
+
(_a = this.floatingWalletComponent) === null || _a === void 0 ? void 0 : _a.addEventListener('iframeWindowReady', (event) => {
|
|
83
|
+
resolve(event.detail);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
if (!iframe) {
|
|
87
|
+
throw new Error('Cannot initialize iframe window');
|
|
88
|
+
}
|
|
89
|
+
this.walletWindow = iframe.contentWindow;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
setWalletVisible(visible) {
|
|
93
|
+
var _a;
|
|
94
|
+
(_a = this.floatingWalletComponent) === null || _a === void 0 ? void 0 : _a.setWalletVisible(visible);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.IframeManager = IframeManager;
|
|
98
|
+
//# sourceMappingURL=IframeManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IframeManager.js","sourceRoot":"","sources":["../../src/IFrameManager/IframeManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wHAAwG;AAMxG,4CAA4C;AAC5C,oDAAiD;AACjD,+EAA4E;AAE5E,MAAa,aAAc,SAAQ,6BAAa;IAI9C,YAAY,KAAgC;QAC1C,KAAK,EAAE,CAAC;QAJF,4BAAuB,GAAuC,IAAI,CAAC;QAC1D,YAAO,GAA6B,SAAS,CAAC;QAI7D,IAAI,CAAC,OAAO,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC;IAChC,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,CAAC;IAEqB,WAAW,CAA4C,EAC3E,IAAI,EACJ,OAAO,EACkB;;;YACzB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAE3B,MAAA,IAAI,CAAC,YAAY,0CAAE,WAAW,CAC5B;gBACE,IAAI;gBACJ,OAAO;aACR,EACD,IAAI,CAAC,SAAS,CACf,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,8CAAe,CAAC,IAAI,CAAC,CAAC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KAAK,CAAC,MAAM,CAAC,CAAC;gBACxB,CAAC,CACF,CAAC;YACJ,CAAC,CACF,CAAC;YAEF,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;aACpD;YAED,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC;;KAC1C;IAEM,gBAAgB,CAAC,OAAgB;;QACtC,MAAA,IAAI,CAAC,uBAAuB,0CAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AAzFD,sCAyFC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const containerStyle = "\n width: 400px;\n height: 600px;\n border: 1px solid #0d0e10;\n border-radius: 5px;\n z-index: 9999;\n position: absolute;\n bottom: 0;\n right: 0;\n visibility: hidden;\n ";
|
|
2
|
+
export declare const headerStyle = "\n color: #fff;\n background-color: #0d0e10;\n padding: 10px 15px;\n cursor: pointer;\n height: 50px;\n ";
|
|
3
|
+
export declare const bodyStyle = "\n width: 100%;\n height: calc(100% - 40px);\n overflow: hidden;\n ";
|
|
4
|
+
export declare const iframeStyle = "\n width: 100%;\n height: 100%;\n border: none;\n border-radius: 0 0 5px 5px;\n ";
|
|
5
|
+
export declare const collapsibleButtonStyle = "\n width: 30px;\n height: 30px;\n cursor: pointer;\n margin: 0px;\n padding: 0px;\n box-sizing: content-box;\n font-family: sans-serif;\n text-align: center;\n font-size: 40px;\n line-height: 14px;\n border-width: 0px;\n border-radius: 2px;\n border-color: rgb(170, 170, 170);\n border-style: solid;\n background-color: transparent;\n color: gray;\n z-index: 50;\n user-select: none;\n float: right;\n ";
|
|
6
|
+
export declare const closeWalletButtonStyle = "\n width: 30px;\n height: 30px;\n cursor: pointer;\n margin-top: 0px; \n display: inline-block; \n cursor: pointer;\n margin-top: 5px;\n padding: 0px;\n box-sizing: content-box;\n font-family: sans-serif;\n text-align: center;\n font-size: 30px;\n line-height: 14px;\n border-width: 0px;\n border-radius: 2px;\n border-color: rgb(170, 170, 170);\n border-style: solid;\n background-color: transparent;\n color: gray;\n z-index: 50;\n user-select: none;\n float: right;\n ";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.closeWalletButtonStyle = exports.collapsibleButtonStyle = exports.iframeStyle = exports.bodyStyle = exports.headerStyle = exports.containerStyle = void 0;
|
|
4
|
+
exports.containerStyle = `
|
|
5
|
+
width: 400px;
|
|
6
|
+
height: 600px;
|
|
7
|
+
border: 1px solid #0d0e10;
|
|
8
|
+
border-radius: 5px;
|
|
9
|
+
z-index: 9999;
|
|
10
|
+
position: absolute;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
right: 0;
|
|
13
|
+
visibility: hidden;
|
|
14
|
+
`;
|
|
15
|
+
exports.headerStyle = `
|
|
16
|
+
color: #fff;
|
|
17
|
+
background-color: #0d0e10;
|
|
18
|
+
padding: 10px 15px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
height: 50px;
|
|
21
|
+
`;
|
|
22
|
+
exports.bodyStyle = `
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: calc(100% - 40px);
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
`;
|
|
27
|
+
exports.iframeStyle = `
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
border: none;
|
|
31
|
+
border-radius: 0 0 5px 5px;
|
|
32
|
+
`;
|
|
33
|
+
exports.collapsibleButtonStyle = `
|
|
34
|
+
width: 30px;
|
|
35
|
+
height: 30px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
margin: 0px;
|
|
38
|
+
padding: 0px;
|
|
39
|
+
box-sizing: content-box;
|
|
40
|
+
font-family: sans-serif;
|
|
41
|
+
text-align: center;
|
|
42
|
+
font-size: 40px;
|
|
43
|
+
line-height: 14px;
|
|
44
|
+
border-width: 0px;
|
|
45
|
+
border-radius: 2px;
|
|
46
|
+
border-color: rgb(170, 170, 170);
|
|
47
|
+
border-style: solid;
|
|
48
|
+
background-color: transparent;
|
|
49
|
+
color: gray;
|
|
50
|
+
z-index: 50;
|
|
51
|
+
user-select: none;
|
|
52
|
+
float: right;
|
|
53
|
+
`;
|
|
54
|
+
exports.closeWalletButtonStyle = `
|
|
55
|
+
width: 30px;
|
|
56
|
+
height: 30px;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
margin-top: 0px;
|
|
59
|
+
display: inline-block;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
margin-top: 5px;
|
|
62
|
+
padding: 0px;
|
|
63
|
+
box-sizing: content-box;
|
|
64
|
+
font-family: sans-serif;
|
|
65
|
+
text-align: center;
|
|
66
|
+
font-size: 30px;
|
|
67
|
+
line-height: 14px;
|
|
68
|
+
border-width: 0px;
|
|
69
|
+
border-radius: 2px;
|
|
70
|
+
border-color: rgb(170, 170, 170);
|
|
71
|
+
border-style: solid;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
color: gray;
|
|
74
|
+
z-index: 50;
|
|
75
|
+
user-select: none;
|
|
76
|
+
float: right;
|
|
77
|
+
`;
|
|
78
|
+
//# sourceMappingURL=iframeManager.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframeManager.styles.js","sourceRoot":"","sources":["../../src/IFrameManager/iframeManager.styles.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;;;;;;;;;;GAU3B,CAAC;AAES,QAAA,WAAW,GAAG;;;;;;GAMxB,CAAC;AAES,QAAA,SAAS,GAAG;;;;GAItB,CAAC;AAES,QAAA,WAAW,GAAG;;;;;GAKxB,CAAC;AAES,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;GAoBnC,CAAC;AAES,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;GAuBnC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CrossWindowProvider, ICrossWindowWalletAccount } from '../CrossWindowProvider';
|
|
2
|
+
export declare class IframeProvider extends CrossWindowProvider {
|
|
3
|
+
constructor();
|
|
4
|
+
static getInstance(): IframeProvider;
|
|
5
|
+
init(): Promise<boolean>;
|
|
6
|
+
login(options?: {
|
|
7
|
+
token?: string;
|
|
8
|
+
}): Promise<ICrossWindowWalletAccount>;
|
|
9
|
+
logout(): Promise<boolean>;
|
|
10
|
+
openPopupConsent(): Promise<boolean>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IframeProvider = void 0;
|
|
13
|
+
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
14
|
+
const errors_1 = require("../errors");
|
|
15
|
+
const IframeManager_1 = require("../IFrameManager/IframeManager");
|
|
16
|
+
class IframeProvider extends CrossWindowProvider_1.CrossWindowProvider {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.windowManager = new IframeManager_1.IframeManager({
|
|
20
|
+
// TODO check why the logout is not sending logout request through postMessage
|
|
21
|
+
onClose: this.logout.bind(this)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
static getInstance() {
|
|
25
|
+
if (!IframeProvider._instance) {
|
|
26
|
+
IframeProvider._instance = new IframeProvider();
|
|
27
|
+
return IframeProvider._instance;
|
|
28
|
+
}
|
|
29
|
+
return IframeProvider._instance;
|
|
30
|
+
}
|
|
31
|
+
init() {
|
|
32
|
+
const _super = Object.create(null, {
|
|
33
|
+
init: { get: () => super.init }
|
|
34
|
+
});
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const initialized = yield _super.init.call(this);
|
|
37
|
+
yield this.windowManager.setWalletWindow();
|
|
38
|
+
return initialized;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
login(options = {}) {
|
|
42
|
+
const _super = Object.create(null, {
|
|
43
|
+
login: { get: () => super.login }
|
|
44
|
+
});
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const account = yield _super.login.call(this, options);
|
|
47
|
+
yield this.windowManager.setWalletWindow();
|
|
48
|
+
return account;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
logout() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (!this.initialized) {
|
|
54
|
+
throw new errors_1.ErrProviderNotInitialized();
|
|
55
|
+
}
|
|
56
|
+
this.ensureConnected();
|
|
57
|
+
const connectionClosed = yield this.windowManager.closeConnection();
|
|
58
|
+
this.initialized = false;
|
|
59
|
+
this.disconnect();
|
|
60
|
+
return connectionClosed;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
openPopupConsent() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.IframeProvider = IframeProvider;
|
|
70
|
+
//# sourceMappingURL=IframeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IframeProvider.js","sourceRoot":"","sources":["../../src/IFrameProvider/IframeProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAGgC;AAChC,sCA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oDC"}
|
|
@@ -2,12 +2,10 @@ import { CrossWindowProviderRequestEnums, CrossWindowProviderResponseEnums } fro
|
|
|
2
2
|
import { PostMessageParamsType, PostMessageReturnType, ReplyWithPostMessagePayloadType } from '@multiversx/sdk-dapp-utils/out/types/crossWindowProviderTypes';
|
|
3
3
|
export declare class WindowManager {
|
|
4
4
|
private _walletUrl;
|
|
5
|
-
|
|
6
|
-
private static _instance;
|
|
5
|
+
protected initialized: boolean;
|
|
7
6
|
walletWindow: Window | null;
|
|
8
7
|
constructor();
|
|
9
8
|
get walletUrl(): string;
|
|
10
|
-
static getInstance(): WindowManager;
|
|
11
9
|
setWalletUrl(url: string): WindowManager;
|
|
12
10
|
init(): Promise<boolean>;
|
|
13
11
|
isWalletOpened(type?: CrossWindowProviderRequestEnums): boolean;
|
|
@@ -20,4 +18,6 @@ export declare class WindowManager {
|
|
|
20
18
|
closeConnection(): Promise<boolean>;
|
|
21
19
|
isInitialized(): boolean;
|
|
22
20
|
postMessage<T extends CrossWindowProviderRequestEnums>({ type, payload }: PostMessageParamsType<T>): Promise<PostMessageReturnType<T>>;
|
|
21
|
+
closeWalletWindow(): void;
|
|
22
|
+
setWalletWindow(): Promise<void>;
|
|
23
23
|
}
|