@stytch/nextjs 13.0.0 → 14.0.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 +7 -0
- package/dist/b2b/index.d.ts +208 -3
- package/dist/b2b/index.headless.d.ts +16 -1
- package/dist/b2b/index.headless.esm.js +1 -1
- package/dist/b2b/index.headless.js +4121 -17
- package/dist/b2b/index.js +250 -14
- package/dist/b2b/index.ui.d.ts +17 -1
- package/dist/b2b/index.ui.js +64 -16
- package/dist/index.d.ts +275 -3
- package/dist/index.headless.d.ts +16 -1
- package/dist/index.headless.js +63 -16
- package/dist/index.js +374 -16
- package/dist/index.ui.d.ts +17 -1
- package/dist/index.ui.js +64 -16
- package/package.json +3 -3
- package/dist/Stytch.d.ts +0 -172
- package/dist/Stytch.js +0 -214
- package/dist/Stytch.js.map +0 -1
- package/dist/Stytch.spec.d.ts +0 -1
- package/dist/Stytch.spec.js +0 -130
- package/dist/Stytch.spec.js.map +0 -1
- package/dist/StytchContext.d.ts +0 -104
- package/dist/StytchContext.js +0 -180
- package/dist/StytchContext.js.map +0 -1
- package/dist/StytchContext.serverside.spec.d.ts +0 -4
- package/dist/StytchContext.serverside.spec.js +0 -51
- package/dist/StytchContext.serverside.spec.js.map +0 -1
- package/dist/StytchContext.spec.d.ts +0 -1
- package/dist/StytchContext.spec.js +0 -212
- package/dist/StytchContext.spec.js.map +0 -1
- package/dist/StytchSSRProxy.d.ts +0 -2
- package/dist/StytchSSRProxy.js +0 -29
- package/dist/StytchSSRProxy.js.map +0 -1
- package/dist/StytchSSRProxy.spec.d.ts +0 -1
- package/dist/StytchSSRProxy.spec.js +0 -16
- package/dist/StytchSSRProxy.spec.js.map +0 -1
- package/dist/b2b/Stytch.d.ts +0 -104
- package/dist/b2b/Stytch.js +0 -90
- package/dist/b2b/Stytch.js.map +0 -1
- package/dist/b2b/StytchB2BContext.d.ts +0 -104
- package/dist/b2b/StytchB2BContext.js +0 -179
- package/dist/b2b/StytchB2BContext.js.map +0 -1
- package/dist/b2b/StytchB2BContext.spec.d.ts +0 -1
- package/dist/b2b/StytchB2BContext.spec.js +0 -217
- package/dist/b2b/StytchB2BContext.spec.js.map +0 -1
- package/dist/b2b/createStytchB2BHeadlessClient.d.ts +0 -15
- package/dist/b2b/createStytchB2BHeadlessClient.js +0 -26
- package/dist/b2b/createStytchB2BHeadlessClient.js.map +0 -1
- package/dist/b2b/createStytchB2BUIClient.d.ts +0 -16
- package/dist/b2b/createStytchB2BUIClient.js +0 -27
- package/dist/b2b/createStytchB2BUIClient.js.map +0 -1
- package/dist/b2b/index.headless.js.map +0 -1
- package/dist/b2b/index.js.map +0 -1
- package/dist/b2b/index.ui.js.map +0 -1
- package/dist/createStytchHeadlessClient.d.ts +0 -15
- package/dist/createStytchHeadlessClient.js +0 -26
- package/dist/createStytchHeadlessClient.js.map +0 -1
- package/dist/createStytchUIClient.d.ts +0 -16
- package/dist/createStytchUIClient.js +0 -27
- package/dist/createStytchUIClient.js.map +0 -1
- package/dist/index.headless.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.ui.js.map +0 -1
- package/dist/utils/async.d.ts +0 -2
- package/dist/utils/async.js +0 -22
- package/dist/utils/async.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -3
- package/dist/utils/errors.js +0 -28
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/invariant.d.ts +0 -1
- package/dist/utils/invariant.js +0 -10
- package/dist/utils/invariant.js.map +0 -1
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +0 -3
- package/dist/utils/useIsomorphicLayoutEffect.js +0 -7
- package/dist/utils/useIsomorphicLayoutEffect.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/dist/b2b/index.d.ts
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { Member, MemberSession, StytchB2BUIClient } from "@stytch/vanilla-js/b2b";
|
|
5
|
+
import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
|
|
6
|
+
import { Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/vanilla-js";
|
|
7
|
+
/**
|
|
8
|
+
* The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
|
|
9
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
10
|
+
*/
|
|
11
|
+
type StytchB2BClient = StytchB2BHeadlessClient | StytchB2BUIClient;
|
|
12
|
+
type SWRMember = {
|
|
13
|
+
member: null;
|
|
14
|
+
fromCache: false;
|
|
15
|
+
isInitialized: false;
|
|
16
|
+
} | {
|
|
17
|
+
member: Member | null;
|
|
18
|
+
fromCache: boolean;
|
|
19
|
+
isInitialized: true;
|
|
20
|
+
};
|
|
21
|
+
type SWRMemberSession = {
|
|
22
|
+
session: null;
|
|
23
|
+
fromCache: false;
|
|
24
|
+
isInitialized: false;
|
|
25
|
+
} | {
|
|
26
|
+
session: MemberSession | null;
|
|
27
|
+
fromCache: boolean;
|
|
28
|
+
isInitialized: true;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Returns the active member.
|
|
32
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
33
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
34
|
+
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
35
|
+
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
36
|
+
* @example
|
|
37
|
+
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
38
|
+
* if (!isInitialized) {
|
|
39
|
+
* return <p>Loading...</p>;
|
|
40
|
+
* }
|
|
41
|
+
* return (<h1>Welcome, {member.name}</h1>);
|
|
42
|
+
*/
|
|
43
|
+
declare const useStytchMember: () => SWRMember;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the member's active Stytch member session.
|
|
46
|
+
* The Stytch SDKs are used for client-side authentication and session management.
|
|
47
|
+
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
48
|
+
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
49
|
+
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
50
|
+
* @example
|
|
51
|
+
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
52
|
+
* useEffect(() => {
|
|
53
|
+
* if (!isInitialized) {
|
|
54
|
+
* return;
|
|
55
|
+
* }
|
|
56
|
+
* if (!session) {
|
|
57
|
+
* router.replace('/login')
|
|
58
|
+
* }
|
|
59
|
+
* }, [session, isInitialized]);
|
|
60
|
+
*/
|
|
61
|
+
declare const useStytchMemberSession: () => SWRMemberSession;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the Stytch client stored in the Stytch context.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const stytch = useStytch();
|
|
67
|
+
* useEffect(() => {
|
|
68
|
+
* stytch.magicLinks.authenticate('...')
|
|
69
|
+
* }, [stytch]);
|
|
70
|
+
*/
|
|
71
|
+
declare const useStytchB2BClient: () => StytchB2BClient;
|
|
72
|
+
declare const withStytchB2BClient: <T extends object>(Component: React.ComponentType<T & {
|
|
73
|
+
stytch: StytchB2BClient;
|
|
74
|
+
}>) => React.ComponentType<T>;
|
|
75
|
+
declare const withStytchMember: <T extends object>(Component: React.ComponentType<T & {
|
|
76
|
+
stytchMember: Member | null;
|
|
77
|
+
stytchMemberIsInitialized: boolean;
|
|
78
|
+
stytchMemberIsFromCache: boolean;
|
|
79
|
+
}>) => React.ComponentType<T>;
|
|
80
|
+
declare const withStytchMemberSession: <T extends object>(Component: React.ComponentType<T & {
|
|
81
|
+
stytchMemberSession: MemberSession | null;
|
|
82
|
+
stytchMemberSessionIsInitialized: boolean;
|
|
83
|
+
stytchMemberSessionIsFromCache: boolean;
|
|
84
|
+
}>) => React.ComponentType<T>;
|
|
85
|
+
interface StytchB2BProviderProps {
|
|
86
|
+
/**
|
|
87
|
+
* A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
|
|
88
|
+
*/
|
|
89
|
+
stytch: StytchB2BClient;
|
|
90
|
+
children?: ReactNode;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The Stytch Context Provider.
|
|
94
|
+
* Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
|
|
95
|
+
* @example
|
|
96
|
+
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
97
|
+
*
|
|
98
|
+
* return (
|
|
99
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
100
|
+
* <App />
|
|
101
|
+
* </StytchB2BProvider>
|
|
102
|
+
* )
|
|
103
|
+
*/
|
|
104
|
+
declare const StytchB2BProvider: ({ stytch, children }: StytchB2BProviderProps) => JSX.Element;
|
|
105
|
+
interface StytchB2BProps {
|
|
106
|
+
/**
|
|
107
|
+
* An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* {
|
|
111
|
+
* fontFamily: 'Arial, Helvetica, sans-serif',
|
|
112
|
+
* width: '360px',
|
|
113
|
+
* primaryColor: '#19303D',
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
styles?: StyleConfig;
|
|
117
|
+
/**
|
|
118
|
+
* An optional {@link Callbacks} object.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* {
|
|
122
|
+
* onError: ({message}) => {
|
|
123
|
+
* console.error('Stytch error', message)
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* {
|
|
129
|
+
* onEvent: ({type, data}) => {
|
|
130
|
+
* if(type === StytchEventType.B2BMagicLinkAuthenticate) {
|
|
131
|
+
* console.log('Logged in with', data);
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
*/
|
|
136
|
+
callbacks?: Callbacks;
|
|
137
|
+
/**
|
|
138
|
+
* A {@link StytchB2BUIConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
139
|
+
*
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* {
|
|
143
|
+
* products: ['emailMagicLinks'],
|
|
144
|
+
* authFlowType: "Discovery",
|
|
145
|
+
* emailMagicLinksOptions: {
|
|
146
|
+
* discoveryRedirectURL: 'https://example.com/authenticate',
|
|
147
|
+
* },
|
|
148
|
+
* sessionOptions: {
|
|
149
|
+
* sessionDurationMinutes: 60,
|
|
150
|
+
* },
|
|
151
|
+
* }
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* {
|
|
155
|
+
* products: ['emailMagicLinks', 'sso'],
|
|
156
|
+
* authFlowType: "Organization",
|
|
157
|
+
* emailMagicLinksOptions: {
|
|
158
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
159
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
160
|
+
* },
|
|
161
|
+
* ssoOptions: {
|
|
162
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
163
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
164
|
+
* },
|
|
165
|
+
* sessionOptions: {
|
|
166
|
+
* sessionDurationMinutes: 60,
|
|
167
|
+
* },
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
170
|
+
config: StytchB2BUIConfig;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The Stytch B2B UI component.
|
|
174
|
+
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
175
|
+
* passed into the {@link StytchB2BProvider}
|
|
176
|
+
*
|
|
177
|
+
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* <StytchB2B
|
|
181
|
+
* config={{
|
|
182
|
+
* authFlowType: "Organization",
|
|
183
|
+
* emailMagicLinksOptions: {
|
|
184
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
185
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
186
|
+
* },
|
|
187
|
+
* ssoOptions: {
|
|
188
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
189
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
190
|
+
* },
|
|
191
|
+
* sessionOptions: {
|
|
192
|
+
* sessionDurationMinutes: 60,
|
|
193
|
+
* }
|
|
194
|
+
* }}
|
|
195
|
+
* styles={{
|
|
196
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
197
|
+
* primaryColor: '#0577CA',
|
|
198
|
+
* width: '321px',
|
|
199
|
+
* }}
|
|
200
|
+
* callbacks={{
|
|
201
|
+
* onEvent: (event) => console.log(event)
|
|
202
|
+
* }}
|
|
203
|
+
* />
|
|
204
|
+
* @param props {@link StytchB2BProps}
|
|
205
|
+
*/
|
|
206
|
+
declare const StytchB2B: ({ styles, callbacks, config }: StytchB2BProps) => React.JSX.Element;
|
|
207
|
+
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B };
|
|
208
|
+
export type { StytchB2BProviderProps };
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Headless Stytch client object to call the stytch B2B APIs.
|
|
4
|
+
* The Stytch client is not available serverside.
|
|
5
|
+
* @example
|
|
6
|
+
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
7
|
+
*
|
|
8
|
+
* return (
|
|
9
|
+
* <StytchB2BProvider stytch={stytch}>
|
|
10
|
+
* <App />
|
|
11
|
+
* </StytchB2BProvider>
|
|
12
|
+
* )
|
|
13
|
+
* @returns A {@link StytchB2BHeadlessClient}
|
|
14
|
+
*/
|
|
15
|
+
declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient;
|
|
16
|
+
export { createStytchB2BHeadlessClient };
|