@onekeyfe/onekey-webln-provider 1.1.33 → 1.1.35
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/ProviderWebln.d.ts +2 -0
- package/dist/ProviderWebln.js +83 -25
- package/dist/cjs/ProviderWebln.js +83 -25
- package/package.json +6 -6
package/dist/ProviderWebln.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { WeblnProviderEventsMap, GetInfoResponse, IProviderWebln, RequestInvoice
|
|
|
4
4
|
declare class ProviderWebln extends ProviderWeblnBase implements IProviderWebln {
|
|
5
5
|
private states;
|
|
6
6
|
constructor(props: IInpageProviderConfig);
|
|
7
|
+
setExecuting(executing: boolean): void;
|
|
8
|
+
private checkEnabled;
|
|
7
9
|
on<E extends keyof WeblnProviderEventsMap>(event: E, listener: WeblnProviderEventsMap[E]): this;
|
|
8
10
|
emit<E extends keyof WeblnProviderEventsMap>(event: E, ...args: Parameters<WeblnProviderEventsMap[E]>): boolean;
|
|
9
11
|
private _callBridge;
|
package/dist/ProviderWebln.js
CHANGED
|
@@ -17,6 +17,21 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
17
17
|
};
|
|
18
18
|
this.handlerLnurl();
|
|
19
19
|
}
|
|
20
|
+
setExecuting(executing) {
|
|
21
|
+
this.states.executing = executing;
|
|
22
|
+
}
|
|
23
|
+
checkEnabled(method) {
|
|
24
|
+
if (!this.states.enabled) {
|
|
25
|
+
const message = `Please allow the connection request of webln before calling the ${method} method`;
|
|
26
|
+
alert(message);
|
|
27
|
+
throw new Error(message);
|
|
28
|
+
}
|
|
29
|
+
if (this.states.executing) {
|
|
30
|
+
const message = `window.webln call already executing`;
|
|
31
|
+
alert(message);
|
|
32
|
+
throw new Error(message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
20
35
|
on(event, listener) {
|
|
21
36
|
return super.on(event, listener);
|
|
22
37
|
}
|
|
@@ -31,52 +46,90 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
31
46
|
if (this.states.enabled) {
|
|
32
47
|
return { enabled: true };
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
if (this.states.executing) {
|
|
50
|
+
const message = `window.webln call already executing`;
|
|
51
|
+
alert(message);
|
|
52
|
+
throw new Error(message);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
this.setExecuting(true);
|
|
56
|
+
const result = yield this._callBridge({ method: "enable" });
|
|
57
|
+
if (typeof result.enabled === "boolean") {
|
|
58
|
+
this.states.enabled = true;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
this.setExecuting(false);
|
|
37
64
|
}
|
|
38
|
-
return result;
|
|
39
65
|
});
|
|
40
66
|
}
|
|
41
67
|
getInfo() {
|
|
42
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
this.checkEnabled('getInfo');
|
|
70
|
+
try {
|
|
71
|
+
this.setExecuting(true);
|
|
72
|
+
const response = yield this._callBridge({ method: "getInfo" });
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
this.setExecuting(false);
|
|
45
77
|
}
|
|
46
|
-
return this._callBridge({ method: "getInfo" });
|
|
47
78
|
});
|
|
48
79
|
}
|
|
49
80
|
makeInvoice(args) {
|
|
50
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
|
|
52
|
-
|
|
82
|
+
this.checkEnabled('makeInvoice');
|
|
83
|
+
try {
|
|
84
|
+
this.setExecuting(true);
|
|
85
|
+
const response = yield this._callBridge({ method: "makeInvoice", params: args });
|
|
86
|
+
return response;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
this.setExecuting(false);
|
|
53
90
|
}
|
|
54
|
-
return this._callBridge({ method: "makeInvoice", params: args });
|
|
55
91
|
});
|
|
56
92
|
}
|
|
57
93
|
sendPayment(paymentRequest) {
|
|
58
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
this.checkEnabled('sendPayment');
|
|
96
|
+
try {
|
|
97
|
+
this.setExecuting(true);
|
|
98
|
+
const response = yield this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
this.setExecuting(false);
|
|
61
103
|
}
|
|
62
|
-
return this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
63
104
|
});
|
|
64
105
|
}
|
|
65
106
|
signMessage(message) {
|
|
66
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
|
|
68
|
-
|
|
108
|
+
this.checkEnabled('signMessage');
|
|
109
|
+
try {
|
|
110
|
+
this.setExecuting(true);
|
|
111
|
+
const response = yield this._callBridge({ method: "signMessage", params: message });
|
|
112
|
+
return response;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
this.setExecuting(false);
|
|
69
116
|
}
|
|
70
|
-
return this._callBridge({ method: "signMessage", params: message });
|
|
71
117
|
});
|
|
72
118
|
}
|
|
73
119
|
verifyMessage(signature, message) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
this.checkEnabled('verifyMessage');
|
|
122
|
+
try {
|
|
123
|
+
this.setExecuting(true);
|
|
124
|
+
const response = yield this._callBridge({
|
|
125
|
+
method: "verifyMessage",
|
|
126
|
+
params: { signature, message },
|
|
127
|
+
});
|
|
128
|
+
return response;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
this.setExecuting(false);
|
|
132
|
+
}
|
|
80
133
|
});
|
|
81
134
|
}
|
|
82
135
|
getBalance() {
|
|
@@ -87,10 +140,15 @@ class ProviderWebln extends ProviderWeblnBase {
|
|
|
87
140
|
}
|
|
88
141
|
lnurl(lnurlString) {
|
|
89
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
|
|
91
|
-
|
|
143
|
+
this.checkEnabled('lnurl');
|
|
144
|
+
try {
|
|
145
|
+
this.setExecuting(true);
|
|
146
|
+
const response = yield this._callBridge({ method: "lnurl", params: lnurlString });
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
this.setExecuting(false);
|
|
92
151
|
}
|
|
93
|
-
return this._callBridge({ method: "lnurl", params: lnurlString });
|
|
94
152
|
});
|
|
95
153
|
}
|
|
96
154
|
handlerLnurl() {
|
|
@@ -20,6 +20,21 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
20
20
|
};
|
|
21
21
|
this.handlerLnurl();
|
|
22
22
|
}
|
|
23
|
+
setExecuting(executing) {
|
|
24
|
+
this.states.executing = executing;
|
|
25
|
+
}
|
|
26
|
+
checkEnabled(method) {
|
|
27
|
+
if (!this.states.enabled) {
|
|
28
|
+
const message = `Please allow the connection request of webln before calling the ${method} method`;
|
|
29
|
+
alert(message);
|
|
30
|
+
throw new Error(message);
|
|
31
|
+
}
|
|
32
|
+
if (this.states.executing) {
|
|
33
|
+
const message = `window.webln call already executing`;
|
|
34
|
+
alert(message);
|
|
35
|
+
throw new Error(message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
on(event, listener) {
|
|
24
39
|
return super.on(event, listener);
|
|
25
40
|
}
|
|
@@ -34,52 +49,90 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
34
49
|
if (this.states.enabled) {
|
|
35
50
|
return { enabled: true };
|
|
36
51
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
if (this.states.executing) {
|
|
53
|
+
const message = `window.webln call already executing`;
|
|
54
|
+
alert(message);
|
|
55
|
+
throw new Error(message);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
this.setExecuting(true);
|
|
59
|
+
const result = yield this._callBridge({ method: "enable" });
|
|
60
|
+
if (typeof result.enabled === "boolean") {
|
|
61
|
+
this.states.enabled = true;
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
this.setExecuting(false);
|
|
40
67
|
}
|
|
41
|
-
return result;
|
|
42
68
|
});
|
|
43
69
|
}
|
|
44
70
|
getInfo() {
|
|
45
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
this.checkEnabled('getInfo');
|
|
73
|
+
try {
|
|
74
|
+
this.setExecuting(true);
|
|
75
|
+
const response = yield this._callBridge({ method: "getInfo" });
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
this.setExecuting(false);
|
|
48
80
|
}
|
|
49
|
-
return this._callBridge({ method: "getInfo" });
|
|
50
81
|
});
|
|
51
82
|
}
|
|
52
83
|
makeInvoice(args) {
|
|
53
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
this.checkEnabled('makeInvoice');
|
|
86
|
+
try {
|
|
87
|
+
this.setExecuting(true);
|
|
88
|
+
const response = yield this._callBridge({ method: "makeInvoice", params: args });
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.setExecuting(false);
|
|
56
93
|
}
|
|
57
|
-
return this._callBridge({ method: "makeInvoice", params: args });
|
|
58
94
|
});
|
|
59
95
|
}
|
|
60
96
|
sendPayment(paymentRequest) {
|
|
61
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
this.checkEnabled('sendPayment');
|
|
99
|
+
try {
|
|
100
|
+
this.setExecuting(true);
|
|
101
|
+
const response = yield this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
102
|
+
return response;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this.setExecuting(false);
|
|
64
106
|
}
|
|
65
|
-
return this._callBridge({ method: "sendPayment", params: paymentRequest });
|
|
66
107
|
});
|
|
67
108
|
}
|
|
68
109
|
signMessage(message) {
|
|
69
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
this.checkEnabled('signMessage');
|
|
112
|
+
try {
|
|
113
|
+
this.setExecuting(true);
|
|
114
|
+
const response = yield this._callBridge({ method: "signMessage", params: message });
|
|
115
|
+
return response;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
this.setExecuting(false);
|
|
72
119
|
}
|
|
73
|
-
return this._callBridge({ method: "signMessage", params: message });
|
|
74
120
|
});
|
|
75
121
|
}
|
|
76
122
|
verifyMessage(signature, message) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
this.checkEnabled('verifyMessage');
|
|
125
|
+
try {
|
|
126
|
+
this.setExecuting(true);
|
|
127
|
+
const response = yield this._callBridge({
|
|
128
|
+
method: "verifyMessage",
|
|
129
|
+
params: { signature, message },
|
|
130
|
+
});
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this.setExecuting(false);
|
|
135
|
+
}
|
|
83
136
|
});
|
|
84
137
|
}
|
|
85
138
|
getBalance() {
|
|
@@ -90,10 +143,15 @@ class ProviderWebln extends ProviderWeblnBase_1.ProviderWeblnBase {
|
|
|
90
143
|
}
|
|
91
144
|
lnurl(lnurlString) {
|
|
92
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
|
|
94
|
-
|
|
146
|
+
this.checkEnabled('lnurl');
|
|
147
|
+
try {
|
|
148
|
+
this.setExecuting(true);
|
|
149
|
+
const response = yield this._callBridge({ method: "lnurl", params: lnurlString });
|
|
150
|
+
return response;
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
this.setExecuting(false);
|
|
95
154
|
}
|
|
96
|
-
return this._callBridge({ method: "lnurl", params: lnurlString });
|
|
97
155
|
});
|
|
98
156
|
}
|
|
99
157
|
handlerLnurl() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-webln-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.35",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
34
|
-
"@onekeyfe/extension-bridge-injected": "1.1.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.35",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.35",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.35",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "1.1.35"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "20d34171fcff35e4557342495dfd3784492ae665"
|
|
37
37
|
}
|