@stytch/vanilla-js 2.2.2 → 3.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b402097: Bug fix for clearing the local storage state and cookies when a stale session exists while using the SDK across subdomains
8
+
9
+ ## 3.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 5dd9d24: Change export of B2B Headless Client to separate subpackage to improve tree-shaking performance
14
+
15
+ ```javascript
16
+ import { StytchB2BHeadlessClient } from '@stytch/vanilla-js/b2b';
17
+ ```
18
+
19
+ Is now updated to
20
+
21
+ ```javascript
22
+ import { StytchB2BHeadlessClient } from '@stytch/vanilla-js/b2b/headless';
23
+ ```
24
+
3
25
  ## 2.2.2
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -12,7 +12,7 @@ npm install @stytch/vanilla-js
12
12
 
13
13
  The vanilla Stytch Javascript SDK is built on open web standards and is compatible with all Javascript frameworks.
14
14
 
15
- ### `StytchUIClient`
15
+ ### **B2C** `StytchUIClient`
16
16
 
17
17
  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.
18
18
 
@@ -45,9 +45,9 @@ stytch.mountLogin({
45
45
  });
46
46
  ```
47
47
 
48
- ### `StytchHeadlessClient`
48
+ ### **B2C** `StytchHeadlessClient`
49
49
 
50
- Developers that don't use Stytch UI elements can use the `StytchHeadlessClient` instead, which is _significantly_ smaller (sub-20kb gzipped!)
50
+ Developers that don't use Stytch UI elements can use the `StytchHeadlessClient` instead, which is _significantly_ smaller!
51
51
 
52
52
  ```js
53
53
  import { StytchHeadlessClient } from '@stytch/vanilla-js/headless';
