@ic-reactor/core 1.6.0-beta.7 → 1.6.1
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/classes/agent/index.js +12 -11
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ yarn add @ic-reactor/core
|
|
|
19
19
|
or you can use the UMD version:
|
|
20
20
|
|
|
21
21
|
```html
|
|
22
|
-
<script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.
|
|
22
|
+
<script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.6.0-beta.7/ic-reactor-core.min.js"></script>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Using `createReactorCore`
|
|
@@ -28,6 +28,7 @@ const auth_client_1 = require("@dfinity/auth-client");
|
|
|
28
28
|
const constants_1 = require("../../utils/constants");
|
|
29
29
|
class AgentManager {
|
|
30
30
|
constructor(options) {
|
|
31
|
+
var _a;
|
|
31
32
|
this._auth = null;
|
|
32
33
|
this._subscribers = [];
|
|
33
34
|
this.initialAgentState = {
|
|
@@ -121,9 +122,9 @@ class AgentManager {
|
|
|
121
122
|
yield this._auth.login(Object.assign(Object.assign({ identityProvider: this.getIsLocal()
|
|
122
123
|
? constants_1.LOCAL_INTERNET_IDENTITY_PROVIDER
|
|
123
124
|
: constants_1.IC_INTERNET_IDENTITY_PROVIDER }, options), { onSuccess: (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
var
|
|
125
|
+
var _c;
|
|
125
126
|
yield this.authenticate();
|
|
126
|
-
(
|
|
127
|
+
(_c = options === null || options === void 0 ? void 0 : options.onSuccess) === null || _c === void 0 ? void 0 : _c.call(options, msg);
|
|
127
128
|
}) }));
|
|
128
129
|
});
|
|
129
130
|
this.logout = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -141,12 +142,11 @@ class AgentManager {
|
|
|
141
142
|
return this._agent._host;
|
|
142
143
|
};
|
|
143
144
|
this.getIsLocal = () => {
|
|
144
|
-
|
|
145
|
-
return ((_b = (_a = this._agent).isLocal) === null || _b === void 0 ? void 0 : _b.call(_a)) === true;
|
|
145
|
+
return this.getNetwork() !== "ic";
|
|
146
146
|
};
|
|
147
147
|
this.getNetwork = () => {
|
|
148
148
|
const hostname = this.getAgentHost().hostname;
|
|
149
|
-
if (
|
|
149
|
+
if (constants_1.LOCAL_HOSTS.some((host) => hostname.endsWith(host))) {
|
|
150
150
|
return "local";
|
|
151
151
|
}
|
|
152
152
|
else if (constants_1.REMOTE_HOSTS.some((host) => hostname.endsWith(host))) {
|
|
@@ -179,17 +179,17 @@ class AgentManager {
|
|
|
179
179
|
const identity = this.authStore.getState().identity;
|
|
180
180
|
return identity ? identity.getPrincipal() : null;
|
|
181
181
|
};
|
|
182
|
-
const
|
|
183
|
-
let host;
|
|
182
|
+
const _b = options || {}, { withDevtools, port = 4943, withLocalEnv, withProcessEnv } = _b, agentOptions = __rest(_b, ["withDevtools", "port", "withLocalEnv", "withProcessEnv"]);
|
|
184
183
|
if (withProcessEnv) {
|
|
185
184
|
const processNetwork = (0, helper_1.getProcessEnvNetwork)();
|
|
186
|
-
host =
|
|
185
|
+
agentOptions.host =
|
|
186
|
+
processNetwork === "ic" ? constants_1.IC_HOST_NETWORK_URI : undefined;
|
|
187
187
|
}
|
|
188
188
|
else if (withLocalEnv) {
|
|
189
|
-
host = `http://127.0.0.1:${port}`;
|
|
189
|
+
agentOptions.host = `http://127.0.0.1:${port}`;
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
host =
|
|
192
|
+
agentOptions.host = (_a = agentOptions.host) !== null && _a !== void 0 ? _a : constants_1.IC_HOST_NETWORK_URI;
|
|
193
193
|
}
|
|
194
194
|
this.agentStore = (0, helper_1.createStoreWithOptionalDevtools)(this.initialAgentState, {
|
|
195
195
|
withDevtools,
|
|
@@ -201,7 +201,8 @@ class AgentManager {
|
|
|
201
201
|
name: "Reactor-Agent",
|
|
202
202
|
store: "auth",
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
console.log(process.env.DFX_NETWORK, window.location);
|
|
205
|
+
this._agent = new agent_1.HttpAgent(agentOptions);
|
|
205
206
|
this.initializeAgent();
|
|
206
207
|
}
|
|
207
208
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const REMOTE_HOSTS: string[];
|
|
2
|
+
export declare const LOCAL_HOSTS: string[];
|
|
2
3
|
export declare const IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
3
4
|
export declare const LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
4
5
|
export declare const DEFAULT_LOCAL_DIDJS_ID = "bd3sg-teaaa-aaaaa-qaaba-cai";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LOCAL_INTERNET_IDENTITY_PROVIDER = exports.IC_INTERNET_IDENTITY_PROVIDER = exports.DEFAULT_IC_DIDJS_ID = exports.DEFAULT_LOCAL_DIDJS_ID = exports.LOCAL_HOST_NETWORK_URI = exports.IC_HOST_NETWORK_URI = exports.REMOTE_HOSTS = void 0;
|
|
3
|
+
exports.LOCAL_INTERNET_IDENTITY_PROVIDER = exports.IC_INTERNET_IDENTITY_PROVIDER = exports.DEFAULT_IC_DIDJS_ID = exports.DEFAULT_LOCAL_DIDJS_ID = exports.LOCAL_HOST_NETWORK_URI = exports.IC_HOST_NETWORK_URI = exports.LOCAL_HOSTS = exports.REMOTE_HOSTS = void 0;
|
|
4
4
|
exports.REMOTE_HOSTS = [".github.dev", ".gitpod.io"];
|
|
5
|
+
exports.LOCAL_HOSTS = ["localhost", "127.0.0.1"];
|
|
5
6
|
exports.IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
6
7
|
exports.LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
7
8
|
exports.DEFAULT_LOCAL_DIDJS_ID = "bd3sg-teaaa-aaaaa-qaaba-cai";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "A library for intracting with the Internet Computer canisters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"zustand": "^4.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@ic-reactor/parser": "^0.1.0
|
|
44
|
+
"@ic-reactor/parser": "^0.1.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=10"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "aed7847793f07e0361747a565a65a17dbc20bc12"
|
|
60
60
|
}
|