@ic-reactor/react 0.4.5 → 0.4.6
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/dist/hooks/auth.d.ts +2 -1
- package/dist/hooks/auth.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +2 -2
package/dist/hooks/auth.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { AuthClientLoginOptions } from "@dfinity/auth-client";
|
|
2
|
-
import type { AgentManager, Identity } from "@ic-reactor/store";
|
|
2
|
+
import type { AgentManager, Identity, Principal } from "@ic-reactor/store";
|
|
3
3
|
import { AuthArgs } from "../types";
|
|
4
4
|
export type AuthHooks = ReturnType<typeof getAuthHooks>;
|
|
5
5
|
export declare const getAuthHooks: (agentManager: AgentManager) => {
|
|
6
|
+
useUserPrincipal: () => Principal | undefined;
|
|
6
7
|
useAgentManager: () => AgentManager;
|
|
7
8
|
useAuthStore: () => import("@ic-reactor/store").AgentAuthState;
|
|
8
9
|
useAuthClient: ({ onAuthentication, onAuthenticationSuccess, onAuthenticationFailure, onLogin, onLoginSuccess, onLoginError, onLoggedOut, }?: AuthArgs) => {
|
package/dist/hooks/auth.js
CHANGED
|
@@ -21,6 +21,10 @@ const getAuthHooks = (agentManager) => {
|
|
|
21
21
|
const authState = (0, zustand_1.useStore)(authStore, (state) => state);
|
|
22
22
|
return authState;
|
|
23
23
|
};
|
|
24
|
+
const useUserPrincipal = () => {
|
|
25
|
+
const { identity } = useAuthStore();
|
|
26
|
+
return identity === null || identity === void 0 ? void 0 : identity.getPrincipal();
|
|
27
|
+
};
|
|
24
28
|
const useAuthClient = ({ onAuthentication, onAuthenticationSuccess, onAuthenticationFailure, onLogin, onLoginSuccess, onLoginError, onLoggedOut, } = {}) => {
|
|
25
29
|
const [loginLoading, setLoginLoading] = (0, react_1.useState)(false);
|
|
26
30
|
const [loginError, setLoginError] = (0, react_1.useState)(null);
|
|
@@ -115,6 +119,7 @@ const getAuthHooks = (agentManager) => {
|
|
|
115
119
|
};
|
|
116
120
|
};
|
|
117
121
|
return {
|
|
122
|
+
useUserPrincipal,
|
|
118
123
|
useAgentManager,
|
|
119
124
|
useAuthStore,
|
|
120
125
|
useAuthClient,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { createReActorStore, createAgentManager, createActorManager, } from "@ic
|
|
|
5
5
|
export * from "./context/agent";
|
|
6
6
|
export * from "./context/actor";
|
|
7
7
|
export declare const createReActor: <A extends unknown>({ isLocalEnv, ...options }: CreateReActorOptions) => ActorHooks<A> & {
|
|
8
|
+
useUserPrincipal: () => import("@dfinity/principal").Principal | undefined;
|
|
8
9
|
useAgentManager: () => import("@ic-reactor/store").AgentManager;
|
|
9
10
|
useAuthStore: () => import("@ic-reactor/store").AgentAuthState;
|
|
10
11
|
useAuthClient: ({ onAuthentication, onAuthenticationSuccess, onAuthenticationFailure, onLogin, onLoginSuccess, onLoginError, onLoggedOut, }?: import("./types").AuthArgs) => {
|
package/dist/index.js
CHANGED
|
@@ -43,10 +43,11 @@ const createReActor = (_a) => {
|
|
|
43
43
|
(process.env.NODE_ENV === "development" ||
|
|
44
44
|
process.env.DFX_NETWORK === "local"));
|
|
45
45
|
const actorManager = (0, store_1.createReActorStore)(Object.assign({ isLocalEnv }, options));
|
|
46
|
-
const { useAuthClient, useAgentManager, useAuthStore } = (0, auth_1.getAuthHooks)(actorManager.agentManager);
|
|
46
|
+
const { useAuthClient, useUserPrincipal, useAgentManager, useAuthStore } = (0, auth_1.getAuthHooks)(actorManager.agentManager);
|
|
47
47
|
const { initialize, useActorStore, useQueryCall, useUpdateCall, useMethodCall, useMethodField, useMethodFields, useMethodNames, useServiceFields, } = (0, actor_1.getActorHooks)(actorManager);
|
|
48
48
|
return {
|
|
49
49
|
initialize,
|
|
50
|
+
useUserPrincipal,
|
|
50
51
|
useAgentManager,
|
|
51
52
|
useMethodFields,
|
|
52
53
|
useMethodField,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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": "
|
|
51
|
+
"gitHead": "48251ebc25add07c5a94ff63ebc8bf2dc8e0caba"
|
|
52
52
|
}
|