@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/dist/StytchContext.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
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]; } };
|
|
7
|
-
}
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.StytchProvider = exports.withStytchSession = exports.withStytchUser = exports.withStytch = exports.useStytch = exports.useStytchSession = exports.useStytchUser = exports.isUIClient = exports.useIsMounted__INTERNAL = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const errors_1 = require("./utils/errors");
|
|
29
|
-
const invariant_1 = require("./utils/invariant");
|
|
30
|
-
const async_1 = require("./utils/async");
|
|
31
|
-
const StytchSSRProxy_1 = require("./StytchSSRProxy");
|
|
32
|
-
const initialUser = {
|
|
33
|
-
user: null,
|
|
34
|
-
fromCache: false,
|
|
35
|
-
isInitialized: false,
|
|
36
|
-
};
|
|
37
|
-
const initialSession = {
|
|
38
|
-
session: null,
|
|
39
|
-
fromCache: false,
|
|
40
|
-
isInitialized: false,
|
|
41
|
-
};
|
|
42
|
-
const StytchContext = (0, react_1.createContext)({ isMounted: false });
|
|
43
|
-
const StytchUserContext = (0, react_1.createContext)(initialUser);
|
|
44
|
-
const StytchSessionContext = (0, react_1.createContext)(initialSession);
|
|
45
|
-
const useIsMounted__INTERNAL = () => (0, react_1.useContext)(StytchContext).isMounted;
|
|
46
|
-
exports.useIsMounted__INTERNAL = useIsMounted__INTERNAL;
|
|
47
|
-
const isUIClient = (client) => {
|
|
48
|
-
return client.mountLogin !== undefined;
|
|
49
|
-
};
|
|
50
|
-
exports.isUIClient = isUIClient;
|
|
51
|
-
/**
|
|
52
|
-
* Returns the active User.
|
|
53
|
-
* The Stytch SDKs are used for client-side authentication and session management.
|
|
54
|
-
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
55
|
-
* 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
|
-
* @example
|
|
58
|
-
* const {user, isInitialized, fromCache} = useStytchUser();
|
|
59
|
-
* if (!isInitialized) {
|
|
60
|
-
* return <p>Loading...</p>;
|
|
61
|
-
* }
|
|
62
|
-
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
63
|
-
*/
|
|
64
|
-
const useStytchUser = () => {
|
|
65
|
-
(0, invariant_1.invariant)((0, exports.useIsMounted__INTERNAL)(), (0, errors_1.noProviderError)('useStytchUser'));
|
|
66
|
-
return (0, react_1.useContext)(StytchUserContext);
|
|
67
|
-
};
|
|
68
|
-
exports.useStytchUser = useStytchUser;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the user's active Stytch session.
|
|
71
|
-
* The Stytch SDKs are used for client-side authentication and session management.
|
|
72
|
-
* Check the isInitialized property to determine if the SDK has completed initialization.
|
|
73
|
-
* Check the fromCache property to determine if the session data is from persistent storage.
|
|
74
|
-
* See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
|
|
75
|
-
* @example
|
|
76
|
-
* const {session, isInitialized, fromCache} = useStytchSession();
|
|
77
|
-
* useEffect(() => {
|
|
78
|
-
* if (!isInitialized) {
|
|
79
|
-
* return;
|
|
80
|
-
* }
|
|
81
|
-
* if (!session) {
|
|
82
|
-
* router.replace('/login')
|
|
83
|
-
* }
|
|
84
|
-
* }, [session, isInitialized]);
|
|
85
|
-
*/
|
|
86
|
-
const useStytchSession = () => {
|
|
87
|
-
(0, invariant_1.invariant)((0, exports.useIsMounted__INTERNAL)(), (0, errors_1.noProviderError)('useStytchSession'));
|
|
88
|
-
return (0, react_1.useContext)(StytchSessionContext);
|
|
89
|
-
};
|
|
90
|
-
exports.useStytchSession = useStytchSession;
|
|
91
|
-
/**
|
|
92
|
-
* Returns the Stytch client stored in the Stytch context.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* const stytch = useStytch();
|
|
96
|
-
* useEffect(() => {
|
|
97
|
-
* stytch.magicLinks.authenticate('...')
|
|
98
|
-
* }, [stytch]);
|
|
99
|
-
*/
|
|
100
|
-
const useStytch = () => {
|
|
101
|
-
const ctx = (0, react_1.useContext)(StytchContext);
|
|
102
|
-
(0, invariant_1.invariant)(ctx.isMounted, (0, errors_1.noProviderError)('useStytch'));
|
|
103
|
-
return ctx.client;
|
|
104
|
-
};
|
|
105
|
-
exports.useStytch = useStytch;
|
|
106
|
-
const withStytch = (Component) => {
|
|
107
|
-
const WithStytch = (props) => {
|
|
108
|
-
(0, invariant_1.invariant)((0, exports.useIsMounted__INTERNAL)(), (0, errors_1.noProviderError)('withStytch'));
|
|
109
|
-
return react_1.default.createElement(Component, Object.assign({}, props, { stytch: (0, exports.useStytch)() }));
|
|
110
|
-
};
|
|
111
|
-
WithStytch.displayName = `withStytch(${Component.displayName || Component.name || 'Component'})`;
|
|
112
|
-
return WithStytch;
|
|
113
|
-
};
|
|
114
|
-
exports.withStytch = withStytch;
|
|
115
|
-
const withStytchUser = (Component) => {
|
|
116
|
-
const WithStytchUser = (props) => {
|
|
117
|
-
(0, invariant_1.invariant)((0, exports.useIsMounted__INTERNAL)(), (0, errors_1.noProviderError)('withStytchUser'));
|
|
118
|
-
const { user, isInitialized, fromCache } = (0, exports.useStytchUser)();
|
|
119
|
-
return (react_1.default.createElement(Component, Object.assign({}, props, { stytchUser: user, stytchUserIsInitialized: isInitialized, stytchUserIsFromCache: fromCache })));
|
|
120
|
-
};
|
|
121
|
-
WithStytchUser.displayName = `withStytchUser(${Component.displayName || Component.name || 'Component'})`;
|
|
122
|
-
return WithStytchUser;
|
|
123
|
-
};
|
|
124
|
-
exports.withStytchUser = withStytchUser;
|
|
125
|
-
const withStytchSession = (Component) => {
|
|
126
|
-
const WithStytchSession = (props) => {
|
|
127
|
-
(0, invariant_1.invariant)((0, exports.useIsMounted__INTERNAL)(), (0, errors_1.noProviderError)('withStytchSession'));
|
|
128
|
-
const { session, isInitialized, fromCache } = (0, exports.useStytchSession)();
|
|
129
|
-
return (react_1.default.createElement(Component, Object.assign({}, props, { stytchSession: session, stytchSessionIsInitialized: isInitialized, stytchSessionIsFromCache: fromCache })));
|
|
130
|
-
};
|
|
131
|
-
WithStytchSession.displayName = `withStytchSession(${Component.displayName || Component.name || 'Component'})`;
|
|
132
|
-
return WithStytchSession;
|
|
133
|
-
};
|
|
134
|
-
exports.withStytchSession = withStytchSession;
|
|
135
|
-
/**
|
|
136
|
-
* The Stytch Context Provider.
|
|
137
|
-
* Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
|
|
138
|
-
* @example
|
|
139
|
-
* const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
140
|
-
*
|
|
141
|
-
* return (
|
|
142
|
-
* <StytchProvider stytch={stytch}>
|
|
143
|
-
* <App />
|
|
144
|
-
* </StytchProvider>
|
|
145
|
-
* )
|
|
146
|
-
*/
|
|
147
|
-
const StytchProvider = ({ stytch, children }) => {
|
|
148
|
-
const ctx = (0, react_1.useMemo)(() => ({ client: stytch, isMounted: true }), [stytch]);
|
|
149
|
-
const [user, setUser] = (0, async_1.useAsyncState)(initialUser);
|
|
150
|
-
const [session, setSession] = (0, async_1.useAsyncState)(initialSession);
|
|
151
|
-
(0, react_1.useEffect)(() => {
|
|
152
|
-
if ((0, StytchSSRProxy_1.isStytchSSRProxy)(stytch)) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
setUser({
|
|
156
|
-
user: stytch.user.getSync(),
|
|
157
|
-
fromCache: true,
|
|
158
|
-
isInitialized: true,
|
|
159
|
-
});
|
|
160
|
-
setSession({
|
|
161
|
-
session: stytch.session.getSync(),
|
|
162
|
-
fromCache: true,
|
|
163
|
-
isInitialized: true,
|
|
164
|
-
});
|
|
165
|
-
const unsubscribeUser = stytch.user.onChange((user) => setUser({ user, fromCache: false, isInitialized: true }));
|
|
166
|
-
const unsubscribeSession = stytch.session.onChange((session) => setSession({ session, fromCache: false, isInitialized: true }));
|
|
167
|
-
return () => {
|
|
168
|
-
unsubscribeUser();
|
|
169
|
-
unsubscribeSession();
|
|
170
|
-
};
|
|
171
|
-
}, [stytch, setUser, setSession]);
|
|
172
|
-
// TODO (SDK-813): Remove this when we have a single top-level onChange handler
|
|
173
|
-
const finalSess = !!session.session === !!user.user ? session : initialSession;
|
|
174
|
-
const finalUser = !!session.session === !!user.user ? user : initialUser;
|
|
175
|
-
return (react_1.default.createElement(StytchContext.Provider, { value: ctx },
|
|
176
|
-
react_1.default.createElement(StytchUserContext.Provider, { value: finalUser },
|
|
177
|
-
react_1.default.createElement(StytchSessionContext.Provider, { value: finalSess }, children))));
|
|
178
|
-
};
|
|
179
|
-
exports.StytchProvider = StytchProvider;
|
|
180
|
-
//# sourceMappingURL=StytchContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StytchContext.js","sourceRoot":"","sources":["../src/StytchContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuG;AAIvG,2CAAiD;AACjD,iDAA8C;AAC9C,yCAA8C;AAC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,IAAC,KAAK,EAAE,GAAG;QAChC,8BAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS;YAC1C,8BAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,IAAG,QAAQ,CAAiC,CAChE,CACN,CAC1B,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,cAAc,kBAyCzB"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @jest-environment node
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
const react_1 = __importDefault(require("react"));
|
|
42
|
-
const ReactDOMServer = __importStar(require("react-dom/server"));
|
|
43
|
-
const StytchContext_1 = require("./StytchContext");
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
const mockStytchClient = { isSSRStub: true };
|
|
46
|
-
describe('StytchContext', () => {
|
|
47
|
-
it('Renders nothing initially - and in SSR environments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
expect(ReactDOMServer.renderToString(react_1.default.createElement(StytchContext_1.StytchProvider, { stytch: mockStytchClient }))).toMatchInlineSnapshot(`""`);
|
|
49
|
-
}));
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=StytchContext.serverside.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StytchContext.serverside.spec.js","sourceRoot":"","sources":["../src/StytchContext.serverside.spec.tsx"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAA0B;AAC1B,iEAAmD;AAEnD,mDAAiD;AAEjD,8DAA8D;AAC9D,MAAM,gBAAgB,GAAG,EAAE,SAAS,EAAE,IAAI,EAAS,CAAC;AAEpD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,qDAAqD,EAAE,GAAS,EAAE;QACnE,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,8BAAC,8BAAc,IAAC,MAAM,EAAE,gBAAgB,GAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAClH,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,212 +0,0 @@
|
|
|
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]; } };
|
|
7
|
-
}
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
const react_1 = __importStar(require("react"));
|
|
36
|
-
const react_2 = require("@testing-library/react");
|
|
37
|
-
const StytchContext_1 = require("./StytchContext");
|
|
38
|
-
const errors_1 = require("./utils/errors");
|
|
39
|
-
const captureValue = jest.fn();
|
|
40
|
-
const userUnsubscribeStub = jest.fn();
|
|
41
|
-
const sessionUnsubscribeStub = jest.fn();
|
|
42
|
-
const mockStytchClient = {
|
|
43
|
-
user: { getSync: jest.fn(), onChange: jest.fn().mockReturnValue(userUnsubscribeStub) },
|
|
44
|
-
session: { getSync: jest.fn(), onChange: jest.fn().mockReturnValue(sessionUnsubscribeStub) },
|
|
45
|
-
magicLinks: { authenticate: jest.fn() },
|
|
46
|
-
mount: jest.fn(),
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
};
|
|
49
|
-
const testUser = {
|
|
50
|
-
user_id: 'test-user-123',
|
|
51
|
-
};
|
|
52
|
-
const testSession = {
|
|
53
|
-
expires_at: new Date(Date.now() + 10000).toUTCString(),
|
|
54
|
-
session_id: 'test-session-123',
|
|
55
|
-
};
|
|
56
|
-
describe('StytchContext', () => {
|
|
57
|
-
const renderWithProvider = (ui, stytch = mockStytchClient) => (0, react_2.render)(react_1.default.createElement(StytchContext_1.StytchProvider, { stytch: stytch }, ui));
|
|
58
|
-
it('normal usage', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
(0, react_2.render)(react_1.default.createElement(StytchContext_1.StytchProvider, { stytch: mockStytchClient }));
|
|
60
|
-
expect(mockStytchClient.user.onChange).toHaveBeenCalled();
|
|
61
|
-
expect(mockStytchClient.session.onChange).toHaveBeenCalled();
|
|
62
|
-
}));
|
|
63
|
-
const UseStytchTest = () => {
|
|
64
|
-
const stytch = (0, StytchContext_1.useStytch)();
|
|
65
|
-
(0, react_1.useEffect)(() => {
|
|
66
|
-
stytch.magicLinks.authenticate('use-stytch-test-token', { session_duration_minutes: 1 });
|
|
67
|
-
}, [stytch]);
|
|
68
|
-
return null;
|
|
69
|
-
};
|
|
70
|
-
it('useStytch passes the Stytch client into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
renderWithProvider(react_1.default.createElement(UseStytchTest, null));
|
|
72
|
-
expect(mockStytchClient.magicLinks.authenticate).toHaveBeenCalledWith('use-stytch-test-token', {
|
|
73
|
-
session_duration_minutes: 1,
|
|
74
|
-
});
|
|
75
|
-
}));
|
|
76
|
-
const WithStytchTest = (0, StytchContext_1.withStytch)(({ stytch }) => {
|
|
77
|
-
(0, react_1.useEffect)(() => {
|
|
78
|
-
stytch.magicLinks.authenticate('with-stytch-test-token', { session_duration_minutes: 1 });
|
|
79
|
-
}, [stytch]);
|
|
80
|
-
return null;
|
|
81
|
-
});
|
|
82
|
-
it('withStytch passes the Stytch client into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
renderWithProvider(react_1.default.createElement(WithStytchTest, null));
|
|
84
|
-
expect(mockStytchClient.magicLinks.authenticate).toHaveBeenCalledWith('with-stytch-test-token', {
|
|
85
|
-
session_duration_minutes: 1,
|
|
86
|
-
});
|
|
87
|
-
}));
|
|
88
|
-
const UseStytchUserTest = () => {
|
|
89
|
-
const user = (0, StytchContext_1.useStytchUser)();
|
|
90
|
-
(0, react_1.useEffect)(() => {
|
|
91
|
-
captureValue(user);
|
|
92
|
-
}, [user]);
|
|
93
|
-
return null;
|
|
94
|
-
};
|
|
95
|
-
it('useStytchUser passes the Stytch User into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
// If the session isn't yet in the context, avoid race conditions! Don't force a render just yet
|
|
97
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
98
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(null);
|
|
99
|
-
renderWithProvider(react_1.default.createElement(UseStytchUserTest, null));
|
|
100
|
-
expect(captureValue).toBeCalledWith({ fromCache: false, isInitialized: false, user: null });
|
|
101
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
102
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
103
|
-
renderWithProvider(react_1.default.createElement(UseStytchUserTest, null));
|
|
104
|
-
expect(captureValue).toBeCalledWith({ fromCache: true, isInitialized: true, user: testUser });
|
|
105
|
-
}));
|
|
106
|
-
const WithStytchUserTest = (0, StytchContext_1.withStytchUser)(({ stytchUser }) => {
|
|
107
|
-
(0, react_1.useEffect)(() => {
|
|
108
|
-
captureValue(stytchUser);
|
|
109
|
-
}, [stytchUser]);
|
|
110
|
-
return null;
|
|
111
|
-
});
|
|
112
|
-
it('withStytchUser passes the Stytch User into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
// If the session isn't yet in the context, avoid race conditions! Don't force a render just yet
|
|
114
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
115
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(null);
|
|
116
|
-
renderWithProvider(react_1.default.createElement(WithStytchUserTest, null));
|
|
117
|
-
expect(captureValue).toBeCalledWith(null);
|
|
118
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
119
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
120
|
-
renderWithProvider(react_1.default.createElement(WithStytchUserTest, null));
|
|
121
|
-
expect(captureValue).toBeCalledWith(testUser);
|
|
122
|
-
}));
|
|
123
|
-
const UseStytchSessionTest = () => {
|
|
124
|
-
const session = (0, StytchContext_1.useStytchSession)();
|
|
125
|
-
(0, react_1.useEffect)(() => {
|
|
126
|
-
captureValue(session);
|
|
127
|
-
}, [session]);
|
|
128
|
-
return null;
|
|
129
|
-
};
|
|
130
|
-
it('useStytchSession passes the Stytch Session into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
-
// If the session isn't yet in the context, avoid race conditions! Don't force a render just yet
|
|
132
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(null);
|
|
133
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
134
|
-
renderWithProvider(react_1.default.createElement(UseStytchSessionTest, null));
|
|
135
|
-
expect(captureValue).toBeCalledWith({ fromCache: false, isInitialized: false, session: null });
|
|
136
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
137
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
138
|
-
renderWithProvider(react_1.default.createElement(UseStytchSessionTest, null));
|
|
139
|
-
expect(captureValue).toBeCalledWith({ fromCache: true, isInitialized: true, session: testSession });
|
|
140
|
-
}));
|
|
141
|
-
const WithStytchSessionTest = (0, StytchContext_1.withStytchSession)(({ stytchSession }) => {
|
|
142
|
-
(0, react_1.useEffect)(() => {
|
|
143
|
-
captureValue(stytchSession);
|
|
144
|
-
}, [stytchSession]);
|
|
145
|
-
return null;
|
|
146
|
-
});
|
|
147
|
-
it('withStytchSession passes the Stytch Session into the component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
-
// If the session isn't yet in the context, avoid race conditions! Don't force a render just yet
|
|
149
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(null);
|
|
150
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
151
|
-
renderWithProvider(react_1.default.createElement(WithStytchSessionTest, null));
|
|
152
|
-
expect(captureValue).toBeCalledWith(null);
|
|
153
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(testUser);
|
|
154
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(testSession);
|
|
155
|
-
renderWithProvider(react_1.default.createElement(WithStytchSessionTest, null));
|
|
156
|
-
expect(captureValue).toBeCalledWith(testSession);
|
|
157
|
-
}));
|
|
158
|
-
const LoginTest = () => {
|
|
159
|
-
const user = (0, StytchContext_1.useStytchUser)();
|
|
160
|
-
const session = (0, StytchContext_1.useStytchSession)();
|
|
161
|
-
captureValue({ user, session });
|
|
162
|
-
return null;
|
|
163
|
-
};
|
|
164
|
-
it('Login and Logout events cause state changes inside the components', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
-
mockStytchClient.user.getSync.mockReturnValueOnce(null);
|
|
166
|
-
mockStytchClient.session.getSync.mockReturnValueOnce(null);
|
|
167
|
-
const userListenerProm = new Promise((captureValue) => mockStytchClient.user.onChange.mockImplementation((listener) => {
|
|
168
|
-
captureValue(listener);
|
|
169
|
-
return userUnsubscribeStub;
|
|
170
|
-
}));
|
|
171
|
-
const sessionListenerProm = new Promise((captureValue) => mockStytchClient.session.onChange.mockImplementation((listener) => {
|
|
172
|
-
captureValue(listener);
|
|
173
|
-
return sessionUnsubscribeStub;
|
|
174
|
-
}));
|
|
175
|
-
// Initial render: nobody is logged in
|
|
176
|
-
renderWithProvider(react_1.default.createElement(LoginTest, null));
|
|
177
|
-
expect(captureValue).toHaveBeenCalledWith({
|
|
178
|
-
user: { fromCache: false, isInitialized: false, user: null },
|
|
179
|
-
session: { fromCache: false, isInitialized: false, session: null },
|
|
180
|
-
});
|
|
181
|
-
const userListener = yield userListenerProm;
|
|
182
|
-
const sessionListener = yield sessionListenerProm;
|
|
183
|
-
// A login event occurs, and a rerender follows
|
|
184
|
-
(0, react_2.act)(() => {
|
|
185
|
-
userListener(testUser);
|
|
186
|
-
sessionListener(testSession);
|
|
187
|
-
});
|
|
188
|
-
expect(captureValue).toHaveBeenCalledWith({
|
|
189
|
-
user: { fromCache: false, isInitialized: true, user: testUser },
|
|
190
|
-
session: { fromCache: false, isInitialized: true, session: testSession },
|
|
191
|
-
});
|
|
192
|
-
captureValue.mockClear();
|
|
193
|
-
// A logout event occurs, and a rerender follows
|
|
194
|
-
(0, react_2.act)(() => {
|
|
195
|
-
userListener(null);
|
|
196
|
-
sessionListener(null);
|
|
197
|
-
});
|
|
198
|
-
expect(captureValue).toHaveBeenCalledWith({
|
|
199
|
-
user: { fromCache: false, isInitialized: true, user: null },
|
|
200
|
-
session: { fromCache: false, isInitialized: true, session: null },
|
|
201
|
-
});
|
|
202
|
-
}));
|
|
203
|
-
it('no provider errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
204
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(UseStytchTest, null))).toThrow((0, errors_1.noProviderError)('useStytch'));
|
|
205
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(WithStytchTest, null))).toThrow((0, errors_1.noProviderError)('withStytch'));
|
|
206
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(UseStytchUserTest, null))).toThrow((0, errors_1.noProviderError)('useStytchUser'));
|
|
207
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(WithStytchUserTest, null))).toThrow((0, errors_1.noProviderError)('withStytchUser'));
|
|
208
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(UseStytchSessionTest, null))).toThrow((0, errors_1.noProviderError)('useStytchSession'));
|
|
209
|
-
expect(() => (0, react_2.render)(react_1.default.createElement(WithStytchSessionTest, null))).toThrow((0, errors_1.noProviderError)('withStytchSession'));
|
|
210
|
-
}));
|
|
211
|
-
});
|
|
212
|
-
//# sourceMappingURL=StytchContext.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StytchContext.spec.js","sourceRoot":"","sources":["../src/StytchContext.spec.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuD;AACvD,kDAAqD;AAErD,mDASyB;AACzB,2CAAiD;AAEjD,M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C,CAAA,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,GAAS,EAAE;QAClC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,aAAa,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,WAAW,CAAC,CAAC,CAAC;QAC9E,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,cAAc,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,YAAY,CAAC,CAAC,CAAC;QAChF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,iBAAiB,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,eAAe,CAAC,CAAC,CAAC;QACtF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,kBAAkB,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,gBAAgB,CAAC,CAAC,CAAC;QACxF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,oBAAoB,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,kBAAkB,CAAC,CAAC,CAAC;QAC5F,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,cAAM,EAAC,8BAAC,qBAAqB,OAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAe,EAAC,mBAAmB,CAAC,CAAC,CAAC;IAChG,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/StytchSSRProxy.d.ts
DELETED
package/dist/StytchSSRProxy.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStytchSSRProxy = exports.isStytchSSRProxy = void 0;
|
|
4
|
-
const errors_1 = require("./utils/errors");
|
|
5
|
-
const SSRStubKey = Symbol('__stytch_SSRStubKey');
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
const isStytchSSRProxy = (proxy) => {
|
|
8
|
-
return !!proxy[SSRStubKey];
|
|
9
|
-
};
|
|
10
|
-
exports.isStytchSSRProxy = isStytchSSRProxy;
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
const createProxy = (path) => {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
14
|
-
const noop = () => { };
|
|
15
|
-
return new Proxy(noop, {
|
|
16
|
-
get(target, p) {
|
|
17
|
-
if (p === SSRStubKey) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return createProxy(path + '.' + String(p));
|
|
21
|
-
},
|
|
22
|
-
apply() {
|
|
23
|
-
throw new Error((0, errors_1.cannotInvokeMethodOnServerError)(path));
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
const createStytchSSRProxy = () => createProxy('stytch');
|
|
28
|
-
exports.createStytchSSRProxy = createStytchSSRProxy;
|
|
29
|
-
//# sourceMappingURL=StytchSSRProxy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StytchSSRProxy.js","sourceRoot":"","sources":["../src/StytchSSRProxy.ts"],"names":[],"mappings":";;;AAAA,2CAAiE;AAEjE,MAAM,UAAU,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAEjD,8DAA8D;AACvD,MAAM,gBAAgB,GAAG,CAAC,KAAU,EAAW,EAAE;IACtD,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF,8DAA8D;AAC9D,MAAM,WAAW,GAAG,CAAC,IAAY,EAAO,EAAE;IACxC,gEAAgE;IAChE,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IACtB,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;QACrB,GAAG,CAAC,MAAe,EAAE,CAAkB;YACrC,IAAK,CAAY,KAAK,UAAU,EAAE;gBAChC,OAAO,IAAI,CAAC;aACb;YACD,OAAO,WAAW,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK;YACH,MAAM,IAAI,KAAK,CAAC,IAAA,wCAA+B,EAAC,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAAnD,QAAA,oBAAoB,wBAA+B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const StytchSSRProxy_1 = require("./StytchSSRProxy");
|
|
4
|
-
const errors_1 = require("./utils/errors");
|
|
5
|
-
describe('StytchSSRProxy', () => {
|
|
6
|
-
it('Throws an error when a user attempts to invoke any Stytch API methods on the serverside', () => {
|
|
7
|
-
const proxy = (0, StytchSSRProxy_1.createStytchSSRProxy)();
|
|
8
|
-
expect(() => proxy.magicLinks.authenticate('foo')).toThrow((0, errors_1.cannotInvokeMethodOnServerError)('stytch.magicLinks.authenticate'));
|
|
9
|
-
});
|
|
10
|
-
it('Can be identified as a proxy', () => {
|
|
11
|
-
const proxy = (0, StytchSSRProxy_1.createStytchSSRProxy)();
|
|
12
|
-
expect((0, StytchSSRProxy_1.isStytchSSRProxy)(proxy)).toBe(true);
|
|
13
|
-
expect((0, StytchSSRProxy_1.isStytchSSRProxy)({})).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=StytchSSRProxy.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StytchSSRProxy.spec.js","sourceRoot":"","sources":["../src/StytchSSRProxy.spec.ts"],"names":[],"mappings":";;AAAA,qDAA0E;AAC1E,2CAAiE;AAEjE,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,yFAAyF,EAAE,GAAG,EAAE;QACjG,MAAM,KAAK,GAAG,IAAA,qCAAoB,GAAE,CAAC;QACrC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CACxD,IAAA,wCAA+B,EAAC,gCAAgC,CAAC,CAClE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,KAAK,GAAG,IAAA,qCAAoB,GAAE,CAAC;QACrC,MAAM,CAAC,IAAA,iCAAgB,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAA,iCAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/b2b/Stytch.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Callbacks, StyleConfig, StytchB2BUIConfig } from '@stytch/vanilla-js';
|
|
3
|
-
export interface StytchB2BProps {
|
|
4
|
-
/**
|
|
5
|
-
* An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* {
|
|
9
|
-
* fontFamily: 'Arial, Helvetica, sans-serif',
|
|
10
|
-
* width: '360px',
|
|
11
|
-
* primaryColor: '#19303D',
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
styles?: StyleConfig;
|
|
15
|
-
/**
|
|
16
|
-
* An optional {@link Callbacks} object.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* {
|
|
20
|
-
* onError: ({message}) => {
|
|
21
|
-
* console.error('Stytch error', message)
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* {
|
|
27
|
-
* onEvent: ({type, data}) => {
|
|
28
|
-
* if(type === StytchEventType.B2BMagicLinkAuthenticate) {
|
|
29
|
-
* console.log('Logged in with', data);
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
*/
|
|
34
|
-
callbacks?: Callbacks;
|
|
35
|
-
/**
|
|
36
|
-
* A {@link StytchB2BUIConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* {
|
|
41
|
-
* products: ['emailMagicLinks'],
|
|
42
|
-
* authFlowType: "Discovery",
|
|
43
|
-
* emailMagicLinksOptions: {
|
|
44
|
-
* discoveryRedirectURL: 'https://example.com/authenticate',
|
|
45
|
-
* },
|
|
46
|
-
* sessionOptions: {
|
|
47
|
-
* sessionDurationMinutes: 60,
|
|
48
|
-
* },
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* {
|
|
53
|
-
* products: ['emailMagicLinks', 'sso'],
|
|
54
|
-
* authFlowType: "Organization",
|
|
55
|
-
* emailMagicLinksOptions: {
|
|
56
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
57
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
58
|
-
* },
|
|
59
|
-
* ssoOptions: {
|
|
60
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
61
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
62
|
-
* },
|
|
63
|
-
* sessionOptions: {
|
|
64
|
-
* sessionDurationMinutes: 60,
|
|
65
|
-
* },
|
|
66
|
-
* }
|
|
67
|
-
*/
|
|
68
|
-
config: StytchB2BUIConfig;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* The Stytch B2B UI component.
|
|
72
|
-
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
73
|
-
* passed into the {@link StytchB2BProvider}
|
|
74
|
-
*
|
|
75
|
-
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* <StytchB2B
|
|
79
|
-
* config={{
|
|
80
|
-
* authFlowType: "Organization",
|
|
81
|
-
* emailMagicLinksOptions: {
|
|
82
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
83
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
84
|
-
* },
|
|
85
|
-
* ssoOptions: {
|
|
86
|
-
* loginRedirectURL: 'https://example.com/authenticate',
|
|
87
|
-
* signupRedirectURL: 'https://example.com/authenticate',
|
|
88
|
-
* },
|
|
89
|
-
* sessionOptions: {
|
|
90
|
-
* sessionDurationMinutes: 60,
|
|
91
|
-
* }
|
|
92
|
-
* }}
|
|
93
|
-
* styles={{
|
|
94
|
-
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
95
|
-
* primaryColor: '#0577CA',
|
|
96
|
-
* width: '321px',
|
|
97
|
-
* }}
|
|
98
|
-
* callbacks={{
|
|
99
|
-
* onEvent: (event) => console.log(event)
|
|
100
|
-
* }}
|
|
101
|
-
* />
|
|
102
|
-
* @param props {@link StytchB2BProps}
|
|
103
|
-
*/
|
|
104
|
-
export declare const StytchB2B: ({ styles, callbacks, config }: StytchB2BProps) => React.JSX.Element;
|