@stytch/vanilla-js 2.1.1 → 2.2.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,28 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [04cec1b]
8
+ - @stytch/core@1.2.1
9
+
10
+ ## 2.2.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 7c1940e: Add DFP Protectd Auth JS final release
15
+
16
+ ### Patch Changes
17
+
18
+ - 47eb388: Add Device Fingerprinting to the React Native SDK
19
+ - d008ef5: Don't delete cookies from the datalayer just because the localstorage is empty
20
+ - 47eb388: Add support for Observation and decisioning mode for DFP
21
+ - Updated dependencies [47eb388]
22
+ - Updated dependencies [47eb388]
23
+ - Updated dependencies [7c1940e]
24
+ - @stytch/core@1.2.0
25
+
3
26
  ## 2.1.1
4
27
 
5
28
  ### Patch Changes
@@ -915,30 +915,44 @@ var q,
915
915
  }));
916
916
  }, this.getDFPTelemetryIDAndCaptcha = function () {
917
917
  return w(i, void 0, void 0, o().mark(function e() {
918
- var t, n, r, i, a;
918
+ var t, n, r, i, a, s;
919
919
  return o().wrap(function (e) {
920
920
  for (;;) switch (e.prev = e.next) {
921
921
  case 0:
922
922
  return e.next = 2, this.state;
923
923
  case 2:
924
- if (t = e.sent, n = t.enabled, r = t.executeRecaptcha, i = void 0, a = void 0, !n) {
925
- e.next = 13;
924
+ if (t = e.sent, n = t.enabled, r = t.executeRecaptcha, i = t.mode, a = void 0, s = void 0, n) {
925
+ e.next = 12;
926
926
  break;
927
927
  }
928
- return e.next = 10, this.getTelemetryID();
929
- case 10:
930
- i = e.sent, e.next = 16;
931
- break;
932
- case 13:
933
- return e.next = 15, r();
928
+ return e.next = 11, r();
929
+ case 11:
930
+ s = e.sent;
931
+ case 12:
932
+ if ("DECISIONING" !== i) {
933
+ e.next = 18;
934
+ break;
935
+ }
936
+ return e.next = 15, this.getTelemetryID();
934
937
  case 15:
935
- a = e.sent;
936
- case 16:
938
+ a = e.sent, e.next = 25;
939
+ break;
940
+ case 18:
941
+ if ("OBSERVATION" !== i) {
942
+ e.next = 25;
943
+ break;
944
+ }
945
+ return e.next = 21, this.getTelemetryID();
946
+ case 21:
947
+ return a = e.sent, e.next = 24, r();
948
+ case 24:
949
+ s = e.sent;
950
+ case 25:
937
951
  return e.abrupt("return", {
938
- dfp_telemetry_id: i,
939
- captcha_token: a
952
+ dfp_telemetry_id: a,
953
+ captcha_token: s
940
954
  });
941
- case 17:
955
+ case 26:
942
956
  case "end":
943
957
  return e.stop();
944
958
  }
@@ -1000,6 +1014,7 @@ var q,
1000
1014
  publicToken: t,
1001
1015
  dfpBackendURL: n,
1002
1016
  enabled: !0,
1017
+ mode: e.dfpProtectedAuthMode || "OBSERVATION",
1003
1018
  loaded: !0,
1004
1019
  executeRecaptcha: a
1005
1020
  });
@@ -1238,28 +1253,33 @@ var re = Promise.resolve({
1238
1253
  }, this.discovery = {
1239
1254
  authenticate: function authenticate(e) {
1240
1255
  return w(a, void 0, void 0, o().mark(function t() {
1241
- var n, r, i;
1256
+ var n, r, i, a, s, l;
1242
1257
  return o().wrap(function (t) {
1243
1258
  for (;;) switch (t.prev = t.next) {
1244
1259
  case 0:
1245
1260
  return X("stytch.magicLinks.discovery.authenticate").isString("discovery_magic_links_token", e.discovery_magic_links_token), t.next = 3, this._pkceManager.getPKPair();
1246
1261
  case 3:
1247
- return n = t.sent, r = Object.assign({
1248
- pkce_code_verifier: null == n ? void 0 : n.code_verifier
1249
- }, e), t.next = 7, this._networkClient.fetchSDK({
1262
+ return n = t.sent, t.next = 6, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
1263
+ case 6:
1264
+ return r = t.sent, i = r.dfp_telemetry_id, a = r.captcha_token, s = Object.assign({
1265
+ pkce_code_verifier: null == n ? void 0 : n.code_verifier,
1266
+ dfp_telemetry_id: i,
1267
+ captcha_token: a
1268
+ }, e), t.next = 12, this._networkClient.retriableFetchSDK({
1250
1269
  url: "/b2b/magic_links/discovery/authenticate",
1251
- body: r,
1270
+ body: s,
1252
1271
  errorMessage: "Failed to authenticate intermediate magic link token",
1253
- method: "POST"
1272
+ method: "POST",
1273
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
1254
1274
  });
1255
- case 7:
1256
- return i = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
1275
+ case 12:
1276
+ return l = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
1257
1277
  state: null,
1258
1278
  session_token: null,
1259
1279
  session_jwt: null,
1260
- intermediate_session_token: i.intermediate_session_token
1261
- }), t.abrupt("return", i);
1262
- case 11:
1280
+ intermediate_session_token: l.intermediate_session_token
1281
+ }), t.abrupt("return", l);
1282
+ case 16:
1263
1283
  case "end":
1264
1284
  return t.stop();
1265
1285
  }
@@ -1543,28 +1563,33 @@ var re = Promise.resolve({
1543
1563
  s(this, e), this._networkClient = t, this._subscriptionService = n, this._pkceManager = r, this._dynamicConfig = i, this._config = a, this.dfpProtectedAuth = c, this.discovery = {
1544
1564
  authenticate: function authenticate(e) {
1545
1565
  return w(l, void 0, void 0, o().mark(function t() {
1546
- var n, r, i;
1566
+ var n, r, i, a, s, l;
1547
1567
  return o().wrap(function (t) {
1548
1568
  for (;;) switch (t.prev = t.next) {
1549
1569
  case 0:
1550
1570
  return X("stytch.oauth.discovery.authenticate").isString("discovery_oauth_token", e.discovery_oauth_token), t.next = 3, this._pkceManager.getPKPair();
1551
1571
  case 3:
1552
- return n = t.sent, r = Object.assign({
1553
- pkce_code_verifier: null == n ? void 0 : n.code_verifier
1554
- }, e), t.next = 7, this._networkClient.fetchSDK({
1572
+ return n = t.sent, t.next = 6, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
1573
+ case 6:
1574
+ return r = t.sent, i = r.dfp_telemetry_id, a = r.captcha_token, s = Object.assign({
1575
+ pkce_code_verifier: null == n ? void 0 : n.code_verifier,
1576
+ dfp_telemetry_id: i,
1577
+ captcha_token: a
1578
+ }, e), t.next = 12, this._networkClient.retriableFetchSDK({
1555
1579
  url: "/b2b/oauth/discovery/authenticate",
1556
- body: r,
1580
+ body: s,
1557
1581
  errorMessage: "Failed to authenticate discovery oauth token",
1558
- method: "POST"
1582
+ method: "POST",
1583
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
1559
1584
  });
1560
- case 7:
1561
- return i = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
1585
+ case 12:
1586
+ return l = t.sent, this._pkceManager.clearPKPair(), this._subscriptionService.updateStateAndTokens({
1562
1587
  state: null,
1563
1588
  session_token: null,
1564
1589
  session_jwt: null,
1565
- intermediate_session_token: i.intermediate_session_token
1566
- }), t.abrupt("return", i);
1567
- case 11:
1590
+ intermediate_session_token: l.intermediate_session_token
1591
+ }), t.abrupt("return", l);
1592
+ case 16:
1568
1593
  case "end":
1569
1594
  return t.stop();
1570
1595
  }
@@ -2740,7 +2765,8 @@ var Ie = /*#__PURE__*/function () {
2740
2765
  slugPattern: e.slug_pattern,
2741
2766
  createOrganizationEnabled: e.create_organization_enabled,
2742
2767
  passwordConfig: n,
2743
- runDFPProtectedAuth: null !== (t = e.dfp_protected_auth_enabled) && void 0 !== t && t
2768
+ runDFPProtectedAuth: null !== (t = e.dfp_protected_auth_enabled) && void 0 !== t && t,
2769
+ dfpProtectedAuthMode: e.dfp_protected_auth_mode
2744
2770
  };
2745
2771
  }
2746
2772
  }]);
@@ -2861,7 +2887,7 @@ var Re = /*#__PURE__*/function () {
2861
2887
  },
2862
2888
  sdk: {
2863
2889
  identifier: "Stytch.js Javascript SDK",
2864
- version: "2.1.1"
2890
+ version: "2.2.1"
2865
2891
  }
2866
2892
  });
2867
2893
  }
@@ -3225,7 +3251,7 @@ var $e = /*#__PURE__*/function () {
3225
3251
  }
3226
3252
  }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (X("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", t.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", t.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.istCookieName", t.cookieOptions.istCookieName).isOptionalString("cookieOptions.path", t.cookieOptions.path).isOptionalString("cookieOptions.domain", t.cookieOptions.domain), this._jwtCookieName = t.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = t.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = t.cookieOptions.path || null, this._domain = t.cookieOptions.domain || null, this._cookieAvailableToSubdomains = t.cookieOptions.availableToSubdomains || !1, this._istCookieName = t.cookieOptions.istCookieName || null) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._domain = null, this._cookieAvailableToSubdomains = !1, this._istCookieName = null);
3227
3253
  var n = localStorage.getItem(Qe(this.publicToken));
3228
- if (!n) return this.removeSessionCookie(), void this.removeISTCookie();
3254
+ if (!n) return;
3229
3255
  var r;
3230
3256
  try {
3231
3257
  r = JSON.parse(n);