@ic-reactor/react 1.1.6 → 1.1.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.
@@ -23,7 +23,7 @@ const authHooks = (agentManager) => {
23
23
  const useAuth = ({ onAuthentication, onAuthenticationSuccess, onAuthenticationFailure, onLogin, onLoginSuccess, onLoginError, onLoggedOut, } = {}) => {
24
24
  const [loginState, setLoginState] = react_1.default.useState({
25
25
  loading: false,
26
- error: null,
26
+ error: undefined,
27
27
  });
28
28
  const { authenticated, authenticating, error, identity } = useAuthState();
29
29
  const authenticate = react_1.default.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -47,7 +47,7 @@ const authHooks = (agentManager) => {
47
47
  onAuthenticationFailure,
48
48
  ]);
49
49
  const login = react_1.default.useCallback((options) => __awaiter(void 0, void 0, void 0, function* () {
50
- setLoginState({ loading: true, error: null });
50
+ setLoginState({ loading: true, error: undefined });
51
51
  const loginPromise = new Promise((resolve, reject) => {
52
52
  try {
53
53
  const authClient = getAuth();
@@ -64,18 +64,16 @@ const authHooks = (agentManager) => {
64
64
  (_a = options === null || options === void 0 ? void 0 : options.onSuccess) === null || _a === void 0 ? void 0 : _a.call(options);
65
65
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess(principal);
66
66
  resolve(principal);
67
- setLoginState({ loading: false, error: null });
67
+ setLoginState({ loading: false, error: undefined });
68
68
  })
69
- .catch((e) => {
70
- const error = e;
69
+ .catch((error) => {
71
70
  setLoginState({ loading: false, error });
72
71
  onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(error);
73
72
  reject(error);
74
73
  });
75
- }, onError: (e) => {
74
+ }, onError: (error) => {
76
75
  var _a;
77
- (_a = options === null || options === void 0 ? void 0 : options.onError) === null || _a === void 0 ? void 0 : _a.call(options, e);
78
- const error = new Error("Login failed: " + e);
76
+ (_a = options === null || options === void 0 ? void 0 : options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error);
79
77
  setLoginState({ loading: false, error });
80
78
  onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(error);
81
79
  reject(error);
@@ -13,9 +13,9 @@ export interface AuthHooksReturnType {
13
13
  export interface UseAuthParameters {
14
14
  onAuthentication?: (promise: () => Promise<Identity>) => void;
15
15
  onAuthenticationSuccess?: (identity: Identity) => void;
16
- onAuthenticationFailure?: (error: Error) => void;
16
+ onAuthenticationFailure?: (error: string | undefined) => void;
17
17
  onLoginSuccess?: (principal: Principal) => void;
18
- onLoginError?: (error: Error) => void;
18
+ onLoginError?: (error: string | undefined) => void;
19
19
  onLogin?: (promise: () => Promise<Principal>) => void;
20
20
  onLoggedOut?: () => void;
21
21
  }
@@ -28,11 +28,11 @@ export interface UseAuthReturnType {
28
28
  logout: (options?: LogoutParameters) => Promise<void>;
29
29
  authenticate: () => Promise<Identity>;
30
30
  loginLoading: boolean;
31
- loginError: Error | null;
31
+ loginError: string | undefined;
32
32
  }
33
33
  export type LoginState = {
34
34
  loading: boolean;
35
- error: Error | null;
35
+ error: string | undefined;
36
36
  };
37
37
  export type LoginParameters = AuthClientLoginOptions;
38
38
  export type LogoutParameters = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "A React library for interacting with Internet Computer canisters",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "react": ">=16.8",
48
48
  "zustand": "4.5"
49
49
  },
50
- "gitHead": "4181bc6228d5efb98f14c48b2855a37bcada97dd"
50
+ "gitHead": "f5b239372688a3343ef371369143b733d876158f"
51
51
  }