@onekeyfe/cross-inpage-provider-core 0.0.7-alpha.0 → 0.0.7
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/README.md +1 -1
- package/dist/JsBridgeBase.d.ts +1 -1
- package/dist/JsBridgeBase.js +5 -1
- package/dist/JsBridgeSimple.d.ts +11 -0
- package/dist/JsBridgeSimple.js +20 -0
- package/dist/cjs/JsBridgeBase.js +5 -1
- package/dist/cjs/JsBridgeSimple.js +23 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/loggers.js +1 -0
- package/dist/cjs/versionInfo.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/loggers.js +1 -0
- package/dist/versionInfo.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cross-inpage-provider
|
package/dist/JsBridgeBase.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare abstract class JsBridgeBase extends EventEmitter {
|
|
|
18
18
|
remoteId?: string | number | null;
|
|
19
19
|
};
|
|
20
20
|
private config;
|
|
21
|
-
|
|
21
|
+
protected callbacksExpireTimeout: number;
|
|
22
22
|
debugLogger: IDebugLogger;
|
|
23
23
|
private callbacks;
|
|
24
24
|
private callbackId;
|
package/dist/JsBridgeBase.js
CHANGED
|
@@ -69,11 +69,14 @@ class JsBridgeBase extends EventEmitter {
|
|
|
69
69
|
origin: '',
|
|
70
70
|
remoteId: '',
|
|
71
71
|
};
|
|
72
|
+
// TODO increase timeout as hardware sign transaction may take a long time
|
|
73
|
+
// can set timeout for each callback
|
|
74
|
+
this.callbacksExpireTimeout = 10 * 60 * 1000;
|
|
72
75
|
this.debugLogger = appDebugLogger;
|
|
73
76
|
this.callbacks = [];
|
|
74
77
|
this.callbackId = 1;
|
|
75
78
|
this.config = config;
|
|
76
|
-
this.callbacksExpireTimeout = (_a = config.timeout) !== null && _a !== void 0 ? _a :
|
|
79
|
+
this.callbacksExpireTimeout = (_a = config.timeout) !== null && _a !== void 0 ? _a : this.callbacksExpireTimeout;
|
|
77
80
|
this.debugLogger = config.debugLogger || appDebugLogger;
|
|
78
81
|
this.sendAsString = (_b = config.sendAsString) !== null && _b !== void 0 ? _b : this.sendAsString;
|
|
79
82
|
if (this.config.receiveHandler) {
|
|
@@ -113,6 +116,7 @@ class JsBridgeBase extends EventEmitter {
|
|
|
113
116
|
if (payload.error) {
|
|
114
117
|
const errorInfo = payload.error;
|
|
115
118
|
payload.error = {
|
|
119
|
+
key: errorInfo.key,
|
|
116
120
|
code: errorInfo.code,
|
|
117
121
|
message: errorInfo.message,
|
|
118
122
|
data: errorInfo.data,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IJsBridgeMessagePayload } from '@onekeyfe/cross-inpage-provider-types';
|
|
2
|
+
import { JsBridgeBase } from './JsBridgeBase';
|
|
3
|
+
declare class JsBridgeSimple extends JsBridgeBase {
|
|
4
|
+
sendAsString: boolean;
|
|
5
|
+
isInjected: boolean;
|
|
6
|
+
private remote;
|
|
7
|
+
callbacksExpireTimeout: number;
|
|
8
|
+
sendPayload(payload: IJsBridgeMessagePayload | string): void;
|
|
9
|
+
setRemote(remote: JsBridgeBase): void;
|
|
10
|
+
}
|
|
11
|
+
export { JsBridgeSimple };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JsBridgeBase } from './JsBridgeBase';
|
|
2
|
+
class JsBridgeSimple extends JsBridgeBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.sendAsString = true;
|
|
6
|
+
this.isInjected = true;
|
|
7
|
+
this.remote = null;
|
|
8
|
+
this.callbacksExpireTimeout = 0;
|
|
9
|
+
}
|
|
10
|
+
sendPayload(payload) {
|
|
11
|
+
if (!this.remote) {
|
|
12
|
+
throw new Error('JsBridgeSimple ERROR: remote not set.');
|
|
13
|
+
}
|
|
14
|
+
this.remote.receive(payload);
|
|
15
|
+
}
|
|
16
|
+
setRemote(remote) {
|
|
17
|
+
this.remote = remote;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export { JsBridgeSimple };
|
package/dist/cjs/JsBridgeBase.js
CHANGED
|
@@ -76,11 +76,14 @@ class JsBridgeBase extends eventemitter3_1.default {
|
|
|
76
76
|
origin: '',
|
|
77
77
|
remoteId: '',
|
|
78
78
|
};
|
|
79
|
+
// TODO increase timeout as hardware sign transaction may take a long time
|
|
80
|
+
// can set timeout for each callback
|
|
81
|
+
this.callbacksExpireTimeout = 10 * 60 * 1000;
|
|
79
82
|
this.debugLogger = loggers_1.appDebugLogger;
|
|
80
83
|
this.callbacks = [];
|
|
81
84
|
this.callbackId = 1;
|
|
82
85
|
this.config = config;
|
|
83
|
-
this.callbacksExpireTimeout = (_a = config.timeout) !== null && _a !== void 0 ? _a :
|
|
86
|
+
this.callbacksExpireTimeout = (_a = config.timeout) !== null && _a !== void 0 ? _a : this.callbacksExpireTimeout;
|
|
84
87
|
this.debugLogger = config.debugLogger || loggers_1.appDebugLogger;
|
|
85
88
|
this.sendAsString = (_b = config.sendAsString) !== null && _b !== void 0 ? _b : this.sendAsString;
|
|
86
89
|
if (this.config.receiveHandler) {
|
|
@@ -120,6 +123,7 @@ class JsBridgeBase extends eventemitter3_1.default {
|
|
|
120
123
|
if (payload.error) {
|
|
121
124
|
const errorInfo = payload.error;
|
|
122
125
|
payload.error = {
|
|
126
|
+
key: errorInfo.key,
|
|
123
127
|
code: errorInfo.code,
|
|
124
128
|
message: errorInfo.message,
|
|
125
129
|
data: errorInfo.data,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsBridgeSimple = void 0;
|
|
4
|
+
const JsBridgeBase_1 = require("./JsBridgeBase");
|
|
5
|
+
class JsBridgeSimple extends JsBridgeBase_1.JsBridgeBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.sendAsString = true;
|
|
9
|
+
this.isInjected = true;
|
|
10
|
+
this.remote = null;
|
|
11
|
+
this.callbacksExpireTimeout = 0;
|
|
12
|
+
}
|
|
13
|
+
sendPayload(payload) {
|
|
14
|
+
if (!this.remote) {
|
|
15
|
+
throw new Error('JsBridgeSimple ERROR: remote not set.');
|
|
16
|
+
}
|
|
17
|
+
this.remote.receive(payload);
|
|
18
|
+
}
|
|
19
|
+
setRemote(remote) {
|
|
20
|
+
this.remote = remote;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.JsBridgeSimple = JsBridgeSimple;
|
package/dist/cjs/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./ProviderBase"), exports);
|
|
|
31
31
|
__exportStar(require("./loggers"), exports);
|
|
32
32
|
__exportStar(require("./injectJsBridge"), exports);
|
|
33
33
|
__exportStar(require("./injectedProviderReceiveHandler"), exports);
|
|
34
|
+
__exportStar(require("./JsBridgeSimple"), exports);
|
|
34
35
|
const consts = __importStar(require("./consts"));
|
|
35
36
|
exports.consts = consts;
|
|
36
37
|
const injectedFactory_1 = __importDefault(require("./injectedFactory"));
|
package/dist/cjs/loggers.js
CHANGED
|
@@ -48,6 +48,7 @@ class FakeDebugLogger {
|
|
|
48
48
|
this.extContentScripts = this._createExternalLog('extContentScripts >>');
|
|
49
49
|
this.webview = this._createExternalLog('webview >>');
|
|
50
50
|
this.desktopInjected = this._createExternalLog('desktopInjected >>');
|
|
51
|
+
this.ethereum = this._createExternalLog('ethereum >>');
|
|
51
52
|
}
|
|
52
53
|
_attachExternalLogger(logger) {
|
|
53
54
|
if (logger) {
|
package/dist/cjs/versionInfo.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './ProviderBase';
|
|
|
3
3
|
export * from './loggers';
|
|
4
4
|
export * from './injectJsBridge';
|
|
5
5
|
export * from './injectedProviderReceiveHandler';
|
|
6
|
+
export * from './JsBridgeSimple';
|
|
6
7
|
import * as consts from './consts';
|
|
7
8
|
export { consts };
|
|
8
9
|
import injectedFactory from './injectedFactory';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './ProviderBase';
|
|
|
3
3
|
export * from './loggers';
|
|
4
4
|
export * from './injectJsBridge';
|
|
5
5
|
export * from './injectedProviderReceiveHandler';
|
|
6
|
+
export * from './JsBridgeSimple';
|
|
6
7
|
import * as consts from './consts';
|
|
7
8
|
export { consts };
|
|
8
9
|
import injectedFactory from './injectedFactory';
|
package/dist/loggers.js
CHANGED
|
@@ -40,6 +40,7 @@ class FakeDebugLogger {
|
|
|
40
40
|
this.extContentScripts = this._createExternalLog('extContentScripts >>');
|
|
41
41
|
this.webview = this._createExternalLog('webview >>');
|
|
42
42
|
this.desktopInjected = this._createExternalLog('desktopInjected >>');
|
|
43
|
+
this.ethereum = this._createExternalLog('ethereum >>');
|
|
43
44
|
}
|
|
44
45
|
_attachExternalLogger(logger) {
|
|
45
46
|
if (logger) {
|
package/dist/versionInfo.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/cross-inpage-provider-core",
|
|
3
|
-
"version": "0.0.7
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"build-version-info": "node ./scripts/buildVersionInfo.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "^0.0.7
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "^0.0.7
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "^0.0.7",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "^0.0.7",
|
|
34
34
|
"eventemitter3": "^4.0.7",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"ms": "^2.1.3"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "74dd1645307232196a30750239156432737092a2"
|
|
39
39
|
}
|