@stytch/nextjs 12.0.0 → 13.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 +11 -0
- package/dist/Stytch.d.ts +172 -0
- package/dist/Stytch.js +214 -0
- package/dist/Stytch.js.map +1 -0
- package/dist/Stytch.spec.d.ts +1 -0
- package/dist/Stytch.spec.js +130 -0
- package/dist/Stytch.spec.js.map +1 -0
- package/dist/StytchContext.d.ts +104 -0
- package/dist/StytchContext.js +180 -0
- package/dist/StytchContext.js.map +1 -0
- package/dist/StytchContext.serverside.spec.d.ts +4 -0
- package/dist/StytchContext.serverside.spec.js +51 -0
- package/dist/StytchContext.serverside.spec.js.map +1 -0
- package/dist/StytchContext.spec.d.ts +1 -0
- package/dist/StytchContext.spec.js +212 -0
- package/dist/StytchContext.spec.js.map +1 -0
- package/dist/StytchSSRProxy.d.ts +2 -0
- package/dist/StytchSSRProxy.js +29 -0
- package/dist/StytchSSRProxy.js.map +1 -0
- package/dist/StytchSSRProxy.spec.d.ts +1 -0
- package/dist/StytchSSRProxy.spec.js +16 -0
- package/dist/StytchSSRProxy.spec.js.map +1 -0
- package/dist/b2b/Stytch.d.ts +104 -0
- package/dist/b2b/Stytch.js +90 -0
- package/dist/b2b/Stytch.js.map +1 -0
- package/dist/b2b/StytchB2BContext.d.ts +104 -0
- package/dist/b2b/StytchB2BContext.js +179 -0
- package/dist/b2b/StytchB2BContext.js.map +1 -0
- package/dist/b2b/StytchB2BContext.spec.d.ts +1 -0
- package/dist/b2b/StytchB2BContext.spec.js +217 -0
- package/dist/b2b/StytchB2BContext.spec.js.map +1 -0
- package/dist/b2b/createStytchB2BHeadlessClient.d.ts +15 -0
- package/dist/b2b/createStytchB2BHeadlessClient.js +26 -0
- package/dist/b2b/createStytchB2BHeadlessClient.js.map +1 -0
- package/dist/b2b/createStytchB2BUIClient.d.ts +16 -0
- package/dist/b2b/createStytchB2BUIClient.js +27 -0
- package/dist/b2b/createStytchB2BUIClient.js.map +1 -0
- package/dist/b2b/index.d.ts +3 -208
- package/dist/b2b/index.headless.d.ts +1 -16
- package/dist/b2b/index.headless.esm.js +569 -612
- package/dist/b2b/index.headless.js +17 -4164
- package/dist/b2b/index.headless.js.map +1 -0
- package/dist/b2b/index.js +14 -250
- package/dist/b2b/index.js.map +1 -0
- package/dist/b2b/index.ui.d.ts +1 -17
- package/dist/b2b/index.ui.js +16 -64
- package/dist/b2b/index.ui.js.map +1 -0
- package/dist/createStytchHeadlessClient.d.ts +15 -0
- package/dist/createStytchHeadlessClient.js +26 -0
- package/dist/createStytchHeadlessClient.js.map +1 -0
- package/dist/createStytchUIClient.d.ts +16 -0
- package/dist/createStytchUIClient.js +27 -0
- package/dist/createStytchUIClient.js.map +1 -0
- package/dist/index.d.ts +3 -244
- package/dist/index.esm.d.ts +32 -1
- package/dist/index.esm.js +56 -1
- package/dist/index.headless.d.ts +1 -16
- package/dist/index.headless.js +16 -63
- package/dist/index.headless.js.map +1 -0
- package/dist/index.js +16 -318
- package/dist/index.js.map +1 -0
- package/dist/index.ui.d.ts +1 -17
- package/dist/index.ui.js +16 -64
- package/dist/index.ui.js.map +1 -0
- package/dist/utils/async.d.ts +2 -0
- package/dist/utils/async.js +22 -0
- package/dist/utils/async.js.map +1 -0
- package/dist/utils/errors.d.ts +3 -0
- package/dist/utils/errors.js +28 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/invariant.d.ts +1 -0
- package/dist/utils/invariant.js +10 -0
- package/dist/utils/invariant.js.map +1 -0
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +7 -0
- package/dist/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.headless.js","sourceRoot":"","sources":["../../src/b2b/index.headless.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD"}
|
package/dist/b2b/index.js
CHANGED
|
@@ -1,250 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
function invariant(cond, message) {
|
|
18
|
-
if (!cond)
|
|
19
|
-
throw new Error(message);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// useState can cause memory leaks if it is set after the component unmounted. For example, if it is
|
|
23
|
-
// set after `await`, or in a `then`, `catch`, or `finally`, or in a setTimout/setInterval.
|
|
24
|
-
const useAsyncState = (initialState) => {
|
|
25
|
-
const isMounted = React.useRef(true);
|
|
26
|
-
const [state, setState] = React.useState(initialState);
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
isMounted.current = true;
|
|
29
|
-
return () => {
|
|
30
|
-
isMounted.current = false;
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
const setStateAction = React.useCallback((newState) => {
|
|
34
|
-
isMounted.current && setState(newState);
|
|
35
|
-
}, []);
|
|
36
|
-
return [state, setStateAction];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const SSRStubKey = Symbol('__stytch_SSRStubKey');
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
const isStytchSSRProxy = (proxy) => {
|
|
42
|
-
return !!proxy[SSRStubKey];
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const initialMember = {
|
|
46
|
-
member: null,
|
|
47
|
-
fromCache: false,
|
|
48
|
-
isInitialized: false,
|
|
49
|
-
};
|
|
50
|
-
const initialMemberSession = {
|
|
51
|
-
session: null,
|
|
52
|
-
fromCache: false,
|
|
53
|
-
isInitialized: false,
|
|
54
|
-
};
|
|
55
|
-
const StytchContext = React.createContext({ isMounted: false });
|
|
56
|
-
const StytchMemberContext = React.createContext(initialMember);
|
|
57
|
-
const StytchMemberSessionContext = React.createContext(initialMemberSession);
|
|
58
|
-
const useIsMounted__INTERNAL = () => React.useContext(StytchContext).isMounted;
|
|
59
|
-
const isUIClient = (client) => {
|
|
60
|
-
return client.mount !== undefined;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Returns the active member.
|
|
64
|
-
* The Stytch SDKs are used for client-side authentication and session management.
|
|
65
|
-
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
66
|
-
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
67
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
68
|
-
* @example
|
|
69
|
-
* const {member, isInitialized, fromCache} = useStytchMember();
|
|
70
|
-
* if (!isInitialized) {
|
|
71
|
-
* return <p>Loading...</p>;
|
|
72
|
-
* }
|
|
73
|
-
* return (<h1>Welcome, {member.name}</h1>);
|
|
74
|
-
*/
|
|
75
|
-
const useStytchMember = () => {
|
|
76
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('useStytchMember', 'StytchB2BProvider'));
|
|
77
|
-
return React.useContext(StytchMemberContext);
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Returns the member's active Stytch member session.
|
|
81
|
-
* The Stytch SDKs are used for client-side authentication and session management.
|
|
82
|
-
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
83
|
-
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
84
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
85
|
-
* @example
|
|
86
|
-
* const {session, isInitialized, fromCache} = useStytchMemberSession();
|
|
87
|
-
* useEffect(() => {
|
|
88
|
-
* if (!isInitialized) {
|
|
89
|
-
* return;
|
|
90
|
-
* }
|
|
91
|
-
* if (!session) {
|
|
92
|
-
* router.replace('/login')
|
|
93
|
-
* }
|
|
94
|
-
* }, [session, isInitialized]);
|
|
95
|
-
*/
|
|
96
|
-
const useStytchMemberSession = () => {
|
|
97
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('useStytchMemberSession', 'StytchB2BProvider'));
|
|
98
|
-
return React.useContext(StytchMemberSessionContext);
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* const stytch = useStytch();
|
|
105
|
-
* useEffect(() => {
|
|
106
|
-
* stytch.magicLinks.authenticate('...')
|
|
107
|
-
* }, [stytch]);
|
|
108
|
-
*/
|
|
109
|
-
const useStytchB2BClient = () => {
|
|
110
|
-
const ctx = React.useContext(StytchContext);
|
|
111
|
-
invariant(ctx.isMounted, noProviderError('useStytchB2BClient', 'StytchB2BProvider'));
|
|
112
|
-
return ctx.client;
|
|
113
|
-
};
|
|
114
|
-
const withStytchB2BClient = (Component) => {
|
|
115
|
-
const WithStytch = (props) => {
|
|
116
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('withStytchB2BClient', 'StytchB2BProvider'));
|
|
117
|
-
return React__default['default'].createElement(Component, Object.assign({}, props, { stytch: useStytchB2BClient() }));
|
|
118
|
-
};
|
|
119
|
-
WithStytch.displayName = `withStytch(${Component.displayName || Component.name || 'Component'})`;
|
|
120
|
-
return WithStytch;
|
|
121
|
-
};
|
|
122
|
-
const withStytchMember = (Component) => {
|
|
123
|
-
const WithStytchUser = (props) => {
|
|
124
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('withStytchMember', 'StytchB2BProvider'));
|
|
125
|
-
const { member, isInitialized, fromCache } = useStytchMember();
|
|
126
|
-
return (React__default['default'].createElement(Component, Object.assign({}, props, { stytchMember: member, stytchMemberIsInitialized: isInitialized, stytchMemberIsFromCache: fromCache })));
|
|
127
|
-
};
|
|
128
|
-
WithStytchUser.displayName = `withStytchMember(${Component.displayName || Component.name || 'Component'})`;
|
|
129
|
-
return WithStytchUser;
|
|
130
|
-
};
|
|
131
|
-
const withStytchMemberSession = (Component) => {
|
|
132
|
-
const WithStytchSession = (props) => {
|
|
133
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('withStytchMemberSession', 'StytchB2BProvider'));
|
|
134
|
-
const { session, isInitialized, fromCache } = useStytchMemberSession();
|
|
135
|
-
return (React__default['default'].createElement(Component, Object.assign({}, props, { stytchMemberSession: session, stytchMemberSessionIsInitialized: isInitialized, stytchMemberSessionIsFromCache: fromCache })));
|
|
136
|
-
};
|
|
137
|
-
WithStytchSession.displayName = `withStytchMemberSession(${Component.displayName || Component.name || 'Component'})`;
|
|
138
|
-
return WithStytchSession;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* The Stytch Context Provider.
|
|
142
|
-
* Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
|
|
143
|
-
* @example
|
|
144
|
-
* const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
145
|
-
*
|
|
146
|
-
* return (
|
|
147
|
-
* <StytchB2BProvider stytch={stytch}>
|
|
148
|
-
* <App />
|
|
149
|
-
* </StytchB2BProvider>
|
|
150
|
-
* )
|
|
151
|
-
*/
|
|
152
|
-
const StytchB2BProvider = ({ stytch, children }) => {
|
|
153
|
-
const ctx = React.useMemo(() => ({ client: stytch, isMounted: true }), [stytch]);
|
|
154
|
-
const [member, setMember] = useAsyncState(initialMember);
|
|
155
|
-
const [session, setMemberSession] = useAsyncState(initialMemberSession);
|
|
156
|
-
React.useEffect(() => {
|
|
157
|
-
if (isStytchSSRProxy(stytch)) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
setMember({
|
|
161
|
-
member: stytch.member.getSync(),
|
|
162
|
-
fromCache: true,
|
|
163
|
-
isInitialized: true,
|
|
164
|
-
});
|
|
165
|
-
setMemberSession({
|
|
166
|
-
session: stytch.session.getSync(),
|
|
167
|
-
fromCache: true,
|
|
168
|
-
isInitialized: true,
|
|
169
|
-
});
|
|
170
|
-
const unsubscribeMember = stytch.member.onChange((member) => setMember({ member, fromCache: false, isInitialized: true }));
|
|
171
|
-
const unsubscribeMemberSession = stytch.session.onChange((session) => setMemberSession({ session, fromCache: false, isInitialized: true }));
|
|
172
|
-
return () => {
|
|
173
|
-
unsubscribeMember();
|
|
174
|
-
unsubscribeMemberSession();
|
|
175
|
-
};
|
|
176
|
-
}, [stytch, setMember, setMemberSession]);
|
|
177
|
-
const finalMemberSession = !!session.session === !!member.member ? session : initialMemberSession;
|
|
178
|
-
const finalMember = !!session.session === !!member.member ? member : initialMember;
|
|
179
|
-
return (React__default['default'].createElement(StytchContext.Provider, { value: ctx },
|
|
180
|
-
React__default['default'].createElement(StytchMemberContext.Provider, { value: finalMember },
|
|
181
|
-
React__default['default'].createElement(StytchMemberSessionContext.Provider, { value: finalMemberSession }, children))));
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The Stytch B2B UI component.
|
|
186
|
-
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
187
|
-
* passed into the {@link StytchB2BProvider}
|
|
188
|
-
*
|
|
189
|
-
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* <StytchB2B
|
|
193
|
-
* config={{
|
|
194
|
-
* authFlowType: "Organization",
|
|
195
|
-
* emailMagicLinksOptions: {
|
|
196
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
197
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
198
|
-
* },
|
|
199
|
-
* ssoOptions: {
|
|
200
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
201
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
202
|
-
* },
|
|
203
|
-
* sessionOptions: {
|
|
204
|
-
* sessionDurationMinutes: 60,
|
|
205
|
-
* }
|
|
206
|
-
* }}
|
|
207
|
-
* styles={{
|
|
208
|
-
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
209
|
-
* primaryColor: '#0577CA',
|
|
210
|
-
* width: '321px',
|
|
211
|
-
* }}
|
|
212
|
-
* callbacks={{
|
|
213
|
-
* onEvent: (event) => console.log(event)
|
|
214
|
-
* }}
|
|
215
|
-
* />
|
|
216
|
-
* @param props {@link StytchB2BProps}
|
|
217
|
-
*/
|
|
218
|
-
const StytchB2B = ({ styles, callbacks, config }) => {
|
|
219
|
-
invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />'));
|
|
220
|
-
const stytchClient = useStytchB2BClient();
|
|
221
|
-
const containerEl = React.useRef(null);
|
|
222
|
-
React.useLayoutEffect(() => {
|
|
223
|
-
if (!isUIClient(stytchClient)) {
|
|
224
|
-
throw Error(noHeadlessClientError);
|
|
225
|
-
}
|
|
226
|
-
if (!containerEl.current) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (!containerEl.current.id) {
|
|
230
|
-
const randId = Math.floor(Math.random() * 1e6);
|
|
231
|
-
containerEl.current.id = `stytch-b2b-ui-${randId}`;
|
|
232
|
-
}
|
|
233
|
-
stytchClient.mount({
|
|
234
|
-
callbacks,
|
|
235
|
-
config,
|
|
236
|
-
elementId: `#${containerEl.current.id}`,
|
|
237
|
-
styles,
|
|
238
|
-
});
|
|
239
|
-
}, [stytchClient, styles, callbacks]);
|
|
240
|
-
return React__default['default'].createElement("div", { ref: containerEl });
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
exports.StytchB2B = StytchB2B;
|
|
244
|
-
exports.StytchB2BProvider = StytchB2BProvider;
|
|
245
|
-
exports.useStytchB2BClient = useStytchB2BClient;
|
|
246
|
-
exports.useStytchMember = useStytchMember;
|
|
247
|
-
exports.useStytchMemberSession = useStytchMemberSession;
|
|
248
|
-
exports.withStytchB2BClient = withStytchB2BClient;
|
|
249
|
-
exports.withStytchMember = withStytchMember;
|
|
250
|
-
exports.withStytchMemberSession = withStytchMemberSession;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StytchB2B = exports.withStytchMember = exports.withStytchMemberSession = exports.withStytchB2BClient = exports.useStytchMember = exports.useStytchMemberSession = exports.useStytchB2BClient = exports.StytchB2BProvider = void 0;
|
|
4
|
+
var StytchB2BContext_1 = require("./StytchB2BContext");
|
|
5
|
+
Object.defineProperty(exports, "StytchB2BProvider", { enumerable: true, get: function () { return StytchB2BContext_1.StytchB2BProvider; } });
|
|
6
|
+
Object.defineProperty(exports, "useStytchB2BClient", { enumerable: true, get: function () { return StytchB2BContext_1.useStytchB2BClient; } });
|
|
7
|
+
Object.defineProperty(exports, "useStytchMemberSession", { enumerable: true, get: function () { return StytchB2BContext_1.useStytchMemberSession; } });
|
|
8
|
+
Object.defineProperty(exports, "useStytchMember", { enumerable: true, get: function () { return StytchB2BContext_1.useStytchMember; } });
|
|
9
|
+
Object.defineProperty(exports, "withStytchB2BClient", { enumerable: true, get: function () { return StytchB2BContext_1.withStytchB2BClient; } });
|
|
10
|
+
Object.defineProperty(exports, "withStytchMemberSession", { enumerable: true, get: function () { return StytchB2BContext_1.withStytchMemberSession; } });
|
|
11
|
+
Object.defineProperty(exports, "withStytchMember", { enumerable: true, get: function () { return StytchB2BContext_1.withStytchMember; } });
|
|
12
|
+
var Stytch_1 = require("./Stytch");
|
|
13
|
+
Object.defineProperty(exports, "StytchB2B", { enumerable: true, get: function () { return Stytch_1.StytchB2B; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/b2b/index.ts"],"names":[],"mappings":";;;AAAA,uDAQ4B;AAP1B,qHAAA,iBAAiB,OAAA;AACjB,sHAAA,kBAAkB,OAAA;AAClB,0HAAA,sBAAsB,OAAA;AACtB,mHAAA,eAAe,OAAA;AACf,uHAAA,mBAAmB,OAAA;AACnB,2HAAA,uBAAuB,OAAA;AACvB,oHAAA,gBAAgB,OAAA;AAElB,mCAAqC;AAA5B,mGAAA,SAAS,OAAA"}
|
package/dist/b2b/index.ui.d.ts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
4
|
-
* The Stytch client is not available serverside.
|
|
5
|
-
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
6
|
-
* @example
|
|
7
|
-
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
8
|
-
*
|
|
9
|
-
* return (
|
|
10
|
-
* <StytchB2BProvider stytch={stytch}>
|
|
11
|
-
* <App />
|
|
12
|
-
* </StytchB2BProvider>
|
|
13
|
-
* )
|
|
14
|
-
* @returns A {@link StytchB2BUIClient}
|
|
15
|
-
*/
|
|
16
|
-
declare const createStytchB2BUIClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BUIClient;
|
|
17
|
-
export { createStytchB2BUIClient };
|
|
1
|
+
export * from './createStytchB2BUIClient';
|
package/dist/b2b/index.ui.js
CHANGED
|
@@ -1,66 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const cannotInvokeMethodOnServerError = (path) => `[Stytch] Invalid serverside function call to ${path}.
|
|
8
|
-
The Stytch Javascript SDK is intended to ony be used on the client side.
|
|
9
|
-
Make sure to wrap your API calls in a hook to ensure they are executed on the client.
|
|
10
|
-
\`\`\`
|
|
11
|
-
const myComponent = () => {
|
|
12
|
-
const stytch = useStytch();
|
|
13
|
-
// This will error out on the server.
|
|
14
|
-
stytch.magicLinks.authenticate(...);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
// This will work well
|
|
17
|
-
stytch.magicLinks.authenticate(...);
|
|
18
|
-
}, []);
|
|
19
|
-
}
|
|
20
|
-
\`\`\`
|
|
21
|
-
|
|
22
|
-
If you want to make API calls from server environments, please use the Stytch Node Library
|
|
23
|
-
https://www.npmjs.com/package/stytch.
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const SSRStubKey = Symbol('__stytch_SSRStubKey');
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
const createProxy = (path) => {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
30
|
-
const noop = () => { };
|
|
31
|
-
return new Proxy(noop, {
|
|
32
|
-
get(target, p) {
|
|
33
|
-
if (p === SSRStubKey) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
return createProxy(path + '.' + String(p));
|
|
37
|
-
},
|
|
38
|
-
apply() {
|
|
39
|
-
throw new Error(cannotInvokeMethodOnServerError(path));
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
const createStytchSSRProxy = () => createProxy('stytch');
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
47
|
-
* The Stytch client is not available serverside.
|
|
48
|
-
* If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
|
|
49
|
-
* @example
|
|
50
|
-
* const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
|
|
51
|
-
*
|
|
52
|
-
* return (
|
|
53
|
-
* <StytchB2BProvider stytch={stytch}>
|
|
54
|
-
* <App />
|
|
55
|
-
* </StytchB2BProvider>
|
|
56
|
-
* )
|
|
57
|
-
* @returns A {@link StytchB2BUIClient}
|
|
58
|
-
*/
|
|
59
|
-
const createStytchB2BUIClient = (...args) => {
|
|
60
|
-
if (typeof window === 'undefined') {
|
|
61
|
-
return createStytchSSRProxy();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
62
7
|
}
|
|
63
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
64
15
|
};
|
|
65
|
-
|
|
66
|
-
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createStytchB2BUIClient"), exports);
|
|
18
|
+
//# sourceMappingURL=index.ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.ui.js","sourceRoot":"","sources":["../../src/b2b/index.ui.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StytchHeadlessClient } from '@stytch/vanilla-js/headless';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Headless Stytch client object to call the stytch APIs.
|
|
4
|
+
* The Stytch client is not available serverside.
|
|
5
|
+
* @example
|
|
6
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
7
|
+
*
|
|
8
|
+
* return (
|
|
9
|
+
* <StytchProvider stytch={stytch}>
|
|
10
|
+
* <App />
|
|
11
|
+
* </StytchProvider>
|
|
12
|
+
* )
|
|
13
|
+
* @returns A {@link StytchHeadlessClient}
|
|
14
|
+
*/
|
|
15
|
+
export declare const createStytchHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("packages/core/dist/public").StytchClientOptions | undefined) => StytchHeadlessClient;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStytchHeadlessClient = void 0;
|
|
4
|
+
const headless_1 = require("@stytch/vanilla-js/headless");
|
|
5
|
+
const StytchSSRProxy_1 = require("./StytchSSRProxy");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Headless Stytch client object to call the stytch APIs.
|
|
8
|
+
* The Stytch client is not available serverside.
|
|
9
|
+
* @example
|
|
10
|
+
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
11
|
+
*
|
|
12
|
+
* return (
|
|
13
|
+
* <StytchProvider stytch={stytch}>
|
|
14
|
+
* <App />
|
|
15
|
+
* </StytchProvider>
|
|
16
|
+
* )
|
|
17
|
+
* @returns A {@link StytchHeadlessClient}
|
|
18
|
+
*/
|
|
19
|
+
const createStytchHeadlessClient = (...args) => {
|
|
20
|
+
if (typeof window === 'undefined') {
|
|
21
|
+
return (0, StytchSSRProxy_1.createStytchSSRProxy)();
|
|
22
|
+
}
|
|
23
|
+
return new headless_1.StytchHeadlessClient(...args);
|
|
24
|
+
};
|
|
25
|
+
exports.createStytchHeadlessClient = createStytchHeadlessClient;
|
|
26
|
+
//# sourceMappingURL=createStytchHeadlessClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createStytchHeadlessClient.js","sourceRoot":"","sources":["../src/createStytchHeadlessClient.ts"],"names":[],"mappings":";;;AAAA,0DAAmE;AACnE,qDAAwD;AAExD;;;;;;;;;;;;GAYG;AACI,MAAM,0BAA0B,GAAG,CACxC,GAAG,IAAwD,EACrC,EAAE;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,IAAA,qCAAoB,GAAE,CAAC;KAC/B;IACD,OAAO,IAAI,+BAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC;AAPW,QAAA,0BAA0B,8BAOrC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StytchUIClient } from '@stytch/vanilla-js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
4
|
+
* The Stytch client is not available serverside.
|
|
5
|
+
* If you do not use Stytch UI components, use {@link createStytchHeadlessClient} to reduce your bundle size.
|
|
6
|
+
* @example
|
|
7
|
+
* const stytch = createStytchUIClient('public-token-<find yours in the stytch dashboard>')
|
|
8
|
+
*
|
|
9
|
+
* return (
|
|
10
|
+
* <StytchProvider stytch={stytch}>
|
|
11
|
+
* <App />
|
|
12
|
+
* </StytchProvider>
|
|
13
|
+
* )
|
|
14
|
+
* @returns A {@link StytchUIClient}
|
|
15
|
+
*/
|
|
16
|
+
export declare const createStytchUIClient: (_PUBLIC_TOKEN: string, options?: import("packages/core/dist/public").StytchClientOptions | undefined) => StytchUIClient;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStytchUIClient = void 0;
|
|
4
|
+
const vanilla_js_1 = require("@stytch/vanilla-js");
|
|
5
|
+
const StytchSSRProxy_1 = require("./StytchSSRProxy");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
|
|
8
|
+
* The Stytch client is not available serverside.
|
|
9
|
+
* If you do not use Stytch UI components, use {@link createStytchHeadlessClient} to reduce your bundle size.
|
|
10
|
+
* @example
|
|
11
|
+
* const stytch = createStytchUIClient('public-token-<find yours in the stytch dashboard>')
|
|
12
|
+
*
|
|
13
|
+
* return (
|
|
14
|
+
* <StytchProvider stytch={stytch}>
|
|
15
|
+
* <App />
|
|
16
|
+
* </StytchProvider>
|
|
17
|
+
* )
|
|
18
|
+
* @returns A {@link StytchUIClient}
|
|
19
|
+
*/
|
|
20
|
+
const createStytchUIClient = (...args) => {
|
|
21
|
+
if (typeof window === 'undefined') {
|
|
22
|
+
return (0, StytchSSRProxy_1.createStytchSSRProxy)();
|
|
23
|
+
}
|
|
24
|
+
return new vanilla_js_1.StytchUIClient(...args);
|
|
25
|
+
};
|
|
26
|
+
exports.createStytchUIClient = createStytchUIClient;
|
|
27
|
+
//# sourceMappingURL=createStytchUIClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createStytchUIClient.js","sourceRoot":"","sources":["../src/createStytchUIClient.ts"],"names":[],"mappings":";;;AAAA,mDAAoD;AACpD,qDAAwD;AAExD;;;;;;;;;;;;;GAaG;AACI,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAkD,EAAkB,EAAE;IAC5G,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,IAAA,qCAAoB,GAAE,CAAC;KAC/B;IACD,OAAO,IAAI,2BAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC;AALW,QAAA,oBAAoB,wBAK/B"}
|