@ic-reactor/react 3.13.0 → 4.0.0-beta.2
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 +237 -787
- package/dist/index.d.ts +260 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +471 -23
- package/dist/index.js.map +1 -1
- package/llms.txt +82 -278
- package/package.json +11 -39
- package/src/index.tsx +612 -0
- package/dist/auth/auth-client-compat.d.ts +0 -122
- package/dist/auth/auth-client-compat.d.ts.map +0 -1
- package/dist/auth/auth-client-compat.js +0 -162
- package/dist/auth/auth-client-compat.js.map +0 -1
- package/dist/auth/authentication-manager.d.ts +0 -405
- package/dist/auth/authentication-manager.d.ts.map +0 -1
- package/dist/auth/authentication-manager.js +0 -1537
- package/dist/auth/authentication-manager.js.map +0 -1
- package/dist/auth/constants.d.ts +0 -24
- package/dist/auth/constants.d.ts.map +0 -1
- package/dist/auth/constants.js +0 -24
- package/dist/auth/constants.js.map +0 -1
- package/dist/auth/createIdentityAttributeHooks.d.ts +0 -14
- package/dist/auth/createIdentityAttributeHooks.d.ts.map +0 -1
- package/dist/auth/createIdentityAttributeHooks.js +0 -122
- package/dist/auth/createIdentityAttributeHooks.js.map +0 -1
- package/dist/auth/identity-attributes-manager.d.ts +0 -27
- package/dist/auth/identity-attributes-manager.d.ts.map +0 -1
- package/dist/auth/identity-attributes-manager.js +0 -191
- package/dist/auth/identity-attributes-manager.js.map +0 -1
- package/dist/auth/identity-attributes.d.ts +0 -19
- package/dist/auth/identity-attributes.d.ts.map +0 -1
- package/dist/auth/identity-attributes.js +0 -227
- package/dist/auth/identity-attributes.js.map +0 -1
- package/dist/auth/index.d.ts +0 -8
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -8
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/local-ii-probe.d.ts +0 -57
- package/dist/auth/local-ii-probe.d.ts.map +0 -1
- package/dist/auth/local-ii-probe.js +0 -121
- package/dist/auth/local-ii-probe.js.map +0 -1
- package/dist/auth/types.d.ts +0 -222
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -2
- package/dist/auth/types.js.map +0 -1
- package/dist/createActorHooks.d.ts +0 -41
- package/dist/createActorHooks.d.ts.map +0 -1
- package/dist/createActorHooks.js +0 -17
- package/dist/createActorHooks.js.map +0 -1
- package/dist/createInfiniteQuery.d.ts +0 -185
- package/dist/createInfiniteQuery.d.ts.map +0 -1
- package/dist/createInfiniteQuery.js +0 -198
- package/dist/createInfiniteQuery.js.map +0 -1
- package/dist/createMutation.d.ts +0 -33
- package/dist/createMutation.d.ts.map +0 -1
- package/dist/createMutation.js +0 -199
- package/dist/createMutation.js.map +0 -1
- package/dist/createQuery.d.ts +0 -63
- package/dist/createQuery.d.ts.map +0 -1
- package/dist/createQuery.js +0 -204
- package/dist/createQuery.js.map +0 -1
- package/dist/createReactorProvider.d.ts +0 -158
- package/dist/createReactorProvider.d.ts.map +0 -1
- package/dist/createReactorProvider.js +0 -256
- package/dist/createReactorProvider.js.map +0 -1
- package/dist/createSuspenseInfiniteQuery.d.ts +0 -154
- package/dist/createSuspenseInfiniteQuery.d.ts.map +0 -1
- package/dist/createSuspenseInfiniteQuery.js +0 -209
- package/dist/createSuspenseInfiniteQuery.js.map +0 -1
- package/dist/createSuspenseQuery.d.ts +0 -46
- package/dist/createSuspenseQuery.d.ts.map +0 -1
- package/dist/createSuspenseQuery.js +0 -158
- package/dist/createSuspenseQuery.js.map +0 -1
- package/dist/defineDisplayReactor.d.ts +0 -43
- package/dist/defineDisplayReactor.d.ts.map +0 -1
- package/dist/defineDisplayReactor.js +0 -42
- package/dist/defineDisplayReactor.js.map +0 -1
- package/dist/defineReactor.d.ts +0 -99
- package/dist/defineReactor.d.ts.map +0 -1
- package/dist/defineReactor.js +0 -15
- package/dist/defineReactor.js.map +0 -1
- package/dist/defineReactorShared.d.ts +0 -84
- package/dist/defineReactorShared.d.ts.map +0 -1
- package/dist/defineReactorShared.js +0 -139
- package/dist/defineReactorShared.js.map +0 -1
- package/dist/hooks/createAuthHooks.d.ts +0 -50
- package/dist/hooks/createAuthHooks.d.ts.map +0 -1
- package/dist/hooks/createAuthHooks.js +0 -291
- package/dist/hooks/createAuthHooks.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -21
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -24
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useActorInfiniteQuery.d.ts +0 -67
- package/dist/hooks/useActorInfiniteQuery.d.ts.map +0 -1
- package/dist/hooks/useActorInfiniteQuery.js +0 -89
- package/dist/hooks/useActorInfiniteQuery.js.map +0 -1
- package/dist/hooks/useActorMethod.d.ts +0 -148
- package/dist/hooks/useActorMethod.d.ts.map +0 -1
- package/dist/hooks/useActorMethod.js +0 -394
- package/dist/hooks/useActorMethod.js.map +0 -1
- package/dist/hooks/useActorMutation.d.ts +0 -51
- package/dist/hooks/useActorMutation.d.ts.map +0 -1
- package/dist/hooks/useActorMutation.js +0 -70
- package/dist/hooks/useActorMutation.js.map +0 -1
- package/dist/hooks/useActorQuery.d.ts +0 -45
- package/dist/hooks/useActorQuery.d.ts.map +0 -1
- package/dist/hooks/useActorQuery.js +0 -67
- package/dist/hooks/useActorQuery.js.map +0 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +0 -51
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +0 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js +0 -76
- package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +0 -1
- package/dist/hooks/useActorSuspenseQuery.d.ts +0 -32
- package/dist/hooks/useActorSuspenseQuery.d.ts.map +0 -1
- package/dist/hooks/useActorSuspenseQuery.js +0 -58
- package/dist/hooks/useActorSuspenseQuery.js.map +0 -1
- package/dist/ownedAuthentication.d.ts +0 -52
- package/dist/ownedAuthentication.d.ts.map +0 -1
- package/dist/ownedAuthentication.js +0 -49
- package/dist/ownedAuthentication.js.map +0 -1
- package/dist/server.d.ts +0 -21
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -23
- package/dist/server.js.map +0 -1
- package/dist/testing.d.ts +0 -19
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -19
- package/dist/testing.js.map +0 -1
- package/dist/types.d.ts +0 -671
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -207
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -405
- package/dist/utils.js.map +0 -1
- package/dist/validation.d.ts +0 -136
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -144
- package/dist/validation.js.map +0 -1
- package/src/auth/auth-client-compat.ts +0 -273
- package/src/auth/authentication-manager.ts +0 -1682
- package/src/auth/constants.ts +0 -32
- package/src/auth/createIdentityAttributeHooks.ts +0 -169
- package/src/auth/identity-attributes-manager.ts +0 -226
- package/src/auth/identity-attributes.ts +0 -345
- package/src/auth/index.ts +0 -7
- package/src/auth/local-ii-probe.ts +0 -173
- package/src/auth/types.ts +0 -243
- package/src/createActorHooks.ts +0 -208
- package/src/createInfiniteQuery.ts +0 -670
- package/src/createMutation.ts +0 -324
- package/src/createQuery.ts +0 -369
- package/src/createReactorProvider.ts +0 -365
- package/src/createSuspenseInfiniteQuery.ts +0 -651
- package/src/createSuspenseQuery.ts +0 -304
- package/src/defineDisplayReactor.ts +0 -62
- package/src/defineReactor.ts +0 -142
- package/src/defineReactorShared.ts +0 -268
- package/src/hooks/createAuthHooks.ts +0 -371
- package/src/hooks/index.ts +0 -103
- package/src/hooks/useActorInfiniteQuery.ts +0 -278
- package/src/hooks/useActorMethod.ts +0 -710
- package/src/hooks/useActorMutation.ts +0 -205
- package/src/hooks/useActorQuery.ts +0 -157
- package/src/hooks/useActorSuspenseInfiniteQuery.ts +0 -248
- package/src/hooks/useActorSuspenseQuery.ts +0 -147
- package/src/index.ts +0 -31
- package/src/ownedAuthentication.ts +0 -81
- package/src/server.ts +0 -23
- package/src/testing.ts +0 -18
- package/src/types.ts +0 -948
- package/src/utils.ts +0 -505
- package/src/validation.ts +0 -226
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
import type { Identity } from "@icp-sdk/core/agent";
|
|
2
|
-
import type { AuthClientLike, AuthClientSignInOptions, AuthState, AuthenticationClientOptions, AuthenticationSignInOptions } from "./types.js";
|
|
3
|
-
import { ClientManager } from "@ic-reactor/core";
|
|
4
|
-
export interface AuthenticationManagerParameters extends AuthenticationClientOptions {
|
|
5
|
-
clientManager: ClientManager;
|
|
6
|
-
/**
|
|
7
|
-
* Bring your own client instance. When provided, IC Reactor never constructs
|
|
8
|
-
* one and never applies the options below to it.
|
|
9
|
-
*/
|
|
10
|
-
authClient?: AuthClientLike;
|
|
11
|
-
/** Canister ID of a locally deployed Internet Identity. */
|
|
12
|
-
internetIdentityId?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Manages Internet Identity sign-in, session restoration, and authentication
|
|
16
|
-
* state for a {@link ClientManager}.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const authentication = new AuthenticationManager({ clientManager })
|
|
21
|
-
* const identity = await authentication.authenticate()
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class AuthenticationManager {
|
|
25
|
-
private authClient?;
|
|
26
|
-
private authPromise?;
|
|
27
|
-
private authClientWasProvided;
|
|
28
|
-
private authStateRevision;
|
|
29
|
-
private authStateSubscribers;
|
|
30
|
-
private authClientConstructor?;
|
|
31
|
-
private authClientConstructorPromise?;
|
|
32
|
-
private authModuleMissing;
|
|
33
|
-
private authClientFlavor;
|
|
34
|
-
private authClientOptions?;
|
|
35
|
-
private authStateValue;
|
|
36
|
-
/** See {@link sessionChecked}. */
|
|
37
|
-
private sessionCheckedValue;
|
|
38
|
-
private sessionCheckedSubscribers;
|
|
39
|
-
/** Stops following the current client's session record; see `watchClient()`. */
|
|
40
|
-
private unwatchClient?;
|
|
41
|
-
/**
|
|
42
|
-
* Set when the client's session record changed while an operation of this
|
|
43
|
-
* manager's own was running; see `followClient()`.
|
|
44
|
-
*/
|
|
45
|
-
private clientChangedDuringOperation;
|
|
46
|
-
/** Counts `followClient()` passes, so that only the latest one publishes. */
|
|
47
|
-
private followRevision;
|
|
48
|
-
/** Counts `dispose()` calls; see {@link releaseCount}. */
|
|
49
|
-
private releases;
|
|
50
|
-
private readonly identityProvider?;
|
|
51
|
-
/** The provider taken from the `ic_env` cookie, when no caller set one. */
|
|
52
|
-
private readonly envIdentityProvider?;
|
|
53
|
-
private readonly internetIdentityId?;
|
|
54
|
-
/** Whether `internetIdentityId` came from the caller rather than the cookie. */
|
|
55
|
-
private readonly internetIdentityIdIsExplicit;
|
|
56
|
-
/**
|
|
57
|
-
* Which authorize path the locally deployed Internet Identity serves, once
|
|
58
|
-
* probed. `undefined` means not probed yet; `null` means it serves no sign-in
|
|
59
|
-
* UI and login should fail with an explanation rather than open a popup onto
|
|
60
|
-
* a gateway error page.
|
|
61
|
-
*/
|
|
62
|
-
private localAuthorizePath?;
|
|
63
|
-
private readonly defaultClientOptions;
|
|
64
|
-
readonly clientManager: ClientManager;
|
|
65
|
-
/** The current authentication state. */
|
|
66
|
-
get authState(): AuthState;
|
|
67
|
-
constructor({ clientManager, authClient, identityProvider, internetIdentityId, ...clientOptions }: AuthenticationManagerParameters);
|
|
68
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
69
|
-
get client(): AuthClientLike | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* @internal Used by the auth hooks.
|
|
72
|
-
*
|
|
73
|
-
* Whether this manager has checked its client for a session: a restore has
|
|
74
|
-
* settled, whether it found a session, found none or failed, or a sign-in or
|
|
75
|
-
* sign-out has completed. Until then {@link authState} is the signed-out state
|
|
76
|
-
* the manager starts in, which says nothing about the session, so the auth
|
|
77
|
-
* hooks report `isAuthenticating: true` instead.
|
|
78
|
-
*/
|
|
79
|
-
get sessionChecked(): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* @internal Used by the auth hooks.
|
|
82
|
-
*
|
|
83
|
-
* Records that the session has been checked, and tells the auth hooks the
|
|
84
|
-
* first time. A restore that failed counts: waiting on one that will not be
|
|
85
|
-
* retried would leave the hooks reporting `isAuthenticating: true` for good.
|
|
86
|
-
*/
|
|
87
|
-
markSessionChecked(): void;
|
|
88
|
-
/**
|
|
89
|
-
* @internal Used by the auth hooks.
|
|
90
|
-
*
|
|
91
|
-
* How many times {@link dispose} has run. A restore the hooks started
|
|
92
|
-
* compares it with the count it began with, to tell whether the manager was
|
|
93
|
-
* released while it ran.
|
|
94
|
-
*/
|
|
95
|
-
get releaseCount(): number;
|
|
96
|
-
/**
|
|
97
|
-
* @internal Used by the auth hooks.
|
|
98
|
-
*
|
|
99
|
-
* Calls `callback` once, when {@link sessionChecked} turns true. Nothing else
|
|
100
|
-
* announces it when the check that settles it publishes no state, as a
|
|
101
|
-
* restore that failed before it read the client does not.
|
|
102
|
-
*
|
|
103
|
-
* @returns An unsubscribe function.
|
|
104
|
-
*/
|
|
105
|
-
subscribeSessionChecked(callback: () => void): () => void;
|
|
106
|
-
/**
|
|
107
|
-
* Releases the `@icp-sdk/auth` client this manager built.
|
|
108
|
-
*
|
|
109
|
-
* A v10 client hooks the page when it is built: activity listeners on
|
|
110
|
-
* `document`, focus and visibility listeners, a watch on the session record
|
|
111
|
-
* that every tab shares and, once signed in, a refresh timer. Nothing
|
|
112
|
-
* releases them when the manager is dropped, so a manager built per mount,
|
|
113
|
-
* as a server-rendered app builds one in its provider, left one live client
|
|
114
|
-
* behind on each remount. Call this when you discard the manager, from the
|
|
115
|
-
* cleanup of whatever built it.
|
|
116
|
-
*
|
|
117
|
-
* The client is disposed and forgotten, so a later {@link prepareClient},
|
|
118
|
-
* {@link login}, {@link logout} or restore that needs a client builds a new
|
|
119
|
-
* one. That keeps it safe in an effect cleanup under React's StrictMode,
|
|
120
|
-
* which runs the cleanup and then the effect again on the same manager. With
|
|
121
|
-
* `@icp-sdk/auth` v8 there is nothing to release, and the manager only drops
|
|
122
|
-
* its reference. A client passed in as `authClient` belongs to the caller: it
|
|
123
|
-
* is never disposed, and the manager goes on using it, but stops following its
|
|
124
|
-
* session record until its next {@link prepareClient}, {@link login} or
|
|
125
|
-
* {@link authenticate}, so that the caller's client does not keep a
|
|
126
|
-
* discarded manager alive.
|
|
127
|
-
*
|
|
128
|
-
* The auth state and the identity on the agent are left as they are. A
|
|
129
|
-
* restore reading the client when it is released ends without publishing
|
|
130
|
-
* what it read, and a sign-in or sign-out under way ends with what the
|
|
131
|
-
* released client reports. A restore `useAuth()` started stops, and
|
|
132
|
-
* releases any client it built meanwhile, once no `useAuth()` of this
|
|
133
|
-
* manager is mounted; one mounted later restores again.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```tsx
|
|
137
|
-
* const [authentication] = useState(
|
|
138
|
-
* () => new AuthenticationManager({ clientManager })
|
|
139
|
-
* )
|
|
140
|
-
* useEffect(() => () => authentication.dispose(), [authentication])
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
dispose(): void;
|
|
144
|
-
/**
|
|
145
|
-
* Subscribes to auth state changes.
|
|
146
|
-
*
|
|
147
|
-
* Callbacks run in the order they subscribed, after the state has changed. A
|
|
148
|
-
* callback that throws does not stop the others; the first error is rethrown
|
|
149
|
-
* to whatever made the change once they have all run. When a callback itself
|
|
150
|
-
* changes the state, the newer state is the last each callback hears.
|
|
151
|
-
*
|
|
152
|
-
* @param callback - Function called with the new state.
|
|
153
|
-
* @returns An unsubscribe function.
|
|
154
|
-
*/
|
|
155
|
-
subscribeAuthState(callback: (state: AuthState) => void): () => void;
|
|
156
|
-
/**
|
|
157
|
-
* Preloads the auth module and creates an AuthClient ahead of time.
|
|
158
|
-
*
|
|
159
|
-
* Call (and await) this before wiring up a login button: it makes
|
|
160
|
-
* {@link login} and {@link IdentityAttributesManager.request} able to open
|
|
161
|
-
* the identity provider synchronously inside the click handler, which is
|
|
162
|
-
* what browser popup blockers and the ICRC-29 transport require.
|
|
163
|
-
*/
|
|
164
|
-
prepareClient(options?: AuthenticationClientOptions): Promise<AuthClientLike | undefined>;
|
|
165
|
-
/**
|
|
166
|
-
* Probe the local Internet Identity canister once, and remember what it
|
|
167
|
-
* serves.
|
|
168
|
-
*
|
|
169
|
-
* Only for the derived local provider: an explicitly configured
|
|
170
|
-
* `identityProvider` is the caller's business, and mainnet is fixed.
|
|
171
|
-
*/
|
|
172
|
-
private ensureLocalAuthorizePath;
|
|
173
|
-
/**
|
|
174
|
-
* Returns an AuthClient without awaiting, or `undefined` when the auth
|
|
175
|
-
* module has not been loaded yet.
|
|
176
|
-
*
|
|
177
|
-
* Callers that must stay inside a user gesture use this instead of
|
|
178
|
-
* `ensureClient`; awaiting anything before opening the identity
|
|
179
|
-
* provider window loses the gesture.
|
|
180
|
-
*/
|
|
181
|
-
getPreparedClient(options?: AuthenticationClientOptions): AuthClientLike | undefined;
|
|
182
|
-
authenticate: () => Promise<Identity | undefined>;
|
|
183
|
-
private checkSession;
|
|
184
|
-
login: (loginOptions?: AuthenticationSignInOptions) => Promise<void>;
|
|
185
|
-
logout: (options?: {
|
|
186
|
-
returnTo?: string;
|
|
187
|
-
}) => Promise<void>;
|
|
188
|
-
private initializeClient;
|
|
189
|
-
/**
|
|
190
|
-
* Makes `client`, which this manager built for `options`, the current one.
|
|
191
|
-
*
|
|
192
|
-
* The client it replaces was built here too, for other options: a caller's
|
|
193
|
-
* `authClient` is never replaced. It was dropped with nothing released, so a
|
|
194
|
-
* v10 client kept its browser listeners, its state subscription and its
|
|
195
|
-
* session's refresh timer for the life of the page, one more for each switch
|
|
196
|
-
* between option sets, such as a one-click sign-in and a plain one (#729).
|
|
197
|
-
* v10 asks for `dispose()` on a client being discarded, and a new
|
|
198
|
-
* interaction already takes its signer channel from the old client, so this
|
|
199
|
-
* adds no failure of its own. A v8 client has nothing to dispose; see
|
|
200
|
-
* `withSharedIdleCallback()` for the callback it leaves registered.
|
|
201
|
-
*/
|
|
202
|
-
private installClient;
|
|
203
|
-
/**
|
|
204
|
-
* Follows a v10 client's session record, which every tab of the origin
|
|
205
|
-
* shares.
|
|
206
|
-
*
|
|
207
|
-
* The manager learned about the session only through its own calls, while a
|
|
208
|
-
* v10 client follows the other tabs. After a sign-out in another tab, this
|
|
209
|
-
* tab's client dropped the session and its manager went on reporting the
|
|
210
|
-
* user signed in, with the replaced identity on the agent signing calls as
|
|
211
|
-
* the account the user had left. After a sign-in there as another account,
|
|
212
|
-
* the manager kept the old account while the client held the new one. When
|
|
213
|
-
* the old identity's app delegation then lapsed, its mint was refused and
|
|
214
|
-
* the client removed the record every tab reads, signing the new account out
|
|
215
|
-
* of every tab (#754). `subscribe()` fires after the record changes, here or
|
|
216
|
-
* in another tab, and the manager then reads the client again.
|
|
217
|
-
*
|
|
218
|
-
* v8 has no notification and never revokes a session, so a v8 client is not
|
|
219
|
-
* followed.
|
|
220
|
-
*/
|
|
221
|
-
private watchClient;
|
|
222
|
-
private stopWatchingClient;
|
|
223
|
-
/**
|
|
224
|
-
* Reads the session from `client` after its record changed, and publishes
|
|
225
|
-
* it when it differs from what this manager holds, as `syncStateFromClient()`
|
|
226
|
-
* derives it. An error recorded for the session it replaces goes with it.
|
|
227
|
-
*
|
|
228
|
-
* An operation of the manager's own, which sets `isAuthenticating`, writes
|
|
229
|
-
* the record itself and publishes what the client holds when it ends, so a
|
|
230
|
-
* change during one is read again once it has. So is a change whose read
|
|
231
|
-
* something else published over.
|
|
232
|
-
*/
|
|
233
|
-
private followClient;
|
|
234
|
-
/**
|
|
235
|
-
* The identity `client` hands out, and whether it vouches for it (see
|
|
236
|
-
* `vouchesFor()`). Both are read from the same client.
|
|
237
|
-
*/
|
|
238
|
-
private readClientSession;
|
|
239
|
-
/**
|
|
240
|
-
* The session `client` holds, or `undefined` to leave the manager's as it is.
|
|
241
|
-
*
|
|
242
|
-
* v10 refuses to hand out an identity while the record names a sign-in it
|
|
243
|
-
* holds no credential for, as when restoring the account another tab signed
|
|
244
|
-
* in as failed. The session this manager holds is kept then only while the
|
|
245
|
-
* record still names its account. One for any other account must not stay
|
|
246
|
-
* on the agent.
|
|
247
|
-
*/
|
|
248
|
-
private readFollowedSession;
|
|
249
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
250
|
-
signInOrRecoverIdentity(options?: AuthClientSignInOptions): Promise<Identity>;
|
|
251
|
-
private ensurePreparedClient;
|
|
252
|
-
/**
|
|
253
|
-
* Hands the installed client the option shape it actually accepts.
|
|
254
|
-
*
|
|
255
|
-
* `authClientOptions` keeps the untranslated values, and `shouldRecreateClient`
|
|
256
|
-
* compares them with the installed major in mind: two calls that differ only
|
|
257
|
-
* in a key that major drops count as the same options, so the client is not
|
|
258
|
-
* rebuilt for them.
|
|
259
|
-
*/
|
|
260
|
-
private toClientOptions;
|
|
261
|
-
/**
|
|
262
|
-
* Options for the agent a v9+ client mints delegations with, off mainnet.
|
|
263
|
-
*
|
|
264
|
-
* That client makes its own calls to the Internet Identity canister, through
|
|
265
|
-
* an agent built from these options alone. Without a root key it checks every
|
|
266
|
-
* certificate against mainnet's, which a local replica or testnet cannot
|
|
267
|
-
* satisfy, so sign-in would fail at the first mint. Off mainnet it gets the
|
|
268
|
-
* replica this app already talks to and fetches that network's root key, the
|
|
269
|
-
* same trust the app's own agent needs there. When the app passed its own
|
|
270
|
-
* `agentOptions.rootKey`, which its agent keeps, the minting agent gets that
|
|
271
|
-
* key instead and verifies against it too. On mainnet nothing is passed, and
|
|
272
|
-
* the client keeps its defaults.
|
|
273
|
-
*/
|
|
274
|
-
private sessionAgentOptions;
|
|
275
|
-
/**
|
|
276
|
-
* Which canister a v9+ client should pair with `identityProvider`.
|
|
277
|
-
*
|
|
278
|
-
* v9+ names a provider by its authorize URL and the canister that mints its
|
|
279
|
-
* delegations, and nothing about the canister follows from the URL. The
|
|
280
|
-
* mainnet URL goes with mainnet's canister unless the caller named another.
|
|
281
|
-
* A canister read from the `ic_env` cookie belongs to a local deployment, so
|
|
282
|
-
* it never overrides that. Any other URL takes `internetIdentityId`, or the
|
|
283
|
-
* well-known local canister when the URL is one IC Reactor derived for a
|
|
284
|
-
* local deployment. A URL the caller set with no canister stays `unknown`.
|
|
285
|
-
*/
|
|
286
|
-
private identityProviderPairing;
|
|
287
|
-
/**
|
|
288
|
-
* Whether `identityProvider` is a local provider IC Reactor chose, from the
|
|
289
|
-
* `ic_env` cookie or built for the local replica, rather than one a caller
|
|
290
|
-
* configured.
|
|
291
|
-
*/
|
|
292
|
-
private isDerivedLocalProvider;
|
|
293
|
-
/**
|
|
294
|
-
* Only rebuild the client when the effective options actually changed.
|
|
295
|
-
*
|
|
296
|
-
* Recreating on every call would discard the client warmed up by
|
|
297
|
-
* `prepareClient()` and register a duplicate sign-out callback on the
|
|
298
|
-
* shared IdleManager singleton each time.
|
|
299
|
-
*/
|
|
300
|
-
private shouldRecreateClient;
|
|
301
|
-
/**
|
|
302
|
-
* Merges constructor-level defaults with per-call overrides and fills in the
|
|
303
|
-
* network-appropriate identity provider.
|
|
304
|
-
*/
|
|
305
|
-
private resolveClientOptions;
|
|
306
|
-
/** Whether the shared agent currently signs as the anonymous principal. */
|
|
307
|
-
private agentIsAnonymous;
|
|
308
|
-
/**
|
|
309
|
-
* @internal Used by IdentityAttributesManager.
|
|
310
|
-
*
|
|
311
|
-
* Whether the client vouches for `identity`, given what its
|
|
312
|
-
* `isAuthenticated()` answered.
|
|
313
|
-
*
|
|
314
|
-
* A v8 client's answer is not about the identity it holds. It reads the
|
|
315
|
-
* delegation expiry v8 keeps in the `localStorage` every tab shares, while
|
|
316
|
-
* `getIdentity()` returns the identity this client restored or signed in
|
|
317
|
-
* with, and v8 never reads storage again once it has loaded. When the session
|
|
318
|
-
* lapses and the user signs in again in another tab, that tab writes a new
|
|
319
|
-
* expiry, and the answer is yes again for the delegation this tab still
|
|
320
|
-
* holds, which the replica refuses. So a v8 identity whose own delegation
|
|
321
|
-
* has expired is not vouched for, whatever the answer. Nor is the anonymous
|
|
322
|
-
* identity, which a v8 client that loaded signed out, or signed out, goes on
|
|
323
|
-
* handing out once another tab signs in and the answer turns yes. It signs
|
|
324
|
-
* no one in.
|
|
325
|
-
*
|
|
326
|
-
* A v10 client's answer is about the session it holds, and its identity
|
|
327
|
-
* replaces its short-lived delegation as it ages, so the delegation it holds
|
|
328
|
-
* can be past its expiry while the session is live. The answer stands alone.
|
|
329
|
-
*/
|
|
330
|
-
vouchesFor(identity: Identity | null | undefined, isAuthenticated: boolean): boolean;
|
|
331
|
-
/**
|
|
332
|
-
* End a session the client no longer vouches for: put the anonymous
|
|
333
|
-
* identity on the agent -- which also sweeps the previous user's
|
|
334
|
-
* caller-scoped cache entries and refetches the rest anonymously -- and
|
|
335
|
-
* publish the signed-out state.
|
|
336
|
-
*
|
|
337
|
-
* A v8 client is also asked to forget the session when its
|
|
338
|
-
* `isAuthenticated()` answered no, since it keeps handing out the lapsed
|
|
339
|
-
* delegation until `signOut()` runs. That answer reads the expiry kept in
|
|
340
|
-
* the `localStorage` every tab shares, so it is no only once the session
|
|
341
|
-
* stored for every tab is over, and v8's `signOut()` takes no lock and
|
|
342
|
-
* revokes nothing. `signOut` failing changes nothing here: the delegation is
|
|
343
|
-
* already unusable, and the agent must not keep it. When the answer was yes,
|
|
344
|
-
* the delegation this tab holds lapsed under a session another tab has
|
|
345
|
-
* signed in to since, and `signOut()` would delete that session from the
|
|
346
|
-
* storage every tab shares. The client is left alone, and `vouchesFor()`
|
|
347
|
-
* keeps the lapsed delegation it goes on handing out off the agent.
|
|
348
|
-
*
|
|
349
|
-
* A v10 client is left alone, as `commitSignedOut()` leaves it. Its
|
|
350
|
-
* `signOut()` ends the sign-in for every tab of the origin: it takes the
|
|
351
|
-
* sign-in lock from a sign-in another tab has in progress, which then fails,
|
|
352
|
-
* revokes whatever session the shared store holds, and removes the record
|
|
353
|
-
* every tab reads. Another tab may have signed in again since this one last
|
|
354
|
-
* looked, and finding a session over is not the user asking to sign out.
|
|
355
|
-
* The client already stopped vouching for the session on its own.
|
|
356
|
-
*
|
|
357
|
-
* @param isAuthenticated - What the client's `isAuthenticated()` answered.
|
|
358
|
-
*/
|
|
359
|
-
private expireSession;
|
|
360
|
-
private syncStateFromClient;
|
|
361
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
362
|
-
ensureClient(options?: AuthenticationClientOptions): Promise<AuthClientLike | undefined>;
|
|
363
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
364
|
-
commitIdentity(identity: Identity, isAuthenticated: boolean): Promise<void>;
|
|
365
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
366
|
-
setAuthenticating(): void;
|
|
367
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
368
|
-
setAuthenticationError(error: Error): void;
|
|
369
|
-
/** @internal Used by IdentityAttributesManager. */
|
|
370
|
-
settleAuthenticating(): void;
|
|
371
|
-
/**
|
|
372
|
-
* @internal Used by IdentityAttributesManager.
|
|
373
|
-
*
|
|
374
|
-
* Signs this manager out after the client lost its session under it, as when
|
|
375
|
-
* another tab signed out. The client itself is left alone: a v10 sign-out
|
|
376
|
-
* clears the storage every tab shares and takes the sign-in lock, so it would
|
|
377
|
-
* also end a sign-in the other tab has made or started since.
|
|
378
|
-
*/
|
|
379
|
-
commitSignedOut(): void;
|
|
380
|
-
private getDefaultIdentityProvider;
|
|
381
|
-
/**
|
|
382
|
-
* Publishes what a check of the session found, then marks the session
|
|
383
|
-
* checked. In that order, so the auth hooks never take the state before it
|
|
384
|
-
* for the answer.
|
|
385
|
-
*/
|
|
386
|
-
private publishSession;
|
|
387
|
-
/**
|
|
388
|
-
* Records a change, then tells every subscriber about it.
|
|
389
|
-
*
|
|
390
|
-
* Every subscriber is called even when one throws, and the first error is
|
|
391
|
-
* rethrown once they all have been, so the caller still sees it. A throw
|
|
392
|
-
* used to end the loop: an app's subscriber registered at module scope comes
|
|
393
|
-
* before every `useAuth()`, and one that failed on a sign-in left them all
|
|
394
|
-
* showing `isAuthenticating: true` while the agent signed as the user.
|
|
395
|
-
*
|
|
396
|
-
* A subscriber that changes the state again from its callback has told every
|
|
397
|
-
* subscriber about that newer state, so the loop stops rather than deliver
|
|
398
|
-
* this older one after it. The list is copied first, so a subscriber added
|
|
399
|
-
* during the loop is first called for the next change. `ClientManager`
|
|
400
|
-
* notifies its subscribers the same way.
|
|
401
|
-
*/
|
|
402
|
-
private updateState;
|
|
403
|
-
private loadAuthClientConstructor;
|
|
404
|
-
}
|
|
405
|
-
//# sourceMappingURL=authentication-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-manager.d.ts","sourceRoot":"","sources":["../../src/auth/authentication-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,aAAa,EAAS,MAAM,kBAAkB,CAAA;AAyBvD,MAAM,WAAW,+BAAgC,SAAQ,2BAA2B;IAClF,aAAa,EAAE,aAAa,CAAA;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAkBD;;;;;;;;;GASG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAgB;IACnC,OAAO,CAAC,WAAW,CAAC,CAA+B;IACnD,OAAO,CAAC,qBAAqB,CAAQ;IACrC,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,oBAAoB,CAAwC;IACpE,OAAO,CAAC,qBAAqB,CAAC,CAAuB;IACrD,OAAO,CAAC,4BAA4B,CAAC,CAEpC;IACD,OAAO,CAAC,iBAAiB,CAAQ;IACjC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