@stytch/react 19.4.3 → 19.5.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/CHANGELOG.md +32 -0
- package/README.md +7 -7
- package/b2b/headless/package.json +6 -0
- package/b2b/ui/package.json +6 -0
- package/dist/StytchB2BContext-9c062712.d.ts +272 -0
- package/dist/{StytchB2BContext-081081ee.js → StytchB2BContext-9c062712.js} +94 -49
- package/dist/StytchB2BContext-c5062f9b.d.ts +272 -0
- package/dist/StytchB2BContext-c5062f9b.js +280 -0
- package/dist/StytchSSRProxy-34c789b5.d.ts +3 -0
- package/dist/StytchSSRProxy-34c789b5.js +48 -0
- package/dist/StytchSSRProxy-86bc42b3.d.ts +3 -0
- package/dist/StytchSSRProxy-86bc42b3.js +54 -0
- package/dist/adminPortal/index.d.ts +1 -1
- package/dist/adminPortal/index.esm.d.ts +1 -1
- package/dist/adminPortal/index.esm.js +5 -4
- package/dist/adminPortal/index.js +5 -4
- package/dist/b2b/index.d.ts +180 -19
- package/dist/b2b/index.esm.d.ts +180 -19
- package/dist/b2b/index.esm.js +91 -18
- package/dist/b2b/index.headless.d.ts +16 -0
- package/dist/b2b/index.headless.esm.d.ts +16 -0
- package/dist/b2b/index.headless.esm.js +24 -0
- package/dist/b2b/index.headless.js +28 -0
- package/dist/b2b/index.js +99 -26
- package/dist/b2b/index.ui.d.ts +17 -0
- package/dist/b2b/index.ui.esm.d.ts +17 -0
- package/dist/b2b/index.ui.esm.js +25 -0
- package/dist/b2b/index.ui.js +29 -0
- package/dist/errors-d9d5fbc8.d.ts +5 -0
- package/dist/index-b14d4efe.d.ts +1 -1
- package/dist/index.d.ts +134 -77
- package/dist/index.esm.d.ts +134 -77
- package/dist/index.esm.js +153 -94
- package/dist/index.headless.d.ts +16 -0
- package/dist/index.headless.esm.d.ts +16 -0
- package/dist/index.headless.esm.js +24 -0
- package/dist/index.headless.js +28 -0
- package/dist/index.js +167 -108
- package/dist/index.ui.d.ts +17 -0
- package/dist/index.ui.esm.d.ts +17 -0
- package/dist/index.ui.esm.js +25 -0
- package/dist/index.ui.js +29 -0
- package/dist/useIsomorphicLayoutEffect-1babb81e.d.ts +24 -0
- package/dist/{invariant-568a7633.js → useIsomorphicLayoutEffect-1babb81e.js} +5 -13
- package/dist/useIsomorphicLayoutEffect-65746ef3.d.ts +24 -0
- package/dist/{invariant-ae5a5bce.js → useIsomorphicLayoutEffect-65746ef3.js} +4 -16
- package/package.json +5 -3
- package/dist/StytchB2BContext-081081ee.d.ts +0 -165
- package/dist/StytchB2BContext-865b6947.d.ts +0 -165
- package/dist/StytchB2BContext-865b6947.js +0 -235
- package/dist/invariant-568a7633.d.ts +0 -27
- package/dist/invariant-ae5a5bce.d.ts +0 -27
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
import { Callbacks, StytchLoginConfig, StyleConfig, StytchProjectConfigurationInput, Session, StytchUIClient, User } from "@stytch/vanilla-js";
|
|
4
|
+
import { StytchProjectConfigurationInput, StytchUIClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
|
|
6
5
|
import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
|
|
6
|
+
import { Session as Session$0 } from "@stytch/vanilla-js/headless";
|
|
7
|
+
import { User as User$0 } from "@stytch/vanilla-js/headless";
|
|
8
|
+
/**
|
|
9
|
+
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
10
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
11
|
+
*/
|
|
12
|
+
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the Stytch client stored in the Stytch context.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const stytch = useStytch();
|
|
18
|
+
* useEffect(() => {
|
|
19
|
+
* stytch.magicLinks.authenticate('...')
|
|
20
|
+
* }, [stytch]);
|
|
21
|
+
*/
|
|
22
|
+
declare const useStytch: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>() => StytchClient<TProjectConfiguration>;
|
|
23
|
+
declare const withStytch: <T extends object, TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(Component: React.ComponentType<T & {
|
|
24
|
+
stytch: StytchClient<TProjectConfiguration>;
|
|
25
|
+
}>) => React.ComponentType<T>;
|
|
7
26
|
interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
8
27
|
/**
|
|
9
28
|
* A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
@@ -70,10 +89,10 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
|
|
|
70
89
|
}
|
|
71
90
|
/**
|
|
72
91
|
* The Stytch Login Screen component.
|
|
73
|
-
* This component can only be used with a
|
|
74
|
-
* passed into the
|
|
92
|
+
* This component can only be used with a Stytch UI Client
|
|
93
|
+
* passed into the StytchProvider.
|
|
75
94
|
*
|
|
76
|
-
* See the {@link https://stytch.com/docs/sdks
|
|
95
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
77
96
|
*
|
|
78
97
|
* @example
|
|
79
98
|
* <StytchLogin
|
|
@@ -96,19 +115,21 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
|
|
|
96
115
|
* onEvent: (event) => console.log(event)
|
|
97
116
|
* }}
|
|
98
117
|
* />
|
|
99
|
-
* @param props {@link StytchProps}
|
|
100
118
|
*/
|
|
101
119
|
declare const StytchLogin: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
|
|
102
120
|
interface StytchResetPasswordProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> extends StytchProps<TProjectConfiguration> {
|
|
121
|
+
/**
|
|
122
|
+
* A Stytch password reset token.
|
|
123
|
+
*/
|
|
103
124
|
passwordResetToken: string;
|
|
104
125
|
}
|
|
105
126
|
type IdentityProviderProps = Omit<StytchProps, "config">;
|
|
106
127
|
/**
|
|
107
128
|
* The Stytch Reset Password component.
|
|
108
|
-
* This component can only be used with a
|
|
109
|
-
* passed into the
|
|
129
|
+
* This component can only be used with a Stytch UI Client
|
|
130
|
+
* passed into the StytchProvider.
|
|
110
131
|
*
|
|
111
|
-
* See the {@link https://stytch.com/docs/sdks
|
|
132
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
112
133
|
*
|
|
113
134
|
* @example
|
|
114
135
|
* <StytchPasswordReset
|
|
@@ -132,23 +153,42 @@ type IdentityProviderProps = Omit<StytchProps, "config">;
|
|
|
132
153
|
* onEvent: (event) => console.log(event)
|
|
133
154
|
* }}
|
|
134
155
|
* />
|
|
135
|
-
*
|
|
136
|
-
* @param config - A {@link StytchLoginConfig} object
|
|
137
|
-
* @param passwordResetToken - A Stytch password reset token
|
|
138
|
-
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
139
|
-
* @param callbacks - An optional {@link Callbacks} object
|
|
140
156
|
*/
|
|
141
157
|
declare const StytchPasswordReset: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks, passwordResetToken }: StytchResetPasswordProps<TProjectConfiguration>) => React.JSX.Element;
|
|
158
|
+
/**
|
|
159
|
+
* The Stytch Passkey Registration component.
|
|
160
|
+
* This component can only be used with a Stytch UI Client
|
|
161
|
+
* passed into the StytchProvider.
|
|
162
|
+
*
|
|
163
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const styles = {
|
|
167
|
+
* container: {
|
|
168
|
+
* backgroundColor: '#e11e1e',
|
|
169
|
+
* },
|
|
170
|
+
* colors: {
|
|
171
|
+
* primary: '#ff00f7',
|
|
172
|
+
* secondary: '#5C727D',
|
|
173
|
+
* },
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* <StytchPasskeyRegistration
|
|
177
|
+
* styles={styles}
|
|
178
|
+
* callbacks={{
|
|
179
|
+
* onEvent: (event) => console.log(event)
|
|
180
|
+
* }}
|
|
181
|
+
* />
|
|
182
|
+
*/
|
|
142
183
|
declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
|
|
143
184
|
/**
|
|
144
185
|
* The Stytch IDP component.
|
|
145
186
|
* Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
|
|
146
187
|
* Requires the user to be logged in.
|
|
147
|
-
* This component can only be used with a
|
|
148
|
-
* passed into the
|
|
149
|
-
*
|
|
150
|
-
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
188
|
+
* This component can only be used with a Stytch UI Client
|
|
189
|
+
* passed into the StytchProvider.
|
|
151
190
|
*
|
|
191
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
152
192
|
*
|
|
153
193
|
* @example
|
|
154
194
|
* const styles = {
|
|
@@ -167,89 +207,106 @@ declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<
|
|
|
167
207
|
* onEvent: (event) => console.log(event)
|
|
168
208
|
* }}
|
|
169
209
|
* />
|
|
170
|
-
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
171
|
-
* @param callbacks - An optional {@link Callbacks} object
|
|
172
210
|
*/
|
|
173
211
|
declare const IdentityProvider: ({ styles, callbacks }: IdentityProviderProps) => React.JSX.Element;
|
|
174
|
-
/**
|
|
175
|
-
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
176
|
-
* Either a StytchUIClient or StytchHeadlessClient.
|
|
177
|
-
*/
|
|
178
|
-
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
179
|
-
type SWRUser = {
|
|
180
|
-
/**
|
|
181
|
-
* Either the active {@link User} object, or null if the user is not logged in.
|
|
182
|
-
*/
|
|
183
|
-
user: User | null;
|
|
184
|
-
/**
|
|
185
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
186
|
-
*/
|
|
187
|
-
fromCache: boolean;
|
|
188
|
-
};
|
|
189
|
-
type SWRSession = {
|
|
190
|
-
/**
|
|
191
|
-
* Either the active {@link Session} object, or null if the user is not logged in.
|
|
192
|
-
*/
|
|
193
|
-
session: Session | null;
|
|
194
|
-
/**
|
|
195
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
196
|
-
*/
|
|
197
|
-
fromCache: boolean;
|
|
198
|
-
};
|
|
199
212
|
/**
|
|
200
213
|
* Returns the active User.
|
|
214
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
215
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
201
216
|
* Check the fromCache property to determine if the user data is from persistent storage.
|
|
202
217
|
* @example
|
|
203
|
-
* const {user} = useStytchUser();
|
|
218
|
+
* const {user, isInitialized, fromCache} = useStytchUser();
|
|
219
|
+
* if (!isInitialized) {
|
|
220
|
+
* return <p>Loading...</p>;
|
|
221
|
+
* }
|
|
204
222
|
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
205
|
-
* @returns A {@link SWRUser}
|
|
206
223
|
*/
|
|
207
|
-
declare const useStytchUser: () =>
|
|
224
|
+
declare const useStytchUser$0: <TAssumeHydrated extends boolean = true>() => TAssumeHydrated extends true ? {
|
|
225
|
+
user: User$0 | null;
|
|
226
|
+
fromCache: boolean;
|
|
227
|
+
isInitialized: true;
|
|
228
|
+
} : {
|
|
229
|
+
user: null;
|
|
230
|
+
fromCache: false;
|
|
231
|
+
isInitialized: false;
|
|
232
|
+
} | {
|
|
233
|
+
user: User$0 | null;
|
|
234
|
+
fromCache: boolean;
|
|
235
|
+
isInitialized: true;
|
|
236
|
+
};
|
|
208
237
|
/**
|
|
209
238
|
* Returns the active user's Stytch session.
|
|
239
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
240
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
241
|
+
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
210
242
|
* @example
|
|
211
|
-
* const {session} = useStytchSession();
|
|
243
|
+
* const {session, isInitialized, fromCache} = useStytchSession();
|
|
212
244
|
* useEffect(() => {
|
|
245
|
+
* if (!isInitialized) {
|
|
246
|
+
* return;
|
|
247
|
+
* }
|
|
213
248
|
* if (!session) {
|
|
214
249
|
* router.replace('/login')
|
|
215
250
|
* }
|
|
216
|
-
* }, [session]);
|
|
217
|
-
* @returns A {@link SWRSession}
|
|
251
|
+
* }, [session, isInitialized]);
|
|
218
252
|
*/
|
|
219
|
-
declare const useStytchSession: () =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
declare const useStytchSession$0: <TAssumeHydrated extends boolean = true>() => TAssumeHydrated extends true ? {
|
|
254
|
+
session: Session$0 | null;
|
|
255
|
+
fromCache: boolean;
|
|
256
|
+
isInitialized: true;
|
|
257
|
+
} : {
|
|
258
|
+
session: null;
|
|
259
|
+
fromCache: false;
|
|
260
|
+
isInitialized: false;
|
|
261
|
+
} | {
|
|
262
|
+
session: Session$0 | null;
|
|
263
|
+
fromCache: boolean;
|
|
264
|
+
isInitialized: true;
|
|
265
|
+
};
|
|
266
|
+
declare const withStytchUser$0: <T extends object, TAssumeHydrated extends boolean = true>(Component: React.ComponentType<T & {
|
|
267
|
+
stytchUser: User$0 | null;
|
|
268
|
+
stytchUserIsInitialized: boolean;
|
|
235
269
|
stytchUserIsFromCache: boolean;
|
|
236
270
|
}>) => React.ComponentType<T>;
|
|
237
|
-
declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
|
|
238
|
-
stytchSession: Session | null;
|
|
271
|
+
declare const withStytchSession$0: <T extends object, TAssumeHydrated extends boolean = true>(Component: React.ComponentType<T & {
|
|
272
|
+
stytchSession: Session$0 | null;
|
|
273
|
+
stytchSessionIsInitialized: boolean;
|
|
239
274
|
stytchSessionIsFromCache: boolean;
|
|
240
275
|
}>) => React.ComponentType<T>;
|
|
241
|
-
|
|
276
|
+
/**
|
|
277
|
+
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
278
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
279
|
+
*/
|
|
280
|
+
type StytchClient$0<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
281
|
+
interface StytchProviderProps$0<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
242
282
|
/**
|
|
243
283
|
* A Stytch client instance, either a {@link StytchUIClient} or {@link StytchHeadlessClient}
|
|
244
284
|
*/
|
|
245
|
-
stytch: StytchClient<TProjectConfiguration>;
|
|
285
|
+
stytch: StytchClient$0<TProjectConfiguration>;
|
|
286
|
+
/**
|
|
287
|
+
* When true, the provider will assume that the component will only be
|
|
288
|
+
* rendered in a browser environment, either in a single-page application or
|
|
289
|
+
* after completing hydration of a server-rendered application. This allows
|
|
290
|
+
* cached values to be retrieved from the browser on the first render, meaning
|
|
291
|
+
* that the `isInitialized` value returned from Stytch hooks will be `true`
|
|
292
|
+
* starting from the first render.
|
|
293
|
+
*
|
|
294
|
+
* When `false`, the provider will defer initialization until after the first
|
|
295
|
+
* render, and `isInitialized` will initially be `false`.
|
|
296
|
+
*
|
|
297
|
+
* If you encounter hydration errors relating to the use of this component,
|
|
298
|
+
* set this to `false`.
|
|
299
|
+
*
|
|
300
|
+
* This value defaults to `true` in `@stytch/react`.
|
|
301
|
+
*/
|
|
302
|
+
assumeHydrated?: boolean;
|
|
246
303
|
children?: ReactNode;
|
|
247
|
-
}
|
|
304
|
+
}
|
|
248
305
|
/**
|
|
249
306
|
* The Stytch Context Provider.
|
|
250
|
-
* Wrap your application with this component in
|
|
307
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
251
308
|
* @example
|
|
252
|
-
* const stytch =
|
|
309
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
253
310
|
*
|
|
254
311
|
* ReactDOM.render(
|
|
255
312
|
* <StytchProvider stytch={stytch}>
|
|
@@ -258,6 +315,6 @@ type StytchProviderProps<TProjectConfiguration extends StytchProjectConfiguratio
|
|
|
258
315
|
* document.getElementById('root'),
|
|
259
316
|
* )
|
|
260
317
|
*/
|
|
261
|
-
declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
262
|
-
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
|
|
263
|
-
export type { StytchProviderProps };
|
|
318
|
+
declare const StytchProvider$0: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children, assumeHydrated }: StytchProviderProps$0<TProjectConfiguration>) => JSX.Element;
|
|
319
|
+
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider$0 as StytchProvider, useStytch, useStytchSession$0 as useStytchSession, useStytchUser$0 as useStytchUser, withStytch, withStytchSession$0 as withStytchSession, withStytchUser$0 as withStytchUser };
|
|
320
|
+
export type { StytchProviderProps$0 as StytchProviderProps, StytchProps, StytchResetPasswordProps, IdentityProviderProps };
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
import { Callbacks, StytchLoginConfig, StyleConfig, StytchProjectConfigurationInput, Session, StytchUIClient, User } from "@stytch/vanilla-js";
|
|
4
|
+
import { StytchProjectConfigurationInput, StytchUIClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
|
|
6
5
|
import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
|
|
6
|
+
import { Session as Session$0 } from "@stytch/vanilla-js/headless";
|
|
7
|
+
import { User as User$0 } from "@stytch/vanilla-js/headless";
|
|
8
|
+
/**
|
|
9
|
+
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
10
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
11
|
+
*/
|
|
12
|
+
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the Stytch client stored in the Stytch context.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const stytch = useStytch();
|
|
18
|
+
* useEffect(() => {
|
|
19
|
+
* stytch.magicLinks.authenticate('...')
|
|
20
|
+
* }, [stytch]);
|
|
21
|
+
*/
|
|
22
|
+
declare const useStytch: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>() => StytchClient<TProjectConfiguration>;
|
|
23
|
+
declare const withStytch: <T extends object, TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(Component: React.ComponentType<T & {
|
|
24
|
+
stytch: StytchClient<TProjectConfiguration>;
|
|
25
|
+
}>) => React.ComponentType<T>;
|
|
7
26
|
interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
8
27
|
/**
|
|
9
28
|
* A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
@@ -70,10 +89,10 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
|
|
|
70
89
|
}
|
|
71
90
|
/**
|
|
72
91
|
* The Stytch Login Screen component.
|
|
73
|
-
* This component can only be used with a
|
|
74
|
-
* passed into the
|
|
92
|
+
* This component can only be used with a Stytch UI Client
|
|
93
|
+
* passed into the StytchProvider.
|
|
75
94
|
*
|
|
76
|
-
* See the {@link https://stytch.com/docs/sdks
|
|
95
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
77
96
|
*
|
|
78
97
|
* @example
|
|
79
98
|
* <StytchLogin
|
|
@@ -96,19 +115,21 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
|
|
|
96
115
|
* onEvent: (event) => console.log(event)
|
|
97
116
|
* }}
|
|
98
117
|
* />
|
|
99
|
-
* @param props {@link StytchProps}
|
|
100
118
|
*/
|
|
101
119
|
declare const StytchLogin: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
|
|
102
120
|
interface StytchResetPasswordProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> extends StytchProps<TProjectConfiguration> {
|
|
121
|
+
/**
|
|
122
|
+
* A Stytch password reset token.
|
|
123
|
+
*/
|
|
103
124
|
passwordResetToken: string;
|
|
104
125
|
}
|
|
105
126
|
type IdentityProviderProps = Omit<StytchProps, "config">;
|
|
106
127
|
/**
|
|
107
128
|
* The Stytch Reset Password component.
|
|
108
|
-
* This component can only be used with a
|
|
109
|
-
* passed into the
|
|
129
|
+
* This component can only be used with a Stytch UI Client
|
|
130
|
+
* passed into the StytchProvider.
|
|
110
131
|
*
|
|
111
|
-
* See the {@link https://stytch.com/docs/sdks
|
|
132
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
112
133
|
*
|
|
113
134
|
* @example
|
|
114
135
|
* <StytchPasswordReset
|
|
@@ -132,23 +153,42 @@ type IdentityProviderProps = Omit<StytchProps, "config">;
|
|
|
132
153
|
* onEvent: (event) => console.log(event)
|
|
133
154
|
* }}
|
|
134
155
|
* />
|
|
135
|
-
*
|
|
136
|
-
* @param config - A {@link StytchLoginConfig} object
|
|
137
|
-
* @param passwordResetToken - A Stytch password reset token
|
|
138
|
-
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
139
|
-
* @param callbacks - An optional {@link Callbacks} object
|
|
140
156
|
*/
|
|
141
157
|
declare const StytchPasswordReset: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks, passwordResetToken }: StytchResetPasswordProps<TProjectConfiguration>) => React.JSX.Element;
|
|
158
|
+
/**
|
|
159
|
+
* The Stytch Passkey Registration component.
|
|
160
|
+
* This component can only be used with a Stytch UI Client
|
|
161
|
+
* passed into the StytchProvider.
|
|
162
|
+
*
|
|
163
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const styles = {
|
|
167
|
+
* container: {
|
|
168
|
+
* backgroundColor: '#e11e1e',
|
|
169
|
+
* },
|
|
170
|
+
* colors: {
|
|
171
|
+
* primary: '#ff00f7',
|
|
172
|
+
* secondary: '#5C727D',
|
|
173
|
+
* },
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* <StytchPasskeyRegistration
|
|
177
|
+
* styles={styles}
|
|
178
|
+
* callbacks={{
|
|
179
|
+
* onEvent: (event) => console.log(event)
|
|
180
|
+
* }}
|
|
181
|
+
* />
|
|
182
|
+
*/
|
|
142
183
|
declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
|
|
143
184
|
/**
|
|
144
185
|
* The Stytch IDP component.
|
|
145
186
|
* Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
|
|
146
187
|
* Requires the user to be logged in.
|
|
147
|
-
* This component can only be used with a
|
|
148
|
-
* passed into the
|
|
149
|
-
*
|
|
150
|
-
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
188
|
+
* This component can only be used with a Stytch UI Client
|
|
189
|
+
* passed into the StytchProvider.
|
|
151
190
|
*
|
|
191
|
+
* See the {@link https://stytch.com/docs/sdks online reference}
|
|
152
192
|
*
|
|
153
193
|
* @example
|
|
154
194
|
* const styles = {
|
|
@@ -167,89 +207,106 @@ declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<
|
|
|
167
207
|
* onEvent: (event) => console.log(event)
|
|
168
208
|
* }}
|
|
169
209
|
* />
|
|
170
|
-
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
171
|
-
* @param callbacks - An optional {@link Callbacks} object
|
|
172
210
|
*/
|
|
173
211
|
declare const IdentityProvider: ({ styles, callbacks }: IdentityProviderProps) => React.JSX.Element;
|
|
174
|
-
/**
|
|
175
|
-
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
176
|
-
* Either a StytchUIClient or StytchHeadlessClient.
|
|
177
|
-
*/
|
|
178
|
-
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
179
|
-
type SWRUser = {
|
|
180
|
-
/**
|
|
181
|
-
* Either the active {@link User} object, or null if the user is not logged in.
|
|
182
|
-
*/
|
|
183
|
-
user: User | null;
|
|
184
|
-
/**
|
|
185
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
186
|
-
*/
|
|
187
|
-
fromCache: boolean;
|
|
188
|
-
};
|
|
189
|
-
type SWRSession = {
|
|
190
|
-
/**
|
|
191
|
-
* Either the active {@link Session} object, or null if the user is not logged in.
|
|
192
|
-
*/
|
|
193
|
-
session: Session | null;
|
|
194
|
-
/**
|
|
195
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
196
|
-
*/
|
|
197
|
-
fromCache: boolean;
|
|
198
|
-
};
|
|
199
212
|
/**
|
|
200
213
|
* Returns the active User.
|
|
214
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
215
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
201
216
|
* Check the fromCache property to determine if the user data is from persistent storage.
|
|
202
217
|
* @example
|
|
203
|
-
* const {user} = useStytchUser();
|
|
218
|
+
* const {user, isInitialized, fromCache} = useStytchUser();
|
|
219
|
+
* if (!isInitialized) {
|
|
220
|
+
* return <p>Loading...</p>;
|
|
221
|
+
* }
|
|
204
222
|
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
205
|
-
* @returns A {@link SWRUser}
|
|
206
223
|
*/
|
|
207
|
-
declare const useStytchUser: () =>
|
|
224
|
+
declare const useStytchUser$0: <TAssumeHydrated extends boolean = true>() => TAssumeHydrated extends true ? {
|
|
225
|
+
user: User$0 | null;
|
|
226
|
+
fromCache: boolean;
|
|
227
|
+
isInitialized: true;
|
|
228
|
+
} : {
|
|
229
|
+
user: null;
|
|
230
|
+
fromCache: false;
|
|
231
|
+
isInitialized: false;
|
|
232
|
+
} | {
|
|
233
|
+
user: User$0 | null;
|
|
234
|
+
fromCache: boolean;
|
|
235
|
+
isInitialized: true;
|
|
236
|
+
};
|
|
208
237
|
/**
|
|
209
238
|
* Returns the active user's Stytch session.
|
|
239
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
240
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
241
|
+
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
210
242
|
* @example
|
|
211
|
-
* const {session} = useStytchSession();
|
|
243
|
+
* const {session, isInitialized, fromCache} = useStytchSession();
|
|
212
244
|
* useEffect(() => {
|
|
245
|
+
* if (!isInitialized) {
|
|
246
|
+
* return;
|
|
247
|
+
* }
|
|
213
248
|
* if (!session) {
|
|
214
249
|
* router.replace('/login')
|
|
215
250
|
* }
|
|
216
|
-
* }, [session]);
|
|
217
|
-
* @returns A {@link SWRSession}
|
|
251
|
+
* }, [session, isInitialized]);
|
|
218
252
|
*/
|
|
219
|
-
declare const useStytchSession: () =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
declare const useStytchSession$0: <TAssumeHydrated extends boolean = true>() => TAssumeHydrated extends true ? {
|
|
254
|
+
session: Session$0 | null;
|
|
255
|
+
fromCache: boolean;
|
|
256
|
+
isInitialized: true;
|
|
257
|
+
} : {
|
|
258
|
+
session: null;
|
|
259
|
+
fromCache: false;
|
|
260
|
+
isInitialized: false;
|
|
261
|
+
} | {
|
|
262
|
+
session: Session$0 | null;
|
|
263
|
+
fromCache: boolean;
|
|
264
|
+
isInitialized: true;
|
|
265
|
+
};
|
|
266
|
+
declare const withStytchUser$0: <T extends object, TAssumeHydrated extends boolean = true>(Component: React.ComponentType<T & {
|
|
267
|
+
stytchUser: User$0 | null;
|
|
268
|
+
stytchUserIsInitialized: boolean;
|
|
235
269
|
stytchUserIsFromCache: boolean;
|
|
236
270
|
}>) => React.ComponentType<T>;
|
|
237
|
-
declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
|
|
238
|
-
stytchSession: Session | null;
|
|
271
|
+
declare const withStytchSession$0: <T extends object, TAssumeHydrated extends boolean = true>(Component: React.ComponentType<T & {
|
|
272
|
+
stytchSession: Session$0 | null;
|
|
273
|
+
stytchSessionIsInitialized: boolean;
|
|
239
274
|
stytchSessionIsFromCache: boolean;
|
|
240
275
|
}>) => React.ComponentType<T>;
|
|
241
|
-
|
|
276
|
+
/**
|
|
277
|
+
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
278
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
279
|
+
*/
|
|
280
|
+
type StytchClient$0<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
281
|
+
interface StytchProviderProps$0<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
242
282
|
/**
|
|
243
283
|
* A Stytch client instance, either a {@link StytchUIClient} or {@link StytchHeadlessClient}
|
|
244
284
|
*/
|
|
245
|
-
stytch: StytchClient<TProjectConfiguration>;
|
|
285
|
+
stytch: StytchClient$0<TProjectConfiguration>;
|
|
286
|
+
/**
|
|
287
|
+
* When true, the provider will assume that the component will only be
|
|
288
|
+
* rendered in a browser environment, either in a single-page application or
|
|
289
|
+
* after completing hydration of a server-rendered application. This allows
|
|
290
|
+
* cached values to be retrieved from the browser on the first render, meaning
|
|
291
|
+
* that the `isInitialized` value returned from Stytch hooks will be `true`
|
|
292
|
+
* starting from the first render.
|
|
293
|
+
*
|
|
294
|
+
* When `false`, the provider will defer initialization until after the first
|
|
295
|
+
* render, and `isInitialized` will initially be `false`.
|
|
296
|
+
*
|
|
297
|
+
* If you encounter hydration errors relating to the use of this component,
|
|
298
|
+
* set this to `false`.
|
|
299
|
+
*
|
|
300
|
+
* This value defaults to `true` in `@stytch/react`.
|
|
301
|
+
*/
|
|
302
|
+
assumeHydrated?: boolean;
|
|
246
303
|
children?: ReactNode;
|
|
247
|
-
}
|
|
304
|
+
}
|
|
248
305
|
/**
|
|
249
306
|
* The Stytch Context Provider.
|
|
250
|
-
* Wrap your application with this component in
|
|
307
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
251
308
|
* @example
|
|
252
|
-
* const stytch =
|
|
309
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
253
310
|
*
|
|
254
311
|
* ReactDOM.render(
|
|
255
312
|
* <StytchProvider stytch={stytch}>
|
|
@@ -258,6 +315,6 @@ type StytchProviderProps<TProjectConfiguration extends StytchProjectConfiguratio
|
|
|
258
315
|
* document.getElementById('root'),
|
|
259
316
|
* )
|
|
260
317
|
*/
|
|
261
|
-
declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
262
|
-
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
|
|
263
|
-
export type { StytchProviderProps };
|
|
318
|
+
declare const StytchProvider$0: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children, assumeHydrated }: StytchProviderProps$0<TProjectConfiguration>) => JSX.Element;
|
|
319
|
+
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider$0 as StytchProvider, useStytch, useStytchSession$0 as useStytchSession, useStytchUser$0 as useStytchUser, withStytch, withStytchSession$0 as withStytchSession, withStytchUser$0 as withStytchUser };
|
|
320
|
+
export type { StytchProviderProps$0 as StytchProviderProps, StytchProps, StytchResetPasswordProps, IdentityProviderProps };
|