@stytch/vanilla-js 0.10.2 → 0.10.4
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 +13 -0
- package/dist/b2b/index.esm.js +2 -2
- package/dist/b2b/index.js +2 -2
- package/dist/index.d.ts +57 -2
- package/dist/index.esm.d.ts +57 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.d.ts +57 -2
- package/dist/index.headless.esm.d.ts +57 -2
- package/dist/index.headless.esm.js +3 -3
- package/dist/index.headless.js +3 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.headless.d.ts
CHANGED
|
@@ -1,4 +1,59 @@
|
|
|
1
|
-
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient,
|
|
1
|
+
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessUserClient, IHeadlessTOTPClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient } from "@stytch/core/public";
|
|
2
|
+
import { PromptMomentNotification } from "google-one-tap";
|
|
3
|
+
type OneTapNotShownReason = ReturnType<PromptMomentNotification["getNotDisplayedReason"]> | ReturnType<PromptMomentNotification["getSkippedReason"]>;
|
|
4
|
+
type OneTapRenderResult = {
|
|
5
|
+
success: true;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
reason: OneTapNotShownReason;
|
|
9
|
+
};
|
|
10
|
+
type GoogleOneTapOAuthOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* The URL that Stytch redirects to after the OAuth flow is completed for a user that already exists.
|
|
13
|
+
* This URL should be an endpoint in the backend server that verifies the request by querying Stytch's /oauth/authenticate endpoint and finishes the login.
|
|
14
|
+
* The URL should be configured as a Login URL in the Stytch Dashboard's Redirect URL page.
|
|
15
|
+
* If the field is not specified, the default in the Dashboard is used.
|
|
16
|
+
*/
|
|
17
|
+
login_redirect_url?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The URL that Stytch redirects to after the OAuth flow is completed for a user that does not yet exist.
|
|
20
|
+
* This URL should be an endpoint in the backend server that verifies the request by querying Stytch's /oauth/authenticate endpoint and finishes the login.
|
|
21
|
+
* The URL should be configured as a Sign Up URL in the Stytch Dashboard's Redirect URL page.
|
|
22
|
+
* If the field is not specified, the default in the Dashboard is used.
|
|
23
|
+
*/
|
|
24
|
+
signup_redirect_url?: string;
|
|
25
|
+
/**
|
|
26
|
+
* An optional callback function that runs when a user explicitly cancels out of the one tap flow.
|
|
27
|
+
*/
|
|
28
|
+
onOneTapCancelled?: () => void;
|
|
29
|
+
};
|
|
30
|
+
interface IGoogleOneTapOAuthProvider {
|
|
31
|
+
/**
|
|
32
|
+
* Start an OAuth flow by showing the Google one tap prompt in the top right corner of the user's browser.
|
|
33
|
+
* You can configure this to be started by a user action (i.e Button click) or on load/render.
|
|
34
|
+
* @example
|
|
35
|
+
* const showGoogleOneTap = useCallback(()=> {
|
|
36
|
+
* stytch.oauth.googleOneTap.start({
|
|
37
|
+
* login_redirect_url: 'https://example.com/oauth/callback',
|
|
38
|
+
* signup_redirect_url: 'https://example.com/oauth/callback',
|
|
39
|
+
* })
|
|
40
|
+
* }, [stytch]);
|
|
41
|
+
* return (
|
|
42
|
+
* <Button onClick={showGoogleOneTap}> Show Google one tap </Button>
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* @param options - An {@link GoogleOneTapOAuthOptions} object
|
|
46
|
+
*
|
|
47
|
+
* @returns A {@link OneTapRenderResult} object. The result object includes if the one-tap prompt
|
|
48
|
+
* was rendered, and a reason if it couldn't be rendered.
|
|
49
|
+
*
|
|
50
|
+
* @throws An Error if the one tap client cannot be created.
|
|
51
|
+
*/
|
|
52
|
+
start(options?: GoogleOneTapOAuthOptions): Promise<OneTapRenderResult>;
|
|
53
|
+
}
|
|
54
|
+
interface IWebOAuthClient extends IHeadlessOAuthClient {
|
|
55
|
+
googleOneTap: IGoogleOneTapOAuthProvider;
|
|
56
|
+
}
|
|
2
57
|
/**
|
|
3
58
|
* A headless client used for invoking the Stytch API.
|
|
4
59
|
* The Stytch Headless Client can be used as a drop-in solution for authentication and session management.
|
|
@@ -22,7 +77,7 @@ declare class StytchHeadlessClient {
|
|
|
22
77
|
magicLinks: IHeadlessMagicLinksClient;
|
|
23
78
|
session: IHeadlessSessionClient;
|
|
24
79
|
otps: IHeadlessOTPsClient;
|
|
25
|
-
oauth:
|
|
80
|
+
oauth: IWebOAuthClient;
|
|
26
81
|
cryptoWallets: IHeadlessCryptoWalletClient;
|
|
27
82
|
totps: IHeadlessTOTPClient;
|
|
28
83
|
webauthn: IHeadlessWebAuthnClient;
|
|
@@ -1,4 +1,59 @@
|
|
|
1
|
-
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient,
|
|
1
|
+
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessUserClient, IHeadlessTOTPClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient } from "@stytch/core/public";
|
|
2
|
+
import { PromptMomentNotification } from "google-one-tap";
|
|
3
|
+
type OneTapNotShownReason = ReturnType<PromptMomentNotification["getNotDisplayedReason"]> | ReturnType<PromptMomentNotification["getSkippedReason"]>;
|
|
4
|
+
type OneTapRenderResult = {
|
|
5
|
+
success: true;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
reason: OneTapNotShownReason;
|
|
9
|
+
};
|
|
10
|
+
type GoogleOneTapOAuthOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* The URL that Stytch redirects to after the OAuth flow is completed for a user that already exists.
|
|
13
|
+
* This URL should be an endpoint in the backend server that verifies the request by querying Stytch's /oauth/authenticate endpoint and finishes the login.
|
|
14
|
+
* The URL should be configured as a Login URL in the Stytch Dashboard's Redirect URL page.
|
|
15
|
+
* If the field is not specified, the default in the Dashboard is used.
|
|
16
|
+
*/
|
|
17
|
+
login_redirect_url?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The URL that Stytch redirects to after the OAuth flow is completed for a user that does not yet exist.
|
|
20
|
+
* This URL should be an endpoint in the backend server that verifies the request by querying Stytch's /oauth/authenticate endpoint and finishes the login.
|
|
21
|
+
* The URL should be configured as a Sign Up URL in the Stytch Dashboard's Redirect URL page.
|
|
22
|
+
* If the field is not specified, the default in the Dashboard is used.
|
|
23
|
+
*/
|
|
24
|
+
signup_redirect_url?: string;
|
|
25
|
+
/**
|
|
26
|
+
* An optional callback function that runs when a user explicitly cancels out of the one tap flow.
|
|
27
|
+
*/
|
|
28
|
+
onOneTapCancelled?: () => void;
|
|
29
|
+
};
|
|
30
|
+
interface IGoogleOneTapOAuthProvider {
|
|
31
|
+
/**
|
|
32
|
+
* Start an OAuth flow by showing the Google one tap prompt in the top right corner of the user's browser.
|
|
33
|
+
* You can configure this to be started by a user action (i.e Button click) or on load/render.
|
|
34
|
+
* @example
|
|
35
|
+
* const showGoogleOneTap = useCallback(()=> {
|
|
36
|
+
* stytch.oauth.googleOneTap.start({
|
|
37
|
+
* login_redirect_url: 'https://example.com/oauth/callback',
|
|
38
|
+
* signup_redirect_url: 'https://example.com/oauth/callback',
|
|
39
|
+
* })
|
|
40
|
+
* }, [stytch]);
|
|
41
|
+
* return (
|
|
42
|
+
* <Button onClick={showGoogleOneTap}> Show Google one tap </Button>
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* @param options - An {@link GoogleOneTapOAuthOptions} object
|
|
46
|
+
*
|
|
47
|
+
* @returns A {@link OneTapRenderResult} object. The result object includes if the one-tap prompt
|
|
48
|
+
* was rendered, and a reason if it couldn't be rendered.
|
|
49
|
+
*
|
|
50
|
+
* @throws An Error if the one tap client cannot be created.
|
|
51
|
+
*/
|
|
52
|
+
start(options?: GoogleOneTapOAuthOptions): Promise<OneTapRenderResult>;
|
|
53
|
+
}
|
|
54
|
+
interface IWebOAuthClient extends IHeadlessOAuthClient {
|
|
55
|
+
googleOneTap: IGoogleOneTapOAuthProvider;
|
|
56
|
+
}
|
|
2
57
|
/**
|
|
3
58
|
* A headless client used for invoking the Stytch API.
|
|
4
59
|
* The Stytch Headless Client can be used as a drop-in solution for authentication and session management.
|
|
@@ -22,7 +77,7 @@ declare class StytchHeadlessClient {
|
|
|
22
77
|
magicLinks: IHeadlessMagicLinksClient;
|
|
23
78
|
session: IHeadlessSessionClient;
|
|
24
79
|
otps: IHeadlessOTPsClient;
|
|
25
|
-
oauth:
|
|
80
|
+
oauth: IWebOAuthClient;
|
|
26
81
|
cryptoWallets: IHeadlessCryptoWalletClient;
|
|
27
82
|
totps: IHeadlessTOTPClient;
|
|
28
83
|
webauthn: IHeadlessWebAuthnClient;
|