@multiversx/sdk-web-wallet-cross-window-provider 0.0.28-alpha.1 → 0.0.28-alpha.11
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/{types/CrossWindowProvider → CrossWindowProvider}/CrossWindowProvider.d.ts +8 -16
- package/out/CrossWindowProvider/CrossWindowProvider.js +90 -104
- package/out/CrossWindowProvider/CrossWindowProvider.js.map +1 -1
- package/out/CrossWindowProvider/index.js +17 -1
- package/out/CrossWindowProvider/index.js.map +1 -1
- package/out/CrossWindowProvider/popupConsent.d.ts +4 -0
- package/out/CrossWindowProvider/popupConsent.js +121 -0
- package/out/CrossWindowProvider/popupConsent.js.map +1 -0
- package/out/CrossWindowProvider/tests/Cancel.test.js +9 -7
- package/out/CrossWindowProvider/tests/Cancel.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Init.test.js +7 -5
- package/out/CrossWindowProvider/tests/Init.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Login.test.js +9 -7
- package/out/CrossWindowProvider/tests/Login.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/Logout.test.js +10 -8
- package/out/CrossWindowProvider/tests/Logout.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/SignMessage.test.js +11 -9
- package/out/CrossWindowProvider/tests/SignMessage.test.js.map +1 -1
- package/out/CrossWindowProvider/tests/SignTransaction.test.js +10 -8
- package/out/CrossWindowProvider/tests/SignTransaction.test.js.map +1 -1
- package/out/{types/CrossWindowProvider → WindowManager}/WindowManager.d.ts +2 -6
- package/out/{CrossWindowProvider → WindowManager}/WindowManager.js +46 -64
- package/out/WindowManager/WindowManager.js.map +1 -0
- package/out/WindowManager/index.d.ts +1 -0
- package/out/WindowManager/index.js +18 -0
- package/out/WindowManager/index.js.map +1 -0
- package/out/{CrossWindowProvider → WindowManager}/tests/windowManager.test.js +17 -15
- package/out/WindowManager/tests/windowManager.test.js.map +1 -0
- package/out/constants.js +14 -11
- package/out/constants.js.map +1 -1
- package/out/{types/errors.d.ts → errors.d.ts} +3 -0
- package/out/errors.js +30 -12
- package/out/errors.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +17 -4
- package/out/index.js.map +1 -1
- package/out/test-utils/createMockTransaction.js +11 -6
- package/out/test-utils/createMockTransaction.js.map +1 -1
- package/out/test-utils/getWalletWindowMock.js +5 -1
- package/out/test-utils/getWalletWindowMock.js.map +1 -1
- package/out/test-utils/index.js +19 -3
- package/out/test-utils/index.js.map +1 -1
- package/out/test-utils/mockWindowManager.js +6 -2
- package/out/test-utils/mockWindowManager.js.map +1 -1
- package/out/{types/types.d.ts → types.d.ts} +9 -0
- package/out/types.js +9 -6
- package/out/types.js.map +1 -1
- package/package.json +7 -13
- package/out/CrossWindowProvider/WindowManager.js.map +0 -1
- package/out/CrossWindowProvider/tests/windowManager.test.js.map +0 -1
- package/out/IframeProvider/IframeManager.js +0 -72
- package/out/IframeProvider/IframeManager.js.map +0 -1
- package/out/IframeProvider/IframeProvider.js +0 -42
- package/out/IframeProvider/IframeProvider.js.map +0 -1
- package/out/IframeProvider/index.js +0 -2
- package/out/IframeProvider/index.js.map +0 -1
- package/out/types/IframeProvider/IframeManager.d.ts +0 -13
- package/out/types/IframeProvider/IframeProvider.d.ts +0 -10
- package/out/types/IframeProvider/index.d.ts +0 -1
- package/out/types/index.d.ts +0 -4
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/index.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/Cancel.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/Init.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/Login.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/Logout.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/SignMessage.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → CrossWindowProvider}/tests/SignTransaction.test.d.ts +0 -0
- /package/out/{types/CrossWindowProvider → WindowManager}/tests/windowManager.test.d.ts +0 -0
- /package/out/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/out/{types/test-utils → test-utils}/createMockTransaction.d.ts +0 -0
- /package/out/{types/test-utils → test-utils}/getWalletWindowMock.d.ts +0 -0
- /package/out/{types/test-utils → test-utils}/index.d.ts +0 -0
- /package/out/{types/test-utils → test-utils}/mockWindowManager.d.ts +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { SignableMessage, Transaction } from '@multiversx/sdk-core';
|
|
2
|
-
import { IframeManager } from '../IframeProvider/IframeManager';
|
|
3
2
|
import { CrossWindowProviderRequestEnums } from '../types';
|
|
4
|
-
|
|
5
|
-
export interface ICrossWindowWalletAccount {
|
|
3
|
+
interface ICrossWindowWalletAccount {
|
|
6
4
|
address: string;
|
|
7
5
|
signature?: string;
|
|
8
6
|
multisig?: string;
|
|
@@ -10,13 +8,13 @@ export interface ICrossWindowWalletAccount {
|
|
|
10
8
|
}
|
|
11
9
|
export declare class CrossWindowProvider {
|
|
12
10
|
account: ICrossWindowWalletAccount;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
private initialized;
|
|
12
|
+
private windowManager;
|
|
13
|
+
private static _instance;
|
|
16
14
|
private accessToken;
|
|
17
15
|
protected _shouldShowConsentPopup: boolean;
|
|
16
|
+
private constructor();
|
|
18
17
|
setShouldShowConsentPopup(shouldShow: boolean): void;
|
|
19
|
-
constructor();
|
|
20
18
|
private ensureConnected;
|
|
21
19
|
private disconnect;
|
|
22
20
|
static getInstance(): CrossWindowProvider;
|
|
@@ -32,15 +30,9 @@ export declare class CrossWindowProvider {
|
|
|
32
30
|
isConnected(): Promise<boolean>;
|
|
33
31
|
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
34
32
|
signTransactions(transactions: Transaction[]): Promise<Transaction[]>;
|
|
35
|
-
protected openPopupConsent(action: string): Promise<{
|
|
36
|
-
popupConsentResponse: boolean;
|
|
37
|
-
popup?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
popup: HTMLOpenPopupNotificationElement;
|
|
40
|
-
popupConsentResponse: unknown;
|
|
41
|
-
}>;
|
|
42
33
|
guardTransactions(transactions: Transaction[]): Promise<Transaction[]>;
|
|
43
34
|
signMessage(message: SignableMessage): Promise<SignableMessage>;
|
|
44
|
-
cancelAction(): Promise<import("../types").PostMessageReturnType<CrossWindowProviderRequestEnums.cancelAction
|
|
45
|
-
|
|
35
|
+
cancelAction(): Promise<import("../types").PostMessageReturnType<CrossWindowProviderRequestEnums.cancelAction>> | undefined;
|
|
36
|
+
protected openPopupConsent(): Promise<boolean>;
|
|
46
37
|
}
|
|
38
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,58 +8,50 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CrossWindowProvider = void 0;
|
|
13
|
+
const sdk_core_1 = require("@multiversx/sdk-core");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const types_1 = require("../types");
|
|
17
|
+
const WindowManager_1 = require("../WindowManager");
|
|
18
|
+
const popupConsent_1 = require("./popupConsent");
|
|
15
19
|
class CrossWindowProvider {
|
|
16
|
-
setShouldShowConsentPopup(shouldShow) {
|
|
17
|
-
this._shouldShowConsentPopup = shouldShow;
|
|
18
|
-
}
|
|
19
20
|
constructor() {
|
|
20
21
|
this.account = { address: '' };
|
|
21
22
|
this.initialized = false;
|
|
22
|
-
this.windowManager = null;
|
|
23
23
|
this.accessToken = undefined;
|
|
24
24
|
this._shouldShowConsentPopup = false;
|
|
25
25
|
if (CrossWindowProvider._instance) {
|
|
26
|
-
throw new ErrInstantiationFailed();
|
|
26
|
+
throw new errors_1.ErrInstantiationFailed();
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
this.windowManager = WindowManager_1.WindowManager.getInstance();
|
|
29
29
|
CrossWindowProvider._instance = this;
|
|
30
30
|
}
|
|
31
|
+
setShouldShowConsentPopup(shouldShow) {
|
|
32
|
+
this._shouldShowConsentPopup = shouldShow;
|
|
33
|
+
}
|
|
31
34
|
ensureConnected() {
|
|
32
35
|
if (!this.account.address) {
|
|
33
|
-
throw new ErrAccountNotConnected();
|
|
36
|
+
throw new errors_1.ErrAccountNotConnected();
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
disconnect() {
|
|
37
40
|
this.account = { address: '' };
|
|
38
41
|
}
|
|
39
42
|
static getInstance() {
|
|
40
|
-
if (!CrossWindowProvider._instance) {
|
|
41
|
-
return new CrossWindowProvider();
|
|
42
|
-
}
|
|
43
43
|
return CrossWindowProvider._instance;
|
|
44
44
|
}
|
|
45
45
|
setAddress(address) {
|
|
46
|
-
if (!CrossWindowProvider._instance) {
|
|
47
|
-
throw new ErrInstantiationFailed();
|
|
48
|
-
}
|
|
49
46
|
this.account.address = address;
|
|
50
47
|
return CrossWindowProvider._instance;
|
|
51
48
|
}
|
|
52
49
|
setWalletUrl(url) {
|
|
53
|
-
if (!CrossWindowProvider._instance || !this.windowManager) {
|
|
54
|
-
throw new ErrInstantiationFailed();
|
|
55
|
-
}
|
|
56
50
|
this.windowManager.setWalletUrl(url);
|
|
57
51
|
return CrossWindowProvider._instance;
|
|
58
52
|
}
|
|
59
53
|
init() {
|
|
60
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
this.windowManager = WindowManager.getInstance();
|
|
62
55
|
this.initialized = yield this.windowManager.init();
|
|
63
56
|
return this.initialized;
|
|
64
57
|
});
|
|
@@ -66,7 +59,7 @@ class CrossWindowProvider {
|
|
|
66
59
|
login(options = {}) {
|
|
67
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
61
|
if (!this.initialized) {
|
|
69
|
-
throw new ErrProviderNotInitialized();
|
|
62
|
+
throw new errors_1.ErrProviderNotInitialized();
|
|
70
63
|
}
|
|
71
64
|
const isRelogin = yield this.isConnected();
|
|
72
65
|
if (isRelogin) {
|
|
@@ -79,23 +72,18 @@ class CrossWindowProvider {
|
|
|
79
72
|
};
|
|
80
73
|
}
|
|
81
74
|
this.accessToken = options.token;
|
|
82
|
-
|
|
83
|
-
throw new ErrInstantiationFailed();
|
|
84
|
-
}
|
|
85
|
-
const { popup, popupConsentResponse } = yield this.openPopupConsent('login');
|
|
75
|
+
const popupConsentResponse = yield this.openPopupConsent();
|
|
86
76
|
if (!popupConsentResponse) {
|
|
87
|
-
|
|
88
|
-
throw new ErrCouldNotLogin();
|
|
77
|
+
throw new errors_1.ErrCouldNotLogin();
|
|
89
78
|
}
|
|
90
|
-
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
91
79
|
const { payload: { data, error } } = yield this.windowManager.postMessage({
|
|
92
|
-
type: CrossWindowProviderRequestEnums.loginRequest,
|
|
80
|
+
type: types_1.CrossWindowProviderRequestEnums.loginRequest,
|
|
93
81
|
payload: {
|
|
94
82
|
token: this.accessToken
|
|
95
83
|
}
|
|
96
84
|
});
|
|
97
85
|
if (error || !data) {
|
|
98
|
-
throw new ErrCouldNotLogin();
|
|
86
|
+
throw new errors_1.ErrCouldNotLogin();
|
|
99
87
|
}
|
|
100
88
|
this.account.address = data.address;
|
|
101
89
|
this.account.signature = data.signature;
|
|
@@ -111,13 +99,9 @@ class CrossWindowProvider {
|
|
|
111
99
|
}
|
|
112
100
|
logout() {
|
|
113
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const
|
|
115
|
-
if (!popupConsentResponse) {
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
119
|
-
if (!this.initialized || !this.windowManager) {
|
|
120
|
-
throw new ErrProviderNotInitialized();
|
|
102
|
+
const popupConsentResponse = yield this.openPopupConsent();
|
|
103
|
+
if (!this.initialized || !popupConsentResponse) {
|
|
104
|
+
throw new errors_1.ErrProviderNotInitialized();
|
|
121
105
|
}
|
|
122
106
|
this.ensureConnected();
|
|
123
107
|
const connectionClosed = yield this.windowManager.closeConnection();
|
|
@@ -130,7 +114,7 @@ class CrossWindowProvider {
|
|
|
130
114
|
var _a, _b;
|
|
131
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
116
|
if (!this.initialized) {
|
|
133
|
-
throw new ErrProviderNotInitialized();
|
|
117
|
+
throw new errors_1.ErrProviderNotInitialized();
|
|
134
118
|
}
|
|
135
119
|
return (_b = (_a = this.account) === null || _a === void 0 ? void 0 : _a.address) !== null && _b !== void 0 ? _b : '';
|
|
136
120
|
});
|
|
@@ -148,7 +132,7 @@ class CrossWindowProvider {
|
|
|
148
132
|
this.ensureConnected();
|
|
149
133
|
const signedTransactions = yield this.signTransactions([transaction]);
|
|
150
134
|
if (signedTransactions.length != 1) {
|
|
151
|
-
throw new ErrCannotSignSingleTransaction();
|
|
135
|
+
throw new errors_1.ErrCannotSignSingleTransaction();
|
|
152
136
|
}
|
|
153
137
|
return signedTransactions[0];
|
|
154
138
|
});
|
|
@@ -156,121 +140,123 @@ class CrossWindowProvider {
|
|
|
156
140
|
signTransactions(transactions) {
|
|
157
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
142
|
this.ensureConnected();
|
|
159
|
-
const
|
|
143
|
+
const popupConsentResponse = yield this.openPopupConsent();
|
|
160
144
|
if (!popupConsentResponse) {
|
|
161
|
-
|
|
162
|
-
throw new ErrTransactionCancelled();
|
|
163
|
-
}
|
|
164
|
-
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
165
|
-
if (!this.windowManager) {
|
|
166
|
-
throw new ErrInstantiationFailed();
|
|
145
|
+
throw new errors_1.ErrTransactionCancelled();
|
|
167
146
|
}
|
|
168
147
|
const { type, payload: { data: signedPlainTransactions, error } } = yield this.windowManager.postMessage({
|
|
169
|
-
type: CrossWindowProviderRequestEnums.signTransactionsRequest,
|
|
148
|
+
type: types_1.CrossWindowProviderRequestEnums.signTransactionsRequest,
|
|
170
149
|
payload: transactions.map((tx) => tx.toPlainObject())
|
|
171
150
|
});
|
|
172
151
|
if (error || !signedPlainTransactions) {
|
|
173
|
-
throw new ErrCouldNotSignTransactions();
|
|
152
|
+
throw new errors_1.ErrCouldNotSignTransactions();
|
|
174
153
|
}
|
|
175
|
-
if (type === CrossWindowProviderResponseEnums.cancelResponse) {
|
|
176
|
-
throw new ErrTransactionCancelled();
|
|
154
|
+
if (type === types_1.CrossWindowProviderResponseEnums.cancelResponse) {
|
|
155
|
+
throw new errors_1.ErrTransactionCancelled();
|
|
177
156
|
}
|
|
178
157
|
const hasTransactions = (signedPlainTransactions === null || signedPlainTransactions === void 0 ? void 0 : signedPlainTransactions.length) > 0;
|
|
179
158
|
if (!hasTransactions) {
|
|
180
|
-
throw new ErrCouldNotSignTransactions();
|
|
159
|
+
throw new errors_1.ErrCouldNotSignTransactions();
|
|
181
160
|
}
|
|
182
|
-
return signedPlainTransactions.map((tx) => Transaction.fromPlainObject(tx));
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
openPopupConsent(action) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
if (!this._shouldShowConsentPopup) {
|
|
188
|
-
return { popupConsentResponse: true };
|
|
189
|
-
}
|
|
190
|
-
const popup = document.createElement('open-popup-notification');
|
|
191
|
-
popup.action = action;
|
|
192
|
-
popup.walletAddress = this.windowManager.walletUrl;
|
|
193
|
-
document.body.appendChild(popup);
|
|
194
|
-
const popupConsentResponse = yield new Promise((resolve) => {
|
|
195
|
-
popup.addEventListener('popupConsent', (event) => {
|
|
196
|
-
resolve(event.detail);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
this._shouldShowConsentPopup = false;
|
|
200
|
-
return { popup, popupConsentResponse };
|
|
161
|
+
return signedPlainTransactions.map((tx) => sdk_core_1.Transaction.fromPlainObject(tx));
|
|
201
162
|
});
|
|
202
163
|
}
|
|
203
164
|
guardTransactions(transactions) {
|
|
204
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
166
|
this.ensureConnected();
|
|
206
|
-
const
|
|
167
|
+
const popupConsentResponse = yield this.openPopupConsent();
|
|
207
168
|
if (!popupConsentResponse) {
|
|
208
|
-
|
|
209
|
-
throw new ErrTransactionCancelled();
|
|
210
|
-
}
|
|
211
|
-
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
212
|
-
if (!this.windowManager) {
|
|
213
|
-
throw new ErrInstantiationFailed();
|
|
169
|
+
throw new errors_1.ErrTransactionCancelled();
|
|
214
170
|
}
|
|
215
171
|
const { type, payload: { data: signedPlainTransactions, error } } = yield this.windowManager.postMessage({
|
|
216
|
-
type: CrossWindowProviderRequestEnums.guardTransactionsRequest,
|
|
172
|
+
type: types_1.CrossWindowProviderRequestEnums.guardTransactionsRequest,
|
|
217
173
|
payload: transactions.map((tx) => tx.toPlainObject())
|
|
218
174
|
});
|
|
219
175
|
if (error || !signedPlainTransactions) {
|
|
220
|
-
throw new ErrCouldNotSignTransactions();
|
|
176
|
+
throw new errors_1.ErrCouldNotSignTransactions();
|
|
221
177
|
}
|
|
222
|
-
if (type === CrossWindowProviderResponseEnums.cancelResponse) {
|
|
223
|
-
throw new ErrTransactionCancelled();
|
|
178
|
+
if (type === types_1.CrossWindowProviderResponseEnums.cancelResponse) {
|
|
179
|
+
throw new errors_1.ErrTransactionCancelled();
|
|
224
180
|
}
|
|
225
181
|
const hasTransactions = (signedPlainTransactions === null || signedPlainTransactions === void 0 ? void 0 : signedPlainTransactions.length) > 0;
|
|
226
182
|
if (!hasTransactions) {
|
|
227
|
-
throw new ErrCouldNotGuardTransactions();
|
|
183
|
+
throw new errors_1.ErrCouldNotGuardTransactions();
|
|
228
184
|
}
|
|
229
|
-
return signedPlainTransactions.map((tx) => Transaction.fromPlainObject(tx));
|
|
185
|
+
return signedPlainTransactions.map((tx) => sdk_core_1.Transaction.fromPlainObject(tx));
|
|
230
186
|
});
|
|
231
187
|
}
|
|
232
188
|
signMessage(message) {
|
|
233
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
234
190
|
this.ensureConnected();
|
|
235
|
-
const
|
|
191
|
+
const popupConsentResponse = yield this.openPopupConsent();
|
|
236
192
|
if (!popupConsentResponse) {
|
|
237
|
-
|
|
238
|
-
throw new ErrCouldNotSignMessage();
|
|
239
|
-
}
|
|
240
|
-
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
241
|
-
if (!this.windowManager) {
|
|
242
|
-
throw new ErrInstantiationFailed();
|
|
193
|
+
throw new errors_1.ErrCouldNotSignMessage();
|
|
243
194
|
}
|
|
244
195
|
const { payload: { data, error } } = yield this.windowManager.postMessage({
|
|
245
|
-
type: CrossWindowProviderRequestEnums.signMessageRequest,
|
|
196
|
+
type: types_1.CrossWindowProviderRequestEnums.signMessageRequest,
|
|
246
197
|
payload: {
|
|
247
198
|
message: message.message.toString()
|
|
248
199
|
}
|
|
249
200
|
});
|
|
250
201
|
if (error || !data) {
|
|
251
|
-
throw new ErrCouldNotSignMessage();
|
|
202
|
+
throw new errors_1.ErrCouldNotSignMessage();
|
|
252
203
|
}
|
|
253
204
|
const { status, signature } = data;
|
|
254
|
-
if (status !== SignMessageStatusEnum.signed) {
|
|
255
|
-
throw new ErrCouldNotSignMessage();
|
|
205
|
+
if (status !== types_1.SignMessageStatusEnum.signed) {
|
|
206
|
+
throw new errors_1.ErrCouldNotSignMessage();
|
|
256
207
|
}
|
|
257
208
|
message.applySignature(Buffer.from(String(signature), 'hex'));
|
|
258
209
|
return message;
|
|
259
210
|
});
|
|
260
211
|
}
|
|
261
212
|
cancelAction() {
|
|
262
|
-
var _a;
|
|
263
|
-
|
|
264
|
-
|
|
213
|
+
var _a, _b;
|
|
214
|
+
const isWalletOpened = (_a = this.windowManager) === null || _a === void 0 ? void 0 : _a.isWalletOpened(types_1.CrossWindowProviderRequestEnums.cancelAction);
|
|
215
|
+
if (!isWalletOpened) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
return (_b = this.windowManager) === null || _b === void 0 ? void 0 : _b.postMessage({
|
|
219
|
+
type: types_1.CrossWindowProviderRequestEnums.cancelAction,
|
|
265
220
|
payload: undefined
|
|
266
221
|
});
|
|
267
222
|
}
|
|
268
|
-
|
|
223
|
+
openPopupConsent() {
|
|
269
224
|
var _a;
|
|
270
|
-
|
|
271
|
-
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const dialog = (_a = constants_1.safeWindow.document) === null || _a === void 0 ? void 0 : _a.createElement('dialog');
|
|
227
|
+
const document = constants_1.safeWindow.document;
|
|
228
|
+
if (!this._shouldShowConsentPopup || !document || !dialog) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
dialog.setAttribute('id', popupConsent_1.dialogId);
|
|
232
|
+
dialog.innerHTML = (0, popupConsent_1.getMarkup)(this.windowManager.walletUrl);
|
|
233
|
+
document.body.appendChild(dialog);
|
|
234
|
+
dialog.showModal();
|
|
235
|
+
const popupConsentResponse = yield new Promise((resolve) => {
|
|
236
|
+
const confirmButton = document.getElementById(popupConsent_1.confirmId);
|
|
237
|
+
const cancelButton = document.getElementById(popupConsent_1.cancelId);
|
|
238
|
+
if (!confirmButton || !cancelButton) {
|
|
239
|
+
resolve(true);
|
|
240
|
+
dialog.close();
|
|
241
|
+
document.body.removeChild(dialog);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
confirmButton.addEventListener('click', function () {
|
|
245
|
+
resolve(true);
|
|
246
|
+
dialog.close();
|
|
247
|
+
document.body.removeChild(dialog);
|
|
248
|
+
});
|
|
249
|
+
cancelButton.addEventListener('click', function () {
|
|
250
|
+
resolve(false);
|
|
251
|
+
dialog.close();
|
|
252
|
+
document.body.removeChild(dialog);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
this._shouldShowConsentPopup = false;
|
|
256
|
+
return popupConsentResponse;
|
|
257
|
+
});
|
|
272
258
|
}
|
|
273
259
|
}
|
|
274
|
-
CrossWindowProvider._instance =
|
|
275
|
-
|
|
260
|
+
CrossWindowProvider._instance = new CrossWindowProvider();
|
|
261
|
+
exports.CrossWindowProvider = CrossWindowProvider;
|
|
276
262
|
//# sourceMappingURL=CrossWindowProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrossWindowProvider.js","sourceRoot":"","sources":["../../src/CrossWindowProvider/CrossWindowProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrossWindowProvider.js","sourceRoot":"","sources":["../../src/CrossWindowProvider/CrossWindowProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAoE;AACpE,4CAA0C;AAC1C,sCAUmB;AACnB,oCAIkB;AAClB,oDAAiD;AACjD,iDAA0E;AAS1E,MAAa,mBAAmB;IAQ9B;QAPO,YAAO,GAA8B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACpD,gBAAW,GAAG,KAAK,CAAC;QAGpB,gBAAW,GAAuB,SAAS,CAAC;QAC1C,4BAAuB,GAAG,KAAK,CAAC;QAGxC,IAAI,mBAAmB,CAAC,SAAS,EAAE;YACjC,MAAM,IAAI,+BAAsB,EAAE,CAAC;SACpC;QACD,IAAI,CAAC,aAAa,GAAG,6BAAa,CAAC,WAAW,EAAE,CAAC;QACjD,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC;IACvC,CAAC;IAEM,yBAAyB,CAAC,UAAm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AC,gBAAgB,CAAC,OAAO,EAAE;oBACtC,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,MAAM,CAAC,KAAK,EAAE,CAAC;oBACf,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC,CAAC,CAAC;gBACH,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBACrC,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,MAAM,CAAC,KAAK,EAAE,CAAC;oBACf,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;YACrC,OAAO,oBAAoB,CAAC;;KAC7B;;AArSc,6BAAS,GAAwB,IAAI,mBAAmB,EAAE,AAAjD,CAAkD;AAJ/D,kDAAmB"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CrossWindowProvider"), exports);
|
|
2
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/CrossWindowProvider/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/CrossWindowProvider/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMarkup = exports.cancelId = exports.confirmId = exports.dialogId = void 0;
|
|
4
|
+
exports.dialogId = 'mxcwp_confirmation-dialog';
|
|
5
|
+
exports.confirmId = 'mxcwp_confirm-button';
|
|
6
|
+
exports.cancelId = 'mxcwp_cancel-button';
|
|
7
|
+
const getStyle = () => `
|
|
8
|
+
<style>
|
|
9
|
+
#${exports.dialogId} {
|
|
10
|
+
position: fixed;
|
|
11
|
+
z-index: 999;
|
|
12
|
+
padding-top: 100px;
|
|
13
|
+
left: 50%;
|
|
14
|
+
top: 50%;
|
|
15
|
+
transform: translate(-50%, -50%);
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
overflow: auto;
|
|
19
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#${exports.dialogId}:modal {
|
|
25
|
+
max-width: 100vw;
|
|
26
|
+
width: 100vw;
|
|
27
|
+
max-height: 100vh;
|
|
28
|
+
height: 100vh;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#${exports.dialogId} .content {
|
|
33
|
+
background: #fff;
|
|
34
|
+
border-radius: 20px;
|
|
35
|
+
z-index: 999;
|
|
36
|
+
max-width: 500px;
|
|
37
|
+
margin: auto;
|
|
38
|
+
padding: 0;
|
|
39
|
+
position: relative;
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#${exports.dialogId} .body {
|
|
44
|
+
padding: 50px 0;
|
|
45
|
+
color: #262525;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#${exports.dialogId} .title {
|
|
50
|
+
text-align: center;
|
|
51
|
+
font-size: 1.5rem;
|
|
52
|
+
}
|
|
53
|
+
#${exports.dialogId} .subtitle {
|
|
54
|
+
margin-top: 10px;
|
|
55
|
+
text-align: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#${exports.dialogId} .actions-container {
|
|
59
|
+
margin-top: 40px;
|
|
60
|
+
margin-bottom: 10px;
|
|
61
|
+
display: flex;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
gap: 20px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#${exports.dialogId} .button {
|
|
67
|
+
max-width: 200px;
|
|
68
|
+
margin-top: 10px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#${exports.dialogId} button {
|
|
73
|
+
border-radius: 8px;
|
|
74
|
+
border: 1px solid transparent;
|
|
75
|
+
padding: 0.6em 1.2em;
|
|
76
|
+
font-size: 1em;
|
|
77
|
+
font-weight: 500;
|
|
78
|
+
font-family: inherit;
|
|
79
|
+
background-color: #efeeee;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
transition: border-color 0.25s;
|
|
82
|
+
}
|
|
83
|
+
#${exports.dialogId} button:hover {
|
|
84
|
+
border-color: #cacaca;
|
|
85
|
+
}
|
|
86
|
+
#${exports.dialogId} button:focus,
|
|
87
|
+
#${exports.dialogId} button:focus-visible {
|
|
88
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#${exports.dialogId} .btn-proceed {
|
|
92
|
+
background-color: #262626;
|
|
93
|
+
color: #fff;
|
|
94
|
+
padding-left: 40px;
|
|
95
|
+
padding-right: 40px;
|
|
96
|
+
}
|
|
97
|
+
</style>`;
|
|
98
|
+
const getMarkup = (walletUrl) => {
|
|
99
|
+
return `
|
|
100
|
+
${getStyle()}
|
|
101
|
+
<div class="content">
|
|
102
|
+
<div class="body">
|
|
103
|
+
<div class="title">Confirm on MultiversX Wallet</div>
|
|
104
|
+
<div class="subtitle">
|
|
105
|
+
Continue to ${walletUrl}
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div class="actions-container">
|
|
109
|
+
<button id="${exports.cancelId}" class="button">
|
|
110
|
+
Cancel
|
|
111
|
+
</button>
|
|
112
|
+
<button id="${exports.confirmId}" class="button btn-proceed">
|
|
113
|
+
Continue →
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
`;
|
|
119
|
+
};
|
|
120
|
+
exports.getMarkup = getMarkup;
|
|
121
|
+
//# sourceMappingURL=popupConsent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popupConsent.js","sourceRoot":"","sources":["../../src/CrossWindowProvider/popupConsent.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,2BAA2B,CAAC;AACvC,QAAA,SAAS,GAAG,sBAAsB,CAAC;AACnC,QAAA,QAAQ,GAAG,qBAAqB,CAAC;AAE9C,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC;;GAEpB,gBAAQ;;;;;;;;;;;;;;;GAeR,gBAAQ;;;;;;;;KAQN,gBAAQ;;;;;;;;;;;KAWR,gBAAQ;;;;;;KAMR,gBAAQ;;;;KAIR,gBAAQ;;;;;KAKR,gBAAQ;;;;;;;;KAQR,gBAAQ;;;;;;KAMR,gBAAQ;;;;;;;;;;;KAWR,gBAAQ;;;KAGR,gBAAQ;KACR,gBAAQ;;;;KAIR,gBAAQ;;;;;;SAMJ,CAAC;AAEH,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC7C,OAAO;IACL,QAAQ,EAAE;;;;;wBAKU,SAAS;;;;0BAIP,gBAAQ;;;0BAGR,iBAAS;;;;;;CAMlC,CAAC;AACF,CAAC,CAAC;AArBW,QAAA,SAAS,aAqBpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,22 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const test_utils_1 = require("../../test-utils");
|
|
13
|
+
const WindowManager_1 = require("../../WindowManager/WindowManager");
|
|
14
|
+
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
13
15
|
describe('CrossWindowProvider Login', () => {
|
|
14
16
|
let crossWindowProvider;
|
|
15
17
|
let walletWindowMock;
|
|
16
18
|
let windowOpenSpy;
|
|
17
19
|
beforeEach(() => {
|
|
18
|
-
walletWindowMock = getWalletWindowMock();
|
|
19
|
-
WindowManager.getInstance().postMessage = jest
|
|
20
|
+
walletWindowMock = (0, test_utils_1.getWalletWindowMock)();
|
|
21
|
+
WindowManager_1.WindowManager.getInstance().postMessage = jest
|
|
20
22
|
.fn()
|
|
21
23
|
.mockImplementation(() => ({
|
|
22
24
|
payload: {}
|
|
23
25
|
}));
|
|
24
|
-
crossWindowProvider = CrossWindowProvider.getInstance();
|
|
25
|
-
mockWindoManager();
|
|
26
|
+
crossWindowProvider = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
27
|
+
(0, test_utils_1.mockWindoManager)();
|
|
26
28
|
windowOpenSpy = jest.spyOn(window, 'open');
|
|
27
29
|
windowOpenSpy.mockImplementation(() => walletWindowMock);
|
|
28
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cancel.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/Cancel.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cancel.test.js","sourceRoot":"","sources":["../../../src/CrossWindowProvider/tests/Cancel.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAI0B;AAC1B,qEAAkE;AAClE,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,6BAAa,CAAC,WAAW,EAAE,CAAC,WAAW,GAAG,IAAI;aAC3C,EAAE,EAAE;aACJ,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;YACzB,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC,CAAC;QAEN,mBAAmB,GAAG,yCAAmB,CAAC,WAAW,EAAE,CAAC;QACxD,IAAA,6BAAgB,GAAE,CAAC;QACnB,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,mCAAmC,EAAE,GAAS,EAAE;QACjD,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,YAAY,EAAE,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,16 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const test_utils_1 = require("../../test-utils");
|
|
13
|
+
const CrossWindowProvider_1 = require("../CrossWindowProvider");
|
|
12
14
|
describe('CrossWindowProvider', () => {
|
|
13
15
|
let crossWindowProvider;
|
|
14
16
|
beforeEach(() => {
|
|
15
|
-
crossWindowProvider = CrossWindowProvider.getInstance();
|
|
16
|
-
mockWindoManager();
|
|
17
|
+
crossWindowProvider = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
18
|
+
(0, test_utils_1.mockWindoManager)();
|
|
17
19
|
});
|
|
18
20
|
it('should be a singleton instance', () => {
|
|
19
|
-
const anotherInstance = CrossWindowProvider.getInstance();
|
|
21
|
+
const anotherInstance = CrossWindowProvider_1.CrossWindowProvider.getInstance();
|
|
20
22
|
expect(crossWindowProvider).toBe(anotherInstance);
|
|
21
23
|
});
|
|
22
24
|
it('should initialize correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|