@stytch/vanilla-js 2.0.3 → 2.0.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 +8 -0
- package/dist/b2b/index.esm.js +84 -39
- package/dist/b2b/index.js +269 -224
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +95 -47
- package/dist/index.headless.js +95 -47
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/b2b/index.esm.js
CHANGED
|
@@ -812,12 +812,12 @@ var Y = Promise.resolve({
|
|
|
812
812
|
pkceRequiredForEmailMagicLinks: !1
|
|
813
813
|
}),
|
|
814
814
|
J = function () {
|
|
815
|
-
function e(t, n, r) {
|
|
816
|
-
var
|
|
817
|
-
|
|
818
|
-
s(this, e), this._networkClient = t, this._subscriptionService = n, this._pkceManager = r, this._config =
|
|
815
|
+
function e(t, n, r, i) {
|
|
816
|
+
var a = this,
|
|
817
|
+
l = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : Y;
|
|
818
|
+
s(this, e), this._networkClient = t, this._subscriptionService = n, this._pkceManager = r, this._passwordResetPKCEManager = i, this._config = l, this.email = {
|
|
819
819
|
loginOrSignup: function loginOrSignup(e) {
|
|
820
|
-
return v(
|
|
820
|
+
return v(a, void 0, void 0, o().mark(function t() {
|
|
821
821
|
var n, r;
|
|
822
822
|
return o().wrap(function (t) {
|
|
823
823
|
for (;;) switch (t.prev = t.next) {
|
|
@@ -841,7 +841,7 @@ var Y = Promise.resolve({
|
|
|
841
841
|
},
|
|
842
842
|
discovery: {
|
|
843
843
|
send: function send(e) {
|
|
844
|
-
return v(
|
|
844
|
+
return v(a, void 0, void 0, o().mark(function t() {
|
|
845
845
|
var n, r;
|
|
846
846
|
return o().wrap(function (t) {
|
|
847
847
|
for (;;) switch (t.prev = t.next) {
|
|
@@ -865,45 +865,62 @@ var Y = Promise.resolve({
|
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
}, this.authenticate = function (e) {
|
|
868
|
-
return v(
|
|
869
|
-
var n, r
|
|
868
|
+
return v(a, void 0, void 0, o().mark(function t() {
|
|
869
|
+
var n, r;
|
|
870
870
|
return o().wrap(function (t) {
|
|
871
871
|
for (;;) switch (t.prev = t.next) {
|
|
872
872
|
case 0:
|
|
873
|
-
return K("stytch.magicLinks.authenticate").isString("magic_links_token", e.magic_links_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this.
|
|
873
|
+
return K("stytch.magicLinks.authenticate").isString("magic_links_token", e.magic_links_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._passwordResetPKCEManager.getPKPair();
|
|
874
874
|
case 3:
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
case
|
|
884
|
-
|
|
875
|
+
if (n = t.sent, r = null, !(null == n ? void 0 : n.code_verifier)) {
|
|
876
|
+
t.next = 19;
|
|
877
|
+
break;
|
|
878
|
+
}
|
|
879
|
+
return t.prev = 6, t.next = 9, this.handlePKCEForAuthenticate(this._passwordResetPKCEManager, e);
|
|
880
|
+
case 9:
|
|
881
|
+
r = t.sent, t.next = 19;
|
|
882
|
+
break;
|
|
883
|
+
case 12:
|
|
884
|
+
if (t.prev = 12, t.t0 = t["catch"](6), !t.t0.message.includes("pkce")) {
|
|
885
|
+
t.next = 18;
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
console.log("Authenticate with passwords pkce namespace failed. Falling back to authenticate with magic_links namespace."), t.next = 19;
|
|
889
|
+
break;
|
|
890
|
+
case 18:
|
|
891
|
+
throw t.t0;
|
|
892
|
+
case 19:
|
|
893
|
+
if (r) {
|
|
894
|
+
t.next = 23;
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
return t.next = 22, this.handlePKCEForAuthenticate(this._pkceManager, e);
|
|
898
|
+
case 22:
|
|
899
|
+
r = t.sent;
|
|
900
|
+
case 23:
|
|
901
|
+
return r.member_session ? this._subscriptionService.updateStateAndTokens({
|
|
885
902
|
state: {
|
|
886
|
-
session:
|
|
887
|
-
member:
|
|
903
|
+
session: r.member_session,
|
|
904
|
+
member: r.member
|
|
888
905
|
},
|
|
889
|
-
session_token:
|
|
890
|
-
session_jwt:
|
|
906
|
+
session_token: r.session_token,
|
|
907
|
+
session_jwt: r.session_jwt,
|
|
891
908
|
intermediate_session_token: null
|
|
892
909
|
}) : this._subscriptionService.updateStateAndTokens({
|
|
893
910
|
state: null,
|
|
894
911
|
session_token: null,
|
|
895
912
|
session_jwt: null,
|
|
896
|
-
intermediate_session_token:
|
|
897
|
-
}), t.abrupt("return",
|
|
898
|
-
case
|
|
913
|
+
intermediate_session_token: r.intermediate_session_token
|
|
914
|
+
}), t.abrupt("return", r);
|
|
915
|
+
case 25:
|
|
899
916
|
case "end":
|
|
900
917
|
return t.stop();
|
|
901
918
|
}
|
|
902
|
-
}, t, this);
|
|
919
|
+
}, t, this, [[6, 12]]);
|
|
903
920
|
}));
|
|
904
921
|
}, this.discovery = {
|
|
905
922
|
authenticate: function authenticate(e) {
|
|
906
|
-
return v(
|
|
923
|
+
return v(a, void 0, void 0, o().mark(function t() {
|
|
907
924
|
var n, r, i;
|
|
908
925
|
return o().wrap(function (t) {
|
|
909
926
|
for (;;) switch (t.prev = t.next) {
|
|
@@ -968,6 +985,33 @@ var Y = Promise.resolve({
|
|
|
968
985
|
}, e, this);
|
|
969
986
|
}));
|
|
970
987
|
}
|
|
988
|
+
}, {
|
|
989
|
+
key: "handlePKCEForAuthenticate",
|
|
990
|
+
value: function value(e, t) {
|
|
991
|
+
return v(this, void 0, void 0, o().mark(function n() {
|
|
992
|
+
var r, i, a;
|
|
993
|
+
return o().wrap(function (n) {
|
|
994
|
+
for (;;) switch (n.prev = n.next) {
|
|
995
|
+
case 0:
|
|
996
|
+
return n.next = 2, e.getPKPair();
|
|
997
|
+
case 2:
|
|
998
|
+
return r = n.sent, i = Object.assign({
|
|
999
|
+
pkce_code_verifier: null == r ? void 0 : r.code_verifier
|
|
1000
|
+
}, t), n.next = 6, this._networkClient.fetchSDK({
|
|
1001
|
+
url: "/b2b/magic_links/authenticate",
|
|
1002
|
+
body: i,
|
|
1003
|
+
errorMessage: "Failed to authenticate token",
|
|
1004
|
+
method: "POST"
|
|
1005
|
+
});
|
|
1006
|
+
case 6:
|
|
1007
|
+
return a = n.sent, e.clearPKPair(), n.abrupt("return", a);
|
|
1008
|
+
case 9:
|
|
1009
|
+
case "end":
|
|
1010
|
+
return n.stop();
|
|
1011
|
+
}
|
|
1012
|
+
}, n, this);
|
|
1013
|
+
}));
|
|
1014
|
+
}
|
|
971
1015
|
}]), e;
|
|
972
1016
|
}(),
|
|
973
1017
|
Z = a(function e(t, n) {
|
|
@@ -1902,7 +1946,7 @@ var he = /*#__PURE__*/function () {
|
|
|
1902
1946
|
},
|
|
1903
1947
|
sdk: {
|
|
1904
1948
|
identifier: "Stytch.js Javascript SDK",
|
|
1905
|
-
version: "2.0.
|
|
1949
|
+
version: "2.0.4"
|
|
1906
1950
|
}
|
|
1907
1951
|
});
|
|
1908
1952
|
}
|
|
@@ -3179,6 +3223,7 @@ var Ge = /*#__PURE__*/_createClass(function Ge(e, t) {
|
|
|
3179
3223
|
};
|
|
3180
3224
|
}(o);
|
|
3181
3225
|
this._dataLayer = _e(e, o), this._subscriptionService = new Se(e, this._dataLayer);
|
|
3226
|
+
var a = new xe(this._dataLayer, "passwords");
|
|
3182
3227
|
this._networkClient = new he(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
|
|
3183
3228
|
var e, t, n, r;
|
|
3184
3229
|
return {
|
|
@@ -3186,19 +3231,19 @@ var Ge = /*#__PURE__*/_createClass(function Ge(e, t) {
|
|
|
3186
3231
|
stytch_member_session_id: null === (r = null === (n = _this8._dataLayer.state) || void 0 === n ? void 0 : n.session) || void 0 === r ? void 0 : r.member_session_id
|
|
3187
3232
|
};
|
|
3188
3233
|
});
|
|
3189
|
-
var
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
this.organization = new ee(this._networkClient), this.member = new Z(this._networkClient, this._subscriptionService), this.session = new ne(this._networkClient, this._subscriptionService), this.magicLinks = new J(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "magic_links"), a.getAsync()), this.oauth = new te(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "oauth"),
|
|
3234
|
+
var s = new Te(e, this._networkClient, this._dataLayer),
|
|
3235
|
+
l = new We(s.getAsync()),
|
|
3236
|
+
c = new Ke(this._networkClient, this._subscriptionService);
|
|
3237
|
+
this.organization = new ee(this._networkClient), this.member = new Z(this._networkClient, this._subscriptionService), this.session = new ne(this._networkClient, this._subscriptionService), this.magicLinks = new J(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "magic_links"), a, s.getAsync()), this.oauth = new te(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "oauth"), s.getAsync(), {
|
|
3193
3238
|
publicToken: e,
|
|
3194
3239
|
testAPIURL: i.endpoints.testAPIURL,
|
|
3195
3240
|
liveAPIURL: i.endpoints.liveAPIURL
|
|
3196
|
-
}), this.sso = new X(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "sso"),
|
|
3241
|
+
}), this.sso = new X(this._networkClient, this._subscriptionService, new xe(this._dataLayer, "sso"), s.getAsync(), {
|
|
3197
3242
|
publicToken: e,
|
|
3198
3243
|
testAPIURL: i.endpoints.testAPIURL,
|
|
3199
3244
|
liveAPIURL: i.endpoints.liveAPIURL
|
|
3200
|
-
}), this.discovery = new re(this._networkClient, this._subscriptionService), this.passwords = new He(this._networkClient, this._subscriptionService,
|
|
3201
|
-
var
|
|
3245
|
+
}), this.discovery = new re(this._networkClient, this._subscriptionService), this.passwords = new He(this._networkClient, this._subscriptionService, a, s.getAsync(), l.executeRecaptcha), this.otps = new ie(this._networkClient, this._subscriptionService), this._sessionManager = new le(this._subscriptionService, this.session);
|
|
3246
|
+
var u = new Pe(this._networkClient);
|
|
3202
3247
|
this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
|
|
3203
3248
|
name: "b2b_sdk_instance_instantiated",
|
|
3204
3249
|
details: {
|
|
@@ -3210,10 +3255,10 @@ var Ge = /*#__PURE__*/_createClass(function Ge(e, t) {
|
|
|
3210
3255
|
(function (e, t) {
|
|
3211
3256
|
Object.assign(e, _defineProperty({}, ce, t));
|
|
3212
3257
|
})(this, {
|
|
3213
|
-
bootstrap:
|
|
3258
|
+
bootstrap: s,
|
|
3214
3259
|
publicToken: e,
|
|
3215
|
-
searchManager:
|
|
3216
|
-
passwordResetClient:
|
|
3260
|
+
searchManager: u,
|
|
3261
|
+
passwordResetClient: c,
|
|
3217
3262
|
dataLayer: this._dataLayer,
|
|
3218
3263
|
networkClient: this._networkClient
|
|
3219
3264
|
});
|