@stytch/nextjs 5.0.0 → 5.0.1
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 +6 -0
- package/dist/b2b/index.d.ts +104 -1
- package/dist/b2b/index.esm.d.ts +104 -1
- package/dist/b2b/index.esm.js +67 -2
- package/dist/b2b/index.js +66 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/b2b/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { StytchB2BHeadlessClient, StytchB2BUIClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
|
|
5
|
+
import { Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/vanilla-js";
|
|
5
6
|
import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
|
|
6
7
|
/**
|
|
7
8
|
* The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
|
|
@@ -101,6 +102,108 @@ interface StytchB2BProviderProps {
|
|
|
101
102
|
* )
|
|
102
103
|
*/
|
|
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) => JSX.Element;
|
|
104
207
|
/**
|
|
105
208
|
* Creates a Headless Stytch client object to call the stytch B2B APIs.
|
|
106
209
|
* The Stytch client is not available serverside.
|
|
@@ -115,5 +218,5 @@ declare const StytchB2BProvider: ({ stytch, children }: StytchB2BProviderProps)
|
|
|
115
218
|
* @returns A {@link StytchHeadlessClient}
|
|
116
219
|
*/
|
|
117
220
|
declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
|
|
118
|
-
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, createStytchB2BHeadlessClient };
|
|
221
|
+
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B, createStytchB2BHeadlessClient };
|
|
119
222
|
export type { StytchB2BProviderProps };
|
package/dist/b2b/index.esm.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { StytchB2BHeadlessClient, StytchB2BUIClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
|
|
5
|
+
import { Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/vanilla-js";
|
|
5
6
|
import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
|
|
6
7
|
/**
|
|
7
8
|
* The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
|
|
@@ -101,6 +102,108 @@ interface StytchB2BProviderProps {
|
|
|
101
102
|
* )
|
|
102
103
|
*/
|
|
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) => JSX.Element;
|
|
104
207
|
/**
|
|
105
208
|
* Creates a Headless Stytch client object to call the stytch B2B APIs.
|
|
106
209
|
* The Stytch client is not available serverside.
|
|
@@ -115,5 +218,5 @@ declare const StytchB2BProvider: ({ stytch, children }: StytchB2BProviderProps)
|
|
|
115
218
|
* @returns A {@link StytchHeadlessClient}
|
|
116
219
|
*/
|
|
117
220
|
declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
|
|
118
|
-
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, createStytchB2BHeadlessClient };
|
|
221
|
+
export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B, createStytchB2BHeadlessClient };
|
|
119
222
|
export type { StytchB2BProviderProps };
|
package/dist/b2b/index.esm.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect, useCallback, createContext, useContext, useMemo } from 'react';
|
|
1
|
+
import React, { useRef, useState, useEffect, useCallback, createContext, useContext, useMemo, useLayoutEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
const noProviderError = (item, provider = 'StytchProvider') => `${item} can only be used inside <${provider}>.`;
|
|
4
|
+
const noHeadlessClientError = `Tried to create a Stytch Login UI element using the Stytch Headless SDK.
|
|
5
|
+
You must use the UI SDK to use UI elements.
|
|
6
|
+
Please make sure you are importing createStytchHeadlessClient from @stytch/nextjs/ui and not from @stytch/nextjs/headless.`;
|
|
4
7
|
const cannotInvokeMethodOnServerError = (path) => `[Stytch] Invalid serverside function call to ${path}.
|
|
5
8
|
The Stytch Javascript SDK is intended to ony be used on the client side.
|
|
6
9
|
Make sure to wrap your API calls in a hook to ensure they are executed on the client.
|
|
@@ -80,6 +83,9 @@ const StytchContext = createContext({ isMounted: false });
|
|
|
80
83
|
const StytchMemberContext = createContext(initialMember);
|
|
81
84
|
const StytchMemberSessionContext = createContext(initialMemberSession);
|
|
82
85
|
const useIsMounted__INTERNAL = () => useContext(StytchContext).isMounted;
|
|
86
|
+
const isUIClient = (client) => {
|
|
87
|
+
return client.mount !== undefined;
|
|
88
|
+
};
|
|
83
89
|
/**
|
|
84
90
|
* Returns the active member.
|
|
85
91
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
@@ -202,6 +208,65 @@ const StytchB2BProvider = ({ stytch, children }) => {
|
|
|
202
208
|
React.createElement(StytchMemberSessionContext.Provider, { value: finalMemberSession }, children))));
|
|
203
209
|
};
|
|
204
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The Stytch B2B UI component.
|
|
213
|
+
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
214
|
+
* passed into the {@link StytchB2BProvider}
|
|
215
|
+
*
|
|
216
|
+
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* <StytchB2B
|
|
220
|
+
* config={{
|
|
221
|
+
* authFlowType: "Organization",
|
|
222
|
+
* emailMagicLinksOptions: {
|
|
223
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
224
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
225
|
+
* },
|
|
226
|
+
* ssoOptions: {
|
|
227
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
228
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
229
|
+
* },
|
|
230
|
+
* sessionOptions: {
|
|
231
|
+
* sessionDurationMinutes: 60,
|
|
232
|
+
* }
|
|
233
|
+
* }}
|
|
234
|
+
* styles={{
|
|
235
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
236
|
+
* primaryColor: '#0577CA',
|
|
237
|
+
* width: '321px',
|
|
238
|
+
* }}
|
|
239
|
+
* callbacks={{
|
|
240
|
+
* onEvent: (event) => console.log(event)
|
|
241
|
+
* }}
|
|
242
|
+
* />
|
|
243
|
+
* @param props {@link StytchB2BProps}
|
|
244
|
+
*/
|
|
245
|
+
const StytchB2B = ({ styles, callbacks, config }) => {
|
|
246
|
+
invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />'));
|
|
247
|
+
const stytchClient = useStytchB2BClient();
|
|
248
|
+
const containerEl = useRef(null);
|
|
249
|
+
useLayoutEffect(() => {
|
|
250
|
+
if (!isUIClient(stytchClient)) {
|
|
251
|
+
throw Error(noHeadlessClientError);
|
|
252
|
+
}
|
|
253
|
+
if (!containerEl.current) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!containerEl.current.id) {
|
|
257
|
+
const randId = Math.floor(Math.random() * 1e6);
|
|
258
|
+
containerEl.current.id = `stytch-b2b-ui-${randId}`;
|
|
259
|
+
}
|
|
260
|
+
stytchClient.mount({
|
|
261
|
+
callbacks,
|
|
262
|
+
config,
|
|
263
|
+
elementId: `#${containerEl.current.id}`,
|
|
264
|
+
styles,
|
|
265
|
+
});
|
|
266
|
+
}, [stytchClient, styles, callbacks]);
|
|
267
|
+
return React.createElement("div", { ref: containerEl });
|
|
268
|
+
};
|
|
269
|
+
|
|
205
270
|
var e, t, n, r, o, i, a, s, u, l, c, f, d, p, h, m, g, v, y, b, w, _, k, S;
|
|
206
271
|
function E(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
207
272
|
function x(e, t) { var n = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (!n) {
|
|
@@ -5562,4 +5627,4 @@ const createStytchB2BHeadlessClient = (...args) => {
|
|
|
5562
5627
|
return new Tt(...args);
|
|
5563
5628
|
};
|
|
5564
5629
|
|
|
5565
|
-
export { StytchB2BProvider, createStytchB2BHeadlessClient, useStytchB2BClient, useStytchMember, useStytchMemberSession, withStytchB2BClient, withStytchMember, withStytchMemberSession };
|
|
5630
|
+
export { StytchB2B, StytchB2BProvider, createStytchB2BHeadlessClient, useStytchB2BClient, useStytchMember, useStytchMemberSession, withStytchB2BClient, withStytchMember, withStytchMemberSession };
|
package/dist/b2b/index.js
CHANGED
|
@@ -9,6 +9,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
11
|
const noProviderError = (item, provider = 'StytchProvider') => `${item} can only be used inside <${provider}>.`;
|
|
12
|
+
const noHeadlessClientError = `Tried to create a Stytch Login UI element using the Stytch Headless SDK.
|
|
13
|
+
You must use the UI SDK to use UI elements.
|
|
14
|
+
Please make sure you are importing createStytchHeadlessClient from @stytch/nextjs/ui and not from @stytch/nextjs/headless.`;
|
|
12
15
|
const cannotInvokeMethodOnServerError = (path) => `[Stytch] Invalid serverside function call to ${path}.
|
|
13
16
|
The Stytch Javascript SDK is intended to ony be used on the client side.
|
|
14
17
|
Make sure to wrap your API calls in a hook to ensure they are executed on the client.
|
|
@@ -88,6 +91,9 @@ const StytchContext = React.createContext({ isMounted: false });
|
|
|
88
91
|
const StytchMemberContext = React.createContext(initialMember);
|
|
89
92
|
const StytchMemberSessionContext = React.createContext(initialMemberSession);
|
|
90
93
|
const useIsMounted__INTERNAL = () => React.useContext(StytchContext).isMounted;
|
|
94
|
+
const isUIClient = (client) => {
|
|
95
|
+
return client.mount !== undefined;
|
|
96
|
+
};
|
|
91
97
|
/**
|
|
92
98
|
* Returns the active member.
|
|
93
99
|
* The Stytch SDKs are used for client-side authentication and session management.
|
|
@@ -210,6 +216,65 @@ const StytchB2BProvider = ({ stytch, children }) => {
|
|
|
210
216
|
React__default['default'].createElement(StytchMemberSessionContext.Provider, { value: finalMemberSession }, children))));
|
|
211
217
|
};
|
|
212
218
|
|
|
219
|
+
/**
|
|
220
|
+
* The Stytch B2B UI component.
|
|
221
|
+
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
222
|
+
* passed into the {@link StytchB2BProvider}
|
|
223
|
+
*
|
|
224
|
+
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* <StytchB2B
|
|
228
|
+
* config={{
|
|
229
|
+
* authFlowType: "Organization",
|
|
230
|
+
* emailMagicLinksOptions: {
|
|
231
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
232
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
233
|
+
* },
|
|
234
|
+
* ssoOptions: {
|
|
235
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
236
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
237
|
+
* },
|
|
238
|
+
* sessionOptions: {
|
|
239
|
+
* sessionDurationMinutes: 60,
|
|
240
|
+
* }
|
|
241
|
+
* }}
|
|
242
|
+
* styles={{
|
|
243
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
244
|
+
* primaryColor: '#0577CA',
|
|
245
|
+
* width: '321px',
|
|
246
|
+
* }}
|
|
247
|
+
* callbacks={{
|
|
248
|
+
* onEvent: (event) => console.log(event)
|
|
249
|
+
* }}
|
|
250
|
+
* />
|
|
251
|
+
* @param props {@link StytchB2BProps}
|
|
252
|
+
*/
|
|
253
|
+
const StytchB2B = ({ styles, callbacks, config }) => {
|
|
254
|
+
invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />'));
|
|
255
|
+
const stytchClient = useStytchB2BClient();
|
|
256
|
+
const containerEl = React.useRef(null);
|
|
257
|
+
React.useLayoutEffect(() => {
|
|
258
|
+
if (!isUIClient(stytchClient)) {
|
|
259
|
+
throw Error(noHeadlessClientError);
|
|
260
|
+
}
|
|
261
|
+
if (!containerEl.current) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!containerEl.current.id) {
|
|
265
|
+
const randId = Math.floor(Math.random() * 1e6);
|
|
266
|
+
containerEl.current.id = `stytch-b2b-ui-${randId}`;
|
|
267
|
+
}
|
|
268
|
+
stytchClient.mount({
|
|
269
|
+
callbacks,
|
|
270
|
+
config,
|
|
271
|
+
elementId: `#${containerEl.current.id}`,
|
|
272
|
+
styles,
|
|
273
|
+
});
|
|
274
|
+
}, [stytchClient, styles, callbacks]);
|
|
275
|
+
return React__default['default'].createElement("div", { ref: containerEl });
|
|
276
|
+
};
|
|
277
|
+
|
|
213
278
|
var e, t, n, r, o, i, a, s, u, l, c, f, d, p, h, m, g, v, y, b, w, _, k, S;
|
|
214
279
|
function E(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
215
280
|
function x(e, t) { var n = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"]; if (!n) {
|
|
@@ -5570,6 +5635,7 @@ const createStytchB2BHeadlessClient = (...args) => {
|
|
|
5570
5635
|
return new Tt(...args);
|
|
5571
5636
|
};
|
|
5572
5637
|
|
|
5638
|
+
exports.StytchB2B = StytchB2B;
|
|
5573
5639
|
exports.StytchB2BProvider = StytchB2BProvider;
|
|
5574
5640
|
exports.createStytchB2BHeadlessClient = createStytchB2BHeadlessClient;
|
|
5575
5641
|
exports.useStytchB2BClient = useStytchB2BClient;
|