@stytch/nextjs 21.4.0 → 21.4.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/CHANGELOG.md +12 -0
- package/dist/{StytchB2BContext-8246a922.js → StytchB2BContext-47d523b4.js} +15 -15
- package/dist/{StytchB2BContext-0ff0e987.js → StytchB2BContext-f172fdfe.js} +1 -1
- package/dist/adminPortal/index.esm.js +4 -4
- package/dist/adminPortal/index.js +4 -4
- package/dist/b2b/index.d.ts +2 -2
- package/dist/b2b/index.esm.d.ts +2 -2
- package/dist/b2b/index.esm.js +6 -6
- package/dist/b2b/index.js +6 -6
- package/dist/index-b14d4efe.d.ts +1 -1
- package/dist/index.esm.js +2 -5
- package/dist/index.js +17 -20
- package/dist/{async-86a7f0d6.d.ts → useIsomorphicLayoutEffect-41b6e419.d.ts} +9 -3
- package/dist/{async-86a7f0d6.js → useIsomorphicLayoutEffect-41b6e419.js} +4 -0
- package/dist/{async-b1e10055.d.ts → useIsomorphicLayoutEffect-8da8c061.d.ts} +9 -3
- package/dist/{async-b1e10055.js → useIsomorphicLayoutEffect-8da8c061.js} +5 -2
- package/package.json +11 -4
- /package/dist/{StytchB2BContext-0ff0e987.d.ts → StytchB2BContext-47d523b4.d.ts} +0 -0
- /package/dist/{StytchB2BContext-8246a922.d.ts → StytchB2BContext-f172fdfe.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @stytch/nextjs
|
|
2
2
|
|
|
3
|
+
## 21.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7d804d9: feat: Add support for accessTokenExchange to B2B Sessions Client
|
|
8
|
+
|
|
9
|
+
## 21.4.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 9997775: Avoid warnings about useLayoutEffect with server rendering
|
|
14
|
+
|
|
3
15
|
## 21.4.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var useIsomorphicLayoutEffect = require('./useIsomorphicLayoutEffect-41b6e419.js');
|
|
4
5
|
var StytchSSRProxy = require('./StytchSSRProxy-63bc6323.js');
|
|
5
|
-
var async = require('./async-86a7f0d6.js');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -45,7 +45,7 @@ const isUIClient = (client) => {
|
|
|
45
45
|
* return (<h1>Welcome, {member.name}</h1>);
|
|
46
46
|
*/
|
|
47
47
|
const useStytchMember = () => {
|
|
48
|
-
|
|
48
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchMember', 'StytchB2BProvider'));
|
|
49
49
|
return React.useContext(StytchMemberContext);
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
@@ -66,7 +66,7 @@ const useStytchMember = () => {
|
|
|
66
66
|
* }, [session, isInitialized]);
|
|
67
67
|
*/
|
|
68
68
|
const useStytchMemberSession = () => {
|
|
69
|
-
|
|
69
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchMemberSession', 'StytchB2BProvider'));
|
|
70
70
|
return React.useContext(StytchMemberSessionContext);
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
@@ -83,7 +83,7 @@ const useStytchMemberSession = () => {
|
|
|
83
83
|
* return (<p>Welcome to {organization.organization_name}</p>);
|
|
84
84
|
*/
|
|
85
85
|
const useStytchOrganization = () => {
|
|
86
|
-
|
|
86
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchOrganization', 'StytchB2BProvider'));
|
|
87
87
|
return React.useContext(StytchOrganizationContext);
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
@@ -99,10 +99,10 @@ const useStytchOrganization = () => {
|
|
|
99
99
|
* return <button disabled={!isAuthorized}>Edit</button>
|
|
100
100
|
*/
|
|
101
101
|
const useStytchIsAuthorized = (resourceId, action) => {
|
|
102
|
-
|
|
102
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchIsAuthorized', 'StytchB2BProvider'));
|
|
103
103
|
const client = useStytchB2BClient();
|
|
104
104
|
const { session } = useStytchMemberSession();
|
|
105
|
-
const [isAuthorized, setIsAuthorized] =
|
|
105
|
+
const [isAuthorized, setIsAuthorized] = useIsomorphicLayoutEffect.useAsyncState({
|
|
106
106
|
isInitialized: false,
|
|
107
107
|
fromCache: false,
|
|
108
108
|
isAuthorized: false,
|
|
@@ -138,12 +138,12 @@ const useStytchIsAuthorized = (resourceId, action) => {
|
|
|
138
138
|
*/
|
|
139
139
|
const useStytchB2BClient = () => {
|
|
140
140
|
const ctx = React.useContext(StytchContext);
|
|
141
|
-
|
|
141
|
+
useIsomorphicLayoutEffect.invariant(ctx.isMounted, StytchSSRProxy.noProviderError('useStytchB2BClient', 'StytchB2BProvider'));
|
|
142
142
|
return ctx.client;
|
|
143
143
|
};
|
|
144
144
|
const withStytchB2BClient = (Component) => {
|
|
145
145
|
const WithStytch = (props) => {
|
|
146
|
-
|
|
146
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchB2BClient', 'StytchB2BProvider'));
|
|
147
147
|
return React__default["default"].createElement(Component, Object.assign({}, props, { stytch: useStytchB2BClient() }));
|
|
148
148
|
};
|
|
149
149
|
WithStytch.displayName = `withStytch(${Component.displayName || Component.name || 'Component'})`;
|
|
@@ -151,7 +151,7 @@ const withStytchB2BClient = (Component) => {
|
|
|
151
151
|
};
|
|
152
152
|
const withStytchMember = (Component) => {
|
|
153
153
|
const WithStytchUser = (props) => {
|
|
154
|
-
|
|
154
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchMember', 'StytchB2BProvider'));
|
|
155
155
|
const { member, isInitialized, fromCache } = useStytchMember();
|
|
156
156
|
return (React__default["default"].createElement(Component, Object.assign({}, props, { stytchMember: member, stytchMemberIsInitialized: isInitialized, stytchMemberIsFromCache: fromCache })));
|
|
157
157
|
};
|
|
@@ -160,7 +160,7 @@ const withStytchMember = (Component) => {
|
|
|
160
160
|
};
|
|
161
161
|
const withStytchMemberSession = (Component) => {
|
|
162
162
|
const WithStytchSession = (props) => {
|
|
163
|
-
|
|
163
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchMemberSession', 'StytchB2BProvider'));
|
|
164
164
|
const { session, isInitialized, fromCache } = useStytchMemberSession();
|
|
165
165
|
return (React__default["default"].createElement(Component, Object.assign({}, props, { stytchMemberSession: session, stytchMemberSessionIsInitialized: isInitialized, stytchMemberSessionIsFromCache: fromCache })));
|
|
166
166
|
};
|
|
@@ -169,7 +169,7 @@ const withStytchMemberSession = (Component) => {
|
|
|
169
169
|
};
|
|
170
170
|
const withStytchOrganization = (Component) => {
|
|
171
171
|
const WithStytchOrganization = (props) => {
|
|
172
|
-
|
|
172
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchOrganization', 'StytchB2BProvider'));
|
|
173
173
|
const { organization, isInitialized, fromCache } = useStytchOrganization();
|
|
174
174
|
return (React__default["default"].createElement(Component, Object.assign({}, props, { stytchOrganization: organization, stytchOrganizationIsInitialized: isInitialized, stytchOrganizationIsFromCache: fromCache })));
|
|
175
175
|
};
|
|
@@ -199,10 +199,10 @@ const withStytchOrganization = (Component) => {
|
|
|
199
199
|
*/
|
|
200
200
|
const withStytchPermissions = (Component) => {
|
|
201
201
|
const WithStytchPermissions = (props) => {
|
|
202
|
-
|
|
202
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useRBACPermissions', 'StytchB2BProvider'));
|
|
203
203
|
const client = useStytchB2BClient();
|
|
204
204
|
const { session } = useStytchMemberSession();
|
|
205
|
-
const [permissions, setPermissions] =
|
|
205
|
+
const [permissions, setPermissions] = useIsomorphicLayoutEffect.useAsyncState({ loaded: false, value: null });
|
|
206
206
|
React.useEffect(() => {
|
|
207
207
|
client.rbac
|
|
208
208
|
.allPermissions()
|
|
@@ -230,7 +230,7 @@ const withStytchPermissions = (Component) => {
|
|
|
230
230
|
*/
|
|
231
231
|
const StytchB2BProvider = ({ stytch, children, }) => {
|
|
232
232
|
const ctx = React.useMemo(() => ({ client: stytch, isMounted: true }), [stytch]);
|
|
233
|
-
const [{ member, session, organization }, setClientState] =
|
|
233
|
+
const [{ member, session, organization }, setClientState] = useIsomorphicLayoutEffect.useAsyncState({
|
|
234
234
|
member: initialMember,
|
|
235
235
|
session: initialMemberSession,
|
|
236
236
|
organization: initialOrganization,
|
|
@@ -251,7 +251,7 @@ const StytchB2BProvider = ({ stytch, children, }) => {
|
|
|
251
251
|
session: Object.assign(Object.assign({}, stytch.session.getInfo()), { isInitialized: true }),
|
|
252
252
|
organization: Object.assign(Object.assign({}, stytch.organization.getInfo()), { isInitialized: true }),
|
|
253
253
|
};
|
|
254
|
-
return
|
|
254
|
+
return useIsomorphicLayoutEffect.mergeWithStableProps(oldState, newState);
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
}, [setClientState, stytch]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useMemo } from 'react';
|
|
2
|
+
import { i as invariant, u as useAsyncState, m as mergeWithStableProps } from './useIsomorphicLayoutEffect-8da8c061.js';
|
|
2
3
|
import { i as isStytchSSRProxy, n as noProviderError } from './StytchSSRProxy-14916009.js';
|
|
3
|
-
import { i as invariant, u as useAsyncState, m as mergeWithStableProps } from './async-b1e10055.js';
|
|
4
4
|
|
|
5
5
|
const initialMember = {
|
|
6
6
|
member: null,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { mountAdminPortalSSO, mountAdminPortalOrgSettings, mountAdminPortalMemberManagement, mountAdminPortalSCIM } from '@stytch/vanilla-js/b2b/adminPortal';
|
|
2
2
|
export { AdminPortalB2BProducts } from '@stytch/vanilla-js/b2b/adminPortal';
|
|
3
|
-
import React, { useRef
|
|
4
|
-
import { u as useIsMounted__INTERNAL, a as useStytchB2BClient } from '../StytchB2BContext-
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { u as useIsMounted__INTERNAL, a as useStytchB2BClient } from '../StytchB2BContext-f172fdfe.js';
|
|
5
5
|
import { n as noProviderError } from '../StytchSSRProxy-14916009.js';
|
|
6
|
-
import { i as invariant } from '../
|
|
6
|
+
import { i as invariant, a as useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect-8da8c061.js';
|
|
7
7
|
|
|
8
8
|
const makeAdminPortalComponent = (mountFn, componentName) => {
|
|
9
9
|
const Component = (props) => {
|
|
10
10
|
invariant(useIsMounted__INTERNAL(), noProviderError(`<${componentName} />`, 'StytchB2BProvider'));
|
|
11
11
|
const stytchClient = useStytchB2BClient();
|
|
12
12
|
const containerEl = useRef(null);
|
|
13
|
-
|
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
|
14
14
|
if (!containerEl.current) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var adminPortal = require('@stytch/vanilla-js/b2b/adminPortal');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var StytchB2BContext = require('../StytchB2BContext-
|
|
7
|
+
var StytchB2BContext = require('../StytchB2BContext-47d523b4.js');
|
|
8
8
|
var StytchSSRProxy = require('../StytchSSRProxy-63bc6323.js');
|
|
9
|
-
var
|
|
9
|
+
var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect-41b6e419.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
@@ -14,10 +14,10 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
14
14
|
|
|
15
15
|
const makeAdminPortalComponent = (mountFn, componentName) => {
|
|
16
16
|
const Component = (props) => {
|
|
17
|
-
|
|
17
|
+
useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError(`<${componentName} />`, 'StytchB2BProvider'));
|
|
18
18
|
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
19
19
|
const containerEl = React.useRef(null);
|
|
20
|
-
|
|
20
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
21
21
|
if (!containerEl.current) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
package/dist/b2b/index.d.ts
CHANGED
|
@@ -145,6 +145,6 @@ declare const StytchB2B: <TProjectConfiguration extends Partial<import("@stytch/
|
|
|
145
145
|
* @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
|
|
146
146
|
*/
|
|
147
147
|
declare const B2BIdentityProvider: ({ styles, callbacks, getIDPConsentManifest }: B2BIdentityProviderProps) => React.JSX.Element;
|
|
148
|
-
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-
|
|
148
|
+
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-47d523b4.js";
|
|
149
149
|
export { StytchB2B, B2BIdentityProvider };
|
|
150
|
-
export type { StytchB2BProviderProps } from "../StytchB2BContext-
|
|
150
|
+
export type { StytchB2BProviderProps } from "../StytchB2BContext-47d523b4.js";
|
package/dist/b2b/index.esm.d.ts
CHANGED
|
@@ -145,6 +145,6 @@ declare const StytchB2B: <TProjectConfiguration extends Partial<import("@stytch/
|
|
|
145
145
|
* @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
|
|
146
146
|
*/
|
|
147
147
|
declare const B2BIdentityProvider: ({ styles, callbacks, getIDPConsentManifest }: B2BIdentityProviderProps) => React.JSX.Element;
|
|
148
|
-
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-
|
|
148
|
+
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-f172fdfe.js";
|
|
149
149
|
export { StytchB2B, B2BIdentityProvider };
|
|
150
|
-
export type { StytchB2BProviderProps } from "../StytchB2BContext-
|
|
150
|
+
export type { StytchB2BProviderProps } from "../StytchB2BContext-f172fdfe.js";
|
package/dist/b2b/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { u as useIsMounted__INTERNAL, a as useStytchB2BClient, i as isUIClient, b as useStytchMember } from '../StytchB2BContext-
|
|
2
|
-
export { S as StytchB2BProvider, a as useStytchB2BClient, d as useStytchIsAuthorized, b as useStytchMember, c as useStytchMemberSession, e as useStytchOrganization, w as withStytchB2BClient, g as withStytchMember, f as withStytchMemberSession, h as withStytchOrganization, j as withStytchPermissions } from '../StytchB2BContext-
|
|
3
|
-
import React, { useRef
|
|
4
|
-
import { i as invariant } from '../
|
|
1
|
+
import { u as useIsMounted__INTERNAL, a as useStytchB2BClient, i as isUIClient, b as useStytchMember } from '../StytchB2BContext-f172fdfe.js';
|
|
2
|
+
export { S as StytchB2BProvider, a as useStytchB2BClient, d as useStytchIsAuthorized, b as useStytchMember, c as useStytchMemberSession, e as useStytchOrganization, w as withStytchB2BClient, g as withStytchMember, f as withStytchMemberSession, h as withStytchOrganization, j as withStytchPermissions } from '../StytchB2BContext-f172fdfe.js';
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { i as invariant, a as useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect-8da8c061.js';
|
|
5
5
|
import { a as noHeadlessClientError, n as noProviderError } from '../StytchSSRProxy-14916009.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -42,7 +42,7 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
|
|
|
42
42
|
invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />', 'StytchB2BProvider'));
|
|
43
43
|
const stytchClient = useStytchB2BClient();
|
|
44
44
|
const containerEl = useRef(null);
|
|
45
|
-
|
|
45
|
+
useIsomorphicLayoutEffect(() => {
|
|
46
46
|
if (!isUIClient(stytchClient)) {
|
|
47
47
|
throw Error(noHeadlessClientError);
|
|
48
48
|
}
|
|
@@ -99,7 +99,7 @@ const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
|
|
|
99
99
|
const stytchClient = useStytchB2BClient();
|
|
100
100
|
const containerEl = useRef(null);
|
|
101
101
|
const { member } = useStytchMember();
|
|
102
|
-
|
|
102
|
+
useIsomorphicLayoutEffect(() => {
|
|
103
103
|
if (!isUIClient(stytchClient)) {
|
|
104
104
|
throw Error(noHeadlessClientError);
|
|
105
105
|
}
|
package/dist/b2b/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var StytchB2BContext = require('../StytchB2BContext-
|
|
5
|
+
var StytchB2BContext = require('../StytchB2BContext-47d523b4.js');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect-41b6e419.js');
|
|
8
8
|
var StytchSSRProxy = require('../StytchSSRProxy-63bc6323.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -46,10 +46,10 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
46
46
|
* @param props {@link StytchB2BProps}
|
|
47
47
|
*/
|
|
48
48
|
const StytchB2B = ({ styles, callbacks, config, }) => {
|
|
49
|
-
|
|
49
|
+
useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchB2B />', 'StytchB2BProvider'));
|
|
50
50
|
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
51
51
|
const containerEl = React.useRef(null);
|
|
52
|
-
|
|
52
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
53
53
|
if (!StytchB2BContext.isUIClient(stytchClient)) {
|
|
54
54
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
55
55
|
}
|
|
@@ -102,11 +102,11 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
|
|
|
102
102
|
* @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
|
|
103
103
|
*/
|
|
104
104
|
const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
|
|
105
|
-
|
|
105
|
+
useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<IdentityProvider />'));
|
|
106
106
|
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
107
107
|
const containerEl = React.useRef(null);
|
|
108
108
|
const { member } = StytchB2BContext.useStytchMember();
|
|
109
|
-
|
|
109
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
110
110
|
if (!StytchB2BContext.isUIClient(stytchClient)) {
|
|
111
111
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
112
112
|
}
|
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-8da8c061.js";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { createContext, useContext, useMemo, useEffect,
|
|
1
|
+
import React, { createContext, useContext, useMemo, useEffect, useRef } from 'react';
|
|
2
|
+
import { i as invariant, u as useAsyncState, m as mergeWithStableProps, a as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-8da8c061.js';
|
|
2
3
|
import { i as isStytchSSRProxy, n as noProviderError, a as noHeadlessClientError } from './StytchSSRProxy-14916009.js';
|
|
3
|
-
import { i as invariant, u as useAsyncState, m as mergeWithStableProps } from './async-b1e10055.js';
|
|
4
4
|
|
|
5
5
|
const initialUser = {
|
|
6
6
|
user: null,
|
|
@@ -138,9 +138,6 @@ const StytchProvider = ({ stytch, children, }) => {
|
|
|
138
138
|
React.createElement(StytchSessionContext.Provider, { value: session }, children))));
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
// cc https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
|
|
142
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
143
|
-
|
|
144
141
|
/**
|
|
145
142
|
* The Stytch Login Screen component.
|
|
146
143
|
* This component can only be used with the Stytch UI Client - use {@link createStytchUIClient}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
+
var useIsomorphicLayoutEffect = require('./useIsomorphicLayoutEffect-41b6e419.js');
|
|
6
7
|
var StytchSSRProxy = require('./StytchSSRProxy-63bc6323.js');
|
|
7
|
-
var async = require('./async-86a7f0d6.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
@@ -41,7 +41,7 @@ const isUIClient = (client) => {
|
|
|
41
41
|
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
42
42
|
*/
|
|
43
43
|
const useStytchUser = () => {
|
|
44
|
-
|
|
44
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchUser'));
|
|
45
45
|
return React.useContext(StytchUserContext);
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
@@ -62,7 +62,7 @@ const useStytchUser = () => {
|
|
|
62
62
|
* }, [session, isInitialized]);
|
|
63
63
|
*/
|
|
64
64
|
const useStytchSession = () => {
|
|
65
|
-
|
|
65
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('useStytchSession'));
|
|
66
66
|
return React.useContext(StytchSessionContext);
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
@@ -76,12 +76,12 @@ const useStytchSession = () => {
|
|
|
76
76
|
*/
|
|
77
77
|
const useStytch = () => {
|
|
78
78
|
const ctx = React.useContext(StytchContext);
|
|
79
|
-
|
|
79
|
+
useIsomorphicLayoutEffect.invariant(ctx.isMounted, StytchSSRProxy.noProviderError('useStytch'));
|
|
80
80
|
return ctx.client;
|
|
81
81
|
};
|
|
82
82
|
const withStytch = (Component) => {
|
|
83
83
|
const WithStytch = (props) => {
|
|
84
|
-
|
|
84
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytch'));
|
|
85
85
|
return React__default["default"].createElement(Component, Object.assign({}, props, { stytch: useStytch() }));
|
|
86
86
|
};
|
|
87
87
|
WithStytch.displayName = `withStytch(${Component.displayName || Component.name || 'Component'})`;
|
|
@@ -89,7 +89,7 @@ const withStytch = (Component) => {
|
|
|
89
89
|
};
|
|
90
90
|
const withStytchUser = (Component) => {
|
|
91
91
|
const WithStytchUser = (props) => {
|
|
92
|
-
|
|
92
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchUser'));
|
|
93
93
|
const { user, isInitialized, fromCache } = useStytchUser();
|
|
94
94
|
return (React__default["default"].createElement(Component, Object.assign({}, props, { stytchUser: user, stytchUserIsInitialized: isInitialized, stytchUserIsFromCache: fromCache })));
|
|
95
95
|
};
|
|
@@ -98,7 +98,7 @@ const withStytchUser = (Component) => {
|
|
|
98
98
|
};
|
|
99
99
|
const withStytchSession = (Component) => {
|
|
100
100
|
const WithStytchSession = (props) => {
|
|
101
|
-
|
|
101
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('withStytchSession'));
|
|
102
102
|
const { session, isInitialized, fromCache } = useStytchSession();
|
|
103
103
|
return (React__default["default"].createElement(Component, Object.assign({}, props, { stytchSession: session, stytchSessionIsInitialized: isInitialized, stytchSessionIsFromCache: fromCache })));
|
|
104
104
|
};
|
|
@@ -119,7 +119,7 @@ const withStytchSession = (Component) => {
|
|
|
119
119
|
*/
|
|
120
120
|
const StytchProvider = ({ stytch, children, }) => {
|
|
121
121
|
const ctx = React.useMemo(() => ({ client: stytch, isMounted: true }), [stytch]);
|
|
122
|
-
const [{ user, session }, setClientState] =
|
|
122
|
+
const [{ user, session }, setClientState] = useIsomorphicLayoutEffect.useAsyncState({
|
|
123
123
|
session: initialSession,
|
|
124
124
|
user: initialUser,
|
|
125
125
|
});
|
|
@@ -137,7 +137,7 @@ const StytchProvider = ({ stytch, children, }) => {
|
|
|
137
137
|
session: Object.assign(Object.assign({}, stytch.session.getInfo()), { isInitialized: true }),
|
|
138
138
|
user: Object.assign(Object.assign({}, stytch.user.getInfo()), { isInitialized: true }),
|
|
139
139
|
};
|
|
140
|
-
return
|
|
140
|
+
return useIsomorphicLayoutEffect.mergeWithStableProps(oldState, newState);
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
}, [setClientState, stytch]);
|
|
@@ -146,9 +146,6 @@ const StytchProvider = ({ stytch, children, }) => {
|
|
|
146
146
|
React__default["default"].createElement(StytchSessionContext.Provider, { value: session }, children))));
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
// cc https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
|
|
150
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
151
|
-
|
|
152
149
|
/**
|
|
153
150
|
* The Stytch Login Screen component.
|
|
154
151
|
* This component can only be used with the Stytch UI Client - use {@link createStytchUIClient}
|
|
@@ -183,10 +180,10 @@ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayou
|
|
|
183
180
|
* @param callbacks - An optional {@link Callbacks} object
|
|
184
181
|
*/
|
|
185
182
|
const StytchLogin = ({ config, styles, callbacks, }) => {
|
|
186
|
-
|
|
183
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchLogin />'));
|
|
187
184
|
const stytchClient = useStytch();
|
|
188
185
|
const containerEl = React.useRef(null);
|
|
189
|
-
useIsomorphicLayoutEffect(() => {
|
|
186
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
190
187
|
if (!isUIClient(stytchClient)) {
|
|
191
188
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
192
189
|
}
|
|
@@ -242,10 +239,10 @@ const StytchLogin = ({ config, styles, callbacks, }) => {
|
|
|
242
239
|
* @param callbacks - An optional {@link Callbacks} object
|
|
243
240
|
*/
|
|
244
241
|
const StytchPasswordReset = ({ config, styles, callbacks, passwordResetToken, }) => {
|
|
245
|
-
|
|
242
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchResetPassword />'));
|
|
246
243
|
const stytchClient = useStytch();
|
|
247
244
|
const containerEl = React.useRef(null);
|
|
248
|
-
useIsomorphicLayoutEffect(() => {
|
|
245
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
249
246
|
if (!isUIClient(stytchClient)) {
|
|
250
247
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
251
248
|
}
|
|
@@ -298,11 +295,11 @@ const StytchPasswordReset = ({ config, styles, callbacks, passwordResetToken, })
|
|
|
298
295
|
* @param callbacks - An optional {@link Callbacks} object
|
|
299
296
|
*/
|
|
300
297
|
const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
|
|
301
|
-
|
|
298
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchPasskeyRegistration />'));
|
|
302
299
|
const stytchClient = useStytch();
|
|
303
300
|
const containerEl = React.useRef(null);
|
|
304
301
|
const user = useStytchUser();
|
|
305
|
-
useIsomorphicLayoutEffect(() => {
|
|
302
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
306
303
|
if (!isUIClient(stytchClient)) {
|
|
307
304
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
308
305
|
}
|
|
@@ -354,11 +351,11 @@ const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
|
|
|
354
351
|
* @param callbacks - An optional {@link Callbacks} object
|
|
355
352
|
*/
|
|
356
353
|
const IdentityProvider = ({ styles, callbacks }) => {
|
|
357
|
-
|
|
354
|
+
useIsomorphicLayoutEffect.invariant(useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<IdentityProvider />'));
|
|
358
355
|
const stytchClient = useStytch();
|
|
359
356
|
const containerEl = React.useRef(null);
|
|
360
357
|
const user = useStytchUser();
|
|
361
|
-
useIsomorphicLayoutEffect(() => {
|
|
358
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
362
359
|
if (!isUIClient(stytchClient)) {
|
|
363
360
|
throw Error(StytchSSRProxy.noHeadlessClientError);
|
|
364
361
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from
|
|
1
|
+
import { Dispatch, SetStateAction, useEffect } from "react";
|
|
2
|
+
// useState can cause memory leaks if it is set after the component unmounted. For example, if it is
|
|
3
|
+
// set after `await`, or in a `then`, `catch`, or `finally`, or in a setTimout/setInterval.
|
|
4
|
+
declare const useAsyncState: <T>(initialState: T | (() => T)) => [
|
|
5
|
+
T,
|
|
6
|
+
Dispatch<SetStateAction<T>>
|
|
7
|
+
];
|
|
2
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
9
|
declare function invariant(cond: any, message: string): asserts cond;
|
|
4
10
|
/**
|
|
@@ -14,5 +20,5 @@ declare function invariant(cond: any, message: string): asserts cond;
|
|
|
14
20
|
* @param newValue The new value
|
|
15
21
|
*/
|
|
16
22
|
declare const mergeWithStableProps: <T extends Record<string, unknown>, U extends Record<string, unknown> = T>(oldValue: U, newValue: T) => T;
|
|
17
|
-
declare const
|
|
18
|
-
export { invariant, mergeWithStableProps
|
|
23
|
+
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
24
|
+
export { useIsomorphicLayoutEffect as default, useAsyncState, invariant, mergeWithStableProps };
|
|
@@ -76,6 +76,10 @@ const useAsyncState = (initialState) => {
|
|
|
76
76
|
return [state, setStateAction];
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
// cc https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
|
|
80
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
81
|
+
|
|
79
82
|
exports.invariant = invariant;
|
|
80
83
|
exports.mergeWithStableProps = mergeWithStableProps;
|
|
81
84
|
exports.useAsyncState = useAsyncState;
|
|
85
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from
|
|
1
|
+
import { Dispatch, SetStateAction, useEffect } from "react";
|
|
2
|
+
// useState can cause memory leaks if it is set after the component unmounted. For example, if it is
|
|
3
|
+
// set after `await`, or in a `then`, `catch`, or `finally`, or in a setTimout/setInterval.
|
|
4
|
+
declare const useAsyncState: <T>(initialState: T | (() => T)) => [
|
|
5
|
+
T,
|
|
6
|
+
Dispatch<SetStateAction<T>>
|
|
7
|
+
];
|
|
2
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
9
|
declare function invariant(cond: any, message: string): asserts cond;
|
|
4
10
|
/**
|
|
@@ -14,5 +20,5 @@ declare function invariant(cond: any, message: string): asserts cond;
|
|
|
14
20
|
* @param newValue The new value
|
|
15
21
|
*/
|
|
16
22
|
declare const mergeWithStableProps: <T extends Record<string, unknown>, U extends Record<string, unknown> = T>(oldValue: U, newValue: T) => T;
|
|
17
|
-
declare const
|
|
18
|
-
export { invariant, mergeWithStableProps
|
|
23
|
+
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
24
|
+
export { useIsomorphicLayoutEffect as default, useAsyncState, invariant, mergeWithStableProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
1
|
+
import { useRef, useState, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
const createDeepEqual = ({ KEYS_TO_EXCLUDE = [] } = {}) => {
|
|
4
4
|
// If comparing functions, this may need some work. Not sure the
|
|
@@ -74,4 +74,7 @@ const useAsyncState = (initialState) => {
|
|
|
74
74
|
return [state, setStateAction];
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
// cc https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
|
|
78
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
79
|
+
|
|
80
|
+
export { useIsomorphicLayoutEffect as a, invariant as i, mergeWithStableProps as m, useAsyncState as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stytch/nextjs",
|
|
3
|
-
"version": "21.4.
|
|
3
|
+
"version": "21.4.2",
|
|
4
4
|
"description": "Stytch's official Next.js Library",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -21,15 +21,22 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "Stytch",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@stytch/
|
|
26
|
-
"@stytch/
|
|
24
|
+
"@babel/runtime": "7.26.10",
|
|
25
|
+
"@stytch/internal-tsconfigs": "0.0.0",
|
|
26
|
+
"@stytch/js-utils": "0.0.1",
|
|
27
|
+
"@stytch/vanilla-js": "5.18.6",
|
|
27
28
|
"@testing-library/react": "14.0.0",
|
|
29
|
+
"@types/jest": "29.5.14",
|
|
28
30
|
"eslint-config-custom": "0.0.1",
|
|
31
|
+
"jest": "29.7.0",
|
|
32
|
+
"jest-environment-jsdom": "29.7.0",
|
|
33
|
+
"jest-environment-jsdom-global": "4.0.0",
|
|
29
34
|
"react": "18.2.0",
|
|
30
35
|
"react-dom": "18.2.0",
|
|
31
36
|
"react-test-renderer": "18.0.0",
|
|
32
37
|
"rollup": "2.79.2",
|
|
38
|
+
"rollup-plugin-ts": "3.4.5",
|
|
39
|
+
"ts-jest": "29.2.5",
|
|
33
40
|
"typescript": "5.3.3"
|
|
34
41
|
},
|
|
35
42
|
"peerDependencies": {
|
|
File without changes
|
|
File without changes
|