@stytch/react 19.4.4 → 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 +25 -0
- package/README.md +7 -7
- package/b2b/headless/package.json +6 -0
- package/b2b/ui/package.json +6 -0
- package/dist/{StytchB2BContext-09d376ba.d.ts → StytchB2BContext-9c062712.d.ts} +127 -23
- package/dist/{StytchB2BContext-09d376ba.js → StytchB2BContext-9c062712.js} +85 -42
- package/dist/{StytchB2BContext-a8d57249.d.ts → StytchB2BContext-c5062f9b.d.ts} +127 -23
- package/dist/{StytchB2BContext-a8d57249.js → StytchB2BContext-c5062f9b.js} +95 -52
- 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 +170 -6
- package/dist/b2b/index.esm.d.ts +170 -6
- package/dist/b2b/index.esm.js +85 -8
- 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 +93 -16
- 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 +92 -54
- package/dist/index.esm.d.ts +92 -54
- package/dist/index.esm.js +112 -38
- 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 +126 -52
- 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 +4 -3
- package/dist/invariant-568a7633.d.ts +0 -27
- package/dist/invariant-ae5a5bce.d.ts +0 -27
package/dist/b2b/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var StytchB2BContext = require('../StytchB2BContext-a8d57249.js');
|
|
6
5
|
var React = require('react');
|
|
7
|
-
var
|
|
6
|
+
var StytchB2BContext = require('../StytchB2BContext-c5062f9b.js');
|
|
7
|
+
var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect-65746ef3.js');
|
|
8
|
+
var StytchSSRProxy = require('../StytchSSRProxy-86bc42b3.js');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
11
|
|
|
@@ -44,12 +45,12 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
44
45
|
* />
|
|
45
46
|
*/
|
|
46
47
|
const StytchB2B = ({ styles, callbacks, config, }) => {
|
|
47
|
-
|
|
48
|
+
useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchB2B />', 'StytchB2BProvider'));
|
|
48
49
|
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
49
50
|
const containerEl = React.useRef(null);
|
|
50
|
-
|
|
51
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
51
52
|
if (!StytchB2BContext.isUIClient(stytchClient)) {
|
|
52
|
-
throw Error(
|
|
53
|
+
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
53
54
|
}
|
|
54
55
|
if (!containerEl.current) {
|
|
55
56
|
return;
|
|
@@ -96,13 +97,13 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
|
|
|
96
97
|
* />
|
|
97
98
|
*/
|
|
98
99
|
const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
|
|
99
|
-
|
|
100
|
+
useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<IdentityProvider />'));
|
|
100
101
|
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
101
102
|
const { member } = StytchB2BContext.useStytchMember();
|
|
102
103
|
const containerEl = React.useRef(null);
|
|
103
|
-
|
|
104
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
104
105
|
if (!StytchB2BContext.isUIClient(stytchClient)) {
|
|
105
|
-
throw Error(
|
|
106
|
+
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
106
107
|
}
|
|
107
108
|
if (!containerEl.current) {
|
|
108
109
|
return;
|
|
@@ -121,16 +122,92 @@ const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
|
|
|
121
122
|
return React__default["default"].createElement("div", { ref: containerEl });
|
|
122
123
|
};
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Returns the active Member.
|
|
127
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
128
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
129
|
+
* Check the fromCache property to determine if the member data is from persistent storage.
|
|
130
|
+
* @example
|
|
131
|
+
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
132
|
+
* if (!isInitialized) {
|
|
133
|
+
* return <p>Loading...</p>;
|
|
134
|
+
* }
|
|
135
|
+
* return (<h1>Welcome, {member.name}</h1>);
|
|
136
|
+
*/
|
|
137
|
+
const useStytchMember = StytchB2BContext.useStytchMember;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the active member's Stytch member session.
|
|
140
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
141
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
142
|
+
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
143
|
+
* @example
|
|
144
|
+
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
145
|
+
* useEffect(() => {
|
|
146
|
+
* if (!isInitialized) {
|
|
147
|
+
* return;
|
|
148
|
+
* }
|
|
149
|
+
* if (!session) {
|
|
150
|
+
* router.replace('/login')
|
|
151
|
+
* }
|
|
152
|
+
* }, [session, isInitialized]);
|
|
153
|
+
*/
|
|
154
|
+
const useStytchMemberSession = StytchB2BContext.useStytchMemberSession;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the active Stytch organization.
|
|
157
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
158
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
159
|
+
* Check the fromCache property to determine if the organization data is from persistent storage.
|
|
160
|
+
* @example
|
|
161
|
+
* const {organization, isInitialized, fromCache} = useStytchOrganization();
|
|
162
|
+
* if (!isInitialized) {
|
|
163
|
+
* return <p>Loading...</p>;
|
|
164
|
+
* }
|
|
165
|
+
* return (<p>Welcome to {organization.organization_name}</p>);
|
|
166
|
+
*/
|
|
167
|
+
const useStytchOrganization = StytchB2BContext.useStytchOrganization;
|
|
168
|
+
/**
|
|
169
|
+
* Determines whether the logged-in member is allowed to perform the specified action on the specified resource.
|
|
170
|
+
* Returns `true` if the member can perform the action, `false` otherwise.
|
|
171
|
+
*
|
|
172
|
+
* If the member is not logged in, this method will always return false.
|
|
173
|
+
* If the resource or action provided are not valid for the configured RBAC policy, this method will return false.
|
|
174
|
+
*
|
|
175
|
+
* Remember - authorization checks for sensitive actions should always occur on the backend as well.
|
|
176
|
+
* @example
|
|
177
|
+
* const { isAuthorized } = useStytchIsAuthorized<Permissions>('documents', 'edit');
|
|
178
|
+
* return <button disabled={!isAuthorized}>Edit</button>
|
|
179
|
+
*/
|
|
180
|
+
const useStytchIsAuthorized = StytchB2BContext.useStytchIsAuthorized;
|
|
181
|
+
const withStytchMember = StytchB2BContext.withStytchMember;
|
|
182
|
+
const withStytchMemberSession = StytchB2BContext.withStytchMemberSession;
|
|
183
|
+
const withStytchOrganization = StytchB2BContext.withStytchOrganization;
|
|
184
|
+
/**
|
|
185
|
+
* The Stytch Context Provider.
|
|
186
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
187
|
+
* @example
|
|
188
|
+
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
189
|
+
*
|
|
190
|
+
* ReactDOM.render(
|
|
191
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
192
|
+
* <App />
|
|
193
|
+
* </StytchProvider>,
|
|
194
|
+
* document.getElementById('root'),
|
|
195
|
+
* )
|
|
196
|
+
*/
|
|
197
|
+
const StytchB2BProvider = ({ stytch, children, assumeHydrated = true, }) => {
|
|
198
|
+
return (React__default["default"].createElement(StytchB2BContext.StytchB2BProvider, { stytch: stytch, assumeHydrated: assumeHydrated }, children));
|
|
199
|
+
};
|
|
200
|
+
|
|
125
201
|
exports.useStytchB2BClient = StytchB2BContext.useStytchB2BClient;
|
|
126
|
-
exports.useStytchIsAuthorized = StytchB2BContext.useStytchIsAuthorized;
|
|
127
|
-
exports.useStytchMember = StytchB2BContext.useStytchMember;
|
|
128
|
-
exports.useStytchMemberSession = StytchB2BContext.useStytchMemberSession;
|
|
129
|
-
exports.useStytchOrganization = StytchB2BContext.useStytchOrganization;
|
|
130
202
|
exports.withStytchB2BClient = StytchB2BContext.withStytchB2BClient;
|
|
131
|
-
exports.withStytchMember = StytchB2BContext.withStytchMember;
|
|
132
|
-
exports.withStytchMemberSession = StytchB2BContext.withStytchMemberSession;
|
|
133
|
-
exports.withStytchOrganization = StytchB2BContext.withStytchOrganization;
|
|
134
203
|
exports.withStytchPermissions = StytchB2BContext.withStytchPermissions;
|
|
135
204
|
exports.B2BIdentityProvider = B2BIdentityProvider;
|
|
136
205
|
exports.StytchB2B = StytchB2B;
|
|
206
|
+
exports.StytchB2BProvider = StytchB2BProvider;
|
|
207
|
+
exports.useStytchIsAuthorized = useStytchIsAuthorized;
|
|
208
|
+
exports.useStytchMember = useStytchMember;
|
|
209
|
+
exports.useStytchMemberSession = useStytchMemberSession;
|
|
210
|
+
exports.useStytchOrganization = useStytchOrganization;
|
|
211
|
+
exports.withStytchMember = withStytchMember;
|
|
212
|
+
exports.withStytchMemberSession = withStytchMemberSession;
|
|
213
|
+
exports.withStytchOrganization = withStytchOrganization;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StytchB2BUIClient } from "@stytch/vanilla-js/b2b";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
4
|
+
* The Stytch client is not available serverside.
|
|
5
|
+
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
6
|
+
* @example
|
|
7
|
+
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
8
|
+
*
|
|
9
|
+
* return (
|
|
10
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
11
|
+
* <App />
|
|
12
|
+
* </StytchB2BProvider>
|
|
13
|
+
* )
|
|
14
|
+
* @returns A {@link StytchB2BUIClient}
|
|
15
|
+
*/
|
|
16
|
+
declare const createStytchB2BUIClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(_PUBLIC_TOKEN: string, options?: import("@stytch/core/public").StytchClientOptions | undefined) => StytchB2BUIClient<TProjectConfiguration>;
|
|
17
|
+
export { createStytchB2BUIClient };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StytchB2BUIClient } from "@stytch/vanilla-js/b2b";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
4
|
+
* The Stytch client is not available serverside.
|
|
5
|
+
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
6
|
+
* @example
|
|
7
|
+
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
8
|
+
*
|
|
9
|
+
* return (
|
|
10
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
11
|
+
* <App />
|
|
12
|
+
* </StytchB2BProvider>
|
|
13
|
+
* )
|
|
14
|
+
* @returns A {@link StytchB2BUIClient}
|
|
15
|
+
*/
|
|
16
|
+
declare const createStytchB2BUIClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(_PUBLIC_TOKEN: string, options?: import("@stytch/core/public").StytchClientOptions | undefined) => StytchB2BUIClient<TProjectConfiguration>;
|
|
17
|
+
export { createStytchB2BUIClient };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StytchB2BUIClient } from '@stytch/vanilla-js/b2b';
|
|
2
|
+
import { c as createStytchSSRProxy } from '../StytchSSRProxy-34c789b5.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
6
|
+
* The Stytch client is not available serverside.
|
|
7
|
+
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
8
|
+
* @example
|
|
9
|
+
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
10
|
+
*
|
|
11
|
+
* return (
|
|
12
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
13
|
+
* <App />
|
|
14
|
+
* </StytchB2BProvider>
|
|
15
|
+
* )
|
|
16
|
+
* @returns A {@link StytchB2BUIClient}
|
|
17
|
+
*/
|
|
18
|
+
const createStytchB2BUIClient = (...args) => {
|
|
19
|
+
if (typeof window === 'undefined') {
|
|
20
|
+
return createStytchSSRProxy();
|
|
21
|
+
}
|
|
22
|
+
return new StytchB2BUIClient(...args);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { createStytchB2BUIClient };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var b2b = require('@stytch/vanilla-js/b2b');
|
|
6
|
+
var StytchSSRProxy = require('../StytchSSRProxy-86bc42b3.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
10
|
+
* The Stytch client is not available serverside.
|
|
11
|
+
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
12
|
+
* @example
|
|
13
|
+
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
17
|
+
* <App />
|
|
18
|
+
* </StytchB2BProvider>
|
|
19
|
+
* )
|
|
20
|
+
* @returns A {@link StytchB2BUIClient}
|
|
21
|
+
*/
|
|
22
|
+
const createStytchB2BUIClient = (...args) => {
|
|
23
|
+
if (typeof window === 'undefined') {
|
|
24
|
+
return StytchSSRProxy.createStytchSSRProxy();
|
|
25
|
+
}
|
|
26
|
+
return new b2b.StytchB2BUIClient(...args);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.createStytchB2BUIClient = createStytchB2BUIClient;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const noProviderError: (item: string, provider?: string) => string;
|
|
2
|
+
declare const providerMustBeUniqueError = "You cannot render a <StytchProvider> inside another <StytchProvider>.";
|
|
3
|
+
declare const noHeadlessClientError = "Tried to create a Stytch Login UI element using the Stytch Headless SDK.\nYou must use the UI SDK to use UI elements.\nPlease make sure you are using a Stytch UI client, not a Stytch Headless client.";
|
|
4
|
+
declare const cannotInvokeMethodOnServerError: (path: string) => string;
|
|
5
|
+
export { noProviderError, providerMustBeUniqueError, noHeadlessClientError, cannotInvokeMethodOnServerError };
|
package/dist/index-b14d4efe.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createDeepEqual } from "./createDeepEqual-5555f2e1.js";
|
|
2
|
-
export { mergeWithStableProps } from "./
|
|
2
|
+
export { mergeWithStableProps } from "./useIsomorphicLayoutEffect-1babb81e.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { StytchProjectConfigurationInput, StytchUIClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
|
|
5
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>;
|
|
6
26
|
interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
7
27
|
/**
|
|
8
28
|
* A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
@@ -189,86 +209,104 @@ declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<
|
|
|
189
209
|
* />
|
|
190
210
|
*/
|
|
191
211
|
declare const IdentityProvider: ({ styles, callbacks }: IdentityProviderProps) => React.JSX.Element;
|
|
192
|
-
/**
|
|
193
|
-
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
194
|
-
* Either a StytchUIClient or StytchHeadlessClient.
|
|
195
|
-
*/
|
|
196
|
-
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
197
|
-
type SWRUser = {
|
|
198
|
-
/**
|
|
199
|
-
* Either the active {@link User} object, or null if the user is not logged in.
|
|
200
|
-
*/
|
|
201
|
-
user: User | null;
|
|
202
|
-
/**
|
|
203
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
204
|
-
*/
|
|
205
|
-
fromCache: boolean;
|
|
206
|
-
};
|
|
207
|
-
type SWRSession = {
|
|
208
|
-
/**
|
|
209
|
-
* Either the active {@link Session} object, or null if the user is not logged in.
|
|
210
|
-
*/
|
|
211
|
-
session: Session | null;
|
|
212
|
-
/**
|
|
213
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
214
|
-
*/
|
|
215
|
-
fromCache: boolean;
|
|
216
|
-
};
|
|
217
212
|
/**
|
|
218
213
|
* Returns the active User.
|
|
219
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.
|
|
220
216
|
* Check the fromCache property to determine if the user data is from persistent storage.
|
|
221
217
|
* @example
|
|
222
|
-
* const {user} = useStytchUser();
|
|
218
|
+
* const {user, isInitialized, fromCache} = useStytchUser();
|
|
219
|
+
* if (!isInitialized) {
|
|
220
|
+
* return <p>Loading...</p>;
|
|
221
|
+
* }
|
|
223
222
|
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
224
223
|
*/
|
|
225
|
-
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
|
+
};
|
|
226
237
|
/**
|
|
227
238
|
* Returns the active user's Stytch session.
|
|
228
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.
|
|
229
241
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
230
242
|
* @example
|
|
231
|
-
* const {session} = useStytchSession();
|
|
243
|
+
* const {session, isInitialized, fromCache} = useStytchSession();
|
|
232
244
|
* useEffect(() => {
|
|
245
|
+
* if (!isInitialized) {
|
|
246
|
+
* return;
|
|
247
|
+
* }
|
|
233
248
|
* if (!session) {
|
|
234
249
|
* router.replace('/login')
|
|
235
250
|
* }
|
|
236
|
-
* }, [session]);
|
|
251
|
+
* }, [session, isInitialized]);
|
|
237
252
|
*/
|
|
238
|
-
declare const useStytchSession: () =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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;
|
|
254
269
|
stytchUserIsFromCache: boolean;
|
|
255
270
|
}>) => React.ComponentType<T>;
|
|
256
|
-
declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
|
|
257
|
-
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;
|
|
258
274
|
stytchSessionIsFromCache: boolean;
|
|
259
275
|
}>) => React.ComponentType<T>;
|
|
260
|
-
|
|
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> {
|
|
261
282
|
/**
|
|
262
283
|
* A Stytch client instance, either a {@link StytchUIClient} or {@link StytchHeadlessClient}
|
|
263
284
|
*/
|
|
264
|
-
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;
|
|
265
303
|
children?: ReactNode;
|
|
266
304
|
}
|
|
267
305
|
/**
|
|
268
306
|
* The Stytch Context Provider.
|
|
269
307
|
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
270
308
|
* @example
|
|
271
|
-
* const stytch =
|
|
309
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
272
310
|
*
|
|
273
311
|
* ReactDOM.render(
|
|
274
312
|
* <StytchProvider stytch={stytch}>
|
|
@@ -277,6 +315,6 @@ interface StytchProviderProps<TProjectConfiguration extends StytchProjectConfigu
|
|
|
277
315
|
* document.getElementById('root'),
|
|
278
316
|
* )
|
|
279
317
|
*/
|
|
280
|
-
declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
281
|
-
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
|
|
282
|
-
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,8 +1,28 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { StytchProjectConfigurationInput, StytchUIClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
|
|
5
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>;
|
|
6
26
|
interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
7
27
|
/**
|
|
8
28
|
* A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
@@ -189,86 +209,104 @@ declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<
|
|
|
189
209
|
* />
|
|
190
210
|
*/
|
|
191
211
|
declare const IdentityProvider: ({ styles, callbacks }: IdentityProviderProps) => React.JSX.Element;
|
|
192
|
-
/**
|
|
193
|
-
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
194
|
-
* Either a StytchUIClient or StytchHeadlessClient.
|
|
195
|
-
*/
|
|
196
|
-
type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
|
|
197
|
-
type SWRUser = {
|
|
198
|
-
/**
|
|
199
|
-
* Either the active {@link User} object, or null if the user is not logged in.
|
|
200
|
-
*/
|
|
201
|
-
user: User | null;
|
|
202
|
-
/**
|
|
203
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
204
|
-
*/
|
|
205
|
-
fromCache: boolean;
|
|
206
|
-
};
|
|
207
|
-
type SWRSession = {
|
|
208
|
-
/**
|
|
209
|
-
* Either the active {@link Session} object, or null if the user is not logged in.
|
|
210
|
-
*/
|
|
211
|
-
session: Session | null;
|
|
212
|
-
/**
|
|
213
|
-
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
214
|
-
*/
|
|
215
|
-
fromCache: boolean;
|
|
216
|
-
};
|
|
217
212
|
/**
|
|
218
213
|
* Returns the active User.
|
|
219
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.
|
|
220
216
|
* Check the fromCache property to determine if the user data is from persistent storage.
|
|
221
217
|
* @example
|
|
222
|
-
* const {user} = useStytchUser();
|
|
218
|
+
* const {user, isInitialized, fromCache} = useStytchUser();
|
|
219
|
+
* if (!isInitialized) {
|
|
220
|
+
* return <p>Loading...</p>;
|
|
221
|
+
* }
|
|
223
222
|
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
224
223
|
*/
|
|
225
|
-
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
|
+
};
|
|
226
237
|
/**
|
|
227
238
|
* Returns the active user's Stytch session.
|
|
228
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.
|
|
229
241
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
230
242
|
* @example
|
|
231
|
-
* const {session} = useStytchSession();
|
|
243
|
+
* const {session, isInitialized, fromCache} = useStytchSession();
|
|
232
244
|
* useEffect(() => {
|
|
245
|
+
* if (!isInitialized) {
|
|
246
|
+
* return;
|
|
247
|
+
* }
|
|
233
248
|
* if (!session) {
|
|
234
249
|
* router.replace('/login')
|
|
235
250
|
* }
|
|
236
|
-
* }, [session]);
|
|
251
|
+
* }, [session, isInitialized]);
|
|
237
252
|
*/
|
|
238
|
-
declare const useStytchSession: () =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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;
|
|
254
269
|
stytchUserIsFromCache: boolean;
|
|
255
270
|
}>) => React.ComponentType<T>;
|
|
256
|
-
declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
|
|
257
|
-
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;
|
|
258
274
|
stytchSessionIsFromCache: boolean;
|
|
259
275
|
}>) => React.ComponentType<T>;
|
|
260
|
-
|
|
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> {
|
|
261
282
|
/**
|
|
262
283
|
* A Stytch client instance, either a {@link StytchUIClient} or {@link StytchHeadlessClient}
|
|
263
284
|
*/
|
|
264
|
-
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;
|
|
265
303
|
children?: ReactNode;
|
|
266
304
|
}
|
|
267
305
|
/**
|
|
268
306
|
* The Stytch Context Provider.
|
|
269
307
|
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
270
308
|
* @example
|
|
271
|
-
* const stytch =
|
|
309
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
272
310
|
*
|
|
273
311
|
* ReactDOM.render(
|
|
274
312
|
* <StytchProvider stytch={stytch}>
|
|
@@ -277,6 +315,6 @@ interface StytchProviderProps<TProjectConfiguration extends StytchProjectConfigu
|
|
|
277
315
|
* document.getElementById('root'),
|
|
278
316
|
* )
|
|
279
317
|
*/
|
|
280
|
-
declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
281
|
-
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
|
|
282
|
-
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 };
|