@@ -58,6 +58,58 @@ const stytch = new StytchHeadlessClient('public-token-test-xxxxxxxx-xxxx-xxxx-xx
58
58
  stytch.magicLinks.email.loginOrCreate('charles.babbage@example.com');
59
59
  ```
60
60
 
61
+ ### **B2B** `StytchB2BUIClient`
62
+
63
+ 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.
64
+
65
+ ```js
66
+ import { StytchB2BUIClient } from '@stytch/vanilla-js/b2b';
67
+
68
+ const stytch = new StytchB2BUIClient('public-token-test-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
69
+
70
+ // Call Stytch APIs from the browser
71
+ stytch.magicLinks.email.loginOrSignup({
72
+ email_address: 'charles.babbage@example.com',
73
+ organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
74
+ });
75
+
76
+ // Render prebuilt UI
77
+ stytch.mountLogin({
78
+ elementId: '#magic-link',
79
+ config: {
80
+ products: ['emailMagicLinks', 'oauth'],
81
+ emailMagicLinksOptions: {
82
+ loginRedirectURL: 'https://example.com/authenticate',
83
+ loginExpirationMinutes: 30,
84
+ signupRedirectURL: 'https://example.com/authenticate',
85
+ signupExpirationMinutes: 30,
86
+ createUserAsPending: true,
87
+ },
88
+ oauthOptions: {
89
+ providers: [{ type: 'google' }, { type: 'microsoft' }],
90
+ loginRedirectURL: 'https://example.com/authenticate',
91
+ signupRedirectURL: 'https://example.com/authenticate',
92
+ },
93
+ },
94
+ });
95
+ ```
96
+
97
+ ### **B2C** `StytchB2BHeadlessClient`
98
+
99
+ Developers that don't use Stytch UI elements can use the `StytchB2BHeadlessClient` instead, which is _significantly_ smaller!
100
+
101
+ ```js
102
+ import { StytchB2BHeadlessClient } from '@stytch/vanilla-js/b2b/headless';
103
+
104
+ const stytch = new StytchB2BHeadlessClient('public-token-test-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
105
+
106
+ // Call Stytch APIs from the browser
107
+ stytch.magicLinks.email.loginOrSignup({
108
+ email_address: 'charles.babbage@example.com',
109
+ organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
110
+ });
111
+ ```
112
+
61
113
  For more information on how to use the Stytch SDK, please refer to the
62
114
  [docs](https://stytch.com/docs/javascript-sdk).
63
115
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "internal": true,
3
+ "main": "../../dist/b2b/index.headless.js",
4
+ "module": "../../dist/b2b/index.headless.esm.js",
5
+ "types": "../../dist/b2b/index.headless.d.ts"
6
+ }
@@ -671,5 +671,5 @@ declare class StytchB2BUIClient extends StytchB2BHeadlessClient {
671
671
  config: StytchB2BUIConfig$0;
672
672
  }): void;
673
673
  }
674
- export { StytchB2BHeadlessClient, StytchB2BUIClient };
674
+ export { StytchB2BUIClient };
675
675
  export * from '@stytch/core/public';
@@ -671,5 +671,5 @@ declare class StytchB2BUIClient extends StytchB2BHeadlessClient {
671
671
  config: StytchB2BUIConfig$0;
672
672
  }): void;
673
673
  }
674
- export { StytchB2BHeadlessClient, StytchB2BUIClient };
674
+ export { StytchB2BUIClient };
675
675
  export * from '@stytch/core/public';
@@ -2887,7 +2887,7 @@ var Re = /*#__PURE__*/function () {
2887
2887
  },
2888
2888
  sdk: {
2889
2889
  identifier: "Stytch.js Javascript SDK",
2890
- version: "2.2.2"
2890
+ version: "3.0.1"
2891
2891
  }
2892
2892
  });
2893
2893
  }
@@ -3436,18 +3436,15 @@ var Ge = /*#__PURE__*/function () {
3436
3436
  function Ge(e, t) {
3437
3437
  var _this6 = this;
3438
3438
  _classCallCheck(this, Ge);
3439
- var n;
3440
3439
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
3441
3440
  if (e.key !== Qe(_this6._publicToken)) return;
3442
3441
  if (null === e.newValue || "null" === e.newValue) return void _this6.destroyState();
3443
3442
  var t = JSON.parse(e.newValue);
3444
3443
  _this6.updateState(t);
3445
3444
  }, window.addEventListener("storage", this._listen);
3446
- var r = null === (n = this._datalayer.state) || void 0 === n ? void 0 : n.session;
3447
- if (r && Date.parse(r.expires_at) < Date.now()) return void this.destroyState();
3448
3445
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
3449
- o = _this$_datalayer$read.session_token;
3450
- o || this.destroyState();
3446
+ n = _this$_datalayer$read.session_token;
3447
+ n || this.destroyState();
3451
3448
  }
3452
3449
  _createClass(Ge, [{
3453
3450
  key: "getTokens",
@@ -15600,4 +15597,4 @@ var KA = /*#__PURE__*/function (_Xe) {
15600
15597
  }]);
15601
15598
  return KA;
15602
15599
  }(Xe);
15603
- export { em as AuthFlowType, tm as B2BOAuthProviders, Xh as B2BProducts, Zh as BiometricsErrors, Lh as OAuthProviders, zh as OTPMethods, Dh as OneTapPositions, Rh as Products, nm as SDKAPIUnreachableError, Xe as StytchB2BHeadlessClient, KA as StytchB2BUIClient, Nh as StytchEventType, im as StytchSDKAPIError, am as StytchSDKNativeError, om as StytchSDKSchemaError, rm as StytchSDKUsageError, sm as UNRECOVERABLE_ERROR_TYPES, Mh as Wallets };
15600
+ export { em as AuthFlowType, tm as B2BOAuthProviders, Xh as B2BProducts, Zh as BiometricsErrors, Lh as OAuthProviders, zh as OTPMethods, Dh as OneTapPositions, Rh as Products, nm as SDKAPIUnreachableError, KA as StytchB2BUIClient, Nh as StytchEventType, im as StytchSDKAPIError, am as StytchSDKNativeError, om as StytchSDKSchemaError, rm as StytchSDKUsageError, sm as UNRECOVERABLE_ERROR_TYPES, Mh as Wallets };