@stytch/react 0.0.0-idp-20241212005436
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 +371 -0
- package/LICENSE +17 -0
- package/README.md +157 -0
- package/b2b/adminPortal/package.json +6 -0
- package/b2b/package.json +6 -0
- package/dist/StytchB2BContext-8acafb28.d.ts +165 -0
- package/dist/StytchB2BContext-8acafb28.js +217 -0
- package/dist/StytchB2BContext-d240104b.d.ts +165 -0
- package/dist/StytchB2BContext-d240104b.js +235 -0
- package/dist/adminPortal/index.d.ts +43 -0
- package/dist/adminPortal/index.esm.d.ts +43 -0
- package/dist/adminPortal/index.esm.js +55 -0
- package/dist/adminPortal/index.js +69 -0
- package/dist/b2b/index.d.ts +108 -0
- package/dist/b2b/index.esm.d.ts +108 -0
- package/dist/b2b/index.esm.js +66 -0
- package/dist/b2b/index.js +84 -0
- package/dist/createDeepEqual-5555f2e1.d.ts +5 -0
- package/dist/index-b14d4efe.d.ts +2 -0
- package/dist/index.d.ts +296 -0
- package/dist/index.esm.d.ts +296 -0
- package/dist/index.esm.js +349 -0
- package/dist/index.js +367 -0
- package/dist/invariant-568a7633.d.ts +27 -0
- package/dist/invariant-568a7633.js +88 -0
- package/dist/invariant-ae5a5bce.d.ts +27 -0
- package/dist/invariant-ae5a5bce.js +97 -0
- package/package.json +52 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { u as useIsMounted__INTERNAL, a as useStytchB2BClient, i as isUIClient } from '../StytchB2BContext-8acafb28.js';
|
|
2
|
+
export { S as StytchB2BProvider, a as useStytchB2BClient, d as useStytchIsAuthorized, c as useStytchMember, b as useStytchMemberSession, e as useStytchOrganization, w as withStytchB2BClient, g as withStytchMember, f as withStytchMemberSession, h as withStytchOrganization, j as withStytchPermissions } from '../StytchB2BContext-8acafb28.js';
|
|
3
|
+
import React, { useRef, useLayoutEffect } from 'react';
|
|
4
|
+
import { i as invariant, b as noHeadlessClientError, n as noProviderError } from '../invariant-568a7633.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Stytch B2B UI component.
|
|
8
|
+
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
9
|
+
* passed into the {@link StytchB2BProvider}
|
|
10
|
+
*
|
|
11
|
+
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <StytchB2B
|
|
15
|
+
* config={{
|
|
16
|
+
* authFlowType: "Organization",
|
|
17
|
+
* emailMagicLinksOptions: {
|
|
18
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
19
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
20
|
+
* },
|
|
21
|
+
* ssoOptions: {
|
|
22
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
23
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
24
|
+
* },
|
|
25
|
+
* sessionOptions: {
|
|
26
|
+
* sessionDurationMinutes: 60,
|
|
27
|
+
* }
|
|
28
|
+
* }}
|
|
29
|
+
* styles={{
|
|
30
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
31
|
+
* primaryColor: '#0577CA',
|
|
32
|
+
* width: '321px',
|
|
33
|
+
* }}
|
|
34
|
+
* callbacks={{
|
|
35
|
+
* onEvent: (event) => console.log(event)
|
|
36
|
+
* }}
|
|
37
|
+
* />
|
|
38
|
+
* @param props {@link StytchB2BProps}
|
|
39
|
+
*/
|
|
40
|
+
const StytchB2B = ({ styles, callbacks, config }) => {
|
|
41
|
+
invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />'));
|
|
42
|
+
const stytchClient = useStytchB2BClient();
|
|
43
|
+
const containerEl = useRef(null);
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
if (!isUIClient(stytchClient)) {
|
|
46
|
+
throw Error(noHeadlessClientError);
|
|
47
|
+
}
|
|
48
|
+
if (!containerEl.current) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!containerEl.current.id) {
|
|
52
|
+
const randId = Math.floor(Math.random() * 1e6);
|
|
53
|
+
containerEl.current.id = `stytch-b2b-ui-${randId}`;
|
|
54
|
+
}
|
|
55
|
+
stytchClient.mount({
|
|
56
|
+
callbacks,
|
|
57
|
+
config,
|
|
58
|
+
elementId: `#${containerEl.current.id}`,
|
|
59
|
+
styles,
|
|
60
|
+
});
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- SDK-1354
|
|
62
|
+
}, [stytchClient, styles, callbacks]);
|
|
63
|
+
return React.createElement("div", { ref: containerEl });
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { StytchB2B };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var StytchB2BContext = require('../StytchB2BContext-d240104b.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var invariant = require('../invariant-ae5a5bce.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The Stytch B2B UI component.
|
|
15
|
+
* This component can only be used with a {@link StytchB2BUIClient} client constructor
|
|
16
|
+
* passed into the {@link StytchB2BProvider}
|
|
17
|
+
*
|
|
18
|
+
* See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <StytchB2B
|
|
22
|
+
* config={{
|
|
23
|
+
* authFlowType: "Organization",
|
|
24
|
+
* emailMagicLinksOptions: {
|
|
25
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
26
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
27
|
+
* },
|
|
28
|
+
* ssoOptions: {
|
|
29
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
30
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
31
|
+
* },
|
|
32
|
+
* sessionOptions: {
|
|
33
|
+
* sessionDurationMinutes: 60,
|
|
34
|
+
* }
|
|
35
|
+
* }}
|
|
36
|
+
* styles={{
|
|
37
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
38
|
+
* primaryColor: '#0577CA',
|
|
39
|
+
* width: '321px',
|
|
40
|
+
* }}
|
|
41
|
+
* callbacks={{
|
|
42
|
+
* onEvent: (event) => console.log(event)
|
|
43
|
+
* }}
|
|
44
|
+
* />
|
|
45
|
+
* @param props {@link StytchB2BProps}
|
|
46
|
+
*/
|
|
47
|
+
const StytchB2B = ({ styles, callbacks, config }) => {
|
|
48
|
+
invariant.invariant(StytchB2BContext.useIsMounted__INTERNAL(), invariant.noProviderError('<StytchB2B />'));
|
|
49
|
+
const stytchClient = StytchB2BContext.useStytchB2BClient();
|
|
50
|
+
const containerEl = React.useRef(null);
|
|
51
|
+
React.useLayoutEffect(() => {
|
|
52
|
+
if (!StytchB2BContext.isUIClient(stytchClient)) {
|
|
53
|
+
throw Error(invariant.noHeadlessClientError);
|
|
54
|
+
}
|
|
55
|
+
if (!containerEl.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!containerEl.current.id) {
|
|
59
|
+
const randId = Math.floor(Math.random() * 1e6);
|
|
60
|
+
containerEl.current.id = `stytch-b2b-ui-${randId}`;
|
|
61
|
+
}
|
|
62
|
+
stytchClient.mount({
|
|
63
|
+
callbacks,
|
|
64
|
+
config,
|
|
65
|
+
elementId: `#${containerEl.current.id}`,
|
|
66
|
+
styles,
|
|
67
|
+
});
|
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- SDK-1354
|
|
69
|
+
}, [stytchClient, styles, callbacks]);
|
|
70
|
+
return React__default["default"].createElement("div", { ref: containerEl });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.StytchB2BProvider = StytchB2BContext.StytchB2BProvider;
|
|
74
|
+
exports.useStytchB2BClient = StytchB2BContext.useStytchB2BClient;
|
|
75
|
+
exports.useStytchIsAuthorized = StytchB2BContext.useStytchIsAuthorized;
|
|
76
|
+
exports.useStytchMember = StytchB2BContext.useStytchMember;
|
|
77
|
+
exports.useStytchMemberSession = StytchB2BContext.useStytchMemberSession;
|
|
78
|
+
exports.useStytchOrganization = StytchB2BContext.useStytchOrganization;
|
|
79
|
+
exports.withStytchB2BClient = StytchB2BContext.withStytchB2BClient;
|
|
80
|
+
exports.withStytchMember = StytchB2BContext.withStytchMember;
|
|
81
|
+
exports.withStytchMemberSession = StytchB2BContext.withStytchMemberSession;
|
|
82
|
+
exports.withStytchOrganization = StytchB2BContext.withStytchOrganization;
|
|
83
|
+
exports.withStytchPermissions = StytchB2BContext.withStytchPermissions;
|
|
84
|
+
exports.StytchB2B = StytchB2B;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
// We need to import the StytchUIClient type to give the TSDoc parser a hint as to where it is from
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
import { Callbacks, StytchLoginConfig, StyleConfig, Session, StytchUIClient, User } from "@stytch/vanilla-js";
|
|
7
|
+
import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
|
|
8
|
+
interface StytchProps {
|
|
9
|
+
/**
|
|
10
|
+
* A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* {
|
|
14
|
+
* products: ['crypto', 'otps']
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* {
|
|
19
|
+
* products: ['emailMagicLinks'>]
|
|
20
|
+
* emailMagicLinksOptions: {
|
|
21
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
22
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* {
|
|
28
|
+
* products: ['oauth'>]
|
|
29
|
+
* oauthOptions: {
|
|
30
|
+
* providers: [
|
|
31
|
+
* { type: 'google', one_tap: true, position: 'embedded' },
|
|
32
|
+
* { type: 'microsoft' },
|
|
33
|
+
* { type: 'apple' },
|
|
34
|
+
* { type: 'facebook' },
|
|
35
|
+
* ],
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
*/
|
|
39
|
+
config: StytchLoginConfig;
|
|
40
|
+
/**
|
|
41
|
+
* An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* {
|
|
45
|
+
* fontFamily: 'Arial, Helvetica, sans-serif',
|
|
46
|
+
* width: '360px',
|
|
47
|
+
* primaryColor: '#19303D',
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
styles?: StyleConfig;
|
|
51
|
+
/**
|
|
52
|
+
* An optional {@link Callbacks} object.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* {
|
|
56
|
+
* onError: ({message}) => {
|
|
57
|
+
* console.error('Stytch login screen error', message)
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* {
|
|
63
|
+
* onEvent: ({type, data}) => {
|
|
64
|
+
* if(type === StytchEventType.CryptoWalletAuthenticate) {
|
|
65
|
+
* console.log('Logged in with crypto wallet', data);
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
*/
|
|
70
|
+
callbacks?: Callbacks;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The Stytch Login Screen component.
|
|
74
|
+
* This component can only be used with a {@link StytchUIClient} client constructor
|
|
75
|
+
* passed into the {@link StytchProvider}
|
|
76
|
+
*
|
|
77
|
+
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* <StytchLogin
|
|
81
|
+
* config={{
|
|
82
|
+
* products: ['emailMagicLinks', 'oauth'],
|
|
83
|
+
* emailMagicLinksOptions: {
|
|
84
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
85
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
86
|
+
* },
|
|
87
|
+
* oauthOptions: {
|
|
88
|
+
* providers: [{ type: OAuthProviders.Google }, { type: OAuthProviders.Microsoft }],
|
|
89
|
+
* },
|
|
90
|
+
* }}
|
|
91
|
+
* styles={{
|
|
92
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
93
|
+
* primaryColor: '#0577CA',
|
|
94
|
+
* width: '321px',
|
|
95
|
+
* }}
|
|
96
|
+
* callbacks={{
|
|
97
|
+
* onEvent: (event) => console.log(event)
|
|
98
|
+
* }}
|
|
99
|
+
* />
|
|
100
|
+
* @param props {@link StytchProps}
|
|
101
|
+
*/
|
|
102
|
+
declare const StytchLogin: ({ config, styles, callbacks }: StytchProps) => React.JSX.Element;
|
|
103
|
+
interface StytchResetPasswordProps extends StytchProps {
|
|
104
|
+
passwordResetToken: string;
|
|
105
|
+
}
|
|
106
|
+
type StytchIDPProps = Omit<StytchProps, "config">;
|
|
107
|
+
/**
|
|
108
|
+
* The Stytch Reset Password component.
|
|
109
|
+
* This component can only be used with a {@link StytchUIClient} client constructor
|
|
110
|
+
* passed into the {@link StytchProvider}
|
|
111
|
+
*
|
|
112
|
+
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* <StytchPasswordReset
|
|
116
|
+
* config={{
|
|
117
|
+
* products: ['emailMagicLinks', 'oauth'],
|
|
118
|
+
* emailMagicLinksOptions: {
|
|
119
|
+
* loginRedirectURL: 'https://example.com/authenticate',
|
|
120
|
+
* signupRedirectURL: 'https://example.com/authenticate',
|
|
121
|
+
* },
|
|
122
|
+
* oauthOptions: {
|
|
123
|
+
* providers: [{ type: OAuthProviders.Google }, { type: OAuthProviders.Microsoft }],
|
|
124
|
+
* },
|
|
125
|
+
* }}
|
|
126
|
+
* passwordResetToken="PvC5UudZ7TPZbELt95yXAQ-8MeEUCRob8bUQ-g52fIJs"
|
|
127
|
+
* styles={{
|
|
128
|
+
* fontFamily: '"Helvetica New", Helvetica, sans-serif',
|
|
129
|
+
* primaryColor: '#0577CA',
|
|
130
|
+
* width: '321px',
|
|
131
|
+
* }}
|
|
132
|
+
* callbacks={{
|
|
133
|
+
* onEvent: (event) => console.log(event)
|
|
134
|
+
* }}
|
|
135
|
+
* />
|
|
136
|
+
*
|
|
137
|
+
* @param config - A {@link StytchLoginConfig} object
|
|
138
|
+
* @param passwordResetToken - A Stytch password reset token
|
|
139
|
+
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
140
|
+
* @param callbacks - An optional {@link Callbacks} object
|
|
141
|
+
*/
|
|
142
|
+
declare const StytchPasswordReset: ({ config, styles, callbacks, passwordResetToken }: StytchResetPasswordProps) => React.JSX.Element;
|
|
143
|
+
/**
|
|
144
|
+
* The Stytch Passkey Registration component.
|
|
145
|
+
* This component can only be used with a {@link StytchUIClient} client constructor
|
|
146
|
+
* passed into the {@link StytchProvider}
|
|
147
|
+
*
|
|
148
|
+
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const styles = {
|
|
153
|
+
* container: {
|
|
154
|
+
* backgroundColor: '#e11e1e',
|
|
155
|
+
* },
|
|
156
|
+
* colors: {
|
|
157
|
+
* primary: '#ff00f7',
|
|
158
|
+
* secondary: '#5C727D',
|
|
159
|
+
* },
|
|
160
|
+
* }
|
|
161
|
+
*
|
|
162
|
+
* <StytchPasskeyRegistration
|
|
163
|
+
* config={{
|
|
164
|
+
* products: ['passkey'],
|
|
165
|
+
* }}
|
|
166
|
+
* styles={styles}
|
|
167
|
+
* callbacks={{
|
|
168
|
+
* onEvent: (event) => console.log(event)
|
|
169
|
+
* }}
|
|
170
|
+
* />
|
|
171
|
+
* @param config - A {@link StytchLoginConfig} object
|
|
172
|
+
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
173
|
+
* @param callbacks - An optional {@link Callbacks} object
|
|
174
|
+
*/
|
|
175
|
+
declare const StytchPasskeyRegistration: ({ config, styles, callbacks }: StytchProps) => React.JSX.Element;
|
|
176
|
+
/**
|
|
177
|
+
* The Stytch IDP component.
|
|
178
|
+
* Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
|
|
179
|
+
* Requires the user to be logged in.
|
|
180
|
+
* This component can only be used with a {@link StytchUIClient} client constructor
|
|
181
|
+
* passed into the {@link StytchProvider}
|
|
182
|
+
*
|
|
183
|
+
* See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
|
|
184
|
+
*
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* const styles = {
|
|
188
|
+
* container: {
|
|
189
|
+
* backgroundColor: '#e11e1e',
|
|
190
|
+
* },
|
|
191
|
+
* colors: {
|
|
192
|
+
* primary: '#ff00f7',
|
|
193
|
+
* secondary: '#5C727D',
|
|
194
|
+
* },
|
|
195
|
+
* }
|
|
196
|
+
*
|
|
197
|
+
* <StytchIDP
|
|
198
|
+
* styles={styles}
|
|
199
|
+
* callbacks={{
|
|
200
|
+
* onEvent: (event) => console.log(event)
|
|
201
|
+
* }}
|
|
202
|
+
* />
|
|
203
|
+
* @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
|
|
204
|
+
* @param callbacks - An optional {@link Callbacks} object
|
|
205
|
+
*/
|
|
206
|
+
declare const StytchIDP: ({ styles, callbacks }: StytchIDPProps) => React.JSX.Element;
|
|
207
|
+
/**
|
|
208
|
+
* The Stytch Client object passed in to <StytchProvider /> in your application root.
|
|
209
|
+
* Either a StytchUIClient or StytchHeadlessClient.
|
|
210
|
+
*/
|
|
211
|
+
type StytchClient = StytchUIClient | StytchHeadlessClient;
|
|
212
|
+
type SWRUser = {
|
|
213
|
+
/**
|
|
214
|
+
* Either the active {@link User} object, or null if the user is not logged in.
|
|
215
|
+
*/
|
|
216
|
+
user: User | null;
|
|
217
|
+
/**
|
|
218
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
219
|
+
*/
|
|
220
|
+
fromCache: boolean;
|
|
221
|
+
};
|
|
222
|
+
type SWRSession = {
|
|
223
|
+
/**
|
|
224
|
+
* Either the active {@link Session} object, or null if the user is not logged in.
|
|
225
|
+
*/
|
|
226
|
+
session: Session | null;
|
|
227
|
+
/**
|
|
228
|
+
* If true, indicates that the value returned is from the application cache and a state refresh is in progress.
|
|
229
|
+
*/
|
|
230
|
+
fromCache: boolean;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Returns the active User.
|
|
234
|
+
* Check the fromCache property to determine if the user data is from persistent storage.
|
|
235
|
+
* @example
|
|
236
|
+
* const {user} = useStytchUser();
|
|
237
|
+
* return (<h1>Welcome, {user.name.first_name}</h1>);
|
|
238
|
+
* @returns A {@link SWRUser}
|
|
239
|
+
*/
|
|
240
|
+
declare const useStytchUser: () => SWRUser;
|
|
241
|
+
/**
|
|
242
|
+
* Returns the active user's Stytch session.
|
|
243
|
+
* @example
|
|
244
|
+
* const {session} = useStytchSession();
|
|
245
|
+
* useEffect(() => {
|
|
246
|
+
* if (!session) {
|
|
247
|
+
* router.replace('/login')
|
|
248
|
+
* }
|
|
249
|
+
* }, [session]);
|
|
250
|
+
* @returns A {@link SWRSession}
|
|
251
|
+
*/
|
|
252
|
+
declare const useStytchSession: () => SWRSession;
|
|
253
|
+
/**
|
|
254
|
+
* Returns the Stytch client stored in the Stytch context.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* const stytch = useStytch();
|
|
258
|
+
* useEffect(() => {
|
|
259
|
+
* stytch.magicLinks.authenticate('...')
|
|
260
|
+
* }, [stytch]);
|
|
261
|
+
*/
|
|
262
|
+
declare const useStytch: () => StytchClient;
|
|
263
|
+
declare const withStytch: <T extends object>(Component: React.ComponentType<T & {
|
|
264
|
+
stytch: StytchClient;
|
|
265
|
+
}>) => React.ComponentType<T>;
|
|
266
|
+
declare const withStytchUser: <T extends object>(Component: React.ComponentType<T & {
|
|
267
|
+
stytchUser: User | null;
|
|
268
|
+
stytchUserIsFromCache: boolean;
|
|
269
|
+
}>) => React.ComponentType<T>;
|
|
270
|
+
declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
|
|
271
|
+
stytchSession: Session | null;
|
|
272
|
+
stytchSessionIsFromCache: boolean;
|
|
273
|
+
}>) => React.ComponentType<T>;
|
|
274
|
+
type StytchProviderProps = {
|
|
275
|
+
/**
|
|
276
|
+
* A Stytch client instance, either a {@link StytchUIClient} or {@link StytchHeadlessClient}
|
|
277
|
+
*/
|
|
278
|
+
stytch: StytchClient;
|
|
279
|
+
children?: ReactNode;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* The Stytch Context Provider.
|
|
283
|
+
* Wrap your application with this component in the root file in order to use Stytch everywhere in your app.
|
|
284
|
+
* @example
|
|
285
|
+
* const stytch = new StytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
|
|
286
|
+
*
|
|
287
|
+
* ReactDOM.render(
|
|
288
|
+
* <StytchProvider stytch={stytch}>
|
|
289
|
+
* <App />
|
|
290
|
+
* </StytchProvider>,
|
|
291
|
+
* document.getElementById('root'),
|
|
292
|
+
* )
|
|
293
|
+
*/
|
|
294
|
+
declare const StytchProvider: ({ stytch, children }: StytchProviderProps) => JSX.Element;
|
|
295
|
+
export { StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, StytchIDP, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
|
|
296
|
+
export type { StytchProviderProps };
|