@stytch/vanilla-js 5.17.2 → 5.18.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 +12 -0
- package/dist/IDPClient.d.ts +11 -0
- package/dist/b2b/B2BIDPClient.d.ts +11 -0
- package/dist/b2b/index.esm.js +601 -330
- package/dist/b2b/index.headless.esm.js +21 -1
- package/dist/b2b/index.headless.js +21 -1
- package/dist/b2b/index.js +610 -339
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +21 -1
- package/dist/index.headless.js +21 -1
- package/dist/index.js +1 -1
- package/dist/ui/b2b/GlobalContextProvider.d.ts +2 -79
- package/dist/ui/b2b/MfaState.d.ts +1 -1
- package/dist/ui/b2b/generateProductComponentsOrdering.d.ts +1 -1
- package/dist/ui/b2b/mfa.d.ts +1 -1
- package/dist/ui/b2b/reducer.d.ts +3 -1
- package/dist/ui/b2b/types/AppScreens.d.ts +27 -0
- package/dist/ui/b2b/types/AppState.d.ts +47 -0
- package/dist/ui/b2b/types/ErrorType.d.ts +7 -0
- package/dist/ui/components/Confirmation.d.ts +6 -1
- package/dist/ui/components/IDPConsent.d.ts +4 -1
- package/dist/ui/components/IDPLogout.d.ts +32 -0
- package/dist/utils/idpHelpers.d.ts +27 -3
- package/package.json +12 -12
|
@@ -1,84 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StytchB2BUIClient } from '../../b2b/StytchB2BUIClient';
|
|
3
|
-
import {
|
|
4
|
-
import { AuthFlowType, Callbacks, DiscoveredOrganization, OrganizationBySlugMatch, PrimaryRequired, SSOActiveConnection, StytchB2BUIConfig, StytchProjectConfigurationInput } from '@stytch/core/public';
|
|
5
|
-
import { MfaState } from './MfaState';
|
|
3
|
+
import { Callbacks, StytchB2BUIConfig, StytchProjectConfigurationInput } from '@stytch/core/public';
|
|
6
4
|
import { Action } from './reducer';
|
|
7
|
-
|
|
8
|
-
Main = "Main",
|
|
9
|
-
EmailConfirmation = "Email Confirmation",
|
|
10
|
-
LoggedIn = "Logged In",
|
|
11
|
-
Discovery = "Discovery",
|
|
12
|
-
Error = "Error",
|
|
13
|
-
PasswordEmailForm = "Password Email",
|
|
14
|
-
PasswordAuthenticate = "Password Authenticate",
|
|
15
|
-
PasswordResetForm = "Password Reset Form",
|
|
16
|
-
PasswordResetVerifyConfirmation = "Password Reset Verify Confirmation",
|
|
17
|
-
PasswordForgotForm = "Password Forgot Form",
|
|
18
|
-
PasswordSetNewConfirmation = "Password Set New Confirmation",
|
|
19
|
-
MFAEnrollmentSelection = "MFA Enrollment Selection",
|
|
20
|
-
RecoveryCodeEntry = "Recovery Code Entry",
|
|
21
|
-
RecoveryCodeSave = "Recovery Code Save",
|
|
22
|
-
SMSOTPEnrollment = "SMS OTP Enrollment",
|
|
23
|
-
SMSOTPEntry = "SMS OTP Entry",
|
|
24
|
-
TOTPEnrollmentManual = "TOTP Enrollment Manual",
|
|
25
|
-
TOTPEnrollmentQRCode = "TOTP Enrollment QR Code",
|
|
26
|
-
TOTPEntry = "TOTP Entry",
|
|
27
|
-
EmailMethodSelection = "Email Method Selection",
|
|
28
|
-
EmailOTPEntry = "Email OTP Entry",
|
|
29
|
-
SSODiscoveryEmail = "SSO Discovery Email",
|
|
30
|
-
SSODiscoveryFallback = "SSO Discovery Fallback",
|
|
31
|
-
SSODiscoveryMenu = "SSO Discovery Menu",
|
|
32
|
-
IDPConsent = "IDP Consent"
|
|
33
|
-
}
|
|
34
|
-
export declare enum ErrorType {
|
|
35
|
-
Default = 0,
|
|
36
|
-
EmailMagicLink = 1,
|
|
37
|
-
Organization = 2,
|
|
38
|
-
CannotJoinOrgDueToAuthPolicy = 3,
|
|
39
|
-
AdBlockerDetected = 4
|
|
40
|
-
}
|
|
41
|
-
export type EmailState = {
|
|
42
|
-
userSuppliedEmail: string;
|
|
43
|
-
};
|
|
44
|
-
export type DiscoveryState = {
|
|
45
|
-
email: string;
|
|
46
|
-
discoveredOrganizations: DiscoveredOrganization[];
|
|
47
|
-
};
|
|
48
|
-
export type PasswordState = {
|
|
49
|
-
email: string;
|
|
50
|
-
};
|
|
51
|
-
export type OtpState = {
|
|
52
|
-
codeExpiration: Date | null;
|
|
53
|
-
};
|
|
54
|
-
export type SSODiscoveryState = {
|
|
55
|
-
connections: SSOActiveConnection[];
|
|
56
|
-
};
|
|
57
|
-
export type FormState = {
|
|
58
|
-
emailState: EmailState;
|
|
59
|
-
discoveryState: DiscoveryState;
|
|
60
|
-
passwordState: PasswordState;
|
|
61
|
-
otpState: OtpState;
|
|
62
|
-
ssoDiscoveryState: SSODiscoveryState;
|
|
63
|
-
};
|
|
64
|
-
export type FlowState = {
|
|
65
|
-
type: StringLiteralFromEnum<AuthFlowType>;
|
|
66
|
-
organization: null | OrganizationBySlugMatch;
|
|
67
|
-
};
|
|
68
|
-
type PrimaryAuthState = {
|
|
69
|
-
primaryAuthMethods?: PrimaryRequired['allowed_auth_methods'];
|
|
70
|
-
email?: string;
|
|
71
|
-
emailVerified?: boolean;
|
|
72
|
-
};
|
|
73
|
-
export type AppState = {
|
|
74
|
-
screen: AppScreens;
|
|
75
|
-
screenHistory: AppScreens[];
|
|
76
|
-
formState: FormState;
|
|
77
|
-
flowState: FlowState;
|
|
78
|
-
mfa: MfaState;
|
|
79
|
-
primary: PrimaryAuthState;
|
|
80
|
-
errorType: ErrorType;
|
|
81
|
-
};
|
|
5
|
+
import { AppState } from './types/AppState';
|
|
82
6
|
export type AppContext<TProjectConfiguration extends StytchProjectConfigurationInput> = {
|
|
83
7
|
client: StytchB2BUIClient<TProjectConfiguration>;
|
|
84
8
|
config: StytchB2BUIConfig;
|
|
@@ -102,4 +26,3 @@ export declare const useGlobalReducer: () => [AppState, React.Dispatch<Action>];
|
|
|
102
26
|
export declare const useConfig: () => StytchB2BUIConfig;
|
|
103
27
|
export declare const useErrorCallback: () => (error: import("@stytch/core/public").StytchSDKUIError) => void;
|
|
104
28
|
export declare const useEventCallback: () => (event: import("@stytch/core/public").StytchEvent<Partial<import("@stytch/core/public").StytchProjectConfiguration>>) => void;
|
|
105
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { B2BMFAProducts } from '@stytch/core/public';
|
|
2
2
|
import { CountryCode } from '@stytch/core';
|
|
3
|
-
import { AppScreens } from './
|
|
3
|
+
import { AppScreens } from './types/AppScreens';
|
|
4
4
|
export interface MfaState {
|
|
5
5
|
primaryInfo: {
|
|
6
6
|
enrolledMfaMethods: B2BMFAProducts[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StringLiteralFromEnum } from '@stytch/core';
|
|
2
2
|
import { B2BProducts } from '@stytch/core/public';
|
|
3
|
-
import { FlowState } from './
|
|
3
|
+
import { FlowState } from './types/AppState';
|
|
4
4
|
export declare enum Component {
|
|
5
5
|
EmailForm = "EmailForm",
|
|
6
6
|
EmailDiscoveryForm = "EmailDiscoveryForm",
|
package/dist/ui/b2b/mfa.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CountryCode, StringLiteralFromEnum } from '@stytch/core';
|
|
2
2
|
import { B2BAuthenticateResponseWithMFA, B2BMFAProducts, B2BSMSSendResponse, B2BTOTPCreateResponse, StytchProjectConfigurationInput } from '@stytch/core/public';
|
|
3
3
|
import { Optional } from '../../utils/Optional';
|
|
4
|
-
import { AppState } from './
|
|
4
|
+
import { AppState } from './types/AppState';
|
|
5
5
|
type PrimaryAuthenticateSuccessAction = {
|
|
6
6
|
type: 'primary_authenticate_success';
|
|
7
7
|
response: B2BAuthenticateResponseWithMFA<StytchProjectConfigurationInput>;
|
package/dist/ui/b2b/reducer.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DiscoveredOrganization, OrganizationBySlugMatch, SSOActiveConnection } from '@stytch/core/public';
|
|
2
|
-
import {
|
|
2
|
+
import { AppState } from './types/AppState';
|
|
3
|
+
import { ErrorType } from './types/ErrorType';
|
|
4
|
+
import { AppScreens } from './types/AppScreens';
|
|
3
5
|
import { MfaAction } from './mfa';
|
|
4
6
|
export type Action = {
|
|
5
7
|
type: 'transition';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare enum AppScreens {
|
|
2
|
+
Main = "Main",
|
|
3
|
+
EmailConfirmation = "Email Confirmation",
|
|
4
|
+
LoggedIn = "Logged In",
|
|
5
|
+
Discovery = "Discovery",
|
|
6
|
+
Error = "Error",
|
|
7
|
+
PasswordEmailForm = "Password Email",
|
|
8
|
+
PasswordAuthenticate = "Password Authenticate",
|
|
9
|
+
PasswordResetForm = "Password Reset Form",
|
|
10
|
+
PasswordResetVerifyConfirmation = "Password Reset Verify Confirmation",
|
|
11
|
+
PasswordForgotForm = "Password Forgot Form",
|
|
12
|
+
PasswordSetNewConfirmation = "Password Set New Confirmation",
|
|
13
|
+
MFAEnrollmentSelection = "MFA Enrollment Selection",
|
|
14
|
+
RecoveryCodeEntry = "Recovery Code Entry",
|
|
15
|
+
RecoveryCodeSave = "Recovery Code Save",
|
|
16
|
+
SMSOTPEnrollment = "SMS OTP Enrollment",
|
|
17
|
+
SMSOTPEntry = "SMS OTP Entry",
|
|
18
|
+
TOTPEnrollmentManual = "TOTP Enrollment Manual",
|
|
19
|
+
TOTPEnrollmentQRCode = "TOTP Enrollment QR Code",
|
|
20
|
+
TOTPEntry = "TOTP Entry",
|
|
21
|
+
EmailMethodSelection = "Email Method Selection",
|
|
22
|
+
EmailOTPEntry = "Email OTP Entry",
|
|
23
|
+
SSODiscoveryEmail = "SSO Discovery Email",
|
|
24
|
+
SSODiscoveryFallback = "SSO Discovery Fallback",
|
|
25
|
+
SSODiscoveryMenu = "SSO Discovery Menu",
|
|
26
|
+
IDPConsent = "IDP Consent"
|
|
27
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StringLiteralFromEnum } from '@stytch/core';
|
|
2
|
+
import { AuthFlowType, DiscoveredOrganization, OrganizationBySlugMatch, PrimaryRequired, SSOActiveConnection } from '@stytch/core/public';
|
|
3
|
+
import { MfaState } from '../MfaState';
|
|
4
|
+
import { AppScreens } from './AppScreens';
|
|
5
|
+
import { ErrorType } from './ErrorType';
|
|
6
|
+
export type EmailState = {
|
|
7
|
+
userSuppliedEmail: string;
|
|
8
|
+
};
|
|
9
|
+
export type DiscoveryState = {
|
|
10
|
+
email: string;
|
|
11
|
+
discoveredOrganizations: DiscoveredOrganization[];
|
|
12
|
+
};
|
|
13
|
+
export type PasswordState = {
|
|
14
|
+
email: string;
|
|
15
|
+
};
|
|
16
|
+
export type OtpState = {
|
|
17
|
+
codeExpiration: Date | null;
|
|
18
|
+
};
|
|
19
|
+
export type SSODiscoveryState = {
|
|
20
|
+
connections: SSOActiveConnection[];
|
|
21
|
+
};
|
|
22
|
+
export type FormState = {
|
|
23
|
+
emailState: EmailState;
|
|
24
|
+
discoveryState: DiscoveryState;
|
|
25
|
+
passwordState: PasswordState;
|
|
26
|
+
otpState: OtpState;
|
|
27
|
+
ssoDiscoveryState: SSODiscoveryState;
|
|
28
|
+
};
|
|
29
|
+
export type FlowState = {
|
|
30
|
+
type: StringLiteralFromEnum<AuthFlowType>;
|
|
31
|
+
organization: null | OrganizationBySlugMatch;
|
|
32
|
+
};
|
|
33
|
+
type PrimaryAuthState = {
|
|
34
|
+
primaryAuthMethods?: PrimaryRequired['allowed_auth_methods'];
|
|
35
|
+
email?: string;
|
|
36
|
+
emailVerified?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type AppState = {
|
|
39
|
+
screen: AppScreens;
|
|
40
|
+
screenHistory: AppScreens[];
|
|
41
|
+
formState: FormState;
|
|
42
|
+
flowState: FlowState;
|
|
43
|
+
mfa: MfaState;
|
|
44
|
+
primary: PrimaryAuthState;
|
|
45
|
+
errorType: ErrorType;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
type ConfirmationProps = {
|
|
3
|
+
header?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const Confirmation: ({ header, text }: ConfirmationProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { OAuthAuthorizeParams } from '../../utils/idpHelpers';
|
|
2
3
|
import { OAuthAuthorizeStartOptions, OAuthAuthorizeStartResponse, OAuthAuthorizeSubmitOptions, OIDCClientPublic } from '../../IDPClient';
|
|
3
4
|
import { BootstrapData } from '@stytch/core';
|
|
4
5
|
import { StytchEvent, StytchSDKUIError } from '@stytch/core/public';
|
|
@@ -19,7 +20,9 @@ interface IDPConsentState {
|
|
|
19
20
|
consent_granted: boolean;
|
|
20
21
|
}): Promise<void>;
|
|
21
22
|
}
|
|
22
|
-
export declare const useIDPState: ({ oauthAuthorizeStart, oauthAuthorizeSubmit, onError, onEvent, }: {
|
|
23
|
+
export declare const useIDPState: ({ initialError, initialParams, oauthAuthorizeStart, oauthAuthorizeSubmit, onError, onEvent, }: {
|
|
24
|
+
initialError: string | null;
|
|
25
|
+
initialParams: OAuthAuthorizeParams;
|
|
23
26
|
oauthAuthorizeStart(data: OAuthAuthorizeStartOptions): Promise<OAuthAuthorizeStartResponse & {
|
|
24
27
|
grantable_scope: string;
|
|
25
28
|
ungrantable_scope: string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OAuthLogoutParams } from '../../utils/idpHelpers';
|
|
3
|
+
import { OAuthLogoutStartOptions, OAuthLogoutStartResponse } from '../../IDPClient';
|
|
4
|
+
import { StytchSDKUIError } from '@stytch/core/public';
|
|
5
|
+
import { BootstrapData } from '@stytch/core';
|
|
6
|
+
type LogoutState = {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
preflight: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
denied: boolean;
|
|
11
|
+
consent_required: boolean;
|
|
12
|
+
redirect_uri: string;
|
|
13
|
+
};
|
|
14
|
+
interface IDPLogoutState {
|
|
15
|
+
state: LogoutState;
|
|
16
|
+
submit({ consent_granted }: {
|
|
17
|
+
consent_granted: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare const useLogoutState: ({ initialError, initialParams, oauthLogoutStart, revokeSession, onError, }: {
|
|
21
|
+
initialError: string | null;
|
|
22
|
+
initialParams: OAuthLogoutParams;
|
|
23
|
+
oauthLogoutStart(data: OAuthLogoutStartOptions): Promise<OAuthLogoutStartResponse>;
|
|
24
|
+
revokeSession(): Promise<unknown>;
|
|
25
|
+
onError(error: StytchSDKUIError): void;
|
|
26
|
+
}) => IDPLogoutState;
|
|
27
|
+
type Props = IDPLogoutState & {
|
|
28
|
+
bootstrap: BootstrapData;
|
|
29
|
+
bootstrapNotLoaded: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const IDPLogout: ({ state, submit, bootstrap, bootstrapNotLoaded }: Props) => React.JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -11,7 +11,7 @@ export declare const fallbackConsentManifestGenerator: ({ scopes, clientName, rb
|
|
|
11
11
|
header: string;
|
|
12
12
|
items: IDPConsentItem[];
|
|
13
13
|
}[];
|
|
14
|
-
export type
|
|
14
|
+
export type OAuthAuthorizeParams = {
|
|
15
15
|
client_id: string;
|
|
16
16
|
redirect_uri: string;
|
|
17
17
|
response_type: string;
|
|
@@ -20,7 +20,31 @@ export type IDPSearchParams = {
|
|
|
20
20
|
state?: string;
|
|
21
21
|
nonce?: string;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type OAuthLogoutParams = {
|
|
24
|
+
client_id: string;
|
|
25
|
+
post_logout_redirect_uri: string;
|
|
26
|
+
id_token_hint?: string;
|
|
27
|
+
state?: string;
|
|
28
|
+
};
|
|
29
|
+
export type IDPFlowParams = {
|
|
30
|
+
type: 'Authorize';
|
|
31
|
+
params: OAuthAuthorizeParams;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'Logout';
|
|
34
|
+
params: OAuthLogoutParams;
|
|
35
|
+
};
|
|
36
|
+
export declare const parseOAuthAuthorizeParams: (params: URLSearchParams) => {
|
|
37
|
+
error: string | null;
|
|
38
|
+
result: OAuthAuthorizeParams;
|
|
39
|
+
};
|
|
40
|
+
export declare const parseOAuthLogoutParams: (params: URLSearchParams) => {
|
|
41
|
+
error: string | null;
|
|
42
|
+
result: OAuthLogoutParams;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Parse generic IDP parameters and determine if it is an Authorize or Logout request.
|
|
46
|
+
*/
|
|
47
|
+
export declare const parseIDPParams: (searchParams: string) => {
|
|
24
48
|
error: string | null;
|
|
25
|
-
|
|
49
|
+
flow: IDPFlowParams;
|
|
26
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stytch/vanilla-js",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "Stytch's official Javascript Client Library",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
63
63
|
"@rollup/plugin-replace": "5.0.5",
|
|
64
64
|
"@rollup/plugin-typescript": "11.1.6",
|
|
65
|
-
"@storybook/addon-essentials": "8.
|
|
66
|
-
"@storybook/addon-interactions": "8.
|
|
67
|
-
"@storybook/addon-links": "8.
|
|
68
|
-
"@storybook/addon-themes": "8.
|
|
69
|
-
"@storybook/blocks": "8.
|
|
70
|
-
"@storybook/preact": "8.
|
|
71
|
-
"@storybook/preact-vite": "8.
|
|
72
|
-
"@storybook/test": "8.
|
|
73
|
-
"@storybook/test-runner": "0.
|
|
65
|
+
"@storybook/addon-essentials": "8.5.8",
|
|
66
|
+
"@storybook/addon-interactions": "8.5.8",
|
|
67
|
+
"@storybook/addon-links": "8.5.8",
|
|
68
|
+
"@storybook/addon-themes": "8.5.8",
|
|
69
|
+
"@storybook/blocks": "8.5.8",
|
|
70
|
+
"@storybook/preact": "8.5.8",
|
|
71
|
+
"@storybook/preact-vite": "8.5.8",
|
|
72
|
+
"@storybook/test": "8.5.8",
|
|
73
|
+
"@storybook/test-runner": "0.21.2",
|
|
74
74
|
"@stytch/js-utils": "0.0.0",
|
|
75
75
|
"@testing-library/preact": "3.2.4",
|
|
76
76
|
"@testing-library/user-event": "14.2.1",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"react-test-renderer": "17.0.0",
|
|
101
101
|
"rollup": "4.22.4",
|
|
102
102
|
"rollup-plugin-sizes": "1.0.6",
|
|
103
|
-
"storybook": "8.
|
|
103
|
+
"storybook": "8.5.8",
|
|
104
104
|
"styled-components": "5.3.5",
|
|
105
105
|
"swr": "2.1.1",
|
|
106
106
|
"typescript": "5.3.3",
|
|
107
107
|
"uuid": "8.3.2",
|
|
108
|
-
"vite": "
|
|
108
|
+
"vite": "6.1.1",
|
|
109
109
|
"wait-on": "7.2.0"
|
|
110
110
|
},
|
|
111
111
|
"homepage": "https://stytch.com/docs/sdks/javascript-sdk",
|