@ic-reactor/react 3.6.0 → 3.7.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.
- package/README.md +28 -8
- package/dist/auth/authentication-manager.d.ts +66 -0
- package/dist/auth/authentication-manager.d.ts.map +1 -0
- package/dist/auth/authentication-manager.js +458 -0
- package/dist/auth/authentication-manager.js.map +1 -0
- package/dist/auth/constants.d.ts +18 -0
- package/dist/auth/constants.d.ts.map +1 -0
- package/dist/auth/constants.js +18 -0
- package/dist/auth/constants.js.map +1 -0
- package/dist/auth/createIdentityAttributeHooks.d.ts +14 -0
- package/dist/auth/createIdentityAttributeHooks.d.ts.map +1 -0
- package/dist/auth/createIdentityAttributeHooks.js +54 -0
- package/dist/auth/createIdentityAttributeHooks.js.map +1 -0
- package/dist/auth/identity-attributes-manager.d.ts +19 -0
- package/dist/auth/identity-attributes-manager.d.ts.map +1 -0
- package/dist/auth/identity-attributes-manager.js +94 -0
- package/dist/auth/identity-attributes-manager.js.map +1 -0
- package/dist/auth/identity-attributes.d.ts +19 -0
- package/dist/auth/identity-attributes.d.ts.map +1 -0
- package/dist/auth/identity-attributes.js +170 -0
- package/dist/auth/identity-attributes.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.ts +75 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/createActorHooks.d.ts +12 -12
- package/dist/createActorHooks.d.ts.map +1 -1
- package/dist/createActorHooks.js.map +1 -1
- package/dist/createInfiniteQuery.d.ts +32 -32
- package/dist/createInfiniteQuery.d.ts.map +1 -1
- package/dist/createInfiniteQuery.js +6 -6
- package/dist/createInfiniteQuery.js.map +1 -1
- package/dist/createMutation.d.ts +12 -1
- package/dist/createMutation.d.ts.map +1 -1
- package/dist/createMutation.js +11 -0
- package/dist/createMutation.js.map +1 -1
- package/dist/createQuery.d.ts +12 -2
- package/dist/createQuery.d.ts.map +1 -1
- package/dist/createQuery.js +15 -5
- package/dist/createQuery.js.map +1 -1
- package/dist/createSuspenseInfiniteQuery.d.ts +31 -31
- package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/createSuspenseInfiniteQuery.js +6 -6
- package/dist/createSuspenseInfiniteQuery.js.map +1 -1
- package/dist/createSuspenseQuery.d.ts +2 -2
- package/dist/createSuspenseQuery.d.ts.map +1 -1
- package/dist/createSuspenseQuery.js.map +1 -1
- package/dist/defineReactor.d.ts +74 -0
- package/dist/defineReactor.d.ts.map +1 -0
- package/dist/defineReactor.js +75 -0
- package/dist/defineReactor.js.map +1 -0
- package/dist/{createAuthHooks.d.ts → hooks/createAuthHooks.d.ts} +6 -13
- package/dist/hooks/createAuthHooks.d.ts.map +1 -0
- package/dist/{createAuthHooks.js → hooks/createAuthHooks.js} +12 -57
- package/dist/hooks/createAuthHooks.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.d.ts +9 -9
- package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.js +3 -1
- package/dist/hooks/useActorInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorMethod.d.ts +17 -17
- package/dist/hooks/useActorMethod.d.ts.map +1 -1
- package/dist/hooks/useActorMethod.js.map +1 -1
- package/dist/hooks/useActorMutation.d.ts +18 -7
- package/dist/hooks/useActorMutation.d.ts.map +1 -1
- package/dist/hooks/useActorMutation.js +11 -0
- package/dist/hooks/useActorMutation.js.map +1 -1
- package/dist/hooks/useActorQuery.d.ts +8 -8
- package/dist/hooks/useActorQuery.d.ts.map +1 -1
- package/dist/hooks/useActorQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +9 -9
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js +3 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.d.ts +8 -8
- package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -2
- package/dist/utils.js.map +1 -1
- package/llms.txt +48 -0
- package/package.json +27 -21
- package/src/auth/authentication-manager.ts +519 -0
- package/src/auth/constants.ts +25 -0
- package/src/auth/createIdentityAttributeHooks.ts +83 -0
- package/src/auth/identity-attributes-manager.ts +127 -0
- package/src/auth/identity-attributes.ts +270 -0
- package/src/auth/index.ts +7 -0
- package/src/auth/types.ts +88 -0
- package/src/createActorHooks.ts +81 -49
- package/src/createInfiniteQuery.ts +153 -97
- package/src/createMutation.ts +34 -18
- package/src/createQuery.ts +92 -48
- package/src/createSuspenseInfiniteQuery.ts +165 -114
- package/src/createSuspenseQuery.ts +67 -41
- package/src/defineReactor.test.ts +70 -0
- package/src/defineReactor.ts +150 -0
- package/src/{createAuthHooks.ts → hooks/createAuthHooks.ts} +17 -98
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useActorInfiniteQuery.ts +44 -30
- package/src/hooks/useActorMethod.ts +62 -53
- package/src/hooks/useActorMutation.ts +47 -30
- package/src/hooks/useActorQuery.ts +36 -32
- package/src/hooks/useActorSuspenseInfiniteQuery.ts +56 -30
- package/src/hooks/useActorSuspenseQuery.ts +42 -32
- package/src/index.ts +3 -1
- package/src/types.ts +76 -71
- package/src/utils.test.ts +14 -0
- package/src/utils.ts +15 -2
- package/dist/createAuthHooks.d.ts.map +0 -1
- package/dist/createAuthHooks.js.map +0 -1
package/README.md
CHANGED
|
@@ -81,8 +81,10 @@ export function App() {
|
|
|
81
81
|
|
|
82
82
|
- `createActorHooks(reactor)` for per-canister hooks like `useActorQuery` and
|
|
83
83
|
`useActorMutation`
|
|
84
|
-
- `createAuthHooks(
|
|
85
|
-
`useUserPrincipal
|
|
84
|
+
- `createAuthHooks(authentication)` for `useAuth`, `useAgentState`, and
|
|
85
|
+
`useUserPrincipal`
|
|
86
|
+
- `createIdentityAttributeHooks(identityAttributes)` for signed identity
|
|
87
|
+
attribute requests
|
|
86
88
|
- direct reactor hooks like `useReactorQuery` when you want to pass the reactor
|
|
87
89
|
instance at call time
|
|
88
90
|
- factory helpers like `createQuery`, `createSuspenseQuery`,
|
|
@@ -136,16 +138,34 @@ const mutation = updateProfile.useMutation({
|
|
|
136
138
|
|
|
137
139
|
## Identity Attributes / OpenID email and profile values
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
Identity attributes use a dedicated `IdentityAttributesManager`, with React
|
|
142
|
+
bindings created by `createIdentityAttributeHooks`. The configured auth client
|
|
143
|
+
must support the `@icp-sdk/auth` v7 constructor, sign-in, sign-out, and
|
|
144
|
+
attribute-request APIs.
|
|
143
145
|
|
|
144
146
|
```tsx
|
|
145
|
-
|
|
147
|
+
// src/auth.ts
|
|
148
|
+
import {
|
|
149
|
+
AuthenticationManager,
|
|
150
|
+
IdentityAttributesManager,
|
|
151
|
+
createAuthHooks,
|
|
152
|
+
createIdentityAttributeHooks,
|
|
153
|
+
} from "@ic-reactor/react"
|
|
146
154
|
import { clientManager } from "./reactor"
|
|
147
155
|
|
|
148
|
-
const
|
|
156
|
+
const authentication = new AuthenticationManager({ clientManager })
|
|
157
|
+
export const { useAuth, useAgentState, useUserPrincipal } =
|
|
158
|
+
createAuthHooks(authentication)
|
|
159
|
+
|
|
160
|
+
const identityAttributes = new IdentityAttributesManager(authentication)
|
|
161
|
+
export const { useIdentityAttributes } =
|
|
162
|
+
createIdentityAttributeHooks(identityAttributes)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
// src/RegisterWithOpenIdProvider.tsx
|
|
167
|
+
import { useIdentityAttributes } from "./auth"
|
|
168
|
+
import { backend } from "./reactor"
|
|
149
169
|
|
|
150
170
|
function RegisterWithOpenIdProvider() {
|
|
151
171
|
const {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Identity } from "@icp-sdk/core/agent";
|
|
2
|
+
import type { AuthClientLike, AuthClientSignInOptions, AuthState, AuthenticationClientOptions, AuthenticationSignInOptions } from "./types";
|
|
3
|
+
import { ClientManager } from "@ic-reactor/core";
|
|
4
|
+
export interface AuthenticationManagerParameters {
|
|
5
|
+
clientManager: ClientManager;
|
|
6
|
+
authClient?: AuthClientLike;
|
|
7
|
+
identityProvider?: string | URL;
|
|
8
|
+
internetIdentityId?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Manages Internet Identity sign-in, session restoration, and authentication
|
|
12
|
+
* state for a {@link ClientManager}.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const authentication = new AuthenticationManager({ clientManager })
|
|
17
|
+
* const identity = await authentication.authenticate()
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class AuthenticationManager {
|
|
21
|
+
private authClient?;
|
|
22
|
+
private authPromise?;
|
|
23
|
+
private authClientWasProvided;
|
|
24
|
+
private authStateRevision;
|
|
25
|
+
private authStateSubscribers;
|
|
26
|
+
private authClientConstructor?;
|
|
27
|
+
private authClientConstructorPromise?;
|
|
28
|
+
private authModuleMissing;
|
|
29
|
+
private authStateValue;
|
|
30
|
+
private readonly identityProvider?;
|
|
31
|
+
private readonly internetIdentityId?;
|
|
32
|
+
readonly clientManager: ClientManager;
|
|
33
|
+
/** The current authentication state. */
|
|
34
|
+
get authState(): AuthState;
|
|
35
|
+
constructor({ clientManager, authClient, identityProvider, internetIdentityId, }: AuthenticationManagerParameters);
|
|
36
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
37
|
+
get client(): AuthClientLike | undefined;
|
|
38
|
+
subscribeAuthState(callback: (state: AuthState) => void): () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Preloads and creates an AuthClient before a user gesture is needed.
|
|
41
|
+
*/
|
|
42
|
+
prepareClient(options?: AuthenticationClientOptions): Promise<AuthClientLike | undefined>;
|
|
43
|
+
authenticate: () => Promise<Identity | undefined>;
|
|
44
|
+
login: (loginOptions?: AuthenticationSignInOptions) => Promise<void>;
|
|
45
|
+
logout: (options?: {
|
|
46
|
+
returnTo?: string;
|
|
47
|
+
}) => Promise<void>;
|
|
48
|
+
private initializeClient;
|
|
49
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
50
|
+
signInOrRecoverIdentity(options?: AuthClientSignInOptions): Promise<Identity>;
|
|
51
|
+
private ensurePreparedClient;
|
|
52
|
+
private shouldRecreateClient;
|
|
53
|
+
private syncStateFromClient;
|
|
54
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
55
|
+
ensureClient(options?: AuthenticationClientOptions): Promise<AuthClientLike | undefined>;
|
|
56
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
57
|
+
commitIdentity(identity: Identity, isAuthenticated: boolean): Promise<void>;
|
|
58
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
59
|
+
setAuthenticating(): void;
|
|
60
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
61
|
+
setAuthenticationError(error: Error): void;
|
|
62
|
+
private getDefaultIdentityProvider;
|
|
63
|
+
private updateState;
|
|
64
|
+
private loadAuthClientConstructor;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=authentication-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authent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IACU,aAAa,CAAC,OAAO,CAAC,EAAE,2BAA2B;IAiBzD,YAAY,QAAa,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAuD5D;IAEM,KAAK,GAAU,eAAe,2BAA2B,mBA2D/D;IAEM,MAAM,GAAU,UAAU;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,mBAerD;YAEa,gBAAgB;IAa9B,mDAAmD;IACtC,uBAAuB,CAClC,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,QAAQ,CAAC;IAyBpB,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,oBAAoB;YAId,mBAAmB;IAmBjC,mDAAmD;IACtC,YAAY,CAAC,OAAO,CAAC,EAAE,2BAA2B;IAY/D,mDAAmD;IACtC,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO;IAQxE,mDAAmD;IAC5C,iBAAiB;IAIxB,mDAAmD;IAC5C,sBAAsB,CAAC,KAAK,EAAE,KAAK;IAI1C,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,WAAW;YASL,yBAAyB;CAsCxC"}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { isDev } from "@ic-reactor/core";
|
|
2
|
+
import { safeGetCanisterEnv } from "@icp-sdk/core/agent/canister-env";
|
|
3
|
+
import { IC_INTERNET_IDENTITY_PROVIDER, INTERNET_IDENTITY_PROVIDER_ENV_KEY, localInternetIdentityProvider, } from "./constants";
|
|
4
|
+
const AUTH_CLIENT_MODULE = "@icp-sdk/auth/client";
|
|
5
|
+
/**
|
|
6
|
+
* Manages Internet Identity sign-in, session restoration, and authentication
|
|
7
|
+
* state for a {@link ClientManager}.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const authentication = new AuthenticationManager({ clientManager })
|
|
12
|
+
* const identity = await authentication.authenticate()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class AuthenticationManager {
|
|
16
|
+
/** The current authentication state. */
|
|
17
|
+
get authState() {
|
|
18
|
+
return this.authStateValue;
|
|
19
|
+
}
|
|
20
|
+
constructor({ clientManager, authClient, identityProvider, internetIdentityId, }) {
|
|
21
|
+
Object.defineProperty(this, "authClient", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "authPromise", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "authClientWasProvided", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: false
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "authStateRevision", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "authStateSubscribers", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: []
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(this, "authClientConstructor", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(this, "authClientConstructorPromise", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(this, "authModuleMissing", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: false
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(this, "authStateValue", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: {
|
|
74
|
+
identity: null,
|
|
75
|
+
isAuthenticating: false,
|
|
76
|
+
isAuthenticated: false,
|
|
77
|
+
error: undefined,
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "identityProvider", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "internetIdentityId", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(this, "clientManager", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "authenticate", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: async () => {
|
|
103
|
+
if (this.authState.isAuthenticated) {
|
|
104
|
+
return this.authState.identity || undefined;
|
|
105
|
+
}
|
|
106
|
+
if (this.authPromise) {
|
|
107
|
+
return this.authPromise;
|
|
108
|
+
}
|
|
109
|
+
if (this.authModuleMissing) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
this.authPromise = (async () => {
|
|
113
|
+
if (isDev() && typeof window !== "undefined") {
|
|
114
|
+
console.info(`%cic-reactor:%c Authenticating...`, "color: #3b82f6; font-weight: bold", "color: inherit", {
|
|
115
|
+
network: this.clientManager.network,
|
|
116
|
+
authClient: this.authClient ? "Shared Instance" : "Dynamic Import",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
this.updateState({ isAuthenticating: true });
|
|
120
|
+
try {
|
|
121
|
+
if (!this.authClient) {
|
|
122
|
+
const authClient = await this.initializeClient(getAuthClientOptions({
|
|
123
|
+
identityProvider: this.getDefaultIdentityProvider(),
|
|
124
|
+
}));
|
|
125
|
+
if (!authClient) {
|
|
126
|
+
this.updateState({ isAuthenticating: false });
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const identity = await this.authClient.getIdentity();
|
|
131
|
+
const isAuthenticated = await this.authClient.isAuthenticated();
|
|
132
|
+
this.clientManager.updateAgent(identity);
|
|
133
|
+
this.updateState({
|
|
134
|
+
identity,
|
|
135
|
+
isAuthenticated,
|
|
136
|
+
isAuthenticating: false,
|
|
137
|
+
});
|
|
138
|
+
return identity;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
this.updateState({ error: error, isAuthenticating: false });
|
|
142
|
+
console.error("Authentication failed:", error);
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
this.authPromise = undefined;
|
|
147
|
+
}
|
|
148
|
+
})();
|
|
149
|
+
return this.authPromise;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(this, "login", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: async (loginOptions) => {
|
|
157
|
+
let didCompleteSignIn = false;
|
|
158
|
+
try {
|
|
159
|
+
const identityProvider = loginOptions?.identityProvider || this.getDefaultIdentityProvider();
|
|
160
|
+
const authClientOptions = getAuthClientOptions({
|
|
161
|
+
...loginOptions,
|
|
162
|
+
identityProvider,
|
|
163
|
+
});
|
|
164
|
+
if (!this.ensurePreparedClient(authClientOptions)) {
|
|
165
|
+
await this.initializeClient(authClientOptions);
|
|
166
|
+
}
|
|
167
|
+
if (!this.authClient) {
|
|
168
|
+
await this.authenticate();
|
|
169
|
+
}
|
|
170
|
+
if (!this.authClient) {
|
|
171
|
+
throw new Error("Authentication module is missing or failed to initialize. To use login, please install the auth package: npm install @icp-sdk/auth");
|
|
172
|
+
}
|
|
173
|
+
this.updateState({ isAuthenticating: true, error: undefined });
|
|
174
|
+
const identity = await this.signInOrRecoverIdentity(getSignInOptions(loginOptions));
|
|
175
|
+
if (!this.clientManager.agentState.isInitialized) {
|
|
176
|
+
await this.clientManager.initializeAgent();
|
|
177
|
+
}
|
|
178
|
+
this.clientManager.updateAgent(identity);
|
|
179
|
+
this.updateState({
|
|
180
|
+
identity,
|
|
181
|
+
isAuthenticated: true,
|
|
182
|
+
isAuthenticating: false,
|
|
183
|
+
});
|
|
184
|
+
didCompleteSignIn = true;
|
|
185
|
+
try {
|
|
186
|
+
await loginOptions?.onSuccess?.();
|
|
187
|
+
}
|
|
188
|
+
catch (callbackError) {
|
|
189
|
+
this.updateState({ error: callbackError });
|
|
190
|
+
await loginOptions?.onError?.(callbackError.message);
|
|
191
|
+
throw callbackError;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (!didCompleteSignIn) {
|
|
196
|
+
await loginOptions?.onError?.(error.message);
|
|
197
|
+
this.updateState({
|
|
198
|
+
error: error,
|
|
199
|
+
isAuthenticating: false,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(this, "logout", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
configurable: true,
|
|
209
|
+
writable: true,
|
|
210
|
+
value: async (options) => {
|
|
211
|
+
if (!this.authClient) {
|
|
212
|
+
throw new Error("Authentication module is missing or failed to initialize. To use logout, please install the auth package: npm install @icp-sdk/auth");
|
|
213
|
+
}
|
|
214
|
+
this.updateState({ isAuthenticating: true, error: undefined });
|
|
215
|
+
await this.authClient.signOut(options);
|
|
216
|
+
const identity = await this.authClient.getIdentity();
|
|
217
|
+
this.clientManager.updateAgent(identity);
|
|
218
|
+
this.updateState({
|
|
219
|
+
identity,
|
|
220
|
+
isAuthenticated: false,
|
|
221
|
+
isAuthenticating: false,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
this.clientManager = clientManager;
|
|
226
|
+
const canisterEnv = typeof window !== "undefined" ? getAuthenticationCanisterEnv() : undefined;
|
|
227
|
+
this.identityProvider =
|
|
228
|
+
identityProvider ||
|
|
229
|
+
canisterEnv?.[INTERNET_IDENTITY_PROVIDER_ENV_KEY] ||
|
|
230
|
+
canisterEnv?.["PUBLIC_INTERNET_IDENTITY_PROVIDER"];
|
|
231
|
+
this.internetIdentityId =
|
|
232
|
+
internetIdentityId ||
|
|
233
|
+
canisterEnv?.["internet_identity"] ||
|
|
234
|
+
canisterEnv?.["PUBLIC_CANISTER_ID:internet_identity"] ||
|
|
235
|
+
canisterEnv?.["CANISTER_ID_INTERNET_IDENTITY"];
|
|
236
|
+
if (authClient) {
|
|
237
|
+
this.authClientWasProvided = true;
|
|
238
|
+
this.authClient = authClient;
|
|
239
|
+
this.syncStateFromClient(this.authStateRevision).catch((error) => {
|
|
240
|
+
this.updateState({ error: error, isAuthenticating: false });
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else if (typeof window !== "undefined") {
|
|
244
|
+
this.loadAuthClientConstructor().catch(() => {
|
|
245
|
+
// Optional auth support is reported when an auth method is used.
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
250
|
+
get client() {
|
|
251
|
+
return this.authClient;
|
|
252
|
+
}
|
|
253
|
+
subscribeAuthState(callback) {
|
|
254
|
+
this.authStateSubscribers.push(callback);
|
|
255
|
+
return () => {
|
|
256
|
+
this.authStateSubscribers = this.authStateSubscribers.filter((subscriber) => subscriber !== callback);
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Preloads and creates an AuthClient before a user gesture is needed.
|
|
261
|
+
*/
|
|
262
|
+
async prepareClient(options) {
|
|
263
|
+
const clientOptions = getAuthClientOptions({
|
|
264
|
+
...options,
|
|
265
|
+
identityProvider: options?.identityProvider ?? this.getDefaultIdentityProvider(),
|
|
266
|
+
});
|
|
267
|
+
if (this.authClient &&
|
|
268
|
+
(!this.shouldRecreateClient(clientOptions) || this.authClientWasProvided)) {
|
|
269
|
+
return this.authClient;
|
|
270
|
+
}
|
|
271
|
+
return this.initializeClient(clientOptions);
|
|
272
|
+
}
|
|
273
|
+
async initializeClient(options) {
|
|
274
|
+
const AuthClient = await this.loadAuthClientConstructor();
|
|
275
|
+
if (!AuthClient) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
this.authClient = new AuthClient(options);
|
|
279
|
+
return this.authClient;
|
|
280
|
+
}
|
|
281
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
282
|
+
async signInOrRecoverIdentity(options) {
|
|
283
|
+
if (!this.authClient) {
|
|
284
|
+
throw new Error("Authentication module is missing or failed to initialize. To use login, please install the auth package: npm install @icp-sdk/auth");
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
return await this.authClient.signIn(options);
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
const identity = await Promise.resolve(this.authClient.getIdentity()).catch(() => null);
|
|
291
|
+
const isAuthenticated = await Promise.resolve(this.authClient.isAuthenticated()).catch(() => false);
|
|
292
|
+
if (identity && isAuthenticated) {
|
|
293
|
+
return identity;
|
|
294
|
+
}
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
ensurePreparedClient(options) {
|
|
299
|
+
if (this.authClient &&
|
|
300
|
+
(!this.shouldRecreateClient(options) || this.authClientWasProvided)) {
|
|
301
|
+
return this.authClient;
|
|
302
|
+
}
|
|
303
|
+
const AuthClient = this.authClientConstructor;
|
|
304
|
+
if (!AuthClient || this.authClientWasProvided) {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
this.authClient = new AuthClient(options);
|
|
308
|
+
return this.authClient;
|
|
309
|
+
}
|
|
310
|
+
shouldRecreateClient(options) {
|
|
311
|
+
return !this.authClientWasProvided && hasAuthClientOptions(options);
|
|
312
|
+
}
|
|
313
|
+
async syncStateFromClient(revision = this.authStateRevision) {
|
|
314
|
+
if (!this.authClient) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const identity = await this.authClient.getIdentity();
|
|
318
|
+
const isAuthenticated = await this.authClient.isAuthenticated();
|
|
319
|
+
if (revision !== this.authStateRevision) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.clientManager.updateAgent(identity);
|
|
323
|
+
this.updateState({
|
|
324
|
+
identity,
|
|
325
|
+
isAuthenticated,
|
|
326
|
+
isAuthenticating: false,
|
|
327
|
+
error: undefined,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
331
|
+
async ensureClient(options) {
|
|
332
|
+
const clientOptions = getAuthClientOptions({
|
|
333
|
+
...options,
|
|
334
|
+
identityProvider: options?.identityProvider ?? this.getDefaultIdentityProvider(),
|
|
335
|
+
});
|
|
336
|
+
if (!this.ensurePreparedClient(clientOptions)) {
|
|
337
|
+
await this.initializeClient(clientOptions);
|
|
338
|
+
}
|
|
339
|
+
return this.authClient;
|
|
340
|
+
}
|
|
341
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
342
|
+
async commitIdentity(identity, isAuthenticated) {
|
|
343
|
+
if (!this.clientManager.agentState.isInitialized) {
|
|
344
|
+
await this.clientManager.initializeAgent();
|
|
345
|
+
}
|
|
346
|
+
this.clientManager.updateAgent(identity);
|
|
347
|
+
this.updateState({ identity, isAuthenticated, isAuthenticating: false });
|
|
348
|
+
}
|
|
349
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
350
|
+
setAuthenticating() {
|
|
351
|
+
this.updateState({ isAuthenticating: true, error: undefined });
|
|
352
|
+
}
|
|
353
|
+
/** @internal Used by IdentityAttributesManager. */
|
|
354
|
+
setAuthenticationError(error) {
|
|
355
|
+
this.updateState({ error, isAuthenticating: false });
|
|
356
|
+
}
|
|
357
|
+
getDefaultIdentityProvider() {
|
|
358
|
+
if (this.identityProvider) {
|
|
359
|
+
return this.identityProvider;
|
|
360
|
+
}
|
|
361
|
+
return this.clientManager.isLocal
|
|
362
|
+
? localInternetIdentityProvider(Number(this.clientManager.agentHost?.port) || 4943, this.internetIdentityId)
|
|
363
|
+
: IC_INTERNET_IDENTITY_PROVIDER;
|
|
364
|
+
}
|
|
365
|
+
updateState(newState) {
|
|
366
|
+
if (isDev())
|
|
367
|
+
console.debug("[ic-reactor] Updating Auth State:", newState);
|
|
368
|
+
this.authStateRevision += 1;
|
|
369
|
+
this.authStateValue = { ...this.authStateValue, ...newState };
|
|
370
|
+
this.authStateSubscribers.forEach((subscriber) => subscriber(this.authStateValue));
|
|
371
|
+
}
|
|
372
|
+
async loadAuthClientConstructor() {
|
|
373
|
+
if (this.authClientConstructor) {
|
|
374
|
+
return this.authClientConstructor;
|
|
375
|
+
}
|
|
376
|
+
if (!this.authClientConstructorPromise) {
|
|
377
|
+
// Keep the optional auth peer out of non-auth bundles. Vite/Rollup/esbuild
|
|
378
|
+
// can otherwise try to resolve this package even when auth APIs are unused.
|
|
379
|
+
this.authClientConstructorPromise = import(
|
|
380
|
+
/* @vite-ignore */ AUTH_CLIENT_MODULE)
|
|
381
|
+
.then((authModule) => {
|
|
382
|
+
const AuthClient = authModule.AuthClient;
|
|
383
|
+
if (!AuthClient) {
|
|
384
|
+
throw new Error("@icp-sdk/auth/client did not export AuthClient");
|
|
385
|
+
}
|
|
386
|
+
this.authClientConstructor = AuthClient;
|
|
387
|
+
return AuthClient;
|
|
388
|
+
})
|
|
389
|
+
.catch((error) => {
|
|
390
|
+
this.authModuleMissing = true;
|
|
391
|
+
this.authClientConstructorPromise = undefined;
|
|
392
|
+
if (error instanceof Error &&
|
|
393
|
+
error.message.includes("did not export AuthClient")) {
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
return undefined;
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
return this.authClientConstructorPromise;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function getAuthClientOptions(options) {
|
|
403
|
+
if (!options) {
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
identityProvider: options.identityProvider,
|
|
408
|
+
windowOpenerFeatures: options.windowOpenerFeatures,
|
|
409
|
+
openIdProvider: getAuthClientOpenIdProvider(options.openIdProvider),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function getAuthClientOpenIdProvider(openIdProvider) {
|
|
413
|
+
return openIdProvider === "google" ||
|
|
414
|
+
openIdProvider === "apple" ||
|
|
415
|
+
openIdProvider === "microsoft"
|
|
416
|
+
? openIdProvider
|
|
417
|
+
: undefined;
|
|
418
|
+
}
|
|
419
|
+
function hasAuthClientOptions(options) {
|
|
420
|
+
return Boolean(options?.identityProvider ||
|
|
421
|
+
options?.windowOpenerFeatures ||
|
|
422
|
+
options?.openIdProvider);
|
|
423
|
+
}
|
|
424
|
+
function getAuthenticationCanisterEnv() {
|
|
425
|
+
const canisterEnv = safeGetCanisterEnv();
|
|
426
|
+
if (canisterEnv) {
|
|
427
|
+
return canisterEnv;
|
|
428
|
+
}
|
|
429
|
+
if (typeof document === "undefined") {
|
|
430
|
+
return undefined;
|
|
431
|
+
}
|
|
432
|
+
const cookie = document.cookie
|
|
433
|
+
.split(";")
|
|
434
|
+
.find((part) => part.trim().startsWith("ic_env="));
|
|
435
|
+
const encodedValue = cookie?.split("=").slice(1).join("=")?.trim();
|
|
436
|
+
if (!encodedValue) {
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
const env = Object.fromEntries(decodeURIComponent(encodedValue)
|
|
440
|
+
.split("&")
|
|
441
|
+
.map((entry) => {
|
|
442
|
+
const separatorIndex = entry.indexOf("=");
|
|
443
|
+
return separatorIndex === -1
|
|
444
|
+
? [entry, ""]
|
|
445
|
+
: [entry.slice(0, separatorIndex), entry.slice(separatorIndex + 1)];
|
|
446
|
+
}));
|
|
447
|
+
return Object.keys(env).length ? env : undefined;
|
|
448
|
+
}
|
|
449
|
+
function getSignInOptions(options) {
|
|
450
|
+
if (!options) {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
return {
|
|
454
|
+
maxTimeToLive: options.maxTimeToLive,
|
|
455
|
+
targets: options.targets,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
//# sourceMappingURL=authentication-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-manager.js","sourceRoot":"","sources":["../../src/auth/authentication-manager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,6BAA6B,GAC9B,MAAM,aAAa,CAAA;AAapB,MAAM,kBAAkB,GAAG,sBAAsB,CAAA;AAEjD;;;;;;;;;GASG;AACH,MAAM,OAAO,qBAAqB;IAqBhC,wCAAwC;IACxC,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAED,YAAY,EACV,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACc;QA9B1B;;;;;WAA2B;QAC3B;;;;;WAA2C;QAC3C;;;;mBAAwB,KAAK;WAAA;QAC7B;;;;mBAAoB,CAAC;WAAA;QACrB;;;;mBAA0D,EAAE;WAAA;QAC5D;;;;;WAA6C;QAC7C;;;;;WAEP;QACO;;;;mBAAoB,KAAK;WAAA;QACzB;;;;mBAA4B;gBAClC,QAAQ,EAAE,IAAI;gBACd,gBAAgB,EAAE,KAAK;gBACvB,eAAe,EAAE,KAAK;gBACtB,KAAK,EAAE,SAAS;aACjB;WAAA;QACgB;;;;;WAA+B;QAC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C,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACzC,OAAO,cAAc,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACb,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAA;IACvE,CAAC,CAAC,CACL,CAAA;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC;AAED,SAAS,gBAAgB,CACvB,OAAqC;IAErC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO;QACL,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const IC_INTERNET_IDENTITY_PROVIDER = "https://id.ai/authorize";
|
|
2
|
+
/**
|
|
3
|
+
* `ic_env` key used to provide a fully resolved Internet Identity URL.
|
|
4
|
+
*/
|
|
5
|
+
export declare const INTERNET_IDENTITY_PROVIDER_ENV_KEY = "INTERNET_IDENTITY_PROVIDER";
|
|
6
|
+
/**
|
|
7
|
+
* Well-known Internet Identity canister ID used when deploying II locally.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LOCAL_INTERNET_IDENTITY_CANISTER_ID = "rdmx6-jaaaa-aaaaa-aaadq-cai";
|
|
10
|
+
/**
|
|
11
|
+
* Builds the local Internet Identity provider URL for the given replica port.
|
|
12
|
+
*/
|
|
13
|
+
export declare const localInternetIdentityProvider: (port: number, canisterId?: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Legacy default URL for local Internet Identity, using port `4943`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LOCAL_INTERNET_IDENTITY_PROVIDER: string;
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/auth/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,4BAA4B,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,kCAAkC,+BAA+B,CAAA;AAE9E;;GAEG;AACH,eAAO,MAAM,mCAAmC,gCAAgC,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACxC,MAAM,MAAM,EACZ,aAAY,MAA4C,WACH,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,gCAAgC,QACR,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const IC_INTERNET_IDENTITY_PROVIDER = "https://id.ai/authorize";
|
|
2
|
+
/**
|
|
3
|
+
* `ic_env` key used to provide a fully resolved Internet Identity URL.
|
|
4
|
+
*/
|
|
5
|
+
export const INTERNET_IDENTITY_PROVIDER_ENV_KEY = "INTERNET_IDENTITY_PROVIDER";
|
|
6
|
+
/**
|
|
7
|
+
* Well-known Internet Identity canister ID used when deploying II locally.
|
|
8
|
+
*/
|
|
9
|
+
export const LOCAL_INTERNET_IDENTITY_CANISTER_ID = "rdmx6-jaaaa-aaaaa-aaadq-cai";
|
|
10
|
+
/**
|
|
11
|
+
* Builds the local Internet Identity provider URL for the given replica port.
|
|
12
|
+
*/
|
|
13
|
+
export const localInternetIdentityProvider = (port, canisterId = LOCAL_INTERNET_IDENTITY_CANISTER_ID) => `http://${canisterId}.localhost:${port}/authorize`;
|
|
14
|
+
/**
|
|
15
|
+
* Legacy default URL for local Internet Identity, using port `4943`.
|
|
16
|
+
*/
|
|
17
|
+
export const LOCAL_INTERNET_IDENTITY_PROVIDER = localInternetIdentityProvider(4943);
|
|
18
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/auth/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,yBAAyB,CAAA;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,4BAA4B,CAAA;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,6BAA6B,CAAA;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,IAAY,EACZ,aAAqB,mCAAmC,EACxD,EAAE,CAAC,UAAU,UAAU,cAAc,IAAI,YAAY,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,6BAA6B,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IdentityAttributesManager } from "./identity-attributes-manager";
|
|
2
|
+
import type { IdentityAttributeResult, RequestIdentityAttributesParameters, RequestOpenIdIdentityAttributesParameters } from "./types";
|
|
3
|
+
export interface UseIdentityAttributesReturn {
|
|
4
|
+
requestAttributes: (params: RequestIdentityAttributesParameters) => Promise<IdentityAttributeResult>;
|
|
5
|
+
requestOpenIdAttributes: (params: RequestOpenIdIdentityAttributesParameters) => Promise<IdentityAttributeResult>;
|
|
6
|
+
attributes: IdentityAttributeResult | null;
|
|
7
|
+
isRequestingAttributes: boolean;
|
|
8
|
+
attributeError: Error | null;
|
|
9
|
+
clearAttributes: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createIdentityAttributeHooks(identityAttributes: IdentityAttributesManager): {
|
|
12
|
+
useIdentityAttributes: () => UseIdentityAttributesReturn;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=createIdentityAttributeHooks.d.ts.map
|