@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/b2b/index.d.ts +208 -3
  3. package/dist/b2b/index.headless.d.ts +16 -1
  4. package/dist/b2b/index.headless.esm.js +1 -1
  5. package/dist/b2b/index.headless.js +4121 -17
  6. package/dist/b2b/index.js +250 -14
  7. package/dist/b2b/index.ui.d.ts +17 -1
  8. package/dist/b2b/index.ui.js +64 -16
  9. package/dist/index.d.ts +275 -3
  10. package/dist/index.headless.d.ts +16 -1
  11. package/dist/index.headless.js +63 -16
  12. package/dist/index.js +374 -16
  13. package/dist/index.ui.d.ts +17 -1
  14. package/dist/index.ui.js +64 -16
  15. package/package.json +3 -3
  16. package/dist/Stytch.d.ts +0 -172
  17. package/dist/Stytch.js +0 -214
  18. package/dist/Stytch.js.map +0 -1
  19. package/dist/Stytch.spec.d.ts +0 -1
  20. package/dist/Stytch.spec.js +0 -130
  21. package/dist/Stytch.spec.js.map +0 -1
  22. package/dist/StytchContext.d.ts +0 -104
  23. package/dist/StytchContext.js +0 -180
  24. package/dist/StytchContext.js.map +0 -1
  25. package/dist/StytchContext.serverside.spec.d.ts +0 -4
  26. package/dist/StytchContext.serverside.spec.js +0 -51
  27. package/dist/StytchContext.serverside.spec.js.map +0 -1
  28. package/dist/StytchContext.spec.d.ts +0 -1
  29. package/dist/StytchContext.spec.js +0 -212
  30. package/dist/StytchContext.spec.js.map +0 -1
  31. package/dist/StytchSSRProxy.d.ts +0 -2
  32. package/dist/StytchSSRProxy.js +0 -29
  33. package/dist/StytchSSRProxy.js.map +0 -1
  34. package/dist/StytchSSRProxy.spec.d.ts +0 -1
  35. package/dist/StytchSSRProxy.spec.js +0 -16
  36. package/dist/StytchSSRProxy.spec.js.map +0 -1
  37. package/dist/b2b/Stytch.d.ts +0 -104
  38. package/dist/b2b/Stytch.js +0 -90
  39. package/dist/b2b/Stytch.js.map +0 -1
  40. package/dist/b2b/StytchB2BContext.d.ts +0 -104
  41. package/dist/b2b/StytchB2BContext.js +0 -179
  42. package/dist/b2b/StytchB2BContext.js.map +0 -1
  43. package/dist/b2b/StytchB2BContext.spec.d.ts +0 -1
  44. package/dist/b2b/StytchB2BContext.spec.js +0 -217
  45. package/dist/b2b/StytchB2BContext.spec.js.map +0 -1
  46. package/dist/b2b/createStytchB2BHeadlessClient.d.ts +0 -15
  47. package/dist/b2b/createStytchB2BHeadlessClient.js +0 -26
  48. package/dist/b2b/createStytchB2BHeadlessClient.js.map +0 -1
  49. package/dist/b2b/createStytchB2BUIClient.d.ts +0 -16
  50. package/dist/b2b/createStytchB2BUIClient.js +0 -27
  51. package/dist/b2b/createStytchB2BUIClient.js.map +0 -1
  52. package/dist/b2b/index.headless.js.map +0 -1
  53. package/dist/b2b/index.js.map +0 -1
  54. package/dist/b2b/index.ui.js.map +0 -1
  55. package/dist/createStytchHeadlessClient.d.ts +0 -15
  56. package/dist/createStytchHeadlessClient.js +0 -26
  57. package/dist/createStytchHeadlessClient.js.map +0 -1
  58. package/dist/createStytchUIClient.d.ts +0 -16
  59. package/dist/createStytchUIClient.js +0 -27
  60. package/dist/createStytchUIClient.js.map +0 -1
  61. package/dist/index.headless.js.map +0 -1
  62. package/dist/index.js.map +0 -1
  63. package/dist/index.ui.js.map +0 -1
  64. package/dist/utils/async.d.ts +0 -2
  65. package/dist/utils/async.js +0 -22
  66. package/dist/utils/async.js.map +0 -1
  67. package/dist/utils/errors.d.ts +0 -3
  68. package/dist/utils/errors.js +0 -28
  69. package/dist/utils/errors.js.map +0 -1
  70. package/dist/utils/invariant.d.ts +0 -1
  71. package/dist/utils/invariant.js +0 -10
  72. package/dist/utils/invariant.js.map +0 -1
  73. package/dist/utils/useIsomorphicLayoutEffect.d.ts +0 -3
  74. package/dist/utils/useIsomorphicLayoutEffect.js +0 -7
  75. package/dist/utils/useIsomorphicLayoutEffect.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @stytch/nextjs
2
2
 
3
+ ## 14.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ec1962c]
8
+ - @stytch/vanilla-js@3.2.0
9
+
3
10
  ## 13.0.0
4
11
 
5
12
  ### Minor Changes
@@ -1,3 +1,208 @@
1
- export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, } from './StytchB2BContext';
2
- export { StytchB2B } from './Stytch';
3
- export type { StytchB2BProviderProps } from './StytchB2BContext';
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
- export * from './createStytchB2BHeadlessClient';
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 };
@@ -3194,7 +3194,7 @@ var Ie = /*#__PURE__*/ function () {
3194
3194
  },
3195
3195
  sdk: {
3196
3196
  identifier: "Stytch.js Javascript SDK",
3197
- version: "3.0.3"
3197
+ version: "3.2.0"
3198
3198
  }
3199
3199
  });
3200
3200
  }