@ic-reactor/core 1.10.3 → 2.0.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.
@@ -1,8 +1,9 @@
1
1
  import { HttpAgent } from "@dfinity/agent";
2
2
  import { AuthClient } from "@dfinity/auth-client";
3
3
  import type { AuthClientLoginOptions } from "../../types";
4
- import type { AgentStore, AgentManagerParameters, UpdateAgentParameters, AuthStore } from "./types";
4
+ import type { AgentStore, AgentManagerParameters, UpdateAgentParameters, AuthState, AuthStore } from "./types";
5
5
  export declare class AgentManager {
6
+ private _anonymousAgent;
6
7
  private _agent;
7
8
  private _auth;
8
9
  private _subscribers;
@@ -11,7 +12,7 @@ export declare class AgentManager {
11
12
  private initialAgentState;
12
13
  private initialAuthState;
13
14
  private updateAgentState;
14
- private updateAuthState;
15
+ updateAuthState: (newState: Partial<AuthState>, action?: string) => void;
15
16
  constructor(options?: AgentManagerParameters);
16
17
  private initializeAgent;
17
18
  subscribeAgent: (callback: (agent: HttpAgent) => void, initialize?: boolean) => () => void;
@@ -46,6 +46,7 @@ class AgentManager {
46
46
  this.updateAgentState = (newState, action) => {
47
47
  this.agentStore.setState((state) => (Object.assign(Object.assign({}, state), newState)), false, action);
48
48
  };
49
+ //TODO: make it private
49
50
  this.updateAuthState = (newState, action) => {
50
51
  this.authStore.setState((state) => (Object.assign(Object.assign({}, state), newState)), false, action);
51
52
  };
@@ -59,6 +60,7 @@ class AgentManager {
59
60
  if (network !== "ic") {
60
61
  try {
61
62
  yield this._agent.fetchRootKey();
63
+ yield this._anonymousAgent.fetchRootKey();
62
64
  }
63
65
  catch (error) {
64
66
  this.updateAgentState({ error: error, initializing: false }, "error");
@@ -205,6 +207,7 @@ class AgentManager {
205
207
  name: "reactor-agent",
206
208
  store: "auth",
207
209
  });
210
+ this._anonymousAgent = agent_1.HttpAgent.createSync(agentOptions);
208
211
  this._agent = agent_1.HttpAgent.createSync(agentOptions);
209
212
  this.initializeAgent();
210
213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/core",
3
- "version": "1.10.3",
3
+ "version": "2.0.0-alpha.0",
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",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=10"
58
58
  },
59
- "gitHead": "1603c5f57869353d4a3d1c18d08f303b0d03fe6d"
59
+ "gitHead": "081197439510ef0327c5a807e0e35ec7aa841fd4"
60
60
  }