@stytch/nextjs 21.4.2 → 21.4.4
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 +13 -0
- package/README.md +9 -8
- package/dist/{StytchB2BContext-47d523b4.d.ts → StytchB2BContext-a27d4ac7.d.ts} +75 -15
- package/dist/{StytchB2BContext-47d523b4.js → StytchB2BContext-a27d4ac7.js} +13 -16
- package/dist/{StytchB2BContext-f172fdfe.d.ts → StytchB2BContext-c11ed503.d.ts} +75 -15
- package/dist/{StytchB2BContext-f172fdfe.js → StytchB2BContext-c11ed503.js} +13 -16
- package/dist/adminPortal/index.d.ts +1 -1
- package/dist/adminPortal/index.esm.d.ts +1 -1
- package/dist/adminPortal/index.esm.js +3 -3
- package/dist/adminPortal/index.js +3 -3
- package/dist/b2b/index.d.ts +19 -23
- package/dist/b2b/index.esm.d.ts +19 -23
- package/dist/b2b/index.esm.js +19 -24
- package/dist/b2b/index.headless.esm.js +1 -1
- package/dist/b2b/index.headless.js +1 -1
- package/dist/b2b/index.js +18 -23
- package/dist/b2b/index.ui.esm.js +1 -1
- package/dist/b2b/index.ui.js +1 -1
- package/dist/index-b14d4efe.d.ts +1 -1
- package/dist/index.d.ts +64 -44
- package/dist/index.esm.d.ts +64 -44
- package/dist/index.esm.js +27 -46
- package/dist/index.headless.esm.js +1 -1
- package/dist/index.headless.js +1 -1
- package/dist/index.js +27 -46
- package/dist/index.ui.esm.js +1 -1
- package/dist/index.ui.js +1 -1
- package/dist/{useIsomorphicLayoutEffect-41b6e419.d.ts → useIsomorphicLayoutEffect-1babb81e.d.ts} +3 -3
- package/dist/{useIsomorphicLayoutEffect-8da8c061.d.ts → useIsomorphicLayoutEffect-65746ef3.d.ts} +3 -3
- package/package.json +3 -4
- package/dist/{StytchSSRProxy-14916009.d.ts → StytchSSRProxy-4e34fb34.d.ts} +0 -0
- package/dist/{StytchSSRProxy-14916009.js → StytchSSRProxy-4e34fb34.js} +0 -0
- package/dist/{StytchSSRProxy-63bc6323.d.ts → StytchSSRProxy-c9d3bc41.d.ts} +0 -0
- package/dist/{StytchSSRProxy-63bc6323.js → StytchSSRProxy-c9d3bc41.js} +0 -0
- package/dist/{useIsomorphicLayoutEffect-8da8c061.js → useIsomorphicLayoutEffect-1babb81e.js} +6 -6
- package/dist/{useIsomorphicLayoutEffect-41b6e419.js → useIsomorphicLayoutEffect-65746ef3.js} +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @stytch/nextjs
|
|
2
2
|
|
|
3
|
+
## 21.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 54275c2: Make some minor improvements to JSDoc comments
|
|
8
|
+
- 54275c2: Add missing default generic type parameters
|
|
9
|
+
|
|
10
|
+
## 21.4.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c20addb: Fix some README typos
|
|
15
|
+
|
|
3
16
|
## 21.4.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -4,8 +4,11 @@ Stytch's Next.js Library
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
With `npm
|
|
8
|
-
|
|
7
|
+
With `npm`:
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install @stytch/nextjs @stytch/vanilla-js --save
|
|
11
|
+
```
|
|
9
12
|
|
|
10
13
|
## Documentation
|
|
11
14
|
|
|
@@ -25,7 +28,7 @@ import { createStytchB2BUIClient } from '@stytch/nextjs/b2b/ui';
|
|
|
25
28
|
import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b/headless';
|
|
26
29
|
```
|
|
27
30
|
|
|
28
|
-
For full documentation please refer to Stytch's javascript SDK documentation on https://stytch.com/docs/sdks
|
|
31
|
+
For full documentation please refer to Stytch's javascript SDK documentation on https://stytch.com/docs/sdks.
|
|
29
32
|
|
|
30
33
|
## Example Usage
|
|
31
34
|
|
|
@@ -36,11 +39,10 @@ import { createStytchUIClient } from '@stytch/nextjs/ui';
|
|
|
36
39
|
const stytch = createStytchUIClient('public-token-<find yours in the stytch dashboard>');
|
|
37
40
|
|
|
38
41
|
// Wrap your App in the StytchProvider
|
|
39
|
-
|
|
42
|
+
const Root = () => (
|
|
40
43
|
<StytchProvider stytch={stytch}>
|
|
41
44
|
<App />
|
|
42
|
-
</StytchProvider
|
|
43
|
-
document.getElementById('root'),
|
|
45
|
+
</StytchProvider>
|
|
44
46
|
);
|
|
45
47
|
|
|
46
48
|
// Now use Stytch in your components
|
|
@@ -59,11 +61,10 @@ const App = () => {
|
|
|
59
61
|
styles: {
|
|
60
62
|
container: { width: '321px' },
|
|
61
63
|
colors: { primary: '#0577CA' },
|
|
62
|
-
fontFamily: '"Helvetica
|
|
64
|
+
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
|
|
63
65
|
},
|
|
64
66
|
callbacks: {
|
|
65
67
|
onEvent: (message) => console.log(message),
|
|
66
|
-
onSuccess: (message) => console.log(message),
|
|
67
68
|
onError: (message) => console.log(message),
|
|
68
69
|
},
|
|
69
70
|
};
|
|
@@ -5,45 +5,98 @@ import { Member, MemberSession, Organization, StytchB2BUIClient } from '@stytch/
|
|
|
5
5
|
import { StytchB2BHeadlessClient, StytchProjectConfigurationInput } from '@stytch/vanilla-js/b2b/headless';
|
|
6
6
|
import { PermissionsMap } from '@stytch/core/public';
|
|
7
7
|
/**
|
|
8
|
-
* The Stytch Client object passed in to <
|
|
9
|
-
* Either a
|
|
8
|
+
* The Stytch Client object passed in to <StytchB2BProvider /> in your application root.
|
|
9
|
+
* Either a StytchB2BUIClient or StytchB2BHeadlessClient.
|
|
10
10
|
*/
|
|
11
11
|
type StytchB2BClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchB2BHeadlessClient<TProjectConfiguration> | StytchB2BUIClient<TProjectConfiguration>;
|
|
12
12
|
type SWRMember = {
|
|
13
|
+
/**
|
|
14
|
+
* Either the active {@link Member} object, or null if the member is not logged in.
|
|
15
|
+
*/
|
|
13
16
|
member: null;
|
|
17
|
+
/**
|
|
18
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
19
|
+
*/
|
|
14
20
|
fromCache: false;
|
|
21
|
+
/**
|
|
22
|
+
* If true, indicates that the SDK has completed initialization.
|
|
23
|
+
*/
|
|
15
24
|
isInitialized: false;
|
|
16
25
|
} | {
|
|
26
|
+
/**
|
|
27
|
+
* Either the active {@link Member} object, or null if the member is not logged in.
|
|
28
|
+
*/
|
|
17
29
|
member: Member | null;
|
|
30
|
+
/**
|
|
31
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
32
|
+
*/
|
|
18
33
|
fromCache: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* If true, indicates that the SDK has completed initialization.
|
|
36
|
+
*/
|
|
19
37
|
isInitialized: true;
|
|
20
38
|
};
|
|
21
39
|
type SWRMemberSession = {
|
|
40
|
+
/**
|
|
41
|
+
* Either the active {@link MemberSession} object, or null if the member is not logged in.
|
|
42
|
+
*/
|
|
22
43
|
session: null;
|
|
44
|
+
/**
|
|
45
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
46
|
+
*/
|
|
23
47
|
fromCache: false;
|
|
48
|
+
/**
|
|
49
|
+
* If true, indicates that the SDK has completed initialization.
|
|
50
|
+
*/
|
|
24
51
|
isInitialized: false;
|
|
25
52
|
} | {
|
|
53
|
+
/**
|
|
54
|
+
* Either the active {@link MemberSession} object, or null if the member is not logged in.
|
|
55
|
+
*/
|
|
26
56
|
session: MemberSession | null;
|
|
57
|
+
/**
|
|
58
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
59
|
+
*/
|
|
27
60
|
fromCache: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* If true, indicates that the SDK has completed initialization.
|
|
63
|
+
*/
|
|
28
64
|
isInitialized: true;
|
|
29
65
|
};
|
|
30
66
|
type SWROrganization = {
|
|
67
|
+
/**
|
|
68
|
+
* Either the active {@link Organization} object, or null if the member is not logged in.
|
|
69
|
+
*/
|
|
31
70
|
organization: null;
|
|
71
|
+
/**
|
|
72
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
73
|
+
*/
|
|
32
74
|
fromCache: false;
|
|
75
|
+
/**
|
|
76
|
+
* If true, indicates that the SDK has completed initialization.
|
|
77
|
+
*/
|
|
33
78
|
isInitialized: false;
|
|
34
79
|
} | {
|
|
80
|
+
/**
|
|
81
|
+
* Either the active {@link Organization} object, or null if the member is not logged in.
|
|
82
|
+
*/
|
|
35
83
|
organization: Organization | null;
|
|
84
|
+
/**
|
|
85
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
86
|
+
*/
|
|
36
87
|
fromCache: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* If true, indicates that the SDK has completed initialization.
|
|
90
|
+
*/
|
|
37
91
|
isInitialized: true;
|
|
38
92
|
};
|
|
39
93
|
declare const useIsMounted__INTERNAL: () => boolean;
|
|
40
94
|
declare const isUIClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration>>(client: StytchB2BClient<TProjectConfiguration>) => client is StytchB2BUIClient<TProjectConfiguration>;
|
|
41
95
|
/**
|
|
42
|
-
* Returns the active
|
|
96
|
+
* Returns the active Member.
|
|
43
97
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
44
98
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
45
|
-
* Check the fromCache property to determine if the
|
|
46
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
99
|
+
* Check the fromCache property to determine if the member data is from persistent storage.
|
|
47
100
|
* @example
|
|
48
101
|
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
49
102
|
* if (!isInitialized) {
|
|
@@ -53,11 +106,10 @@ declare const isUIClient: <TProjectConfiguration extends Partial<import("@stytch
|
|
|
53
106
|
*/
|
|
54
107
|
declare const useStytchMember: () => SWRMember;
|
|
55
108
|
/**
|
|
56
|
-
* Returns the member's
|
|
109
|
+
* Returns the active member's Stytch member session.
|
|
57
110
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
58
111
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
59
112
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
60
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
61
113
|
* @example
|
|
62
114
|
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
63
115
|
* useEffect(() => {
|
|
@@ -74,8 +126,7 @@ declare const useStytchMemberSession: () => SWRMemberSession;
|
|
|
74
126
|
* Returns the active Stytch organization.
|
|
75
127
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
76
128
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
77
|
-
* Check the fromCache property to determine if the
|
|
78
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
129
|
+
* Check the fromCache property to determine if the organization data is from persistent storage.
|
|
79
130
|
* @example
|
|
80
131
|
* const {organization, isInitialized, fromCache} = useStytchOrganization();
|
|
81
132
|
* if (!isInitialized) {
|
|
@@ -85,8 +136,17 @@ declare const useStytchMemberSession: () => SWRMemberSession;
|
|
|
85
136
|
*/
|
|
86
137
|
declare const useStytchOrganization: () => SWROrganization;
|
|
87
138
|
type SWRIsAuthorized = {
|
|
139
|
+
/**
|
|
140
|
+
* Whether the logged-in member is allowed to perform the specified action on the specified resource.
|
|
141
|
+
*/
|
|
88
142
|
isAuthorized: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
145
|
+
*/
|
|
89
146
|
fromCache: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* If true, indicates that the SDK has completed initialization.
|
|
149
|
+
*/
|
|
90
150
|
isInitialized: boolean;
|
|
91
151
|
};
|
|
92
152
|
/**
|
|
@@ -103,15 +163,15 @@ type SWRIsAuthorized = {
|
|
|
103
163
|
*/
|
|
104
164
|
declare const useStytchIsAuthorized: (resourceId: string, action: string) => SWRIsAuthorized;
|
|
105
165
|
/**
|
|
106
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
166
|
+
* Returns the Stytch B2B client stored in the Stytch context.
|
|
107
167
|
*
|
|
108
168
|
* @example
|
|
109
|
-
* const stytch =
|
|
169
|
+
* const stytch = useStytchB2BClient();
|
|
110
170
|
* useEffect(() => {
|
|
111
171
|
* stytch.magicLinks.authenticate('...')
|
|
112
172
|
* }, [stytch]);
|
|
113
173
|
*/
|
|
114
|
-
declare const useStytchB2BClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration
|
|
174
|
+
declare const useStytchB2BClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>() => StytchB2BHeadlessClient<TProjectConfiguration>;
|
|
115
175
|
declare const withStytchB2BClient: <T extends object, TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration>>(Component: React.ComponentType<T & {
|
|
116
176
|
stytch: StytchB2BHeadlessClient<TProjectConfiguration>;
|
|
117
177
|
}>) => React.ComponentType<T>;
|
|
@@ -154,7 +214,7 @@ declare const withStytchOrganization: <T extends object>(Component: React.Compon
|
|
|
154
214
|
declare const withStytchPermissions: <Permissions_1 extends Record<string, string>, T extends object>(Component: React.ComponentType<T & {
|
|
155
215
|
stytchPermissions: PermissionsMap<Permissions_1>;
|
|
156
216
|
}>) => React.ComponentType<T>;
|
|
157
|
-
interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConfigurationInput> {
|
|
217
|
+
interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
158
218
|
/**
|
|
159
219
|
* A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
|
|
160
220
|
*/
|
|
@@ -163,7 +223,7 @@ interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConf
|
|
|
163
223
|
}
|
|
164
224
|
/**
|
|
165
225
|
* The Stytch Context Provider.
|
|
166
|
-
* Wrap your application with this component in
|
|
226
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
167
227
|
* @example
|
|
168
228
|
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
169
229
|
*
|
|
@@ -173,5 +233,5 @@ interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConf
|
|
|
173
233
|
* </StytchB2BProvider>
|
|
174
234
|
* )
|
|
175
235
|
*/
|
|
176
|
-
declare const StytchB2BProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration
|
|
236
|
+
declare const StytchB2BProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children, }: StytchB2BProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
177
237
|
export { useIsMounted__INTERNAL, isUIClient, useStytchMember, useStytchMemberSession, useStytchOrganization, useStytchIsAuthorized, useStytchB2BClient, withStytchB2BClient, withStytchMember, withStytchMemberSession, withStytchOrganization, withStytchPermissions, StytchB2BProviderProps, StytchB2BProvider };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var useIsomorphicLayoutEffect = require('./useIsomorphicLayoutEffect-
|
|
5
|
-
var StytchSSRProxy = require('./StytchSSRProxy-
|
|
4
|
+
var useIsomorphicLayoutEffect = require('./useIsomorphicLayoutEffect-65746ef3.js');
|
|
5
|
+
var StytchSSRProxy = require('./StytchSSRProxy-c9d3bc41.js');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -23,20 +23,19 @@ const initialOrganization = {
|
|
|
23
23
|
fromCache: false,
|
|
24
24
|
isInitialized: false,
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const StytchB2BContext = React.createContext({ isMounted: false });
|
|
27
27
|
const StytchMemberContext = React.createContext(initialMember);
|
|
28
28
|
const StytchMemberSessionContext = React.createContext(initialMemberSession);
|
|
29
29
|
const StytchOrganizationContext = React.createContext(initialOrganization);
|
|
30
|
-
const useIsMounted__INTERNAL = () => React.useContext(
|
|
30
|
+
const useIsMounted__INTERNAL = () => React.useContext(StytchB2BContext).isMounted;
|
|
31
31
|
const isUIClient = (client) => {
|
|
32
32
|
return client.mount !== undefined;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
* Returns the active
|
|
35
|
+
* Returns the active Member.
|
|
36
36
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
37
37
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
38
|
-
* Check the fromCache property to determine if the
|
|
39
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
38
|
+
* Check the fromCache property to determine if the member data is from persistent storage.
|
|
40
39
|
* @example
|
|
41
40
|
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
42
41
|
* if (!isInitialized) {
|
|
@@ -49,11 +48,10 @@ const useStytchMember = () => {
|
|
|
49
48
|
return React.useContext(StytchMemberContext);
|
|
50
49
|
};
|
|
51
50
|
/**
|
|
52
|
-
* Returns the member's
|
|
51
|
+
* Returns the active member's Stytch member session.
|
|
53
52
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
54
53
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
55
54
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
56
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
57
55
|
* @example
|
|
58
56
|
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
59
57
|
* useEffect(() => {
|
|
@@ -73,8 +71,7 @@ const useStytchMemberSession = () => {
|
|
|
73
71
|
* Returns the active Stytch organization.
|
|
74
72
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
75
73
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
76
|
-
* Check the fromCache property to determine if the
|
|
77
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
74
|
+
* Check the fromCache property to determine if the organization data is from persistent storage.
|
|
78
75
|
* @example
|
|
79
76
|
* const {organization, isInitialized, fromCache} = useStytchOrganization();
|
|
80
77
|
* if (!isInitialized) {
|
|
@@ -128,16 +125,16 @@ const useStytchIsAuthorized = (resourceId, action) => {
|
|
|
128
125
|
return isAuthorized;
|
|
129
126
|
};
|
|
130
127
|
/**
|
|
131
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
128
|
+
* Returns the Stytch B2B client stored in the Stytch context.
|
|
132
129
|
*
|
|
133
130
|
* @example
|
|
134
|
-
* const stytch =
|
|
131
|
+
* const stytch = useStytchB2BClient();
|
|
135
132
|
* useEffect(() => {
|
|
136
133
|
* stytch.magicLinks.authenticate('...')
|
|
137
134
|
* }, [stytch]);
|
|
138
135
|
*/
|
|
139
136
|
const useStytchB2BClient = () => {
|
|
140
|
-
const ctx = React.useContext(
|
|
137
|
+
const ctx = React.useContext(StytchB2BContext);
|
|
141
138
|
useIsomorphicLayoutEffect.invariant(ctx.isMounted, StytchSSRProxy.noProviderError('useStytchB2BClient', 'StytchB2BProvider'));
|
|
142
139
|
return ctx.client;
|
|
143
140
|
};
|
|
@@ -218,7 +215,7 @@ const withStytchPermissions = (Component) => {
|
|
|
218
215
|
};
|
|
219
216
|
/**
|
|
220
217
|
* The Stytch Context Provider.
|
|
221
|
-
* Wrap your application with this component in
|
|
218
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
222
219
|
* @example
|
|
223
220
|
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
224
221
|
*
|
|
@@ -255,7 +252,7 @@ const StytchB2BProvider = ({ stytch, children, }) => {
|
|
|
255
252
|
});
|
|
256
253
|
});
|
|
257
254
|
}, [setClientState, stytch]);
|
|
258
|
-
return (React__default["default"].createElement(
|
|
255
|
+
return (React__default["default"].createElement(StytchB2BContext.Provider, { value: ctx },
|
|
259
256
|
React__default["default"].createElement(StytchOrganizationContext.Provider, { value: organization },
|
|
260
257
|
React__default["default"].createElement(StytchMemberContext.Provider, { value: member },
|
|
261
258
|
React__default["default"].createElement(StytchMemberSessionContext.Provider, { value: session }, children)))));
|
|
@@ -5,45 +5,98 @@ import { Member, MemberSession, Organization, StytchB2BUIClient } from '@stytch/
|
|
|
5
5
|
import { StytchB2BHeadlessClient, StytchProjectConfigurationInput } from '@stytch/vanilla-js/b2b/headless';
|
|
6
6
|
import { PermissionsMap } from '@stytch/core/public';
|
|
7
7
|
/**
|
|
8
|
-
* The Stytch Client object passed in to <
|
|
9
|
-
* Either a
|
|
8
|
+
* The Stytch Client object passed in to <StytchB2BProvider /> in your application root.
|
|
9
|
+
* Either a StytchB2BUIClient or StytchB2BHeadlessClient.
|
|
10
10
|
*/
|
|
11
11
|
type StytchB2BClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchB2BHeadlessClient<TProjectConfiguration> | StytchB2BUIClient<TProjectConfiguration>;
|
|
12
12
|
type SWRMember = {
|
|
13
|
+
/**
|
|
14
|
+
* Either the active {@link Member} object, or null if the member is not logged in.
|
|
15
|
+
*/
|
|
13
16
|
member: null;
|
|
17
|
+
/**
|
|
18
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
19
|
+
*/
|
|
14
20
|
fromCache: false;
|
|
21
|
+
/**
|
|
22
|
+
* If true, indicates that the SDK has completed initialization.
|
|
23
|
+
*/
|
|
15
24
|
isInitialized: false;
|
|
16
25
|
} | {
|
|
26
|
+
/**
|
|
27
|
+
* Either the active {@link Member} object, or null if the member is not logged in.
|
|
28
|
+
*/
|
|
17
29
|
member: Member | null;
|
|
30
|
+
/**
|
|
31
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
32
|
+
*/
|
|
18
33
|
fromCache: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* If true, indicates that the SDK has completed initialization.
|
|
36
|
+
*/
|
|
19
37
|
isInitialized: true;
|
|
20
38
|
};
|
|
21
39
|
type SWRMemberSession = {
|
|
40
|
+
/**
|
|
41
|
+
* Either the active {@link MemberSession} object, or null if the member is not logged in.
|
|
42
|
+
*/
|
|
22
43
|
session: null;
|
|
44
|
+
/**
|
|
45
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
46
|
+
*/
|
|
23
47
|
fromCache: false;
|
|
48
|
+
/**
|
|
49
|
+
* If true, indicates that the SDK has completed initialization.
|
|
50
|
+
*/
|
|
24
51
|
isInitialized: false;
|
|
25
52
|
} | {
|
|
53
|
+
/**
|
|
54
|
+
* Either the active {@link MemberSession} object, or null if the member is not logged in.
|
|
55
|
+
*/
|
|
26
56
|
session: MemberSession | null;
|
|
57
|
+
/**
|
|
58
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
59
|
+
*/
|
|
27
60
|
fromCache: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* If true, indicates that the SDK has completed initialization.
|
|
63
|
+
*/
|
|
28
64
|
isInitialized: true;
|
|
29
65
|
};
|
|
30
66
|
type SWROrganization = {
|
|
67
|
+
/**
|
|
68
|
+
* Either the active {@link Organization} object, or null if the member is not logged in.
|
|
69
|
+
*/
|
|
31
70
|
organization: null;
|
|
71
|
+
/**
|
|
72
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
73
|
+
*/
|
|
32
74
|
fromCache: false;
|
|
75
|
+
/**
|
|
76
|
+
* If true, indicates that the SDK has completed initialization.
|
|
77
|
+
*/
|
|
33
78
|
isInitialized: false;
|
|
34
79
|
} | {
|
|
80
|
+
/**
|
|
81
|
+
* Either the active {@link Organization} object, or null if the member is not logged in.
|
|
82
|
+
*/
|
|
35
83
|
organization: Organization | null;
|
|
84
|
+
/**
|
|
85
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
86
|
+
*/
|
|
36
87
|
fromCache: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* If true, indicates that the SDK has completed initialization.
|
|
90
|
+
*/
|
|
37
91
|
isInitialized: true;
|
|
38
92
|
};
|
|
39
93
|
declare const useIsMounted__INTERNAL: () => boolean;
|
|
40
94
|
declare const isUIClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration>>(client: StytchB2BClient<TProjectConfiguration>) => client is StytchB2BUIClient<TProjectConfiguration>;
|
|
41
95
|
/**
|
|
42
|
-
* Returns the active
|
|
96
|
+
* Returns the active Member.
|
|
43
97
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
44
98
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
45
|
-
* Check the fromCache property to determine if the
|
|
46
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
99
|
+
* Check the fromCache property to determine if the member data is from persistent storage.
|
|
47
100
|
* @example
|
|
48
101
|
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
49
102
|
* if (!isInitialized) {
|
|
@@ -53,11 +106,10 @@ declare const isUIClient: <TProjectConfiguration extends Partial<import("@stytch
|
|
|
53
106
|
*/
|
|
54
107
|
declare const useStytchMember: () => SWRMember;
|
|
55
108
|
/**
|
|
56
|
-
* Returns the member's
|
|
109
|
+
* Returns the active member's Stytch member session.
|
|
57
110
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
58
111
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
59
112
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
60
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
61
113
|
* @example
|
|
62
114
|
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
63
115
|
* useEffect(() => {
|
|
@@ -74,8 +126,7 @@ declare const useStytchMemberSession: () => SWRMemberSession;
|
|
|
74
126
|
* Returns the active Stytch organization.
|
|
75
127
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
76
128
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
77
|
-
* Check the fromCache property to determine if the
|
|
78
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
129
|
+
* Check the fromCache property to determine if the organization data is from persistent storage.
|
|
79
130
|
* @example
|
|
80
131
|
* const {organization, isInitialized, fromCache} = useStytchOrganization();
|
|
81
132
|
* if (!isInitialized) {
|
|
@@ -85,8 +136,17 @@ declare const useStytchMemberSession: () => SWRMemberSession;
|
|
|
85
136
|
*/
|
|
86
137
|
declare const useStytchOrganization: () => SWROrganization;
|
|
87
138
|
type SWRIsAuthorized = {
|
|
139
|
+
/**
|
|
140
|
+
* Whether the logged-in member is allowed to perform the specified action on the specified resource.
|
|
141
|
+
*/
|
|
88
142
|
isAuthorized: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
145
|
+
*/
|
|
89
146
|
fromCache: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* If true, indicates that the SDK has completed initialization.
|
|
149
|
+
*/
|
|
90
150
|
isInitialized: boolean;
|
|
91
151
|
};
|
|
92
152
|
/**
|
|
@@ -103,15 +163,15 @@ type SWRIsAuthorized = {
|
|
|
103
163
|
*/
|
|
104
164
|
declare const useStytchIsAuthorized: (resourceId: string, action: string) => SWRIsAuthorized;
|
|
105
165
|
/**
|
|
106
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
166
|
+
* Returns the Stytch B2B client stored in the Stytch context.
|
|
107
167
|
*
|
|
108
168
|
* @example
|
|
109
|
-
* const stytch =
|
|
169
|
+
* const stytch = useStytchB2BClient();
|
|
110
170
|
* useEffect(() => {
|
|
111
171
|
* stytch.magicLinks.authenticate('...')
|
|
112
172
|
* }, [stytch]);
|
|
113
173
|
*/
|
|
114
|
-
declare const useStytchB2BClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration
|
|
174
|
+
declare const useStytchB2BClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>() => StytchB2BHeadlessClient<TProjectConfiguration>;
|
|
115
175
|
declare const withStytchB2BClient: <T extends object, TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration>>(Component: React.ComponentType<T & {
|
|
116
176
|
stytch: StytchB2BHeadlessClient<TProjectConfiguration>;
|
|
117
177
|
}>) => React.ComponentType<T>;
|
|
@@ -154,7 +214,7 @@ declare const withStytchOrganization: <T extends object>(Component: React.Compon
|
|
|
154
214
|
declare const withStytchPermissions: <Permissions_1 extends Record<string, string>, T extends object>(Component: React.ComponentType<T & {
|
|
155
215
|
stytchPermissions: PermissionsMap<Permissions_1>;
|
|
156
216
|
}>) => React.ComponentType<T>;
|
|
157
|
-
interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConfigurationInput> {
|
|
217
|
+
interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
|
|
158
218
|
/**
|
|
159
219
|
* A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
|
|
160
220
|
*/
|
|
@@ -163,7 +223,7 @@ interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConf
|
|
|
163
223
|
}
|
|
164
224
|
/**
|
|
165
225
|
* The Stytch Context Provider.
|
|
166
|
-
* Wrap your application with this component in
|
|
226
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
167
227
|
* @example
|
|
168
228
|
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
169
229
|
*
|
|
@@ -173,5 +233,5 @@ interface StytchB2BProviderProps<TProjectConfiguration extends StytchProjectConf
|
|
|
173
233
|
* </StytchB2BProvider>
|
|
174
234
|
* )
|
|
175
235
|
*/
|
|
176
|
-
declare const StytchB2BProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration
|
|
236
|
+
declare const StytchB2BProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children, }: StytchB2BProviderProps<TProjectConfiguration>) => JSX.Element;
|
|
177
237
|
export { useIsMounted__INTERNAL, isUIClient, useStytchMember, useStytchMemberSession, useStytchOrganization, useStytchIsAuthorized, useStytchB2BClient, withStytchB2BClient, withStytchMember, withStytchMemberSession, withStytchOrganization, withStytchPermissions, StytchB2BProviderProps, StytchB2BProvider };
|
|
@@ -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-
|
|
3
|
-
import { i as isStytchSSRProxy, n as noProviderError } from './StytchSSRProxy-
|
|
2
|
+
import { i as invariant, u as useAsyncState, m as mergeWithStableProps } from './useIsomorphicLayoutEffect-1babb81e.js';
|
|
3
|
+
import { i as isStytchSSRProxy, n as noProviderError } from './StytchSSRProxy-4e34fb34.js';
|
|
4
4
|
|
|
5
5
|
const initialMember = {
|
|
6
6
|
member: null,
|
|
@@ -17,20 +17,19 @@ const initialOrganization = {
|
|
|
17
17
|
fromCache: false,
|
|
18
18
|
isInitialized: false,
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const StytchB2BContext = createContext({ isMounted: false });
|
|
21
21
|
const StytchMemberContext = createContext(initialMember);
|
|
22
22
|
const StytchMemberSessionContext = createContext(initialMemberSession);
|
|
23
23
|
const StytchOrganizationContext = createContext(initialOrganization);
|
|
24
|
-
const useIsMounted__INTERNAL = () => useContext(
|
|
24
|
+
const useIsMounted__INTERNAL = () => useContext(StytchB2BContext).isMounted;
|
|
25
25
|
const isUIClient = (client) => {
|
|
26
26
|
return client.mount !== undefined;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
* Returns the active
|
|
29
|
+
* Returns the active Member.
|
|
30
30
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
31
31
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
32
|
-
* Check the fromCache property to determine if the
|
|
33
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
32
|
+
* Check the fromCache property to determine if the member data is from persistent storage.
|
|
34
33
|
* @example
|
|
35
34
|
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
36
35
|
* if (!isInitialized) {
|
|
@@ -43,11 +42,10 @@ const useStytchMember = () => {
|
|
|
43
42
|
return useContext(StytchMemberContext);
|
|
44
43
|
};
|
|
45
44
|
/**
|
|
46
|
-
* Returns the member's
|
|
45
|
+
* Returns the active member's Stytch member session.
|
|
47
46
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
48
47
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
49
48
|
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
50
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
51
49
|
* @example
|
|
52
50
|
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
53
51
|
* useEffect(() => {
|
|
@@ -67,8 +65,7 @@ const useStytchMemberSession = () => {
|
|
|
67
65
|
* Returns the active Stytch organization.
|
|
68
66
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
69
67
|
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
70
|
-
* Check the fromCache property to determine if the
|
|
71
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
68
|
+
* Check the fromCache property to determine if the organization data is from persistent storage.
|
|
72
69
|
* @example
|
|
73
70
|
* const {organization, isInitialized, fromCache} = useStytchOrganization();
|
|
74
71
|
* if (!isInitialized) {
|
|
@@ -122,16 +119,16 @@ const useStytchIsAuthorized = (resourceId, action) => {
|
|
|
122
119
|
return isAuthorized;
|
|
123
120
|
};
|
|
124
121
|
/**
|
|
125
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
122
|
+
* Returns the Stytch B2B client stored in the Stytch context.
|
|
126
123
|
*
|
|
127
124
|
* @example
|
|
128
|
-
* const stytch =
|
|
125
|
+
* const stytch = useStytchB2BClient();
|
|
129
126
|
* useEffect(() => {
|
|
130
127
|
* stytch.magicLinks.authenticate('...')
|
|
131
128
|
* }, [stytch]);
|
|
132
129
|
*/
|
|
133
130
|
const useStytchB2BClient = () => {
|
|
134
|
-
const ctx = useContext(
|
|
131
|
+
const ctx = useContext(StytchB2BContext);
|
|
135
132
|
invariant(ctx.isMounted, noProviderError('useStytchB2BClient', 'StytchB2BProvider'));
|
|
136
133
|
return ctx.client;
|
|
137
134
|
};
|
|
@@ -212,7 +209,7 @@ const withStytchPermissions = (Component) => {
|
|
|
212
209
|
};
|
|
213
210
|
/**
|
|
214
211
|
* The Stytch Context Provider.
|
|
215
|
-
* Wrap your application with this component in
|
|
212
|
+
* Wrap your application with this component in order to use Stytch everywhere in your app.
|
|
216
213
|
* @example
|
|
217
214
|
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
218
215
|
*
|
|
@@ -249,7 +246,7 @@ const StytchB2BProvider = ({ stytch, children, }) => {
|
|
|
249
246
|
});
|
|
250
247
|
});
|
|
251
248
|
}, [setClientState, stytch]);
|
|
252
|
-
return (React.createElement(
|
|
249
|
+
return (React.createElement(StytchB2BContext.Provider, { value: ctx },
|
|
253
250
|
React.createElement(StytchOrganizationContext.Provider, { value: organization },
|
|
254
251
|
React.createElement(StytchMemberContext.Provider, { value: member },
|
|
255
252
|
React.createElement(StytchMemberSessionContext.Provider, { value: session }, children)))));
|
|
@@ -39,6 +39,6 @@ type AdminPortalSCIMProps<TProjectConfiguration extends StytchProjectConfigurati
|
|
|
39
39
|
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
40
40
|
*/
|
|
41
41
|
declare const AdminPortalSCIM: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(props: ExcludeInjectedOptions<AdminPortalSCIMMountOptions<Partial<import("@stytch/core/public").StytchProjectConfiguration>>>) => JSX.Element;
|
|
42
|
-
export { AdminPortalSSO, AdminPortalOrgSettings, AdminPortalMemberManagement, AdminPortalSCIM };
|
|
43
42
|
export { AdminPortalB2BProducts } from "@stytch/vanilla-js/b2b/adminPortal";
|
|
43
|
+
export { AdminPortalSSO, AdminPortalOrgSettings, AdminPortalMemberManagement, AdminPortalSCIM };
|
|
44
44
|
export type { AdminPortalSSOProps, AdminPortalOrgSettingsProps, AdminPortalMemberManagementProps, AdminPortalSCIMProps };
|
|
@@ -39,6 +39,6 @@ type AdminPortalSCIMProps<TProjectConfiguration extends StytchProjectConfigurati
|
|
|
39
39
|
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
40
40
|
*/
|
|
41
41
|
declare const AdminPortalSCIM: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(props: ExcludeInjectedOptions<AdminPortalSCIMMountOptions<Partial<import("@stytch/core/public").StytchProjectConfiguration>>>) => JSX.Element;
|
|
42
|
-
export { AdminPortalSSO, AdminPortalOrgSettings, AdminPortalMemberManagement, AdminPortalSCIM };
|
|
43
42
|
export { AdminPortalB2BProducts } from "@stytch/vanilla-js/b2b/adminPortal";
|
|
43
|
+
export { AdminPortalSSO, AdminPortalOrgSettings, AdminPortalMemberManagement, AdminPortalSCIM };
|
|
44
44
|
export type { AdminPortalSSOProps, AdminPortalOrgSettingsProps, AdminPortalMemberManagementProps, AdminPortalSCIMProps };
|