@ic-reactor/react 0.4.3 → 0.4.4

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.
@@ -16,6 +16,6 @@ export declare const getAuthHooks: (agentManager: AgentManager) => {
16
16
  }) => Promise<void>;
17
17
  authenticate: () => Promise<void>;
18
18
  loginLoading: boolean;
19
- loginError: unknown;
19
+ loginError: Error | null;
20
20
  };
21
21
  };
@@ -48,27 +48,28 @@ const getAuthHooks = (agentManager) => {
48
48
  if (!authClient) {
49
49
  throw new Error("Auth client not initialized");
50
50
  }
51
- yield authClient.login(Object.assign(Object.assign({ identityProvider: isLocalEnv
51
+ return yield authClient.login(Object.assign(Object.assign({ identityProvider: isLocalEnv
52
52
  ? "https://identity.ic0.app/#authorize"
53
53
  : "http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:4943/#authorize" }, options), { onSuccess: () => __awaiter(void 0, void 0, void 0, function* () {
54
54
  var _a;
55
- setLoginLoading(false);
56
55
  yield authenticate();
57
56
  (_a = options === null || options === void 0 ? void 0 : options.onSuccess) === null || _a === void 0 ? void 0 : _a.call(options);
58
57
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess();
59
58
  }), onError: (e) => {
60
59
  var _a;
61
- setLoginError(e);
62
- setLoginLoading(false);
63
60
  (_a = options === null || options === void 0 ? void 0 : options.onError) === null || _a === void 0 ? void 0 : _a.call(options, e);
64
- onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(e);
61
+ const error = new Error("Login failed:" + e);
62
+ setLoginError(error);
63
+ onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(error);
65
64
  } }));
66
65
  }
67
66
  catch (e) {
68
- setLoginLoading(false);
69
67
  setLoginError(e);
70
68
  onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(e);
71
69
  }
70
+ finally {
71
+ setLoginLoading(false);
72
+ }
72
73
  }), [authClient, onLogin, onLoginSuccess, onLoginError, isLocalEnv]);
73
74
  const logout = (0, react_1.useCallback)((options) => __awaiter(void 0, void 0, void 0, function* () {
74
75
  if (!authClient) {
package/dist/index.d.ts CHANGED
@@ -18,6 +18,6 @@ export declare const createReActor: <A extends unknown>({ isLocalEnv, ...options
18
18
  } | undefined) => Promise<void>;
19
19
  authenticate: () => Promise<void>;
20
20
  loginLoading: boolean;
21
- loginError: unknown;
21
+ loginError: Error | null;
22
22
  };
23
23
  };
package/dist/types.d.ts CHANGED
@@ -4,9 +4,9 @@ export type * from "@ic-reactor/store/dist/actor/types";
4
4
  export type AuthArgs = {
5
5
  onAuthentication?: () => void;
6
6
  onAuthenticationSuccess?: (identity: Identity) => void;
7
- onAuthenticationFailure?: (error: Error | unknown | null) => void;
7
+ onAuthenticationFailure?: (error: Error | undefined) => void;
8
8
  onLoginSuccess?: () => void;
9
- onLoginError?: (error: Error | unknown | null) => void;
9
+ onLoginError?: (error: Error | undefined) => void;
10
10
  onLogin?: () => void;
11
11
  onLoggedOut?: () => void;
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "A React library for interacting with Dfinity actors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,5 +48,5 @@
48
48
  "react": ">=16.8",
49
49
  "zustand": "4.4"
50
50
  },
51
- "gitHead": "b7de729b76ac8e1db098bf2eadf975cfb4a57fa2"
51
+ "gitHead": "be65990c31a4e7a86539fec2c6600de3e32a0c79"
52
52
  }