@stytch/vanilla-js 0.0.0-rc.1
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/README.md +69 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.esm.d.ts +27 -0
- package/dist/index.esm.js +142 -0
- package/dist/index.headless.d.ts +20 -0
- package/dist/index.headless.esm.d.ts +20 -0
- package/dist/index.headless.esm.js +2 -0
- package/dist/index.headless.js +2 -0
- package/dist/index.js +142 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Stytch Javascript SDK as an ES Module
|
|
2
|
+
|
|
3
|
+
[](https://stytch.com/docs/javascript-sdk)
|
|
4
|
+
[](https://stytch.slack.com)
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @stytch/vanilla-js
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
The vanilla Stytch Javascript SDK is built on open web standards and is compatible with all Javascript frameworks.
|
|
15
|
+
|
|
16
|
+
### `StytchUIClient`
|
|
17
|
+
|
|
18
|
+
The Stytch UI Client provides methods for interacting with the Stytch API from a browser environment, along with prebuilt UI components such as our login form.
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { StytchUIClient } from '@stytch/vanilla-js';
|
|
22
|
+
|
|
23
|
+
const stytch = new StytchUIClient('public-token-test-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
|
|
24
|
+
|
|
25
|
+
// Call Stytch APIs from the browser
|
|
26
|
+
stytch.magicLinks.email.loginOrCreate('charles.babbage@example.com');
|
|
27
|
+
|
|
28
|
+
// Render prebuilt UI
|
|
29
|
+
stytch.mount({
|
|
30
|
+
elementId: '#magic-link',
|
|
31
|
+
loginOrSignupView: {
|
|
32
|
+
products: ['emailMagicLinks', 'oauth'],
|
|
33
|
+
emailMagicLinksOptions: {
|
|
34
|
+
loginRedirectURL: 'https://example.com/authenticate',
|
|
35
|
+
loginExpirationMinutes: 30,
|
|
36
|
+
signupRedirectURL: 'https://example.com/authenticate',
|
|
37
|
+
signupExpirationMinutes: 30,
|
|
38
|
+
createUserAsPending: true,
|
|
39
|
+
},
|
|
40
|
+
oauthOptions: {
|
|
41
|
+
providers: [{ type: 'google' }, { type: 'microsoft' }, { type: 'apple' }],
|
|
42
|
+
loginRedirectURL: 'https://example.com/authenticate',
|
|
43
|
+
signupRedirectURL: 'https://example.com/authenticate',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `StytchHeadlessClient`
|
|
50
|
+
|
|
51
|
+
Developers that don't use Stytch UI elements can use the `StytchHeadlessClient` instead, which is _significantly_ smaller (sub-20kb gzipped!)
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { StytchHeadlessClient } from '@stytch/vanilla-js/headless';
|
|
55
|
+
|
|
56
|
+
const stytch = new StytchHeadlessClient('public-token-test-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
|
|
57
|
+
|
|
58
|
+
// Call Stytch APIs from the browser
|
|
59
|
+
stytch.magicLinks.email.loginOrCreate('charles.babbage@example.com');
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For more information on how to use the Stytch SDK, please refer to the
|
|
63
|
+
[docs](https://stytch.com/docs/javascript-sdk).
|
|
64
|
+
|
|
65
|
+
## See Also
|
|
66
|
+
|
|
67
|
+
- For usage with React: see the [@stytch/react](https://www.npmjs.com/package/@stytch/react) library
|
|
68
|
+
and [sample app](https://github.com/stytchauth/stytchjs-react-magic-links)
|
|
69
|
+
- For usage with Next.js: see the [sample app](https://github.com/stytchauth/stytch-nextjs-integration)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOAuthClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessUserClient, IHeadlessTOTPClient, Config, StyleConfig } from "@stytch/core/public";
|
|
2
|
+
declare class StytchHeadlessClient {
|
|
3
|
+
private readonly _subscriptionService;
|
|
4
|
+
private readonly _sessionManager;
|
|
5
|
+
private readonly _networkClient;
|
|
6
|
+
private readonly _dataLayer;
|
|
7
|
+
private readonly _pkceManager;
|
|
8
|
+
// External API Clients
|
|
9
|
+
user: IHeadlessUserClient;
|
|
10
|
+
magicLinks: IHeadlessMagicLinksClient;
|
|
11
|
+
session: IHeadlessSessionClient;
|
|
12
|
+
otps: IHeadlessOTPsClient;
|
|
13
|
+
oauth: IHeadlessOAuthClient;
|
|
14
|
+
cryptoWallets: IHeadlessCryptoWalletClient;
|
|
15
|
+
totps: IHeadlessTOTPClient;
|
|
16
|
+
passwords: IHeadlessPasswordClient;
|
|
17
|
+
constructor(_PUBLIC_TOKEN: string);
|
|
18
|
+
}
|
|
19
|
+
declare class StytchUIClient extends StytchHeadlessClient {
|
|
20
|
+
mount({ elementId, config, styles }: {
|
|
21
|
+
elementId: string;
|
|
22
|
+
config: Config;
|
|
23
|
+
styles: StyleConfig;
|
|
24
|
+
}): void;
|
|
25
|
+
}
|
|
26
|
+
export { StytchUIClient };
|
|
27
|
+
export * from '@stytch/core/public';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOAuthClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessUserClient, IHeadlessTOTPClient, Config, StyleConfig } from "@stytch/core/public";
|
|
2
|
+
declare class StytchHeadlessClient {
|
|
3
|
+
private readonly _subscriptionService;
|
|
4
|
+
private readonly _sessionManager;
|
|
5
|
+
private readonly _networkClient;
|
|
6
|
+
private readonly _dataLayer;
|
|
7
|
+
private readonly _pkceManager;
|
|
8
|
+
// External API Clients
|
|
9
|
+
user: IHeadlessUserClient;
|
|
10
|
+
magicLinks: IHeadlessMagicLinksClient;
|
|
11
|
+
session: IHeadlessSessionClient;
|
|
12
|
+
otps: IHeadlessOTPsClient;
|
|
13
|
+
oauth: IHeadlessOAuthClient;
|
|
14
|
+
cryptoWallets: IHeadlessCryptoWalletClient;
|
|
15
|
+
totps: IHeadlessTOTPClient;
|
|
16
|
+
passwords: IHeadlessPasswordClient;
|
|
17
|
+
constructor(_PUBLIC_TOKEN: string);
|
|
18
|
+
}
|
|
19
|
+
declare class StytchUIClient extends StytchHeadlessClient {
|
|
20
|
+
mount({ elementId, config, styles }: {
|
|
21
|
+
elementId: string;
|
|
22
|
+
config: Config;
|
|
23
|
+
styles: StyleConfig;
|
|
24
|
+
}): void;
|
|
25
|
+
}
|
|
26
|
+
export { StytchUIClient };
|
|
27
|
+
export * from '@stytch/core/public';
|