@passflow/core 0.34.0 → 0.35.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 +3 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.mjs +695 -666
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var i = "__passflowAntiBot", a = (e, t) => {
|
|
|
11
11
|
if (typeof e != "object" || !e) return;
|
|
12
12
|
let t = e[i];
|
|
13
13
|
return typeof t == "object" && t ? t : void 0;
|
|
14
|
-
}, s = "0.
|
|
14
|
+
}, s = "0.35.1", c = "X-Passflow-Clientid", l = "Authorization", u = "X-Passflow-DeviceId", d = "X-Passflow-DeviceType", f = "X-Passflow-Anti-Bot", p = "X-Passflow-Agent-Tool", m = "passflow_auth", h = s, g = [
|
|
15
15
|
"id",
|
|
16
16
|
"offline",
|
|
17
17
|
"openid"
|
|
@@ -192,7 +192,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
192
192
|
this.storageManager.storage.removeItem(this.SESSION_STATE_KEY);
|
|
193
193
|
} catch {}
|
|
194
194
|
}
|
|
195
|
-
}, P = "tokens_scopes", F = "passflowDeviceId", I = "passflowInvitationToken", le = "passflowPreviousRedirectUrl",
|
|
195
|
+
}, P = "tokens_scopes", F = "passflowDeviceId", I = "passflowInvitationToken", le = "passflowPreviousRedirectUrl", ue = class {
|
|
196
196
|
constructor({ storage: e, prefix: t, appId: n } = {}) {
|
|
197
197
|
this.keyStoragePrefix = "", this.STORAGE_PREFIX = "passflow_", this.ID_TOKEN_KEY = `${this.STORAGE_PREFIX}id_token`, this.CSRF_TOKEN_KEY = `${this.STORAGE_PREFIX}csrf_token`, this.DELIVERY_MODE_KEY = `${this.STORAGE_PREFIX}delivery_mode`, this.storage = e ?? localStorage, this.keyStoragePrefix = t ? `${t}_` : "", this.scopes = `${this.keyStoragePrefix}${P}`, this.deviceId = `${this.keyStoragePrefix}${F}`, this.invitationToken = `${this.keyStoragePrefix}${I}`, this.previousRedirectUrl = `${this.keyStoragePrefix}${le}`, this.appId = n || void 0;
|
|
198
198
|
}
|
|
@@ -243,9 +243,16 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
243
243
|
removeOwnToken(e) {
|
|
244
244
|
this.holdsOtherAppToken(e) || this.storage.removeItem(e);
|
|
245
245
|
}
|
|
246
|
-
saveTokens(e, t) {
|
|
247
|
-
let { id_token:
|
|
248
|
-
t === N.Cookie || t === N.BFF
|
|
246
|
+
saveTokens(e, t, n) {
|
|
247
|
+
let { id_token: r, access_token: i, refresh_token: a, scopes: o } = e;
|
|
248
|
+
if (t === N.Cookie || t === N.BFF) r && this.storage.setItem(this.ID_TOKEN_KEY, r);
|
|
249
|
+
else {
|
|
250
|
+
if (n?.replace && i) {
|
|
251
|
+
let e = this.holdsOnlyOtherAppSession();
|
|
252
|
+
r || this.removeOwnToken(this.getKeyForTokenType(M.id_token)), a || this.removeOwnToken(this.getKeyForTokenType(M.refresh_token)), !o && !e && this.removePrefixed(this.scopes, P);
|
|
253
|
+
}
|
|
254
|
+
r && this.storage.setItem(this.getKeyForTokenType(M.id_token), r), i && this.storage.setItem(this.getKeyForTokenType(M.access_token), i), a && this.storage.setItem(this.getKeyForTokenType(M.refresh_token), a), o && this.storage.setItem(this.scopes, o.join(","));
|
|
255
|
+
}
|
|
249
256
|
}
|
|
250
257
|
getToken(e) {
|
|
251
258
|
return this.readToken(this.getKeyForTokenType(e));
|
|
@@ -393,9 +400,9 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
393
400
|
getKeyForTokenType(e) {
|
|
394
401
|
return `${this.keyStoragePrefix}${e}`;
|
|
395
402
|
}
|
|
396
|
-
},
|
|
403
|
+
}, de = class {
|
|
397
404
|
constructor(e) {
|
|
398
|
-
this.storageManager = e ?? new
|
|
405
|
+
this.storageManager = e ?? new ue();
|
|
399
406
|
}
|
|
400
407
|
getDeviceId() {
|
|
401
408
|
return this.storageManager.getDeviceId() || (this.mintedDeviceId ?? (this.mintedDeviceId = this.generateUniqueDeviceId()), this.storageManager.setDeviceId(this.mintedDeviceId), this.mintedDeviceId);
|
|
@@ -403,11 +410,11 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
403
410
|
generateUniqueDeviceId() {
|
|
404
411
|
return re();
|
|
405
412
|
}
|
|
406
|
-
},
|
|
413
|
+
}, fe = class extends Error {
|
|
407
414
|
constructor(e = "Authentication popup was closed") {
|
|
408
415
|
super(e), this.name = "PopupClosedError";
|
|
409
416
|
}
|
|
410
|
-
},
|
|
417
|
+
}, L = class {
|
|
411
418
|
constructor() {
|
|
412
419
|
this.passkeys = {
|
|
413
420
|
startRegistration: (e) => r({ optionsJSON: e }),
|
|
@@ -484,7 +491,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
484
491
|
watchPopup(e, t) {
|
|
485
492
|
return new Promise((n, r) => {
|
|
486
493
|
let i = Date.now(), a = setInterval(() => {
|
|
487
|
-
if (e.closed) clearInterval(a), r(new
|
|
494
|
+
if (e.closed) clearInterval(a), r(new fe());
|
|
488
495
|
else if (Date.now() - i > 6e4) clearInterval(a), e.close(), r(/* @__PURE__ */ Error("Authentication popup timed out"));
|
|
489
496
|
else try {
|
|
490
497
|
if (e.location.href.startsWith(t)) {
|
|
@@ -519,16 +526,16 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
519
526
|
getDeviceType() {
|
|
520
527
|
return "web";
|
|
521
528
|
}
|
|
522
|
-
},
|
|
529
|
+
}, R = new L(), pe = /^[0-9]+$/, me = Object.freeze({
|
|
523
530
|
unorderable: !1,
|
|
524
531
|
zero: !1
|
|
525
|
-
}),
|
|
526
|
-
if (!e) return
|
|
532
|
+
}), he = (e) => pe.test(e) ? Number.parseInt(e, 10) : void 0, ge = (e) => {
|
|
533
|
+
if (!e) return me;
|
|
527
534
|
let t = e.split(/\s+/).filter((e) => e !== "");
|
|
528
|
-
if (t.length === 0) return
|
|
535
|
+
if (t.length === 0) return me;
|
|
529
536
|
let n = [];
|
|
530
537
|
for (let e of t) {
|
|
531
|
-
let t =
|
|
538
|
+
let t = he(e);
|
|
532
539
|
t !== void 0 && n.push(t);
|
|
533
540
|
}
|
|
534
541
|
if (n.length === 0) return {
|
|
@@ -547,17 +554,17 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
547
554
|
unorderable: !1,
|
|
548
555
|
zero: !1
|
|
549
556
|
};
|
|
550
|
-
},
|
|
557
|
+
}, _e = (e) => ge(e).level, ve = "insufficient_user_authentication", ye = "upgrade_required", be = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, xe = (e) => e.replace(/\\(.)/g, "$1"), Se = (e) => {
|
|
551
558
|
let t = {};
|
|
552
|
-
|
|
553
|
-
for (let n of e.matchAll(
|
|
559
|
+
be.lastIndex = 0;
|
|
560
|
+
for (let n of e.matchAll(be)) {
|
|
554
561
|
let e = n[1];
|
|
555
562
|
if (!e) continue;
|
|
556
563
|
let r = n[2], i = n[3];
|
|
557
|
-
t[e.toLowerCase()] = r === void 0 ? i ?? "" :
|
|
564
|
+
t[e.toLowerCase()] = r === void 0 ? i ?? "" : xe(r);
|
|
558
565
|
}
|
|
559
566
|
return t;
|
|
560
|
-
},
|
|
567
|
+
}, Ce = (e) => {
|
|
561
568
|
if (e == null || e === "") return { kind: "absent" };
|
|
562
569
|
let t = typeof e == "number" ? e : Number.parseInt(String(e), 10);
|
|
563
570
|
return Number.isFinite(t) && t > 0 ? {
|
|
@@ -567,38 +574,38 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
567
574
|
kind: "invalid",
|
|
568
575
|
raw: e
|
|
569
576
|
};
|
|
570
|
-
},
|
|
571
|
-
let t =
|
|
577
|
+
}, we = (e) => {
|
|
578
|
+
let t = Ce(e);
|
|
572
579
|
return t.kind === "valid" ? t.value : void 0;
|
|
573
|
-
},
|
|
580
|
+
}, Te = (e, t) => {
|
|
574
581
|
if (!e || !/(^|[\s,])Bearer\b/i.test(e)) return;
|
|
575
|
-
let n =
|
|
582
|
+
let n = Se(e);
|
|
576
583
|
if (n.error === "insufficient_user_authentication") return {
|
|
577
584
|
acrValues: n.acr_values || void 0,
|
|
578
|
-
maxAge:
|
|
585
|
+
maxAge: we(n.max_age),
|
|
579
586
|
status: t
|
|
580
587
|
};
|
|
581
|
-
},
|
|
588
|
+
}, Ee = (e, t) => {
|
|
582
589
|
if (!e || typeof e != "object") return;
|
|
583
590
|
let n = e;
|
|
584
591
|
if (n.error !== "upgrade_required") return;
|
|
585
592
|
let r = Array.isArray(n.available_factors) ? n.available_factors.filter((e) => typeof e == "string") : void 0;
|
|
586
593
|
return {
|
|
587
594
|
acrValues: typeof n.acr_values == "string" && n.acr_values ? n.acr_values : void 0,
|
|
588
|
-
maxAge:
|
|
595
|
+
maxAge: we(n.max_age),
|
|
589
596
|
status: t,
|
|
590
597
|
...r ? { availableFactors: r } : {},
|
|
591
598
|
...typeof n.sign_in_required == "boolean" ? { signInRequired: n.sign_in_required } : {}
|
|
592
599
|
};
|
|
593
|
-
},
|
|
600
|
+
}, De = (e, t, n) => ({
|
|
594
601
|
channel: e,
|
|
595
|
-
acr:
|
|
596
|
-
maxAge:
|
|
602
|
+
acr: ge(t.acrValues),
|
|
603
|
+
maxAge: Ce(n),
|
|
597
604
|
raw: t.acrValues
|
|
598
|
-
}),
|
|
605
|
+
}), Oe = (e) => e ? Se(e) : {}, ke = (e, t) => {
|
|
599
606
|
let { status: n } = e;
|
|
600
607
|
if (n !== 401 && n !== 403) return { diagnostics: [] };
|
|
601
|
-
let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a =
|
|
608
|
+
let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a = Te(i, n), o = r ? void 0 : Ee(e.body, n), s = [], c = (e, t) => {
|
|
602
609
|
s.push({
|
|
603
610
|
status: n,
|
|
604
611
|
url: "",
|
|
@@ -608,9 +615,9 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
608
615
|
};
|
|
609
616
|
if (!a && !o) return r && c("header-required-but-absent", i ? { header: i } : void 0), { diagnostics: s };
|
|
610
617
|
let l = [];
|
|
611
|
-
if (a && l.push(
|
|
618
|
+
if (a && l.push(De("header", a, Oe(i).max_age)), o) {
|
|
612
619
|
let t = e.body;
|
|
613
|
-
l.push(
|
|
620
|
+
l.push(De("body", o, t?.max_age));
|
|
614
621
|
}
|
|
615
622
|
let u = (e) => e;
|
|
616
623
|
for (let e of l) e.acr.unorderable && c("channels-unorderable", { [u(e.channel)]: e.raw }), e.acr.zero && c("zero-constraint-ignored", {
|
|
@@ -646,23 +653,23 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
646
653
|
},
|
|
647
654
|
diagnostics: s
|
|
648
655
|
};
|
|
649
|
-
},
|
|
656
|
+
}, Ae = (e, t, n) => ke({
|
|
650
657
|
status: e,
|
|
651
658
|
getHeader: t,
|
|
652
659
|
body: n
|
|
653
|
-
}).challenge,
|
|
660
|
+
}).challenge, je = "__passflowUpgradeTransaction", Me = "__passflowUpgradeReplayed", Ne = (e, t) => typeof e == "object" && !!e && e[t] === !0, Pe = (e) => ({
|
|
654
661
|
...e ?? {},
|
|
655
|
-
[Ae]: !0
|
|
656
|
-
}), Pe = (e) => Me(e, Ae), Fe = (e) => ({
|
|
657
|
-
...e,
|
|
658
662
|
[je]: !0
|
|
659
|
-
}),
|
|
663
|
+
}), Fe = (e) => Ne(e, je), Ie = (e) => ({
|
|
664
|
+
...e,
|
|
665
|
+
[Me]: !0
|
|
666
|
+
}), Le = (e) => Ne(e, Me), Re = /* @__PURE__ */ function(e) {
|
|
660
667
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
661
|
-
}({}),
|
|
668
|
+
}({}), z = /* @__PURE__ */ function(e) {
|
|
662
669
|
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e;
|
|
663
|
-
}({}),
|
|
670
|
+
}({}), ze = /* @__PURE__ */ function(e) {
|
|
664
671
|
return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
|
|
665
|
-
}({}),
|
|
672
|
+
}({}), Be = (e) => {
|
|
666
673
|
if (!e) return null;
|
|
667
674
|
try {
|
|
668
675
|
let t = new URL(e), n = t.pathname.replace(/\/+$/, "");
|
|
@@ -673,57 +680,57 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
673
680
|
} catch {
|
|
674
681
|
return null;
|
|
675
682
|
}
|
|
676
|
-
},
|
|
683
|
+
}, Ve = (e) => typeof e == "object" && !!e && e.email_verification_required === !0, He = "error.service.unavailable", Ue = "Passflow is temporarily unavailable. Please try again in a moment.", B = class extends Error {
|
|
677
684
|
constructor(e, t) {
|
|
678
685
|
super(), this.name = "PassflowError", this.id = e?.id ?? "unknown", this.message = e?.message ?? e ?? "Something went wrong", this.status = e?.status ?? 500, this.location = e?.location ?? "unknown", this.time = e?.time ?? (/* @__PURE__ */ new Date()).toISOString(), t?.cause !== void 0 && (this.cause = t.cause);
|
|
679
686
|
}
|
|
680
|
-
},
|
|
687
|
+
}, We = "error.api.password.change.required", Ge = "error.api.anti_bot.required", Ke = "error.api.anti_bot.failed", qe = "error.api.anti_bot.unavailable", Je = "error.anti_bot.provider_missing", Ye = "error.anti_bot.provider_failed", Xe = "error.anti_bot.solve_failed", Ze = class extends B {
|
|
681
688
|
constructor(e, t) {
|
|
682
689
|
super(e, t), this.name = "PassflowPasswordChangeRequiredError";
|
|
683
690
|
}
|
|
684
|
-
},
|
|
691
|
+
}, Qe = /* @__PURE__ */ function(e) {
|
|
685
692
|
return e.google = "google", e.facebook = "facebook", e;
|
|
686
|
-
}({}),
|
|
693
|
+
}({}), $e = Object.freeze([
|
|
687
694
|
"debug_otp_code_for_registration",
|
|
688
695
|
"fcm_server_key",
|
|
689
696
|
"webpush_vapid_private_key"
|
|
690
|
-
]),
|
|
697
|
+
]), et = "mask://", tt = "error.server.update.settings.masked.value.unknown", nt = (e) => typeof e == "string" && e.startsWith("mask://"), rt = /* @__PURE__ */ function(e) {
|
|
691
698
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
692
699
|
}({});
|
|
693
|
-
function
|
|
700
|
+
function it(e) {
|
|
694
701
|
return e;
|
|
695
702
|
}
|
|
696
|
-
function
|
|
703
|
+
function at(e, t) {
|
|
697
704
|
let n = e;
|
|
698
705
|
return Object.entries(t).forEach(([e, t]) => {
|
|
699
706
|
n = n.replace(`:${e}`, t);
|
|
700
707
|
}), n;
|
|
701
708
|
}
|
|
702
|
-
var
|
|
709
|
+
var ot = /* @__PURE__ */ function(e) {
|
|
703
710
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
704
|
-
}({}),
|
|
711
|
+
}({}), st = 3, ct = 1e3, lt = (e) => (t) => {
|
|
705
712
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
706
713
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
707
|
-
},
|
|
714
|
+
}, ut = (e) => Ae(e.status, lt(e), e.data), dt = (e) => ut(e) !== void 0, ft = (e) => {
|
|
708
715
|
let t = e.response?.data?.error;
|
|
709
716
|
return typeof t?.id == "string" ? t.id : void 0;
|
|
710
|
-
},
|
|
717
|
+
}, pt = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), mt = [
|
|
711
718
|
502,
|
|
712
719
|
503,
|
|
713
720
|
504
|
|
714
|
-
],
|
|
721
|
+
], ht = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, gt = (e, n) => {
|
|
715
722
|
let r = new t(e.message, e.code);
|
|
716
|
-
return e.cause instanceof TypeError && (r.cause = e.cause), new
|
|
717
|
-
id:
|
|
718
|
-
message:
|
|
723
|
+
return e.cause instanceof TypeError && (r.cause = e.cause), new B({
|
|
724
|
+
id: He,
|
|
725
|
+
message: Ue,
|
|
719
726
|
status: n,
|
|
720
727
|
location: e.config?.url ?? "unknown",
|
|
721
728
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
722
729
|
}, { cause: r });
|
|
723
|
-
},
|
|
730
|
+
}, _t = (e) => e?.includes(z.refresh) ?? !1, vt = (e) => e?.includes("/auth/session/") ?? !1, yt = (e) => e?.includes("logout") ?? !1, bt = "__passflowOwnBearer", xt = (e) => typeof e == "object" && !!e && e[bt] === !0, St = (e) => e ? {
|
|
724
731
|
headers: { [l]: `Bearer ${e}` },
|
|
725
|
-
[
|
|
726
|
-
} : {},
|
|
732
|
+
[bt]: !0
|
|
733
|
+
} : {}, Ct = class {
|
|
727
734
|
get origin() {
|
|
728
735
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
729
736
|
}
|
|
@@ -742,10 +749,10 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
742
749
|
"upgrade"
|
|
743
750
|
];
|
|
744
751
|
let { url: i, appId: a, keyStoragePrefix: s } = t;
|
|
745
|
-
this._platform = t.platform ??
|
|
752
|
+
this._platform = t.platform ?? R, this.url = i || "https://auth.passflow.cloud", this.upgradeDomain = Be(i), this.storageManager = n ?? new ue({
|
|
746
753
|
prefix: s ?? "",
|
|
747
754
|
appId: a
|
|
748
|
-
}), this.deviceService = r ?? new
|
|
755
|
+
}), this.deviceService = r ?? new de(this.storageManager), this.tokenService = new k(this.storageManager), this.tokenDeliveryManager = new ce(this.storageManager), a && (this.appId = a, this.defaultHeaders = {
|
|
749
756
|
...this.defaultHeaders,
|
|
750
757
|
[c]: a
|
|
751
758
|
}), this.defaultHeaders = {
|
|
@@ -761,17 +768,17 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
761
768
|
let n = await this.antiBotHandler(t);
|
|
762
769
|
n && (e.headers[f] = n.value, t.builtin = n.builtin);
|
|
763
770
|
}
|
|
764
|
-
if (this.isNonAuthEndpoint(e.url) ||
|
|
771
|
+
if (this.isNonAuthEndpoint(e.url) || xt(e) || vt(e.url)) return e;
|
|
765
772
|
if (this.tokenDeliveryManager.isCookieMode()) {
|
|
766
773
|
e.withCredentials = !0;
|
|
767
774
|
let t = this.storageManager.getCsrfToken();
|
|
768
775
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
769
776
|
}
|
|
770
|
-
if (
|
|
777
|
+
if (_t(e.url)) return e;
|
|
771
778
|
let n = this.storageManager.getTokens();
|
|
772
779
|
if (!n?.access_token) return e;
|
|
773
780
|
let r = n.access_token;
|
|
774
|
-
if (this.refreshHandler && n.refresh_token && !
|
|
781
|
+
if (this.refreshHandler && n.refresh_token && !yt(e.url)) {
|
|
775
782
|
let e = j(n.access_token);
|
|
776
783
|
if (A(e, 30)) {
|
|
777
784
|
let t = !A(e, 0);
|
|
@@ -787,11 +794,11 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
787
794
|
}
|
|
788
795
|
return e.headers[l] = `Bearer ${r}`, e;
|
|
789
796
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
790
|
-
e.response?.status !== 401 ||
|
|
797
|
+
e.response?.status !== 401 || _t(e.config?.url) || vt(e.config?.url) || xt(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid();
|
|
791
798
|
let t = o(e.config);
|
|
792
|
-
if (e.config && e.response?.status === 403 &&
|
|
793
|
-
if (e.response && this.upgradeHandler && !
|
|
794
|
-
let t =
|
|
799
|
+
if (e.config && e.response?.status === 403 && ft(e) === "error.api.anti_bot.failed" && t?.builtin && !t.retried) return t.retried = !0, this.instance.request(e.config);
|
|
800
|
+
if (e.response && this.upgradeHandler && !vt(e.config?.url)) {
|
|
801
|
+
let t = ut(e.response);
|
|
795
802
|
if (t) try {
|
|
796
803
|
return await this.upgradeHandler(e, t);
|
|
797
804
|
} catch (t) {
|
|
@@ -802,7 +809,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
802
809
|
});
|
|
803
810
|
}
|
|
804
811
|
isUpgradeTransactionError(e) {
|
|
805
|
-
return
|
|
812
|
+
return Fe(e.config) || e.response !== void 0 && dt(e.response);
|
|
806
813
|
}
|
|
807
814
|
setUpgradeInterceptor(e) {
|
|
808
815
|
this.upgradeHandler = e;
|
|
@@ -827,7 +834,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
827
834
|
}
|
|
828
835
|
async handleRateLimitError(e) {
|
|
829
836
|
let t = e.config;
|
|
830
|
-
if (!t ||
|
|
837
|
+
if (!t || _t(t.url)) return Promise.reject(e);
|
|
831
838
|
let n = t.method?.toUpperCase();
|
|
832
839
|
if (![
|
|
833
840
|
"GET",
|
|
@@ -835,8 +842,8 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
835
842
|
"OPTIONS"
|
|
836
843
|
].includes(n || "")) return Promise.reject(e);
|
|
837
844
|
let r = t._retryCount || 0;
|
|
838
|
-
if (r >=
|
|
839
|
-
let i =
|
|
845
|
+
if (r >= st) return Promise.reject(e);
|
|
846
|
+
let i = ct * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
840
847
|
if (a) {
|
|
841
848
|
let e = Number.parseInt(a, 10);
|
|
842
849
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -848,16 +855,16 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
848
855
|
return await new Promise((e) => setTimeout(e, i)), t._retryCount = r + 1, this.instance.request(t);
|
|
849
856
|
}
|
|
850
857
|
async handleAxiosError(e) {
|
|
851
|
-
if (
|
|
858
|
+
if (pt(e)) return Promise.reject(gt(e, 0));
|
|
852
859
|
if (!e.response) return Promise.reject(e);
|
|
853
860
|
let t = e.response.status;
|
|
854
|
-
if (
|
|
861
|
+
if (mt.includes(t) && !ht(e.response.data)) return Promise.reject(gt(e, t));
|
|
855
862
|
let n = e.response.data;
|
|
856
863
|
if ("error" in n && typeof n.error == "object" && n.error !== null) {
|
|
857
864
|
let { error: e } = n;
|
|
858
|
-
return e.id === "error.api.password.change.required" ? Promise.reject(new
|
|
865
|
+
return e.id === "error.api.password.change.required" ? Promise.reject(new Ze(e)) : Promise.reject(new B(e));
|
|
859
866
|
}
|
|
860
|
-
return Promise.reject(new
|
|
867
|
+
return Promise.reject(new B({
|
|
861
868
|
id: `error.http.${t}`,
|
|
862
869
|
message: e.message || "An error occurred",
|
|
863
870
|
status: t,
|
|
@@ -873,28 +880,28 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
873
880
|
})).data;
|
|
874
881
|
}
|
|
875
882
|
get(e, t) {
|
|
876
|
-
return this.send(
|
|
883
|
+
return this.send(Re.GET, e, t);
|
|
877
884
|
}
|
|
878
885
|
post(e, t, n) {
|
|
879
|
-
return this.send(
|
|
886
|
+
return this.send(Re.POST, e, {
|
|
880
887
|
data: t,
|
|
881
888
|
...n
|
|
882
889
|
});
|
|
883
890
|
}
|
|
884
891
|
put(e, t, n) {
|
|
885
|
-
return this.send(
|
|
892
|
+
return this.send(Re.PUT, e, {
|
|
886
893
|
data: t,
|
|
887
894
|
...n
|
|
888
895
|
});
|
|
889
896
|
}
|
|
890
897
|
patch(e, t, n) {
|
|
891
|
-
return this.send(
|
|
898
|
+
return this.send(Re.PATCH, e, {
|
|
892
899
|
data: t,
|
|
893
900
|
...n
|
|
894
901
|
});
|
|
895
902
|
}
|
|
896
903
|
delete(e, t) {
|
|
897
|
-
return this.send(
|
|
904
|
+
return this.send(Re.DELETE, e, t);
|
|
898
905
|
}
|
|
899
906
|
setAppId(e) {
|
|
900
907
|
this.appId = e, this.defaultHeaders = {
|
|
@@ -902,27 +909,27 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
902
909
|
[c]: e
|
|
903
910
|
}, this.instance.defaults.headers[c] = e;
|
|
904
911
|
}
|
|
905
|
-
},
|
|
912
|
+
}, wt = class {
|
|
906
913
|
constructor(e, t, n) {
|
|
907
|
-
this.axiosClient = new
|
|
914
|
+
this.axiosClient = new Ct(e, t, n);
|
|
908
915
|
}
|
|
909
916
|
setAppId(e) {
|
|
910
917
|
this.axiosClient.setAppId(e);
|
|
911
918
|
}
|
|
912
919
|
getAppSettings() {
|
|
913
|
-
return this.axiosClient.get(
|
|
920
|
+
return this.axiosClient.get(z.appSettings);
|
|
914
921
|
}
|
|
915
|
-
},
|
|
916
|
-
if (e instanceof
|
|
922
|
+
}, Tt = { withCredentials: !0 }, Et = 15e3, Dt = "X-Passflow-CSRF", Ot = "Sign-in failed. Start again.", kt = "Something went wrong. Try again later.", At = (e, t, n, r) => {
|
|
923
|
+
if (e instanceof B) return e;
|
|
917
924
|
let i = e?.response?.data?.error;
|
|
918
|
-
return new
|
|
925
|
+
return new B({
|
|
919
926
|
id: typeof i?.id == "string" ? i.id : n,
|
|
920
927
|
message: typeof i?.message == "string" ? i.message : r,
|
|
921
928
|
status: typeof i?.status == "number" ? i.status : 0,
|
|
922
929
|
location: t,
|
|
923
930
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
924
931
|
});
|
|
925
|
-
},
|
|
932
|
+
}, V = (e, t, n, r) => !t && !r?.agentTool ? e : {
|
|
926
933
|
...e,
|
|
927
934
|
...t ? a(t, n) : {},
|
|
928
935
|
...r?.agentTool ? { headers: {
|
|
@@ -931,7 +938,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
931
938
|
} } : {}
|
|
932
939
|
}, jt = class {
|
|
933
940
|
constructor(e, t, n) {
|
|
934
|
-
this.axiosClient = new
|
|
941
|
+
this.axiosClient = new Ct(e, t, n);
|
|
935
942
|
}
|
|
936
943
|
setAppId(e) {
|
|
937
944
|
this.axiosClient.setAppId(e);
|
|
@@ -941,20 +948,20 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
941
948
|
}
|
|
942
949
|
async antiBotChallenge(e) {
|
|
943
950
|
try {
|
|
944
|
-
return await this.axiosClient.post(
|
|
951
|
+
return await this.axiosClient.post(z.antiBotChallenge, e);
|
|
945
952
|
} catch (e) {
|
|
946
|
-
throw
|
|
953
|
+
throw At(e, z.antiBotChallenge, "error.anti_bot.challenge", kt);
|
|
947
954
|
}
|
|
948
955
|
}
|
|
949
956
|
async deviceAntiBotChallenge(e, t) {
|
|
950
957
|
try {
|
|
951
|
-
return await this.axiosClient.post(
|
|
958
|
+
return await this.axiosClient.post(z.deviceAntiBotChallenge, e, { headers: { [Dt]: t } });
|
|
952
959
|
} catch (e) {
|
|
953
|
-
throw
|
|
960
|
+
throw At(e, z.deviceAntiBotChallenge, "error.anti_bot.challenge", kt);
|
|
954
961
|
}
|
|
955
962
|
}
|
|
956
963
|
federatedStart(e, t, n) {
|
|
957
|
-
return this.axiosClient.post(`${
|
|
964
|
+
return this.axiosClient.post(`${z.signInWithProvider}${e}`, t, V(Tt, "federated.start", void 0, n));
|
|
958
965
|
}
|
|
959
966
|
refreshToken(e, t, n, r) {
|
|
960
967
|
let i = {
|
|
@@ -962,7 +969,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
962
969
|
scopes: t,
|
|
963
970
|
...r ? { upgrade: r } : {}
|
|
964
971
|
}, a = { headers: { [l]: `Bearer ${e}` } };
|
|
965
|
-
return this.axiosClient.post(
|
|
972
|
+
return this.axiosClient.post(z.refresh, i, r ? Pe(a) : a);
|
|
966
973
|
}
|
|
967
974
|
signIn(e, t, n, r) {
|
|
968
975
|
let i = {
|
|
@@ -970,7 +977,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
970
977
|
device: t,
|
|
971
978
|
os: n
|
|
972
979
|
};
|
|
973
|
-
return this.axiosClient.post(
|
|
980
|
+
return this.axiosClient.post(z.signin, i, V(Tt, "sign-in", e.email ?? e.phone ?? e.username, r));
|
|
974
981
|
}
|
|
975
982
|
signUp(e, t) {
|
|
976
983
|
let { create_tenant: n, anonymous: r } = e, i = {
|
|
@@ -978,16 +985,16 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
978
985
|
create_tenant: n ?? !1,
|
|
979
986
|
anonymous: r ?? !1
|
|
980
987
|
};
|
|
981
|
-
return this.axiosClient.post(
|
|
988
|
+
return this.axiosClient.post(z.signup, i, V(Tt, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
|
|
982
989
|
}
|
|
983
990
|
async pkceExchange(e, t) {
|
|
984
991
|
try {
|
|
985
|
-
return await this.axiosClient.post(
|
|
992
|
+
return await this.axiosClient.post(z.pkceExchange, {
|
|
986
993
|
authz_code: e,
|
|
987
994
|
verifier: t
|
|
988
|
-
},
|
|
995
|
+
}, Tt);
|
|
989
996
|
} catch (e) {
|
|
990
|
-
throw
|
|
997
|
+
throw At(e, z.pkceExchange, "error.pkce.exchange", Ot);
|
|
991
998
|
}
|
|
992
999
|
}
|
|
993
1000
|
async passwordlessSignIn(e, t, n, r) {
|
|
@@ -998,68 +1005,68 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
998
1005
|
os: n
|
|
999
1006
|
};
|
|
1000
1007
|
try {
|
|
1001
|
-
return await this.axiosClient.post(
|
|
1008
|
+
return await this.axiosClient.post(z.passwordless, a, V(void 0, "passwordless.start", e.email ?? e.phone, r));
|
|
1002
1009
|
} catch (e) {
|
|
1003
|
-
throw
|
|
1010
|
+
throw At(e, z.passwordless, "error.passwordless.start", kt);
|
|
1004
1011
|
}
|
|
1005
1012
|
}
|
|
1006
1013
|
async passwordlessSignInComplete(e, t) {
|
|
1007
1014
|
try {
|
|
1008
|
-
return await this.axiosClient.post(
|
|
1015
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, V(Tt, void 0, void 0, t));
|
|
1009
1016
|
} catch (e) {
|
|
1010
|
-
throw
|
|
1017
|
+
throw At(e, z.passwordlessComplete, "error.passwordless.complete", kt);
|
|
1011
1018
|
}
|
|
1012
1019
|
}
|
|
1013
1020
|
async passwordlessStatus(e, t) {
|
|
1014
1021
|
try {
|
|
1015
|
-
return await this.axiosClient.post(
|
|
1016
|
-
...
|
|
1017
|
-
timeout:
|
|
1022
|
+
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
1023
|
+
...Tt,
|
|
1024
|
+
timeout: Et,
|
|
1018
1025
|
signal: t?.signal
|
|
1019
1026
|
});
|
|
1020
1027
|
} catch (e) {
|
|
1021
|
-
throw
|
|
1028
|
+
throw At(e, z.passwordlessStatus, "error.passwordless.status", Ot);
|
|
1022
1029
|
}
|
|
1023
1030
|
}
|
|
1024
1031
|
async checkRedirectUrl(e) {
|
|
1025
1032
|
try {
|
|
1026
|
-
return (await this.axiosClient.post(
|
|
1033
|
+
return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
|
|
1027
1034
|
} catch (e) {
|
|
1028
|
-
throw
|
|
1035
|
+
throw At(e, z.redirectCheck, "error.redirect.check", kt);
|
|
1029
1036
|
}
|
|
1030
1037
|
}
|
|
1031
1038
|
async passwordlessApprovalInfo(e) {
|
|
1032
1039
|
try {
|
|
1033
|
-
return await this.axiosClient.post(
|
|
1040
|
+
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
1034
1041
|
} catch (e) {
|
|
1035
|
-
throw
|
|
1042
|
+
throw At(e, z.passwordlessApprovalInfo, "error.passwordless.approval", kt);
|
|
1036
1043
|
}
|
|
1037
1044
|
}
|
|
1038
1045
|
async passwordlessApprovalDecide(e) {
|
|
1039
1046
|
try {
|
|
1040
|
-
return await this.axiosClient.post(
|
|
1047
|
+
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
1041
1048
|
} catch (e) {
|
|
1042
|
-
throw
|
|
1049
|
+
throw At(e, z.passwordlessApprovalDecide, "error.passwordless.approval", kt);
|
|
1043
1050
|
}
|
|
1044
1051
|
}
|
|
1045
1052
|
validateEmailCode(e) {
|
|
1046
|
-
return this.axiosClient.post(
|
|
1053
|
+
return this.axiosClient.post(z.passkeyValidate, {
|
|
1047
1054
|
challenge_id: e.challenge_id,
|
|
1048
1055
|
otp: e.otp
|
|
1049
|
-
},
|
|
1056
|
+
}, Tt);
|
|
1050
1057
|
}
|
|
1051
1058
|
logOut(e, t, n = !1) {
|
|
1052
1059
|
let r = n ? void 0 : {
|
|
1053
1060
|
refresh_token: t,
|
|
1054
1061
|
device: e
|
|
1055
|
-
}, i = n ?
|
|
1062
|
+
}, i = n ? ze.logout : z.logout;
|
|
1056
1063
|
return this.axiosClient.post(i, r);
|
|
1057
1064
|
}
|
|
1058
1065
|
validateSession() {
|
|
1059
|
-
return this.axiosClient.get(
|
|
1066
|
+
return this.axiosClient.get(z.validateSession);
|
|
1060
1067
|
}
|
|
1061
1068
|
sendPasswordResetEmail(e, t) {
|
|
1062
|
-
return this.axiosClient.post(
|
|
1069
|
+
return this.axiosClient.post(z.sendPasswordResetEmail, e, V(void 0, "password-reset.send", e.email ?? e.phone ?? e.username, t));
|
|
1063
1070
|
}
|
|
1064
1071
|
resetPassword(e, t, n, r) {
|
|
1065
1072
|
let i = {
|
|
@@ -1067,7 +1074,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1067
1074
|
scopes: t,
|
|
1068
1075
|
...r ? { code_challenge: r } : {}
|
|
1069
1076
|
};
|
|
1070
|
-
return this.axiosClient.post(
|
|
1077
|
+
return this.axiosClient.post(z.resetPassword, i, { headers: {
|
|
1071
1078
|
[l]: `Bearer ${n}`,
|
|
1072
1079
|
[c]: void 0
|
|
1073
1080
|
} });
|
|
@@ -1078,16 +1085,16 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1078
1085
|
create_tenant: a ?? !1,
|
|
1079
1086
|
device: t,
|
|
1080
1087
|
os: n
|
|
1081
|
-
}, s = r ?
|
|
1082
|
-
return this.axiosClient.post(s, o,
|
|
1088
|
+
}, s = r ? ze.passkeyRegisterStart : z.passkeyRegisterStart;
|
|
1089
|
+
return this.axiosClient.post(s, o, V(void 0, r ? void 0 : "passkey.register", e.passkey_username, i));
|
|
1083
1090
|
}
|
|
1084
1091
|
passkeyRegisterComplete(e, t, n, r = !1, i) {
|
|
1085
1092
|
let a = {
|
|
1086
1093
|
challenge_id: n,
|
|
1087
1094
|
device: t,
|
|
1088
1095
|
passkey_data: e
|
|
1089
|
-
}, o = r ?
|
|
1090
|
-
return this.axiosClient.post(o, a,
|
|
1096
|
+
}, o = r ? ze.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
1097
|
+
return this.axiosClient.post(o, a, V(Tt, void 0, void 0, i));
|
|
1091
1098
|
}
|
|
1092
1099
|
passkeyAuthenticateStart(e, t, n, r = !1, i) {
|
|
1093
1100
|
let a = {
|
|
@@ -1095,91 +1102,91 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1095
1102
|
user_id: e.user_id ?? "",
|
|
1096
1103
|
device: t,
|
|
1097
1104
|
os: n
|
|
1098
|
-
}, o = r ?
|
|
1099
|
-
return this.axiosClient.post(o, a,
|
|
1105
|
+
}, o = r ? ze.passkeyAuthenticateStart : z.passkeyAuthenticateStart;
|
|
1106
|
+
return this.axiosClient.post(o, a, V(void 0, r ? void 0 : "passkey.authenticate", void 0, i));
|
|
1100
1107
|
}
|
|
1101
1108
|
passkeyAuthenticateComplete(e, t, n, r = !1, i) {
|
|
1102
1109
|
let a = {
|
|
1103
1110
|
challenge_id: n,
|
|
1104
1111
|
device: t,
|
|
1105
1112
|
passkey_data: e
|
|
1106
|
-
}, o = r ?
|
|
1107
|
-
return this.axiosClient.post(o, a,
|
|
1113
|
+
}, o = r ? ze.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
1114
|
+
return this.axiosClient.post(o, a, V(Tt, void 0, void 0, i));
|
|
1108
1115
|
}
|
|
1109
1116
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
1110
1117
|
let a = {
|
|
1111
1118
|
otp: e,
|
|
1112
1119
|
device: t,
|
|
1113
1120
|
challenge_id: n
|
|
1114
|
-
}, o =
|
|
1115
|
-
!i && r && (o =
|
|
1121
|
+
}, o = z.passkeyValidate;
|
|
1122
|
+
!i && r && (o = ze.passkeyValidate);
|
|
1116
1123
|
let s = i ? { [c]: i } : {};
|
|
1117
1124
|
return this.axiosClient.post(o, a, { headers: s });
|
|
1118
1125
|
}
|
|
1119
1126
|
}, Mt = class {
|
|
1120
1127
|
constructor(e, t, n) {
|
|
1121
|
-
this.axiosClient = new
|
|
1128
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1122
1129
|
}
|
|
1123
1130
|
setAppId(e) {
|
|
1124
1131
|
this.axiosClient.setAppId(e);
|
|
1125
1132
|
}
|
|
1126
1133
|
getCLIAuthStatus(e) {
|
|
1127
|
-
let t =
|
|
1134
|
+
let t = at(z.cliAuthStatus, { sessionId: e });
|
|
1128
1135
|
return this.axiosClient.get(t);
|
|
1129
1136
|
}
|
|
1130
1137
|
completeCLIAuth(e) {
|
|
1131
|
-
return this.axiosClient.post(
|
|
1138
|
+
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
1132
1139
|
}
|
|
1133
1140
|
}, Nt = class {
|
|
1134
1141
|
constructor(e, t, n) {
|
|
1135
|
-
this.axiosClient = new
|
|
1142
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1136
1143
|
}
|
|
1137
1144
|
setAppId(e) {
|
|
1138
1145
|
this.axiosClient.setAppId(e);
|
|
1139
1146
|
}
|
|
1140
1147
|
requestInviteLink(e) {
|
|
1141
|
-
return this.axiosClient.post(
|
|
1148
|
+
return this.axiosClient.post(z.requestInvitation, e);
|
|
1142
1149
|
}
|
|
1143
1150
|
getInvitations(e) {
|
|
1144
1151
|
let t = {};
|
|
1145
1152
|
e.groupID && (t.group_id = e.groupID.toString()), e.skip !== void 0 && (t.skip = e.skip.toString()), e.limit !== void 0 && (t.limit = e.limit.toString());
|
|
1146
|
-
let n =
|
|
1153
|
+
let n = at(z.invitationsPath, { tenantID: e.tenantID });
|
|
1147
1154
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
1148
1155
|
invites: e.invites,
|
|
1149
1156
|
nextPageSkip: e.next_page_skip
|
|
1150
1157
|
}));
|
|
1151
1158
|
}
|
|
1152
1159
|
deleteInvitation(e) {
|
|
1153
|
-
let t =
|
|
1160
|
+
let t = at(z.invitationDelete, { invitationID: e });
|
|
1154
1161
|
return this.axiosClient.delete(t);
|
|
1155
1162
|
}
|
|
1156
1163
|
resendInvitation(e) {
|
|
1157
|
-
let t =
|
|
1164
|
+
let t = at(z.invitationResend, { invitationID: e });
|
|
1158
1165
|
return this.axiosClient.post(t, {});
|
|
1159
1166
|
}
|
|
1160
1167
|
getInvitationLink(e) {
|
|
1161
|
-
let t =
|
|
1168
|
+
let t = at(z.invitationGetLink, { invitationID: e });
|
|
1162
1169
|
return this.axiosClient.get(t);
|
|
1163
1170
|
}
|
|
1164
1171
|
}, Pt = class {
|
|
1165
1172
|
constructor(e, t, n) {
|
|
1166
|
-
this.axiosClient = new
|
|
1173
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1167
1174
|
}
|
|
1168
1175
|
setAppId(e) {
|
|
1169
1176
|
this.axiosClient.setAppId(e);
|
|
1170
1177
|
}
|
|
1171
1178
|
getSettingsAll() {
|
|
1172
|
-
return this.axiosClient.get(
|
|
1179
|
+
return this.axiosClient.get(z.settingsAll);
|
|
1173
1180
|
}
|
|
1174
1181
|
getPasswordPolicySettings() {
|
|
1175
|
-
return this.axiosClient.get(
|
|
1182
|
+
return this.axiosClient.get(z.settingsPasswordPolicy);
|
|
1176
1183
|
}
|
|
1177
1184
|
getPasskeySettings() {
|
|
1178
|
-
return this.axiosClient.get(
|
|
1185
|
+
return this.axiosClient.get(z.settingsPasskey);
|
|
1179
1186
|
}
|
|
1180
1187
|
}, Ft = class {
|
|
1181
1188
|
constructor(e, t, n) {
|
|
1182
|
-
this.axiosClient = new
|
|
1189
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1183
1190
|
}
|
|
1184
1191
|
setAppId(e) {
|
|
1185
1192
|
this.axiosClient.setAppId(e);
|
|
@@ -1189,108 +1196,108 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1189
1196
|
invite_token: e,
|
|
1190
1197
|
scopes: t
|
|
1191
1198
|
};
|
|
1192
|
-
return this.axiosClient.post(
|
|
1199
|
+
return this.axiosClient.post(z.joinInvitation, n);
|
|
1193
1200
|
}
|
|
1194
1201
|
createTenant(e) {
|
|
1195
1202
|
let t = { name: e };
|
|
1196
|
-
return this.axiosClient.post(
|
|
1203
|
+
return this.axiosClient.post(z.tenantPath, t);
|
|
1197
1204
|
}
|
|
1198
1205
|
getTenantDetails(e) {
|
|
1199
|
-
let t = `${
|
|
1206
|
+
let t = `${z.tenantPath}/${e}`;
|
|
1200
1207
|
return this.axiosClient.get(t);
|
|
1201
1208
|
}
|
|
1202
1209
|
updateTenant(e, t) {
|
|
1203
|
-
let n = `${
|
|
1210
|
+
let n = `${z.tenantPath}/${e}`, r = { name: t };
|
|
1204
1211
|
return this.axiosClient.put(n, r);
|
|
1205
1212
|
}
|
|
1206
1213
|
deleteTenant(e) {
|
|
1207
|
-
let t = `${
|
|
1214
|
+
let t = `${z.tenantPath}/${e}`;
|
|
1208
1215
|
return this.axiosClient.delete(t);
|
|
1209
1216
|
}
|
|
1210
1217
|
getUserTenantMembership() {
|
|
1211
|
-
return this.axiosClient.get(
|
|
1218
|
+
return this.axiosClient.get(z.tenantPath);
|
|
1212
1219
|
}
|
|
1213
1220
|
createGroup(e, t) {
|
|
1214
|
-
let n = `${
|
|
1221
|
+
let n = `${z.tenantPath}/${e}/group`, r = { name: t };
|
|
1215
1222
|
return this.axiosClient.post(n, r);
|
|
1216
1223
|
}
|
|
1217
1224
|
getGroupInfo(e, t) {
|
|
1218
|
-
let n = `${
|
|
1225
|
+
let n = `${z.tenantPath}/${e}/group/${t}`;
|
|
1219
1226
|
return this.axiosClient.get(n);
|
|
1220
1227
|
}
|
|
1221
1228
|
updateGroup(e, t, n) {
|
|
1222
|
-
let r = `${
|
|
1229
|
+
let r = `${z.tenantPath}/${e}/group/${t}`, i = { name: n };
|
|
1223
1230
|
return this.axiosClient.put(r, i);
|
|
1224
1231
|
}
|
|
1225
1232
|
deleteGroup(e, t) {
|
|
1226
|
-
let n = `${
|
|
1233
|
+
let n = `${z.tenantPath}/${e}/group/${t}`;
|
|
1227
1234
|
return this.axiosClient.delete(n);
|
|
1228
1235
|
}
|
|
1229
1236
|
addUserToGroup(e, t, n, r) {
|
|
1230
|
-
let i = `${
|
|
1237
|
+
let i = `${z.tenantPath}/${e}/group/${t}/add`, a = {
|
|
1231
1238
|
user_id: n,
|
|
1232
1239
|
role: r
|
|
1233
1240
|
};
|
|
1234
1241
|
return this.axiosClient.post(i, a);
|
|
1235
1242
|
}
|
|
1236
1243
|
removeUserRolesFromGroup(e, t, n, r) {
|
|
1237
|
-
let i = `${
|
|
1244
|
+
let i = `${z.tenantPath}/${e}/group/${t}/remove_roles`, a = {
|
|
1238
1245
|
user_id: n,
|
|
1239
1246
|
roles: r
|
|
1240
1247
|
};
|
|
1241
1248
|
return this.axiosClient.post(i, a);
|
|
1242
1249
|
}
|
|
1243
1250
|
changeUserRoles(e, t, n, r) {
|
|
1244
|
-
let i = `${
|
|
1251
|
+
let i = `${z.tenantPath}/${e}/group/${t}/change`, a = {
|
|
1245
1252
|
user_id: n,
|
|
1246
1253
|
roles: r
|
|
1247
1254
|
};
|
|
1248
1255
|
return this.axiosClient.post(i, a);
|
|
1249
1256
|
}
|
|
1250
1257
|
deleteUserFromGroup(e, t, n) {
|
|
1251
|
-
let r = `${
|
|
1258
|
+
let r = `${z.tenantPath}/${e}/group/${t}/${n}`;
|
|
1252
1259
|
return this.axiosClient.delete(r);
|
|
1253
1260
|
}
|
|
1254
1261
|
getRolesForTenant(e) {
|
|
1255
|
-
let t = `${
|
|
1262
|
+
let t = `${z.tenantPath}/${e}/role`;
|
|
1256
1263
|
return this.axiosClient.get(t);
|
|
1257
1264
|
}
|
|
1258
1265
|
createRoleForTenant(e, t) {
|
|
1259
|
-
let n = `${
|
|
1266
|
+
let n = `${z.tenantPath}/${e}/role`, r = { name: t };
|
|
1260
1267
|
return this.axiosClient.post(n, r);
|
|
1261
1268
|
}
|
|
1262
1269
|
updateRole(e, t, n) {
|
|
1263
|
-
let r = `${
|
|
1270
|
+
let r = `${z.tenantPath}/${e}/role/${t}`, i = { name: n };
|
|
1264
1271
|
return this.axiosClient.put(r, i);
|
|
1265
1272
|
}
|
|
1266
1273
|
deleteRole(e, t) {
|
|
1267
|
-
let n = `${
|
|
1274
|
+
let n = `${z.tenantPath}/${e}/role/${t}`;
|
|
1268
1275
|
return this.axiosClient.delete(n);
|
|
1269
1276
|
}
|
|
1270
1277
|
deleteUserFromTenant(e, t) {
|
|
1271
|
-
let n = `${
|
|
1278
|
+
let n = `${z.tenantPath}/${e}/user/${t}`;
|
|
1272
1279
|
return this.axiosClient.delete(n);
|
|
1273
1280
|
}
|
|
1274
1281
|
getGroupInvitations(e, t, n, r) {
|
|
1275
|
-
let i = `${
|
|
1282
|
+
let i = `${z.tenantPath}/${e}/group/${t}/invitations`;
|
|
1276
1283
|
return this.axiosClient.get(i, { params: {
|
|
1277
1284
|
limit: n,
|
|
1278
1285
|
skip: r
|
|
1279
1286
|
} });
|
|
1280
1287
|
}
|
|
1281
1288
|
getTenantInvitations(e, t, n) {
|
|
1282
|
-
let r = `${
|
|
1289
|
+
let r = `${z.tenantPath}/${e}/invitations`;
|
|
1283
1290
|
return this.axiosClient.get(r, { params: {
|
|
1284
1291
|
limit: t,
|
|
1285
1292
|
skip: n
|
|
1286
1293
|
} });
|
|
1287
1294
|
}
|
|
1288
1295
|
invalidateInviteById(e, t, n) {
|
|
1289
|
-
let r = `${
|
|
1296
|
+
let r = `${z.tenantPath}/${e}/group/${t}/invite/${n}`;
|
|
1290
1297
|
return this.axiosClient.delete(r);
|
|
1291
1298
|
}
|
|
1292
1299
|
invalidateInviteByEmail(e, t, n) {
|
|
1293
|
-
let r = `${
|
|
1300
|
+
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1294
1301
|
return this.axiosClient.delete(r);
|
|
1295
1302
|
}
|
|
1296
1303
|
}, It = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, Lt = (e) => ({
|
|
@@ -1306,54 +1313,54 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1306
1313
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1307
1314
|
}, Bt = class {
|
|
1308
1315
|
constructor(e, t, n) {
|
|
1309
|
-
this.axiosClient = new
|
|
1316
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1310
1317
|
}
|
|
1311
1318
|
setAppId(e) {
|
|
1312
1319
|
this.axiosClient.setAppId(e);
|
|
1313
1320
|
}
|
|
1314
1321
|
getStatus(e) {
|
|
1315
|
-
return this.axiosClient.get(
|
|
1322
|
+
return this.axiosClient.get(z.twoFactorStatus, St(e));
|
|
1316
1323
|
}
|
|
1317
1324
|
async beginSetup(e) {
|
|
1318
|
-
return Rt(await this.axiosClient.post(
|
|
1325
|
+
return Rt(await this.axiosClient.post(z.twoFactorSetupBegin, {}, St(e)));
|
|
1319
1326
|
}
|
|
1320
1327
|
confirmSetup(e, t) {
|
|
1321
|
-
return this.axiosClient.post(
|
|
1328
|
+
return this.axiosClient.post(z.twoFactorSetupConfirm, e, St(t));
|
|
1322
1329
|
}
|
|
1323
1330
|
getEnrollment(e) {
|
|
1324
|
-
return this.axiosClient.get(
|
|
1331
|
+
return this.axiosClient.get(z.twoFactorEnrollment, St(e));
|
|
1325
1332
|
}
|
|
1326
1333
|
sendSetupLink(e) {
|
|
1327
|
-
return this.axiosClient.post(
|
|
1334
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, St(e));
|
|
1328
1335
|
}
|
|
1329
1336
|
async beginEnrollment(e) {
|
|
1330
|
-
return Rt(await this.axiosClient.post(
|
|
1337
|
+
return Rt(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, St(e)));
|
|
1331
1338
|
}
|
|
1332
1339
|
confirmEnrollment(e, t) {
|
|
1333
|
-
return this.axiosClient.post(
|
|
1340
|
+
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, St(e));
|
|
1334
1341
|
}
|
|
1335
1342
|
verify(e) {
|
|
1336
1343
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1337
|
-
return this.axiosClient.post(
|
|
1344
|
+
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1338
1345
|
code: n,
|
|
1339
1346
|
...r ? { trust_device: !0 } : {}
|
|
1340
1347
|
}, Lt(t));
|
|
1341
1348
|
}
|
|
1342
1349
|
useRecoveryCode(e) {
|
|
1343
1350
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1344
|
-
return this.axiosClient.post(
|
|
1351
|
+
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1345
1352
|
recovery_code: n,
|
|
1346
1353
|
...r ? { trust_device: !0 } : {}
|
|
1347
1354
|
}, Lt(t));
|
|
1348
1355
|
}
|
|
1349
1356
|
disable(e) {
|
|
1350
|
-
return this.axiosClient.delete(
|
|
1357
|
+
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
1351
1358
|
}
|
|
1352
1359
|
regenerateRecoveryCodes(e) {
|
|
1353
|
-
return this.axiosClient.post(
|
|
1360
|
+
return this.axiosClient.post(z.twoFactorRegenerateCodes, e);
|
|
1354
1361
|
}
|
|
1355
1362
|
validateTwoFactorSetupMagicLink(e) {
|
|
1356
|
-
let t = `${
|
|
1363
|
+
let t = `${z.twoFactorSetupMagicLink}/${e}`;
|
|
1357
1364
|
return this.axiosClient.get(t, { transformRequest: [(e, t) => (t && delete t.Authorization, e)] }).then((e) => {
|
|
1358
1365
|
let t = e;
|
|
1359
1366
|
return t.valid === !1 ? {
|
|
@@ -1370,7 +1377,7 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1370
1377
|
appId: t.app_id
|
|
1371
1378
|
};
|
|
1372
1379
|
}).catch((e) => {
|
|
1373
|
-
if (e instanceof
|
|
1380
|
+
if (e instanceof B) return {
|
|
1374
1381
|
success: !1,
|
|
1375
1382
|
error: {
|
|
1376
1383
|
code: zt[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
@@ -1416,78 +1423,78 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1416
1423
|
}
|
|
1417
1424
|
}
|
|
1418
1425
|
async getAvailableMethods() {
|
|
1419
|
-
return (await this.axiosClient.get(
|
|
1426
|
+
return (await this.axiosClient.get(z.TwoFactorMethodsAvailable))?.available_methods ?? [];
|
|
1420
1427
|
}
|
|
1421
1428
|
async getRegisteredMethods() {
|
|
1422
|
-
return (await this.axiosClient.get(
|
|
1429
|
+
return (await this.axiosClient.get(z.TwoFactorMethodsRegistered))?.registered_methods ?? [];
|
|
1423
1430
|
}
|
|
1424
1431
|
startMethodSetup(e, t) {
|
|
1425
|
-
return this.axiosClient.post(
|
|
1432
|
+
return this.axiosClient.post(z.TwoFactorSetupStart, {
|
|
1426
1433
|
...t,
|
|
1427
1434
|
method: e
|
|
1428
1435
|
});
|
|
1429
1436
|
}
|
|
1430
1437
|
completeMethodSetup(e, t) {
|
|
1431
|
-
return this.axiosClient.post(
|
|
1438
|
+
return this.axiosClient.post(z.TwoFactorSetupComplete, {
|
|
1432
1439
|
...t,
|
|
1433
1440
|
method: e
|
|
1434
1441
|
});
|
|
1435
1442
|
}
|
|
1436
1443
|
removeMethod(e) {
|
|
1437
|
-
let t =
|
|
1444
|
+
let t = at(z.TwoFactorMethodRemove, { id: e });
|
|
1438
1445
|
return this.axiosClient.delete(t);
|
|
1439
1446
|
}
|
|
1440
1447
|
requestChallenge(e, t) {
|
|
1441
|
-
return this.axiosClient.post(
|
|
1448
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, It(t));
|
|
1442
1449
|
}
|
|
1443
1450
|
verifyV2(e, t) {
|
|
1444
1451
|
let { trust_device: n, ...r } = e;
|
|
1445
|
-
return this.axiosClient.post(
|
|
1452
|
+
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1446
1453
|
...r,
|
|
1447
1454
|
...n ? { trust_device: !0 } : {}
|
|
1448
1455
|
}, Lt(t));
|
|
1449
1456
|
}
|
|
1450
1457
|
switchToAlternative(e, t) {
|
|
1451
|
-
return this.axiosClient.post(
|
|
1458
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, It(t));
|
|
1452
1459
|
}
|
|
1453
1460
|
async getTrustedDevices() {
|
|
1454
|
-
return (await this.axiosClient.get(
|
|
1461
|
+
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1455
1462
|
}
|
|
1456
1463
|
revokeTrustedDevice(e) {
|
|
1457
|
-
let t =
|
|
1464
|
+
let t = at(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1458
1465
|
return this.axiosClient.delete(t);
|
|
1459
1466
|
}
|
|
1460
1467
|
}, Vt = class {
|
|
1461
1468
|
constructor(e, t, n) {
|
|
1462
|
-
this.axiosClient = new
|
|
1469
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1463
1470
|
}
|
|
1464
1471
|
setAppId(e) {
|
|
1465
1472
|
this.axiosClient.setAppId(e);
|
|
1466
1473
|
}
|
|
1467
1474
|
startUpgrade(e) {
|
|
1468
|
-
return this.axiosClient.post(
|
|
1475
|
+
return this.axiosClient.post(z.upgradeStart, e, Pe({}));
|
|
1469
1476
|
}
|
|
1470
1477
|
startHostedUpgrade(e) {
|
|
1471
|
-
return this.axiosClient.post(
|
|
1478
|
+
return this.axiosClient.post(z.hostedUpgradeStart, e, { withCredentials: !0 });
|
|
1472
1479
|
}
|
|
1473
1480
|
async commitHostedUpgrade(e) {
|
|
1474
|
-
await this.axiosClient.post(
|
|
1481
|
+
await this.axiosClient.post(z.hostedUpgrade, e, { withCredentials: !0 });
|
|
1475
1482
|
}
|
|
1476
1483
|
}, Ht = class {
|
|
1477
1484
|
constructor(e, t, n) {
|
|
1478
|
-
this.axiosClient = new
|
|
1485
|
+
this.axiosClient = new Ct(e, t, n);
|
|
1479
1486
|
}
|
|
1480
1487
|
setAppId(e) {
|
|
1481
1488
|
this.axiosClient.setAppId(e);
|
|
1482
1489
|
}
|
|
1483
1490
|
getUserPasskeys() {
|
|
1484
|
-
return this.axiosClient.get(
|
|
1491
|
+
return this.axiosClient.get(z.userPasskey);
|
|
1485
1492
|
}
|
|
1486
1493
|
renameUserPasskey(e, t) {
|
|
1487
|
-
return this.axiosClient.patch(`${
|
|
1494
|
+
return this.axiosClient.patch(`${z.userPasskey}/${t}`, { name: e });
|
|
1488
1495
|
}
|
|
1489
1496
|
deleteUserPasskey(e) {
|
|
1490
|
-
return this.axiosClient.delete(`${
|
|
1497
|
+
return this.axiosClient.delete(`${z.userPasskey}/${e}`);
|
|
1491
1498
|
}
|
|
1492
1499
|
addUserPasskeyStart({ relyingPartyId: e, deviceId: t, os: n, passkeyDisplayName: r, passkeyUsername: i }) {
|
|
1493
1500
|
let a = {
|
|
@@ -1497,23 +1504,23 @@ var at = /* @__PURE__ */ function(e) {
|
|
|
1497
1504
|
deviceId: t,
|
|
1498
1505
|
os: n
|
|
1499
1506
|
};
|
|
1500
|
-
return this.axiosClient.post(
|
|
1507
|
+
return this.axiosClient.post(z.addUserPasskey, a);
|
|
1501
1508
|
}
|
|
1502
1509
|
addUserPasskeyComplete(e, t, n) {
|
|
1503
|
-
return this.axiosClient.post(
|
|
1510
|
+
return this.axiosClient.post(z.completeAddUserPasskey, {
|
|
1504
1511
|
challenge_id: n,
|
|
1505
1512
|
device: t,
|
|
1506
1513
|
passkey_data: e
|
|
1507
1514
|
});
|
|
1508
1515
|
}
|
|
1509
1516
|
getUserSessions() {
|
|
1510
|
-
return this.axiosClient.get(
|
|
1517
|
+
return this.axiosClient.get(z.userSessions);
|
|
1511
1518
|
}
|
|
1512
1519
|
revokeUserSession(e) {
|
|
1513
|
-
return this.axiosClient.delete(`${
|
|
1520
|
+
return this.axiosClient.delete(`${z.userSessions}/${encodeURIComponent(e)}`);
|
|
1514
1521
|
}
|
|
1515
1522
|
revokeOtherUserSessions() {
|
|
1516
|
-
return this.axiosClient.post(
|
|
1523
|
+
return this.axiosClient.post(z.userSessionsRevokeOthers);
|
|
1517
1524
|
}
|
|
1518
1525
|
}, Ut = 10, Wt = 20, Gt = class extends Error {
|
|
1519
1526
|
constructor(e) {
|
|
@@ -2052,7 +2059,7 @@ async function Un(e, t, n, r = Infinity) {
|
|
|
2052
2059
|
return null;
|
|
2053
2060
|
}
|
|
2054
2061
|
// lib/anti-bot/solve.ts
|
|
2055
|
-
var Wn = "The browser check could not be completed. Try again later.", Gn = "Verification failed. Try again.", Kn = 6e4, qn = class extends Error {}, Jn = (e, t, n, r) => new
|
|
2062
|
+
var Wn = "The browser check could not be completed. Try again later.", Gn = "Verification failed. Try again.", Kn = 6e4, qn = class extends Error {}, Jn = (e, t, n, r) => new B({
|
|
2056
2063
|
id: e,
|
|
2057
2064
|
message: t,
|
|
2058
2065
|
status: 0,
|
|
@@ -2068,8 +2075,8 @@ var Wn = "The browser check could not be completed. Try again later.", Gn = "Ver
|
|
|
2068
2075
|
}), i.addEventListener("error", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker failed")))), i.addEventListener("messageerror", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker message failed")))), i.postMessage(t);
|
|
2069
2076
|
});
|
|
2070
2077
|
async function Xn(e, t, n = "anti-bot") {
|
|
2071
|
-
if (e.algorithm !== "SHA-256") throw Jn(
|
|
2072
|
-
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw Jn(
|
|
2078
|
+
if (e.algorithm !== "SHA-256") throw Jn(Xe, Wn, n);
|
|
2079
|
+
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw Jn(Xe, Gn, n);
|
|
2073
2080
|
let r = {
|
|
2074
2081
|
salt: e.salt,
|
|
2075
2082
|
challenge: e.challenge,
|
|
@@ -2078,9 +2085,9 @@ async function Xn(e, t, n = "anti-bot") {
|
|
|
2078
2085
|
try {
|
|
2079
2086
|
i = t && typeof Worker < "u" ? await Yn(t, r) : await Un(r.salt, r.challenge, r.max, Date.now() + Kn);
|
|
2080
2087
|
} catch (e) {
|
|
2081
|
-
throw Jn(
|
|
2088
|
+
throw Jn(Xe, e instanceof qn || e instanceof Hn ? Gn : Wn, n, e);
|
|
2082
2089
|
}
|
|
2083
|
-
if (i === null) throw Jn(
|
|
2090
|
+
if (i === null) throw Jn(Xe, Wn, n);
|
|
2084
2091
|
return i;
|
|
2085
2092
|
}
|
|
2086
2093
|
function Zn(e, t) {
|
|
@@ -2106,9 +2113,9 @@ function er(e) {
|
|
|
2106
2113
|
operation: t.operation
|
|
2107
2114
|
});
|
|
2108
2115
|
} catch (e) {
|
|
2109
|
-
throw Jn(
|
|
2116
|
+
throw Jn(Ye, $n, t.operation, e);
|
|
2110
2117
|
}
|
|
2111
|
-
if (typeof n != "string" || n === "") throw Jn(
|
|
2118
|
+
if (typeof n != "string" || n === "") throw Jn(Ye, $n, t.operation);
|
|
2112
2119
|
return n;
|
|
2113
2120
|
}, r = async (t) => {
|
|
2114
2121
|
let n = await e.fetchChallenge({
|
|
@@ -2133,7 +2140,7 @@ function er(e) {
|
|
|
2133
2140
|
if (s) c = await r(i);
|
|
2134
2141
|
else {
|
|
2135
2142
|
let e = t;
|
|
2136
|
-
if (!e) throw Jn(
|
|
2143
|
+
if (!e) throw Jn(Je, Qn, i.operation);
|
|
2137
2144
|
c = await n(e, i);
|
|
2138
2145
|
}
|
|
2139
2146
|
return e.store.notify(G.AntiBotSolved, {
|
|
@@ -2668,7 +2675,7 @@ var J = {
|
|
|
2668
2675
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2669
2676
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2670
2677
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2671
|
-
}, Y = class extends
|
|
2678
|
+
}, Y = class extends B {
|
|
2672
2679
|
constructor(e, t = {}) {
|
|
2673
2680
|
super({
|
|
2674
2681
|
id: e,
|
|
@@ -2795,44 +2802,46 @@ function ri(e) {
|
|
|
2795
2802
|
if (!t || t.fp === e.fp || !ee()) return !1;
|
|
2796
2803
|
let n = x();
|
|
2797
2804
|
return !e.sub || n !== e.sub || t.iat === void 0 || e.iat === void 0 ? !1 : t.sid !== e.sid || o.isAfter(t, e);
|
|
2798
|
-
}, C = (e) => {
|
|
2805
|
+
}, C = (e) => !!e?.access_token && !e.refresh_token && !n.getTokens()?.refresh_token, w = (e) => {
|
|
2799
2806
|
let t = x();
|
|
2800
2807
|
return d.some((n) => n.seq > e && (!n.sub || !t || n.sub === t));
|
|
2801
|
-
},
|
|
2808
|
+
}, T = () => {
|
|
2802
2809
|
let e = x();
|
|
2803
2810
|
for (let t = u.length - 1; t >= 0; t--) {
|
|
2804
2811
|
let n = u[t];
|
|
2805
2812
|
if (!n || n.seq <= f) break;
|
|
2806
2813
|
if (!n.sub || !e || n.sub === e) return n;
|
|
2807
2814
|
}
|
|
2808
|
-
}, T = () => {
|
|
2809
|
-
if (!ee()) return "end";
|
|
2810
|
-
let e = c?.seq ?? 0, t = w();
|
|
2811
|
-
return C(t ? Math.min(e, t.seq) : e) ? "end" : t ? S(t) ? "keep" : "end" : s ? "wait" : "end";
|
|
2812
2815
|
}, E = () => {
|
|
2816
|
+
if (!ee()) return "end";
|
|
2817
|
+
let e = c?.seq ?? 0, t = T();
|
|
2818
|
+
return w(t ? Math.min(e, t.seq) : e) ? "end" : t ? S(t) ? "keep" : "end" : s ? "wait" : "end";
|
|
2819
|
+
}, D = () => {
|
|
2813
2820
|
h?.(), h = void 0;
|
|
2814
|
-
},
|
|
2815
|
-
let t =
|
|
2816
|
-
t === "wait" && e && (t = "end"), t !== "wait" &&
|
|
2817
|
-
h = void 0
|
|
2821
|
+
}, te = (e = !1) => {
|
|
2822
|
+
let t = E();
|
|
2823
|
+
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2824
|
+
h = void 0;
|
|
2825
|
+
let e = y();
|
|
2826
|
+
e?.refresh_token || C(e) ? A() : te(!0) === "end" && s?.("emptied");
|
|
2818
2827
|
}, ur));
|
|
2819
|
-
let n = t === "keep" ?
|
|
2828
|
+
let n = t === "keep" ? T() : void 0;
|
|
2820
2829
|
return n && (m = Math.max(m, n.seq)), n && g !== n.fp && (g = n.fp, a(`[passflow] The shared token storage was emptied by the end of the session of ${n.fp}, a refresh token the ${b()?.fp ?? "(none)"} this tab holds is ahead of: keeping it. Nothing is refreshed until the storage holds a token again.`)), t;
|
|
2821
|
-
},
|
|
2830
|
+
}, O = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, ne = (e) => {
|
|
2822
2831
|
let t = b();
|
|
2823
2832
|
return !!t && !o.isRetired(t) && !o.isEnded(t) && o.isAfter(t, e);
|
|
2824
|
-
},
|
|
2825
|
-
if (!
|
|
2833
|
+
}, re = (e) => {
|
|
2834
|
+
if (!ne(e)) return !1;
|
|
2826
2835
|
if (o.isRetired(e)) return !0;
|
|
2827
2836
|
let t = b();
|
|
2828
2837
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2829
|
-
},
|
|
2838
|
+
}, ie = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), ae = (e) => {
|
|
2830
2839
|
let t = b();
|
|
2831
2840
|
t && t.fp !== Jr(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2832
|
-
},
|
|
2841
|
+
}, oe = (e) => {
|
|
2833
2842
|
let t = y(), n = t?.refresh_token;
|
|
2834
2843
|
if (n === e.refreshToken) return null;
|
|
2835
|
-
if (!t || !n) return
|
|
2844
|
+
if (!t || !n) return te() === "end" ? {
|
|
2836
2845
|
kind: "ended",
|
|
2837
2846
|
cause: "emptied"
|
|
2838
2847
|
} : {
|
|
@@ -2854,32 +2863,33 @@ function ri(e) {
|
|
|
2854
2863
|
};
|
|
2855
2864
|
o.retire(e.order);
|
|
2856
2865
|
let a = b();
|
|
2857
|
-
return
|
|
2866
|
+
return ie(i, a) || i?.fp === a?.fp && !o.isRetired(i) ? (ae(t), {
|
|
2858
2867
|
kind: "superseded",
|
|
2859
2868
|
adopted: !0
|
|
2860
2869
|
}) : {
|
|
2861
2870
|
kind: "superseded",
|
|
2862
2871
|
adopted: !1
|
|
2863
2872
|
};
|
|
2864
|
-
},
|
|
2873
|
+
}, k = (e) => S(e) ? {
|
|
2865
2874
|
kind: "superseded",
|
|
2866
2875
|
adopted: !1
|
|
2867
2876
|
} : {
|
|
2868
2877
|
kind: "ended",
|
|
2869
2878
|
cause: "ended"
|
|
2870
|
-
},
|
|
2879
|
+
}, A = () => {
|
|
2871
2880
|
let t = y();
|
|
2872
|
-
if (!t?.refresh_token) {
|
|
2873
|
-
|
|
2881
|
+
if (!t?.refresh_token && !C(t)) {
|
|
2882
|
+
te() === "end" && s?.("emptied");
|
|
2874
2883
|
return;
|
|
2875
2884
|
}
|
|
2876
|
-
|
|
2885
|
+
D();
|
|
2877
2886
|
let n = i(), r = Z(t);
|
|
2878
2887
|
n && r && n !== r ? s?.("identity-changed") : e.onStoredSessionSeen?.();
|
|
2879
|
-
},
|
|
2888
|
+
}, j = !!s || !!e.onStoredSessionSeen, M = j && e.onStorageChange ? e.onStorageChange(A) : void 0, N = j && e.onWake ? e.onWake(A) : void 0, se = () => {
|
|
2880
2889
|
let e = y();
|
|
2890
|
+
if (C(e)) return "held";
|
|
2881
2891
|
if (!e?.refresh_token) {
|
|
2882
|
-
if (
|
|
2892
|
+
if (te() === "end") throw new Qr("emptied");
|
|
2883
2893
|
return "held";
|
|
2884
2894
|
}
|
|
2885
2895
|
let t = n.getTokens();
|
|
@@ -2892,13 +2902,13 @@ function ri(e) {
|
|
|
2892
2902
|
throw new Qr("ended");
|
|
2893
2903
|
}
|
|
2894
2904
|
let c = X(t?.refresh_token);
|
|
2895
|
-
return
|
|
2896
|
-
},
|
|
2905
|
+
return ie(s, c) ? (ae(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && ne(s) ? "held" : "send";
|
|
2906
|
+
}, ce = (e) => {
|
|
2897
2907
|
let t = i(), r = ei(e);
|
|
2898
2908
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2899
2909
|
let a = X(e) ?? { fp: e };
|
|
2900
2910
|
if (o.isEnded(a)) return S(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
2901
|
-
if (o.isRetired(a) &&
|
|
2911
|
+
if (o.isRetired(a) && ne(a)) return { kind: "superseded" };
|
|
2902
2912
|
let s = {
|
|
2903
2913
|
refreshToken: e,
|
|
2904
2914
|
order: a
|
|
@@ -2907,11 +2917,11 @@ function ri(e) {
|
|
|
2907
2917
|
kind: "send",
|
|
2908
2918
|
sent: s
|
|
2909
2919
|
};
|
|
2910
|
-
},
|
|
2911
|
-
if (o.isEnded(e.order)) return
|
|
2912
|
-
let i =
|
|
2920
|
+
}, P = (e, r) => {
|
|
2921
|
+
if (o.isEnded(e.order)) return k(e.order);
|
|
2922
|
+
let i = oe(e);
|
|
2913
2923
|
if (i) return i;
|
|
2914
|
-
if (!
|
|
2924
|
+
if (!O(e) && re(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${Jr(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
|
|
2915
2925
|
kind: "superseded",
|
|
2916
2926
|
adopted: !1
|
|
2917
2927
|
};
|
|
@@ -2925,16 +2935,16 @@ function ri(e) {
|
|
|
2925
2935
|
kind: "superseded",
|
|
2926
2936
|
adopted: !1
|
|
2927
2937
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
2928
|
-
},
|
|
2929
|
-
if (o.isEnded(e.order)) return
|
|
2930
|
-
let n =
|
|
2938
|
+
}, F = (e, t) => {
|
|
2939
|
+
if (o.isEnded(e.order)) return k(e.order);
|
|
2940
|
+
let n = oe(e);
|
|
2931
2941
|
if (n) return n.kind === "identity-changed" ? { kind: "identity-changed" } : n;
|
|
2932
|
-
if (o.isRetired(e.order) &&
|
|
2942
|
+
if (o.isRetired(e.order) && ne(e.order)) return {
|
|
2933
2943
|
kind: "superseded",
|
|
2934
2944
|
adopted: !1
|
|
2935
2945
|
};
|
|
2936
2946
|
let r = Br(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2937
|
-
return
|
|
2947
|
+
return O(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2938
2948
|
kind: "own",
|
|
2939
2949
|
failure: r,
|
|
2940
2950
|
heldRefused: !0
|
|
@@ -2943,7 +2953,7 @@ function ri(e) {
|
|
|
2943
2953
|
failure: r,
|
|
2944
2954
|
heldRefused: !1
|
|
2945
2955
|
});
|
|
2946
|
-
},
|
|
2956
|
+
}, I = (e) => {
|
|
2947
2957
|
if (!ni(e)) return !1;
|
|
2948
2958
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2949
2959
|
if (typeof t != "string" || typeof c != "string" || !ni(l)) return !1;
|
|
@@ -2965,31 +2975,31 @@ function ri(e) {
|
|
|
2965
2975
|
}
|
|
2966
2976
|
return !0;
|
|
2967
2977
|
};
|
|
2968
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && Jr(d.refresh_token) !== c ? !1 : (
|
|
2969
|
-
},
|
|
2978
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && Jr(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
|
|
2979
|
+
}, le = (e) => {
|
|
2970
2980
|
if (!e || !_) return !1;
|
|
2971
2981
|
let t = _;
|
|
2972
2982
|
return e.fp === t.fp || o.isEnded(e) || o.isRetired(e) ? !1 : e.iat !== void 0 && t.iat !== void 0 && e.sid !== t.sid || o.isAfter(e, t);
|
|
2973
|
-
},
|
|
2983
|
+
}, ue = () => {
|
|
2974
2984
|
let e = b();
|
|
2975
2985
|
if (!e) return !1;
|
|
2976
|
-
if (
|
|
2986
|
+
if (le(e)) return !0;
|
|
2977
2987
|
let t = y(), r = X(t?.refresh_token);
|
|
2978
|
-
if (!t || !r || r.fp === e.fp || !
|
|
2988
|
+
if (!t || !r || r.fp === e.fp || !le(r) || !ie(r, e)) return !1;
|
|
2979
2989
|
let a = i() ?? Z(n.getTokens()), o = Z(t);
|
|
2980
|
-
return a && o && a !== o ? (s?.("identity-changed"), !1) : (
|
|
2981
|
-
},
|
|
2990
|
+
return a && o && a !== o ? (s?.("identity-changed"), !1) : (ae(t), !0);
|
|
2991
|
+
}, de = (e) => {
|
|
2982
2992
|
let t = X(e?.refresh_token), n = {}, r = i() ?? Z(e);
|
|
2983
2993
|
return t?.fp !== void 0 && (n.fp = t.fp), r !== void 0 && (n.sub = r), t?.sid !== void 0 && (n.sid = t.sid), t?.iat !== void 0 && (n.iat = t.iat), n;
|
|
2984
2994
|
};
|
|
2985
2995
|
return {
|
|
2986
2996
|
lineage: o,
|
|
2987
|
-
checkStoredBeforeSend:
|
|
2988
|
-
beginSend:
|
|
2989
|
-
commitSave:
|
|
2990
|
-
judgeFailure:
|
|
2991
|
-
adoptTokens:
|
|
2992
|
-
adoptSuccessor:
|
|
2997
|
+
checkStoredBeforeSend: se,
|
|
2998
|
+
beginSend: ce,
|
|
2999
|
+
commitSave: P,
|
|
3000
|
+
judgeFailure: F,
|
|
3001
|
+
adoptTokens: I,
|
|
3002
|
+
adoptSuccessor: ue,
|
|
2993
3003
|
beginHeldSend: () => {
|
|
2994
3004
|
let e = X(y()?.refresh_token);
|
|
2995
3005
|
if (!e || o.isRetired(e) || o.isEnded(e)) return v = void 0, !1;
|
|
@@ -3012,10 +3022,10 @@ function ri(e) {
|
|
|
3012
3022
|
...t,
|
|
3013
3023
|
fp: t.fp,
|
|
3014
3024
|
seq: l
|
|
3015
|
-
}), u.length > 4 && u.shift()), b() && n &&
|
|
3025
|
+
}), u.length > 4 && u.shift()), b() && n && te() === "end" && s?.("emptied");
|
|
3016
3026
|
},
|
|
3017
|
-
session: () =>
|
|
3018
|
-
storedSession: () =>
|
|
3027
|
+
session: () => de(n.getTokens()),
|
|
3028
|
+
storedSession: () => de(y()),
|
|
3019
3029
|
dropSession: () => {
|
|
3020
3030
|
n.setTokensCache(void 0), n.stopTokenCheck?.();
|
|
3021
3031
|
},
|
|
@@ -3026,7 +3036,7 @@ function ri(e) {
|
|
|
3026
3036
|
return n.fp === e.fp || r && n.iat !== void 0 && e.iat !== void 0 && n.iat < e.iat ? (t.deleteTokens(), !0) : !1;
|
|
3027
3037
|
},
|
|
3028
3038
|
stop: () => {
|
|
3029
|
-
|
|
3039
|
+
M?.(), N?.(), D();
|
|
3030
3040
|
}
|
|
3031
3041
|
};
|
|
3032
3042
|
}
|
|
@@ -3094,9 +3104,9 @@ function fi(e) {
|
|
|
3094
3104
|
schedule: (e, t) => o.setTimeout(e, t),
|
|
3095
3105
|
onStorageChange: (e) => (ne.add(e), () => ne.delete(e)),
|
|
3096
3106
|
onWake: (e) => (re.add(e), () => re.delete(e)),
|
|
3097
|
-
onSessionLost: (e) =>
|
|
3107
|
+
onSessionLost: (e) => pe(e),
|
|
3098
3108
|
onStoredSessionSeen: () => {
|
|
3099
|
-
u.kind === "blocked-wait" &&
|
|
3109
|
+
u.kind === "blocked-wait" && Ae();
|
|
3100
3110
|
},
|
|
3101
3111
|
warn: (e) => s.warn(e)
|
|
3102
3112
|
}), A = (e) => ({
|
|
@@ -3113,11 +3123,11 @@ function fi(e) {
|
|
|
3113
3123
|
return e.fresh.push(n), n.deferred.promise;
|
|
3114
3124
|
}, N = (e, t, n = !1) => {
|
|
3115
3125
|
e.plain.resolve(D());
|
|
3116
|
-
for (let r of e.fresh) n || t !== void 0 && t >= r.callTime ? r.deferred.resolve(D()) :
|
|
3126
|
+
for (let r of e.fresh) n || t !== void 0 && t >= r.callTime ? r.deferred.resolve(D()) : z("refresh-token", r.callTime).then(r.deferred.resolve, r.deferred.reject);
|
|
3117
3127
|
e.fresh = [];
|
|
3118
3128
|
}, se = (e, t, n) => {
|
|
3119
3129
|
e.plain.reject(t);
|
|
3120
|
-
for (let r of e.fresh) n !== void 0 && n < r.callTime ?
|
|
3130
|
+
for (let r of e.fresh) n !== void 0 && n < r.callTime ? z("refresh-token", r.callTime).then(r.deferred.resolve, r.deferred.reject) : r.deferred.reject(t);
|
|
3121
3131
|
e.fresh = [];
|
|
3122
3132
|
}, ce = (e, t) => {
|
|
3123
3133
|
if (e) {
|
|
@@ -3160,7 +3170,7 @@ function fi(e) {
|
|
|
3160
3170
|
origin: r
|
|
3161
3171
|
};
|
|
3162
3172
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
3163
|
-
},
|
|
3173
|
+
}, ue = (e, t) => {
|
|
3164
3174
|
let n = r.getTokens(), i = Jr(n?.refresh_token);
|
|
3165
3175
|
e.fp && i && l.post({
|
|
3166
3176
|
type: "tokens-refreshed",
|
|
@@ -3171,14 +3181,14 @@ function fi(e) {
|
|
|
3171
3181
|
to: i,
|
|
3172
3182
|
...t === void 0 ? {} : { sentAt: t }
|
|
3173
3183
|
});
|
|
3174
|
-
},
|
|
3184
|
+
}, de = () => {
|
|
3175
3185
|
p || (p = !0, s.warn(Cr));
|
|
3176
|
-
},
|
|
3186
|
+
}, fe = (e) => {
|
|
3177
3187
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
3178
|
-
},
|
|
3188
|
+
}, L = (e, n) => {
|
|
3179
3189
|
if (u.kind === "ended") return;
|
|
3180
3190
|
let r = j(u);
|
|
3181
|
-
|
|
3191
|
+
fe(u);
|
|
3182
3192
|
let a = k.session(), o = O();
|
|
3183
3193
|
switch (d += 1, m = 0, h = 0, g = void 0, _ = void 0, v = void 0, l.setRetryInfo(void 0), C || l.release(), b = {
|
|
3184
3194
|
...a,
|
|
@@ -3223,7 +3233,7 @@ function fi(e) {
|
|
|
3223
3233
|
case "disposed": break;
|
|
3224
3234
|
default: oi(e);
|
|
3225
3235
|
}
|
|
3226
|
-
},
|
|
3236
|
+
}, R = () => {
|
|
3227
3237
|
if (u.kind !== "ended" || u.cause === "disposed" || f || T() !== "json") return;
|
|
3228
3238
|
let e = n.getTokens(), i = X(e?.refresh_token);
|
|
3229
3239
|
if (!e?.refresh_token || !e.access_token || !i || k.lineage.isEnded(i) || k.lineage.isRetired(i)) return;
|
|
@@ -3235,13 +3245,13 @@ function fi(e) {
|
|
|
3235
3245
|
tokens: s,
|
|
3236
3246
|
origin: "other-tab"
|
|
3237
3247
|
});
|
|
3238
|
-
}, fe = (e) => {
|
|
3239
|
-
u.kind === "ended" || f || T() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && z());
|
|
3240
3248
|
}, pe = (e) => {
|
|
3241
|
-
|
|
3242
|
-
}, me = () => {
|
|
3249
|
+
u.kind === "ended" || f || T() === "json" && (L(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && R());
|
|
3250
|
+
}, me = (e) => {
|
|
3251
|
+
e instanceof $r ? (L("identity-changed"), R()) : e instanceof Qr ? L(e.cause === "emptied" ? "emptied" : "stored-ended") : L("stored-ended", e);
|
|
3252
|
+
}, he = () => {
|
|
3243
3253
|
u = { kind: "idle" }, C || l.release();
|
|
3244
|
-
},
|
|
3254
|
+
}, ge = (e) => !e.from || T() !== "json" || e.from === E() || e.from === Jr(n.getTokens()?.refresh_token), _e = (e) => {
|
|
3245
3255
|
let t = g;
|
|
3246
3256
|
if (!t) return;
|
|
3247
3257
|
if (!l.holding) {
|
|
@@ -3258,10 +3268,10 @@ function fi(e) {
|
|
|
3258
3268
|
pending: e,
|
|
3259
3269
|
dueAt: r,
|
|
3260
3270
|
cancel: o.setTimeout(() => {
|
|
3261
|
-
n === d &&
|
|
3271
|
+
n === d && ve();
|
|
3262
3272
|
}, Math.max(0, r - w()))
|
|
3263
3273
|
};
|
|
3264
|
-
},
|
|
3274
|
+
}, ve = () => {
|
|
3265
3275
|
if (u.kind !== "backoff" || C) return;
|
|
3266
3276
|
let { pending: e, dueAt: t } = u;
|
|
3267
3277
|
!l.holding || l.foreignHolderHeard() || w() - t > 2e4 ? (l.release(), u = {
|
|
@@ -3270,18 +3280,18 @@ function fi(e) {
|
|
|
3270
3280
|
}, l.request((g?.nextAt ?? w()) + K)) : (u = {
|
|
3271
3281
|
kind: "waiting",
|
|
3272
3282
|
pending: e
|
|
3273
|
-
},
|
|
3274
|
-
}, ve = () => {
|
|
3275
|
-
u.kind === "idle" && l.release();
|
|
3283
|
+
}, be() || ye());
|
|
3276
3284
|
}, ye = () => {
|
|
3285
|
+
u.kind === "idle" && l.release();
|
|
3286
|
+
}, be = () => {
|
|
3277
3287
|
if (u.kind !== "waiting") return !1;
|
|
3278
3288
|
let e = u.pending;
|
|
3279
|
-
if (T() !== "json") return
|
|
3289
|
+
if (T() !== "json") return xe(e);
|
|
3280
3290
|
let t = k.session(), n;
|
|
3281
3291
|
try {
|
|
3282
3292
|
n = k.checkStoredBeforeSend();
|
|
3283
3293
|
} catch (e) {
|
|
3284
|
-
return
|
|
3294
|
+
return me(e), !1;
|
|
3285
3295
|
}
|
|
3286
3296
|
if (n === "held") {
|
|
3287
3297
|
let t = E();
|
|
@@ -3291,25 +3301,25 @@ function fi(e) {
|
|
|
3291
3301
|
}), u = { kind: "idle" }, N(e, void 0, !0), !1) : (v = {
|
|
3292
3302
|
fp: t,
|
|
3293
3303
|
at: w()
|
|
3294
|
-
}, k.beginHeldSend() ?
|
|
3304
|
+
}, k.beginHeldSend() ? Se(e, "held") : (u = { kind: "idle" }, N(e, void 0, !0), !1));
|
|
3295
3305
|
}
|
|
3296
3306
|
if (v = void 0, n === "adopted") {
|
|
3297
|
-
if (I("adopted", "other-tab"),
|
|
3307
|
+
if (I("adopted", "other-tab"), ue(t), e.fresh.length === 0) return u = { kind: "idle" }, N(e, void 0), !1;
|
|
3298
3308
|
e.plain.resolve(D());
|
|
3299
3309
|
}
|
|
3300
|
-
return g && !
|
|
3301
|
-
},
|
|
3310
|
+
return g && !ge(g) && (g = void 0), g && g.nextAt > w() ? (m = g.attempt, h = g.strikes, g.failingSince !== void 0 && le(g.failingSince, g.nextAt, "other-tab"), _e(e), !0) : (g && (m = g.attempt, h = g.strikes), Se(e, e.trigger === "held" ? "refresh-token" : e.trigger));
|
|
3311
|
+
}, xe = (e) => y !== void 0 && y >= e.startedAt ? (r.setTokensCache(n.getTokens()), I("adopted", "other-tab"), u = { kind: "idle" }, N(e, y), !1) : g && g.nextAt > w() ? (m = g.attempt, h = g.strikes, _e(e), !0) : Ce(e, e.trigger, void 0, void 0), Se = (e, t) => {
|
|
3302
3312
|
let r = n.getTokens(), i = r?.refresh_token;
|
|
3303
3313
|
if (!i) return u = { kind: "idle" }, N(e, void 0, !0), !1;
|
|
3304
3314
|
let a = k.beginSend(i);
|
|
3305
3315
|
switch (a.kind) {
|
|
3306
3316
|
case "superseded": return k.endHeldSend(), I("adopted", "other-tab"), u = { kind: "idle" }, N(e, void 0), !1;
|
|
3307
|
-
case "ended": return k.endHeldSend(),
|
|
3308
|
-
case "identity-changed": return k.endHeldSend(),
|
|
3309
|
-
case "send": return
|
|
3317
|
+
case "ended": return k.endHeldSend(), L("stored-ended"), !1;
|
|
3318
|
+
case "identity-changed": return k.endHeldSend(), L("identity-changed"), R(), !1;
|
|
3319
|
+
case "send": return Ce(e, t, a.sent, r);
|
|
3310
3320
|
default: return oi(a);
|
|
3311
3321
|
}
|
|
3312
|
-
},
|
|
3322
|
+
}, Ce = (e, n, r, a) => {
|
|
3313
3323
|
let o = {
|
|
3314
3324
|
generation: d,
|
|
3315
3325
|
sentAt: w(),
|
|
@@ -3328,27 +3338,27 @@ function fi(e) {
|
|
|
3328
3338
|
c = Promise.reject(e);
|
|
3329
3339
|
}
|
|
3330
3340
|
return c.then((e) => {
|
|
3331
|
-
|
|
3341
|
+
Te(o, e).catch((e) => s.error("[passflow] Applying a refresh result failed", e)).finally(() => o.settled.resolve());
|
|
3332
3342
|
}, (e) => {
|
|
3333
|
-
|
|
3343
|
+
Ee(o, e), o.settled.resolve();
|
|
3334
3344
|
}), !0;
|
|
3335
|
-
},
|
|
3336
|
-
if (e.sent?.held && k.endHeldSend(), !
|
|
3345
|
+
}, we = (e) => !f && e.generation === d && u.kind === "refreshing" && u.request === e, Te = async (e, t) => {
|
|
3346
|
+
if (e.sent?.held && k.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
3337
3347
|
let { pending: a } = u;
|
|
3338
3348
|
if (!e.sent) {
|
|
3339
3349
|
let o = Z({ ...t.id_token ? { id_token: t.id_token } : {} }), s = O();
|
|
3340
3350
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
3341
3351
|
let t = new Y(J.identityChanged);
|
|
3342
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3352
|
+
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t);
|
|
3343
3353
|
return;
|
|
3344
3354
|
}
|
|
3345
3355
|
try {
|
|
3346
3356
|
await i.applyOpaque(t);
|
|
3347
3357
|
} catch (t) {
|
|
3348
|
-
|
|
3358
|
+
Ee(e, t);
|
|
3349
3359
|
return;
|
|
3350
3360
|
}
|
|
3351
|
-
if (!
|
|
3361
|
+
if (!we(e)) return;
|
|
3352
3362
|
r.setTokensCache({
|
|
3353
3363
|
...n.getTokens() ?? {},
|
|
3354
3364
|
...di(t, void 0)
|
|
@@ -3361,43 +3371,43 @@ function fi(e) {
|
|
|
3361
3371
|
type: "session-refreshed",
|
|
3362
3372
|
at: w(),
|
|
3363
3373
|
sub: c
|
|
3364
|
-
}),
|
|
3374
|
+
}), he(), N(a, e.sentAt);
|
|
3365
3375
|
return;
|
|
3366
3376
|
}
|
|
3367
3377
|
let o = E(), s = k.commitSave(e.sent, di(t, e.stored));
|
|
3368
3378
|
switch (s.kind) {
|
|
3369
3379
|
case "saved":
|
|
3370
|
-
I("refresh", "this-tab"),
|
|
3380
|
+
I("refresh", "this-tab"), ue(e.sent.order, e.sentAt), he(), N(a, e.sentAt);
|
|
3371
3381
|
return;
|
|
3372
3382
|
case "superseded":
|
|
3373
|
-
e.outcome && E() === o || I("adopted", "other-tab"), s.adopted &&
|
|
3383
|
+
e.outcome && E() === o || I("adopted", "other-tab"), s.adopted && ue(e.sent.order), he(), N(a, e.sentAt);
|
|
3374
3384
|
return;
|
|
3375
3385
|
case "ended": {
|
|
3376
3386
|
let t = new Y(s.cause === "emptied" ? J.signedOut : J.sessionEnded);
|
|
3377
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3387
|
+
P("refresh", e.trigger, t, F("auth")), L(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
3378
3388
|
return;
|
|
3379
3389
|
}
|
|
3380
3390
|
case "identity-changed": {
|
|
3381
3391
|
let t = new Y(J.identityChanged);
|
|
3382
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3392
|
+
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), R();
|
|
3383
3393
|
return;
|
|
3384
3394
|
}
|
|
3385
3395
|
default: oi(s);
|
|
3386
3396
|
}
|
|
3387
|
-
},
|
|
3388
|
-
if (e.sent?.held && k.endHeldSend(), !
|
|
3397
|
+
}, Ee = (e, t) => {
|
|
3398
|
+
if (e.sent?.held && k.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
3389
3399
|
let { pending: n } = u, r, i = !1;
|
|
3390
3400
|
if (e.sent) {
|
|
3391
3401
|
let a = E(), o = k.judgeFailure(e.sent, t);
|
|
3392
3402
|
switch (o.kind) {
|
|
3393
3403
|
case "superseded":
|
|
3394
|
-
e.outcome && E() === a || I("adopted", "other-tab"),
|
|
3404
|
+
e.outcome && E() === a || I("adopted", "other-tab"), he(), N(n, e.sentAt);
|
|
3395
3405
|
return;
|
|
3396
3406
|
case "ended":
|
|
3397
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3407
|
+
P("refresh", e.trigger, t, F("auth")), L(o.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
3398
3408
|
return;
|
|
3399
3409
|
case "identity-changed":
|
|
3400
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3410
|
+
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), R();
|
|
3401
3411
|
return;
|
|
3402
3412
|
case "own":
|
|
3403
3413
|
r = o.failure, i = o.heldRefused;
|
|
@@ -3405,24 +3415,24 @@ function fi(e) {
|
|
|
3405
3415
|
default: oi(o);
|
|
3406
3416
|
}
|
|
3407
3417
|
} else r = Br(t, w());
|
|
3408
|
-
if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"),
|
|
3418
|
+
if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"), he(), N(n, void 0, !0);
|
|
3409
3419
|
else switch (r.kind) {
|
|
3410
3420
|
case "blocked":
|
|
3411
|
-
P("refresh", e.trigger, t, F("blocked")),
|
|
3421
|
+
P("refresh", e.trigger, t, F("blocked")), ke(n, e.sentAt, t, e.marker);
|
|
3412
3422
|
return;
|
|
3413
3423
|
case "auth":
|
|
3414
3424
|
if (h += 1, m += 1, h >= c) {
|
|
3415
|
-
P("refresh", e.trigger, t, F("auth")),
|
|
3425
|
+
P("refresh", e.trigger, t, F("auth")), Oe(e, t);
|
|
3416
3426
|
return;
|
|
3417
3427
|
}
|
|
3418
|
-
|
|
3428
|
+
De(e, n, t, r);
|
|
3419
3429
|
return;
|
|
3420
3430
|
case "transient":
|
|
3421
|
-
m += 1,
|
|
3431
|
+
m += 1, De(e, n, t, r);
|
|
3422
3432
|
return;
|
|
3423
3433
|
default: oi(r.kind);
|
|
3424
3434
|
}
|
|
3425
|
-
},
|
|
3435
|
+
}, De = (e, t, n, r) => {
|
|
3426
3436
|
let i = w() + Vr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3427
3437
|
P("refresh", e.trigger, n, F(a, i)), a === "transient" && le(w(), i, "this-tab");
|
|
3428
3438
|
let s = {
|
|
@@ -3435,8 +3445,8 @@ function fi(e) {
|
|
|
3435
3445
|
type: "retry-scheduled",
|
|
3436
3446
|
message: ci(n, "Token refresh failed"),
|
|
3437
3447
|
retry: s
|
|
3438
|
-
}),
|
|
3439
|
-
},
|
|
3448
|
+
}), _e(A("retry")), se(t, n, e.sentAt);
|
|
3449
|
+
}, Oe = (e, t) => {
|
|
3440
3450
|
let n = e.sent?.sub ?? O(), r = e.sent?.order, i = {};
|
|
3441
3451
|
r?.fp && (i.fp = r.fp), n && (i.sub = n), r?.sid && (i.sid = r.sid), r?.iat !== void 0 && (i.iat = r.iat), (i.fp || i.sub) && l.post({
|
|
3442
3452
|
type: "session-ended",
|
|
@@ -3444,8 +3454,8 @@ function fi(e) {
|
|
|
3444
3454
|
}), i.fp && (x = i.fp, k.endLineage({
|
|
3445
3455
|
...i,
|
|
3446
3456
|
fp: i.fp
|
|
3447
|
-
})), r && k.deleteIfStillDead(r),
|
|
3448
|
-
},
|
|
3457
|
+
})), r && k.deleteIfStillDead(r), L("strikes", t);
|
|
3458
|
+
}, ke = (e, t, n, r) => {
|
|
3449
3459
|
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${ci(n, "blocked")}`);
|
|
3450
3460
|
let i = d, a = w() + cr, c = {
|
|
3451
3461
|
kind: "blocked-wait",
|
|
@@ -3455,15 +3465,15 @@ function fi(e) {
|
|
|
3455
3465
|
cancel: () => void 0,
|
|
3456
3466
|
marker: r
|
|
3457
3467
|
};
|
|
3458
|
-
if (u = c,
|
|
3468
|
+
if (u = c, Ae()) return;
|
|
3459
3469
|
let f = T() !== "json" && !l.coordinated && !e.cookieRetried, p = () => {
|
|
3460
|
-
i === d && u === c && (
|
|
3470
|
+
i === d && u === c && (Ae() || (f ? (e.cookieRetried = !0, u = {
|
|
3461
3471
|
kind: "waiting",
|
|
3462
3472
|
pending: e
|
|
3463
|
-
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."),
|
|
3473
|
+
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p, lr)));
|
|
3464
3474
|
};
|
|
3465
3475
|
c.cancel = o.setTimeout(p, f ? dr : lr);
|
|
3466
|
-
},
|
|
3476
|
+
}, Ae = () => {
|
|
3467
3477
|
if (u.kind !== "blocked-wait") return !1;
|
|
3468
3478
|
let e = u;
|
|
3469
3479
|
if (T() === "json") {
|
|
@@ -3474,15 +3484,15 @@ function fi(e) {
|
|
|
3474
3484
|
r.setTokensCache(n.getTokens());
|
|
3475
3485
|
}
|
|
3476
3486
|
return u === e && (e.cancel(), I("adopted", "other-tab"), u = { kind: "idle" }, N(e.pending, void 0, !0), !0);
|
|
3477
|
-
},
|
|
3487
|
+
}, je = (e) => {
|
|
3478
3488
|
let t = O(), n = !e.sub || !t || e.sub === t;
|
|
3479
3489
|
return T() === "json" ? !!e.fp && e.fp === E() && n : !e.fp && n;
|
|
3480
|
-
},
|
|
3490
|
+
}, Me = (e, t) => {
|
|
3481
3491
|
if (e !== "signed-out" || !t.sub) return !1;
|
|
3482
3492
|
let n = O();
|
|
3483
3493
|
return n !== void 0 && t.sub === n;
|
|
3484
|
-
},
|
|
3485
|
-
if (u.kind === "ended" || !
|
|
3494
|
+
}, Ne = (e, t, n) => {
|
|
3495
|
+
if (u.kind === "ended" || !ge(e)) return;
|
|
3486
3496
|
let r = g?.nextAt;
|
|
3487
3497
|
if (g = e, e.failingSince !== void 0 && le(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
3488
3498
|
let i = new Y(e.kind === "transient" ? J.unavailable : J.authRetry, {
|
|
@@ -3490,12 +3500,12 @@ function fi(e) {
|
|
|
3490
3500
|
cause: n || void 0
|
|
3491
3501
|
}), a = u.pending;
|
|
3492
3502
|
u.pending = A(a.trigger), se(a, i, r);
|
|
3493
|
-
},
|
|
3503
|
+
}, Pe = (e, t) => {
|
|
3494
3504
|
switch (t && I("adopted", "other-tab"), u.kind) {
|
|
3495
3505
|
case "waiting":
|
|
3496
3506
|
case "backoff": {
|
|
3497
3507
|
let t = u.pending;
|
|
3498
|
-
|
|
3508
|
+
fe(u), he(), N(t, e);
|
|
3499
3509
|
return;
|
|
3500
3510
|
}
|
|
3501
3511
|
case "blocked-wait": {
|
|
@@ -3508,19 +3518,19 @@ function fi(e) {
|
|
|
3508
3518
|
case "ended": return;
|
|
3509
3519
|
default: oi(u);
|
|
3510
3520
|
}
|
|
3511
|
-
},
|
|
3521
|
+
}, Fe = (e) => {
|
|
3512
3522
|
let t = {};
|
|
3513
3523
|
e.fp && (t.fp = e.fp), e.sub && (t.sub = e.sub), e.sid && (t.sid = e.sid), e.iat !== void 0 && (t.iat = e.iat);
|
|
3514
|
-
let n = u.kind !== "ended" && (
|
|
3524
|
+
let n = u.kind !== "ended" && (je(t) || Me(e.type, t));
|
|
3515
3525
|
t.fp && k.endLineage({
|
|
3516
3526
|
...t,
|
|
3517
3527
|
fp: t.fp
|
|
3518
|
-
}), n &&
|
|
3519
|
-
},
|
|
3528
|
+
}), n && L(e.type === "signed-out" ? "signed-out" : "session-ended"), k.endedElsewhere(e.type, t);
|
|
3529
|
+
}, Ie = (e) => {
|
|
3520
3530
|
if (!f) switch (e.type) {
|
|
3521
3531
|
case "tokens-refreshed": {
|
|
3522
3532
|
if (u.kind === "ended") {
|
|
3523
|
-
|
|
3533
|
+
R();
|
|
3524
3534
|
return;
|
|
3525
3535
|
}
|
|
3526
3536
|
if (T() !== "json") return;
|
|
@@ -3528,7 +3538,7 @@ function fi(e) {
|
|
|
3528
3538
|
if (!k.adoptTokens(e)) return;
|
|
3529
3539
|
let n = E() !== t;
|
|
3530
3540
|
if (!n && u.kind === "idle") return;
|
|
3531
|
-
g = void 0,
|
|
3541
|
+
g = void 0, Pe(e.sentAt, n);
|
|
3532
3542
|
return;
|
|
3533
3543
|
}
|
|
3534
3544
|
case "session-refreshed": {
|
|
@@ -3536,17 +3546,17 @@ function fi(e) {
|
|
|
3536
3546
|
let t = O();
|
|
3537
3547
|
if (e.sub && t && e.sub !== t || (y = Math.max(y ?? 0, e.at), u.kind === "refreshing")) return;
|
|
3538
3548
|
if (r.setTokensCache(n.getTokens()), g = void 0, u.kind === "blocked-wait") {
|
|
3539
|
-
|
|
3549
|
+
Ae();
|
|
3540
3550
|
return;
|
|
3541
3551
|
}
|
|
3542
|
-
|
|
3552
|
+
Pe(e.at, !0);
|
|
3543
3553
|
return;
|
|
3544
3554
|
}
|
|
3545
3555
|
case "still-refreshing":
|
|
3546
|
-
e.retry &&
|
|
3556
|
+
e.retry && Ne(e.retry, !1, ""), Le();
|
|
3547
3557
|
return;
|
|
3548
3558
|
case "retry-scheduled":
|
|
3549
|
-
|
|
3559
|
+
Ne(e.retry, !0, e.message), Le();
|
|
3550
3560
|
return;
|
|
3551
3561
|
case "refresh-failed":
|
|
3552
3562
|
if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== Jr(n.getTokens()?.refresh_token)) return;
|
|
@@ -3566,13 +3576,13 @@ function fi(e) {
|
|
|
3566
3576
|
return;
|
|
3567
3577
|
case "session-ended":
|
|
3568
3578
|
case "signed-out":
|
|
3569
|
-
|
|
3579
|
+
Fe(e);
|
|
3570
3580
|
return;
|
|
3571
3581
|
case "takeover":
|
|
3572
3582
|
case "rate-limited": return;
|
|
3573
3583
|
default: oi(e);
|
|
3574
3584
|
}
|
|
3575
|
-
},
|
|
3585
|
+
}, Le = () => {
|
|
3576
3586
|
S && !l.holding && l.post({
|
|
3577
3587
|
type: "lock-wanted",
|
|
3578
3588
|
purpose: S.purpose
|
|
@@ -3585,7 +3595,7 @@ function fi(e) {
|
|
|
3585
3595
|
let e = S;
|
|
3586
3596
|
return S = void 0, e.granted(), !0;
|
|
3587
3597
|
}
|
|
3588
|
-
return u.kind === "waiting" &&
|
|
3598
|
+
return u.kind === "waiting" && be();
|
|
3589
3599
|
},
|
|
3590
3600
|
onLockLost: () => {
|
|
3591
3601
|
if (u.kind === "backoff") {
|
|
@@ -3596,16 +3606,16 @@ function fi(e) {
|
|
|
3596
3606
|
}, l.request((g?.nextAt ?? w()) + K);
|
|
3597
3607
|
}
|
|
3598
3608
|
},
|
|
3599
|
-
onMessage:
|
|
3609
|
+
onMessage: Ie
|
|
3600
3610
|
});
|
|
3601
|
-
let
|
|
3611
|
+
let Re = () => {
|
|
3602
3612
|
if (f) return;
|
|
3603
3613
|
if (u.kind === "ended") {
|
|
3604
|
-
|
|
3614
|
+
R();
|
|
3605
3615
|
return;
|
|
3606
3616
|
}
|
|
3607
3617
|
if (u.kind === "blocked-wait" && T() !== "json") {
|
|
3608
|
-
|
|
3618
|
+
Ae();
|
|
3609
3619
|
return;
|
|
3610
3620
|
}
|
|
3611
3621
|
if (u.kind !== "idle" || T() !== "json" || C) return;
|
|
@@ -3615,10 +3625,10 @@ function fi(e) {
|
|
|
3615
3625
|
} catch {
|
|
3616
3626
|
return;
|
|
3617
3627
|
}
|
|
3618
|
-
I("adopted", "other-tab"), l.coordinated &&
|
|
3628
|
+
I("adopted", "other-tab"), l.coordinated && ue(e);
|
|
3619
3629
|
};
|
|
3620
|
-
ne.add(
|
|
3621
|
-
let
|
|
3630
|
+
ne.add(Re), re.add(Re);
|
|
3631
|
+
let z = (e, t) => {
|
|
3622
3632
|
if (f) return Promise.reject(new Y(J.disposed));
|
|
3623
3633
|
switch (u.kind) {
|
|
3624
3634
|
case "ended": return Promise.reject(new Y(J.sessionEnded));
|
|
@@ -3629,7 +3639,7 @@ function fi(e) {
|
|
|
3629
3639
|
pending: n
|
|
3630
3640
|
};
|
|
3631
3641
|
let r = M(n, t);
|
|
3632
|
-
return l.holding && !C ?
|
|
3642
|
+
return l.holding && !C ? be() || ye() : l.request(g ? g.nextAt + K : void 0), r;
|
|
3633
3643
|
}
|
|
3634
3644
|
case "waiting":
|
|
3635
3645
|
case "refreshing":
|
|
@@ -3637,9 +3647,9 @@ function fi(e) {
|
|
|
3637
3647
|
case "blocked-wait": return M(u.pending, t);
|
|
3638
3648
|
default: return oi(u);
|
|
3639
3649
|
}
|
|
3640
|
-
},
|
|
3650
|
+
}, ze = (e) => {
|
|
3641
3651
|
if (f) return Promise.reject(new Y(J.disposed));
|
|
3642
|
-
if (
|
|
3652
|
+
if (de(), u.kind === "ended") return Promise.reject(new Y(J.sessionEnded));
|
|
3643
3653
|
if (T() === "json" && !r.getTokens()?.refresh_token) {
|
|
3644
3654
|
let t = n.getTokens();
|
|
3645
3655
|
if (!t?.refresh_token) {
|
|
@@ -3647,13 +3657,13 @@ function fi(e) {
|
|
|
3647
3657
|
return P("refresh", e.trigger, n), Promise.reject(n);
|
|
3648
3658
|
}
|
|
3649
3659
|
}
|
|
3650
|
-
return
|
|
3651
|
-
},
|
|
3660
|
+
return z(e.trigger, e.fresh ? w() : void 0);
|
|
3661
|
+
}, Be = (e) => {
|
|
3652
3662
|
if (f) return Promise.reject(new Y(J.disposed));
|
|
3653
3663
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3654
3664
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > w();
|
|
3655
|
-
return e.allowStale && t ? Promise.resolve(r.getTokens()) :
|
|
3656
|
-
},
|
|
3665
|
+
return e.allowStale && t ? Promise.resolve(r.getTokens()) : ze({ trigger: e.trigger }).then(() => r.getTokens());
|
|
3666
|
+
}, Ve = (e, t) => l.holding ? Promise.resolve("granted") : new Promise((n) => {
|
|
3657
3667
|
let r = () => void 0, i = {
|
|
3658
3668
|
purpose: e,
|
|
3659
3669
|
granted: () => {
|
|
@@ -3666,7 +3676,7 @@ function fi(e) {
|
|
|
3666
3676
|
}), l.request(), r = o.setTimeout(() => {
|
|
3667
3677
|
S === i && (S = void 0, u.kind !== "waiting" && l.release(), n("timeout"));
|
|
3668
3678
|
}, Math.max(0, t));
|
|
3669
|
-
}),
|
|
3679
|
+
}), He = async (e) => {
|
|
3670
3680
|
if (u.kind !== "refreshing") return;
|
|
3671
3681
|
let t = u.request.settled.promise;
|
|
3672
3682
|
await new Promise((n) => {
|
|
@@ -3675,34 +3685,34 @@ function fi(e) {
|
|
|
3675
3685
|
r(), n();
|
|
3676
3686
|
});
|
|
3677
3687
|
});
|
|
3678
|
-
},
|
|
3688
|
+
}, Ue = () => {
|
|
3679
3689
|
if (C = !1, !f && l.holding) {
|
|
3680
|
-
if (u.kind === "waiting")
|
|
3690
|
+
if (u.kind === "waiting") be() || ye();
|
|
3681
3691
|
else if (u.kind === "backoff") {
|
|
3682
3692
|
let e = u.pending;
|
|
3683
|
-
u.cancel(),
|
|
3684
|
-
} else u.kind === "idle" && g && g.nextAt > w() &&
|
|
3693
|
+
u.cancel(), _e(e);
|
|
3694
|
+
} else u.kind === "idle" && g && g.nextAt > w() && ge(g) ? (m = g.attempt, h = g.strikes, _e(A("retry"))) : u.kind === "idle" && l.release();
|
|
3685
3695
|
}
|
|
3686
|
-
},
|
|
3696
|
+
}, B = async (e, t) => {
|
|
3687
3697
|
if (f) throw new Y(J.disposed);
|
|
3688
|
-
|
|
3698
|
+
de();
|
|
3689
3699
|
let n = w() + fr;
|
|
3690
|
-
if (await
|
|
3700
|
+
if (await He(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await Ve("commit", n - w())) === "timeout") {
|
|
3691
3701
|
let e = new qr("lock-timeout");
|
|
3692
3702
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3693
3703
|
}
|
|
3694
3704
|
C = !0;
|
|
3695
3705
|
try {
|
|
3696
|
-
return await
|
|
3706
|
+
return await We(e, t);
|
|
3697
3707
|
} finally {
|
|
3698
|
-
|
|
3708
|
+
Ue();
|
|
3699
3709
|
}
|
|
3700
|
-
},
|
|
3710
|
+
}, We = async (e, a) => {
|
|
3701
3711
|
let o, s;
|
|
3702
3712
|
if (T() === "json") {
|
|
3703
3713
|
let e = k.session();
|
|
3704
3714
|
try {
|
|
3705
|
-
k.checkStoredBeforeSend() === "adopted" && (I("adopted", "other-tab"),
|
|
3715
|
+
k.checkStoredBeforeSend() === "adopted" && (I("adopted", "other-tab"), ue(e));
|
|
3706
3716
|
} catch {}
|
|
3707
3717
|
s = n.getTokens();
|
|
3708
3718
|
let t = s?.refresh_token;
|
|
@@ -3736,7 +3746,7 @@ function fi(e) {
|
|
|
3736
3746
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3737
3747
|
...n.getTokens() ?? {},
|
|
3738
3748
|
...di(u, void 0)
|
|
3739
|
-
}),
|
|
3749
|
+
}), Ge(c);
|
|
3740
3750
|
let e = O();
|
|
3741
3751
|
return l.post(e === void 0 ? {
|
|
3742
3752
|
type: "session-refreshed",
|
|
@@ -3748,15 +3758,15 @@ function fi(e) {
|
|
|
3748
3758
|
}), D();
|
|
3749
3759
|
}
|
|
3750
3760
|
let d = k.commitSave(o, di(u, s));
|
|
3751
|
-
if (d.kind === "saved") return
|
|
3761
|
+
if (d.kind === "saved") return Ge(c), ue(o.order, c), D();
|
|
3752
3762
|
let f = new qr("superseded");
|
|
3753
3763
|
throw P("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && I("adopted", "other-tab"), f;
|
|
3754
|
-
},
|
|
3764
|
+
}, Ge = (e) => {
|
|
3755
3765
|
if (I("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
3756
3766
|
let t = u.pending;
|
|
3757
|
-
|
|
3767
|
+
fe(u), u = { kind: "idle" }, N(t, e);
|
|
3758
3768
|
}
|
|
3759
|
-
},
|
|
3769
|
+
}, Ke = () => {
|
|
3760
3770
|
let e = k.storedSession(), t = e.fp ? e : k.session();
|
|
3761
3771
|
(T() === "json" ? !t.fp : !t.sub) || t.fp && t.fp === x || (l.post({
|
|
3762
3772
|
type: "signed-out",
|
|
@@ -3765,37 +3775,37 @@ function fi(e) {
|
|
|
3765
3775
|
...t,
|
|
3766
3776
|
fp: t.fp
|
|
3767
3777
|
}));
|
|
3768
|
-
},
|
|
3778
|
+
}, qe = () => {
|
|
3769
3779
|
let e = j(u);
|
|
3770
|
-
ce(e, new Y(J.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (
|
|
3780
|
+
ce(e, new Y(J.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (fe(u), u = { kind: "idle" });
|
|
3771
3781
|
};
|
|
3772
3782
|
return {
|
|
3773
|
-
refresh:
|
|
3774
|
-
ensureFresh:
|
|
3775
|
-
commitUpgrade:
|
|
3783
|
+
refresh: ze,
|
|
3784
|
+
ensureFresh: Be,
|
|
3785
|
+
commitUpgrade: B,
|
|
3776
3786
|
signOut: async (e) => {
|
|
3777
3787
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3778
3788
|
let t = w() + pr;
|
|
3779
|
-
|
|
3789
|
+
qe(), await He(t - w()), qe(), l.coordinated && !l.holding && await Ve("logout", t - w());
|
|
3780
3790
|
try {
|
|
3781
|
-
|
|
3791
|
+
Ke(), await e(n.getTokens()?.refresh_token);
|
|
3782
3792
|
} finally {
|
|
3783
|
-
u.kind !== "ended" &&
|
|
3793
|
+
u.kind !== "ended" && L("signed-out-here"), x = void 0, l.release();
|
|
3784
3794
|
}
|
|
3785
3795
|
},
|
|
3786
3796
|
signOutNow: (e) => {
|
|
3787
3797
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3788
|
-
|
|
3798
|
+
qe();
|
|
3789
3799
|
try {
|
|
3790
|
-
|
|
3800
|
+
Ke(), e(n.getTokens()?.refresh_token);
|
|
3791
3801
|
} finally {
|
|
3792
|
-
u.kind !== "ended" &&
|
|
3802
|
+
u.kind !== "ended" && L("signed-out-here"), x = void 0;
|
|
3793
3803
|
}
|
|
3794
3804
|
},
|
|
3795
3805
|
sessionStarted: () => {
|
|
3796
3806
|
if (f) return;
|
|
3797
3807
|
let e = j(u);
|
|
3798
|
-
|
|
3808
|
+
fe(u), d += 1, m = 0, h = 0, g = void 0, _ = void 0, v = void 0, b = void 0, x = void 0, ee = void 0, l.setRetryInfo(void 0), u = { kind: "idle" }, C || l.release(), e && N(e, void 0, !0);
|
|
3799
3809
|
},
|
|
3800
3810
|
identity: O,
|
|
3801
3811
|
get coordinated() {
|
|
@@ -3810,7 +3820,7 @@ function fi(e) {
|
|
|
3810
3820
|
dispose: () => {
|
|
3811
3821
|
if (f) return;
|
|
3812
3822
|
let e = j(u);
|
|
3813
|
-
|
|
3823
|
+
fe(u), f = !0, d += 1, u = {
|
|
3814
3824
|
kind: "ended",
|
|
3815
3825
|
cause: "disposed"
|
|
3816
3826
|
}, ce(e, new Y(J.disposed)), S = void 0, k.stop(), l.dispose(), ae?.(), oe?.();
|
|
@@ -4044,7 +4054,18 @@ function Gi(e) {
|
|
|
4044
4054
|
return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
|
|
4045
4055
|
}
|
|
4046
4056
|
// lib/services/auth-service.ts
|
|
4047
|
-
var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow_pwless_pending", Xi = 3e3, Zi = "passflow_federated_pkce", Qi = 6e5, $i = "AppId is required for federated auth"
|
|
4057
|
+
var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow_pwless_pending", Xi = 3e3, Zi = "passflow_federated_pkce", Qi = 6e5, $i = "AppId is required for federated auth";
|
|
4058
|
+
function ea(e) {
|
|
4059
|
+
let t;
|
|
4060
|
+
try {
|
|
4061
|
+
t = new URL(e).protocol;
|
|
4062
|
+
} catch {
|
|
4063
|
+
t = void 0;
|
|
4064
|
+
}
|
|
4065
|
+
if (t !== "https:" && t !== "http:") throw Error("The federated start returned an address that is not http or https");
|
|
4066
|
+
return e;
|
|
4067
|
+
}
|
|
4068
|
+
var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is gone", ra = (e, t) => new Promise((n, r) => {
|
|
4048
4069
|
if (t?.aborted) {
|
|
4049
4070
|
r(t.reason);
|
|
4050
4071
|
return;
|
|
@@ -4055,20 +4076,20 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4055
4076
|
t?.removeEventListener("abort", i), n();
|
|
4056
4077
|
}, e);
|
|
4057
4078
|
t?.addEventListener("abort", i, { once: !0 });
|
|
4058
|
-
}),
|
|
4079
|
+
}), ia = (e) => {
|
|
4059
4080
|
if (!e) return;
|
|
4060
4081
|
let t = new URLSearchParams(e.search).get("token");
|
|
4061
4082
|
if (t) return t;
|
|
4062
4083
|
let n = e.hash.indexOf("?");
|
|
4063
4084
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
4064
|
-
},
|
|
4085
|
+
}, aa = (e) => {
|
|
4065
4086
|
if (e) try {
|
|
4066
4087
|
return j(e).email;
|
|
4067
4088
|
} catch {
|
|
4068
4089
|
return;
|
|
4069
4090
|
}
|
|
4070
|
-
},
|
|
4071
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d =
|
|
4091
|
+
}, oa = class {
|
|
4092
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination: jr() }, m) {
|
|
4072
4093
|
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ce(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh = fi({
|
|
4073
4094
|
emit: this.createRefreshEmit(),
|
|
4074
4095
|
storage: n,
|
|
@@ -4113,11 +4134,11 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4113
4134
|
}
|
|
4114
4135
|
}
|
|
4115
4136
|
async processAuthResponse(e, t) {
|
|
4116
|
-
await this.applyAuthResponse(e, t), this.refresh.sessionStarted();
|
|
4137
|
+
await this.applyAuthResponse(e, t, { replace: !0 }), this.refresh.sessionStarted();
|
|
4117
4138
|
}
|
|
4118
|
-
async applyAuthResponse(e, t) {
|
|
4139
|
+
async applyAuthResponse(e, t, n) {
|
|
4119
4140
|
if (e.code && !e.access_token) throw Error("A PKCE authorization code was not exchanged, so there are no tokens to apply");
|
|
4120
|
-
this.tokenExchangeConfig?.enabled || "token_delivery" in e && e.token_delivery && this.tokenDeliveryManager.setMode(e.token_delivery), this.tokenDeliveryManager.setSessionValid(), this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.callbackUrl && await this.forwardTokensToBFF(e), e.scopes = t, this.storageManager.saveTokens(e, this.tokenDeliveryManager.getMode()), this.tokenCacheService.setTokensCache(e), e.csrf_token && this.storageManager.setCsrfToken(e.csrf_token);
|
|
4141
|
+
this.tokenExchangeConfig?.enabled || "token_delivery" in e && e.token_delivery && this.tokenDeliveryManager.setMode(e.token_delivery), this.tokenDeliveryManager.setSessionValid(), this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.callbackUrl && await this.forwardTokensToBFF(e), e.scopes = t, this.storageManager.saveTokens(e, this.tokenDeliveryManager.getMode(), n), this.tokenCacheService.setTokensCache(e), e.csrf_token && this.storageManager.setCsrfToken(e.csrf_token);
|
|
4121
4142
|
}
|
|
4122
4143
|
notifyRegisteredAndSignedIn(e) {
|
|
4123
4144
|
let t = {
|
|
@@ -4134,7 +4155,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4134
4155
|
}), !0) : !1;
|
|
4135
4156
|
}
|
|
4136
4157
|
handleEmailVerificationStep(e, t, n, r, i) {
|
|
4137
|
-
if (!
|
|
4158
|
+
if (!Ve(e)) return !1;
|
|
4138
4159
|
let a = e.challenge_id || void 0;
|
|
4139
4160
|
return a && r ? this.rememberPkceSignIn(r.verifier, i) : this.forgetPkceSignIn(), a && this.rememberEmailChallenge(a, {
|
|
4140
4161
|
operation: t,
|
|
@@ -4150,7 +4171,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4150
4171
|
rememberEmailChallenge(e, t) {
|
|
4151
4172
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
4152
4173
|
for (let e of this.emailChallenges.keys()) {
|
|
4153
|
-
if (this.emailChallenges.size <=
|
|
4174
|
+
if (this.emailChallenges.size <= ta) break;
|
|
4154
4175
|
this.emailChallenges.delete(e);
|
|
4155
4176
|
}
|
|
4156
4177
|
}
|
|
@@ -4237,7 +4258,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4237
4258
|
}
|
|
4238
4259
|
async completePkceSignIn(e) {
|
|
4239
4260
|
let t = this.readPendingPkce();
|
|
4240
|
-
if (!t) throw Error(
|
|
4261
|
+
if (!t) throw Error(na);
|
|
4241
4262
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4242
4263
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
4243
4264
|
}
|
|
@@ -4295,7 +4316,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4295
4316
|
throw W(this.subscribeStore, t), e;
|
|
4296
4317
|
}
|
|
4297
4318
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4298
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4319
|
+
let n = this.deviceService.getDeviceId(), r = it(this.platform.getDeviceType());
|
|
4299
4320
|
e.scopes = e.scopes ?? this.scopes;
|
|
4300
4321
|
try {
|
|
4301
4322
|
let i = await this.startPkce(), a = await this.authApi.signIn(i ? {
|
|
@@ -4313,7 +4334,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4313
4334
|
operation: "sign-in",
|
|
4314
4335
|
message: e instanceof Error ? e.message : "Sign in failed",
|
|
4315
4336
|
originalError: e,
|
|
4316
|
-
code: e instanceof
|
|
4337
|
+
code: e instanceof B ? e.id : void 0
|
|
4317
4338
|
};
|
|
4318
4339
|
throw W(this.subscribeStore, t), e;
|
|
4319
4340
|
}
|
|
@@ -4351,7 +4372,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4351
4372
|
operation: "sign-up",
|
|
4352
4373
|
message: e instanceof Error ? e.message : "Sign up failed",
|
|
4353
4374
|
originalError: e,
|
|
4354
|
-
code: e instanceof
|
|
4375
|
+
code: e instanceof B ? e.id : void 0
|
|
4355
4376
|
};
|
|
4356
4377
|
throw W(this.subscribeStore, t), e;
|
|
4357
4378
|
}
|
|
@@ -4376,7 +4397,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4376
4397
|
throw W(this.subscribeStore, t), e;
|
|
4377
4398
|
}
|
|
4378
4399
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4379
|
-
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i =
|
|
4400
|
+
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = it(this.platform.getDeviceType());
|
|
4380
4401
|
try {
|
|
4381
4402
|
let a = await this.startPkce(), o = await this.authApi.passwordlessSignIn({
|
|
4382
4403
|
...e,
|
|
@@ -4397,7 +4418,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4397
4418
|
operation: "passwordless.start",
|
|
4398
4419
|
message: e instanceof Error ? e.message : "Failed to send passwordless sign-in link",
|
|
4399
4420
|
originalError: e,
|
|
4400
|
-
code: e instanceof
|
|
4421
|
+
code: e instanceof B ? e.id : void 0
|
|
4401
4422
|
};
|
|
4402
4423
|
throw W(this.subscribeStore, t), e;
|
|
4403
4424
|
}
|
|
@@ -4410,7 +4431,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4410
4431
|
if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
|
|
4411
4432
|
let a = n;
|
|
4412
4433
|
if (n.code) {
|
|
4413
|
-
if (!r) throw Error(
|
|
4434
|
+
if (!r) throw Error(na);
|
|
4414
4435
|
if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
|
|
4415
4436
|
...a,
|
|
4416
4437
|
redirect_url: n.redirect_url ?? ""
|
|
@@ -4433,7 +4454,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4433
4454
|
operation: "passwordless.complete",
|
|
4434
4455
|
message: e instanceof Error ? e.message : "Passwordless sign in failed",
|
|
4435
4456
|
originalError: e,
|
|
4436
|
-
code: e instanceof
|
|
4457
|
+
code: e instanceof B ? e.id : void 0
|
|
4437
4458
|
};
|
|
4438
4459
|
throw W(this.subscribeStore, t), e;
|
|
4439
4460
|
}
|
|
@@ -4442,11 +4463,11 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4442
4463
|
let n = t?.signal;
|
|
4443
4464
|
try {
|
|
4444
4465
|
let t = this.readPendingPasswordless();
|
|
4445
|
-
if (t?.challengeId !== e) throw Error(
|
|
4466
|
+
if (t?.challengeId !== e) throw Error(na);
|
|
4446
4467
|
for (;;) {
|
|
4447
4468
|
if (n?.aborted) throw n.reason;
|
|
4448
4469
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4449
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4470
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(na);
|
|
4450
4471
|
let r;
|
|
4451
4472
|
try {
|
|
4452
4473
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4455,7 +4476,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4455
4476
|
}, { signal: n });
|
|
4456
4477
|
} catch (e) {
|
|
4457
4478
|
if (n?.aborted) throw n.reason;
|
|
4458
|
-
if (e instanceof
|
|
4479
|
+
if (e instanceof B && e.status >= 400 && e.status < 500 && e.status !== 429) throw this.forgetPendingPasswordless(), e;
|
|
4459
4480
|
}
|
|
4460
4481
|
if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
|
|
4461
4482
|
if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
|
|
@@ -4464,7 +4485,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4464
4485
|
status: "signed-in",
|
|
4465
4486
|
tokens: { redirect_url: r.redirect_url }
|
|
4466
4487
|
};
|
|
4467
|
-
await
|
|
4488
|
+
await ra(Xi, n);
|
|
4468
4489
|
}
|
|
4469
4490
|
} catch (e) {
|
|
4470
4491
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4472,7 +4493,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4472
4493
|
operation: "passwordless.wait",
|
|
4473
4494
|
message: e instanceof Error ? e.message : "Waiting for the passwordless sign-in failed",
|
|
4474
4495
|
originalError: e,
|
|
4475
|
-
code: e instanceof
|
|
4496
|
+
code: e instanceof B ? e.id : void 0
|
|
4476
4497
|
};
|
|
4477
4498
|
throw W(this.subscribeStore, t), e;
|
|
4478
4499
|
}
|
|
@@ -4525,7 +4546,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4525
4546
|
operation: "passwordless.approval",
|
|
4526
4547
|
message: e instanceof Error ? e.message : "Passwordless approval failed",
|
|
4527
4548
|
originalError: e,
|
|
4528
|
-
code: e instanceof
|
|
4549
|
+
code: e instanceof B ? e.id : void 0
|
|
4529
4550
|
};
|
|
4530
4551
|
W(this.subscribeStore, t);
|
|
4531
4552
|
}
|
|
@@ -4533,14 +4554,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4533
4554
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4534
4555
|
try {
|
|
4535
4556
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4536
|
-
if (t?.pkce && !r) throw Error(
|
|
4557
|
+
if (t?.pkce && !r) throw Error(na);
|
|
4537
4558
|
let i = await this.authApi.validateEmailCode(e);
|
|
4538
4559
|
this.emailChallenges.delete(e.challenge_id);
|
|
4539
4560
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4540
4561
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4541
4562
|
let o = i;
|
|
4542
4563
|
if (i.code) {
|
|
4543
|
-
if (!r) throw Error(
|
|
4564
|
+
if (!r) throw Error(na);
|
|
4544
4565
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4545
4566
|
}
|
|
4546
4567
|
let s = i.redirect_url ? {
|
|
@@ -4556,7 +4577,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4556
4577
|
operation: "email-verification.complete",
|
|
4557
4578
|
message: e instanceof Error ? e.message : "Email verification failed",
|
|
4558
4579
|
originalError: e,
|
|
4559
|
-
code: e instanceof
|
|
4580
|
+
code: e instanceof B ? e.id : void 0
|
|
4560
4581
|
};
|
|
4561
4582
|
throw W(this.subscribeStore, t), e;
|
|
4562
4583
|
}
|
|
@@ -4695,7 +4716,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4695
4716
|
let e = await t.json();
|
|
4696
4717
|
typeof e?.error?.id == "string" && (n = e.error.id), typeof e?.error?.message == "string" && (r = e.error.message);
|
|
4697
4718
|
} catch {}
|
|
4698
|
-
throw new
|
|
4719
|
+
throw new B({
|
|
4699
4720
|
id: n ?? `error.http.${t.status}`,
|
|
4700
4721
|
message: r ?? "BFF token refresh failed",
|
|
4701
4722
|
status: t.status,
|
|
@@ -4736,17 +4757,17 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4736
4757
|
operation: "password-reset.send",
|
|
4737
4758
|
message: e instanceof Error ? e.message : "Failed to send password reset email",
|
|
4738
4759
|
originalError: e,
|
|
4739
|
-
code: e instanceof
|
|
4760
|
+
code: e instanceof B ? e.id : void 0
|
|
4740
4761
|
};
|
|
4741
4762
|
throw W(this.subscribeStore, t), e;
|
|
4742
4763
|
}
|
|
4743
4764
|
}
|
|
4744
4765
|
async resetPassword(e, t, n) {
|
|
4745
4766
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4746
|
-
let r = n ??
|
|
4767
|
+
let r = n ?? ia(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4747
4768
|
try {
|
|
4748
4769
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4749
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4770
|
+
if (this.handleEmailVerificationStep(n, "reset-password", aa(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4750
4771
|
let a = await this.exchangeCode(n, t);
|
|
4751
4772
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4752
4773
|
let o = n.redirect_url ? {
|
|
@@ -4762,7 +4783,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4762
4783
|
operation: "password-reset.complete",
|
|
4763
4784
|
message: e instanceof Error ? e.message : "Password reset failed",
|
|
4764
4785
|
originalError: e,
|
|
4765
|
-
code: e instanceof
|
|
4786
|
+
code: e instanceof B ? e.id : void 0
|
|
4766
4787
|
};
|
|
4767
4788
|
throw W(this.subscribeStore, t), e;
|
|
4768
4789
|
}
|
|
@@ -4770,7 +4791,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4770
4791
|
async passkeyRegister(e, t) {
|
|
4771
4792
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4772
4793
|
this.subscribeStore.notify(G.RegisterStart, {});
|
|
4773
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4794
|
+
let n = this.deviceService.getDeviceId(), r = it(this.platform.getDeviceType());
|
|
4774
4795
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4775
4796
|
try {
|
|
4776
4797
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyRegisterStart(i ? {
|
|
@@ -4789,7 +4810,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4789
4810
|
operation: "passkey.register",
|
|
4790
4811
|
message: e instanceof Error ? e.message : "Passkey registration failed",
|
|
4791
4812
|
originalError: e,
|
|
4792
|
-
code: e instanceof
|
|
4813
|
+
code: e instanceof B ? e.id : void 0
|
|
4793
4814
|
};
|
|
4794
4815
|
throw W(this.subscribeStore, t), e;
|
|
4795
4816
|
}
|
|
@@ -4797,7 +4818,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4797
4818
|
async passkeyAuthenticate(e, t) {
|
|
4798
4819
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4799
4820
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4800
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4821
|
+
let n = this.deviceService.getDeviceId(), r = it(this.platform.getDeviceType());
|
|
4801
4822
|
e.scopes = e.scopes ?? this.scopes;
|
|
4802
4823
|
try {
|
|
4803
4824
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyAuthenticateStart(i ? {
|
|
@@ -4817,7 +4838,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4817
4838
|
operation: "passkey.authenticate",
|
|
4818
4839
|
message: e instanceof Error ? e.message : "Passkey authentication failed",
|
|
4819
4840
|
originalError: e,
|
|
4820
|
-
code: e instanceof
|
|
4841
|
+
code: e instanceof B ? e.id : void 0
|
|
4821
4842
|
};
|
|
4822
4843
|
throw W(this.subscribeStore, t), e;
|
|
4823
4844
|
}
|
|
@@ -4879,7 +4900,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4879
4900
|
} : {}
|
|
4880
4901
|
};
|
|
4881
4902
|
return {
|
|
4882
|
-
url: await this.usesFederatedPost(t) ? (await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url : this.createFederatedAuthUrl(a),
|
|
4903
|
+
url: await this.usesFederatedPost(t) ? ea((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
|
|
4883
4904
|
pkce: i
|
|
4884
4905
|
};
|
|
4885
4906
|
})(), o, s = (e) => {
|
|
@@ -4924,7 +4945,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4924
4945
|
let t = {
|
|
4925
4946
|
operation: "federated.popup",
|
|
4926
4947
|
message: e instanceof Error ? e.message : "Authentication failed",
|
|
4927
|
-
code: e instanceof
|
|
4948
|
+
code: e instanceof fe ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4928
4949
|
originalError: e
|
|
4929
4950
|
};
|
|
4930
4951
|
W(this.subscribeStore, t);
|
|
@@ -4942,7 +4963,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4942
4963
|
code_challenge: i.challenge,
|
|
4943
4964
|
code_challenge_method: "S256"
|
|
4944
4965
|
} : {}
|
|
4945
|
-
}, o = await this.usesFederatedPost(t) ? (await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url : this.createFederatedAuthUrl(a);
|
|
4966
|
+
}, o = await this.usesFederatedPost(t) ? ea((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
|
|
4946
4967
|
i ? this.rememberFederatedSlot(i.verifier, n) : this.forgetFederatedSlot(), this.platform.navigateTo(o);
|
|
4947
4968
|
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
4948
4969
|
}
|
|
@@ -4969,7 +4990,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
4969
4990
|
operation: "federated.redirect",
|
|
4970
4991
|
message: e instanceof Error ? e.message : "Federated sign-in failed",
|
|
4971
4992
|
originalError: e,
|
|
4972
|
-
code: e instanceof
|
|
4993
|
+
code: e instanceof B ? e.id : void 0
|
|
4973
4994
|
};
|
|
4974
4995
|
W(this.subscribeStore, t);
|
|
4975
4996
|
}
|
|
@@ -5018,7 +5039,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5018
5039
|
operation: "auth-redirect",
|
|
5019
5040
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
5020
5041
|
originalError: e,
|
|
5021
|
-
code: e instanceof U ? e.code : e instanceof
|
|
5042
|
+
code: e instanceof U ? e.code : e instanceof B ? e.id : void 0
|
|
5022
5043
|
};
|
|
5023
5044
|
throw W(this.subscribeStore, t), e;
|
|
5024
5045
|
}
|
|
@@ -5090,7 +5111,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5090
5111
|
} catch (e) {
|
|
5091
5112
|
let n = {
|
|
5092
5113
|
operation: "session.check",
|
|
5093
|
-
message: e instanceof Error || e instanceof
|
|
5114
|
+
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
5094
5115
|
originalError: e
|
|
5095
5116
|
};
|
|
5096
5117
|
W(this.subscribeStore, n), t = void 0;
|
|
@@ -5113,7 +5134,15 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5113
5134
|
return t?.id_token ? this.tokenDeliveryManager.isSessionInvalid() && e ? await this.refreshForSession() : t : void 0;
|
|
5114
5135
|
}
|
|
5115
5136
|
let t = this.storageManager.getTokens();
|
|
5116
|
-
|
|
5137
|
+
if (!t || !t.access_token) return;
|
|
5138
|
+
if (A(j(t.access_token))) {
|
|
5139
|
+
if (e) {
|
|
5140
|
+
let e = await this.refreshForSession();
|
|
5141
|
+
return e?.refresh_token || this.storageManager.getTokens()?.refresh_token || !this.tokenCacheService.isExpired() ? e : void 0;
|
|
5142
|
+
}
|
|
5143
|
+
return;
|
|
5144
|
+
}
|
|
5145
|
+
return t;
|
|
5117
5146
|
} catch (e) {
|
|
5118
5147
|
let t = {
|
|
5119
5148
|
operation: "tokens.get",
|
|
@@ -5124,7 +5153,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5124
5153
|
return;
|
|
5125
5154
|
}
|
|
5126
5155
|
}
|
|
5127
|
-
},
|
|
5156
|
+
}, sa = class {
|
|
5128
5157
|
constructor(e) {
|
|
5129
5158
|
this.invitationApi = e;
|
|
5130
5159
|
}
|
|
@@ -5143,7 +5172,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5143
5172
|
getInvitationLink(e) {
|
|
5144
5173
|
return this.invitationApi.getInvitationLink(e);
|
|
5145
5174
|
}
|
|
5146
|
-
},
|
|
5175
|
+
}, ca = class {
|
|
5147
5176
|
constructor(e) {
|
|
5148
5177
|
this.data = this.normalize(e);
|
|
5149
5178
|
}
|
|
@@ -5200,7 +5229,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5200
5229
|
getData() {
|
|
5201
5230
|
return this.data;
|
|
5202
5231
|
}
|
|
5203
|
-
},
|
|
5232
|
+
}, la = class {
|
|
5204
5233
|
constructor(e, t, n) {
|
|
5205
5234
|
this.tenantApi = e, this.scopes = t, this.logger = n || Pr();
|
|
5206
5235
|
}
|
|
@@ -5238,7 +5267,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5238
5267
|
}
|
|
5239
5268
|
async getTenantUserMembership(e) {
|
|
5240
5269
|
try {
|
|
5241
|
-
return new
|
|
5270
|
+
return new ca(await this.tenantApi.getTenantDetails(e));
|
|
5242
5271
|
} catch (t) {
|
|
5243
5272
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
5244
5273
|
}
|
|
@@ -5383,8 +5412,8 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5383
5412
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5384
5413
|
}
|
|
5385
5414
|
}
|
|
5386
|
-
},
|
|
5387
|
-
constructor(e, t, n, r =
|
|
5415
|
+
}, ua = class {
|
|
5416
|
+
constructor(e, t, n, r = R) {
|
|
5388
5417
|
this.storageManager = e, this.subscribeStore = n, this.platform = r, this.checkInterval = null, this.CHECK_INTERVAL = 6e4, this.unsubscribeForeground = null, this.unsubscribeUnload = null, this.tokenExpiredFlag = !1, this.storageManager = e, this.setupLifecycleListeners();
|
|
5389
5418
|
}
|
|
5390
5419
|
get isRefreshing() {
|
|
@@ -5463,7 +5492,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5463
5492
|
isExpired() {
|
|
5464
5493
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5465
5494
|
}
|
|
5466
|
-
},
|
|
5495
|
+
}, da = class {
|
|
5467
5496
|
constructor(e, t, n) {
|
|
5468
5497
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
5469
5498
|
if (e === G.TwoFactorRequired) {
|
|
@@ -5794,8 +5823,8 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5794
5823
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5795
5824
|
}
|
|
5796
5825
|
}
|
|
5797
|
-
},
|
|
5798
|
-
constructor(e, t, n =
|
|
5826
|
+
}, fa = class {
|
|
5827
|
+
constructor(e, t, n = R) {
|
|
5799
5828
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5800
5829
|
}
|
|
5801
5830
|
getUserPasskeys() {
|
|
@@ -5809,7 +5838,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5809
5838
|
}
|
|
5810
5839
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
5811
5840
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
5812
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
5841
|
+
let r = this.deviceService.getDeviceId(), i = it(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
5813
5842
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
5814
5843
|
deviceId: r,
|
|
5815
5844
|
os: i,
|
|
@@ -5830,77 +5859,77 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5830
5859
|
signOutOtherSessions() {
|
|
5831
5860
|
return this.userAPI.revokeOtherUserSessions();
|
|
5832
5861
|
}
|
|
5833
|
-
},
|
|
5862
|
+
}, pa = class extends Error {
|
|
5834
5863
|
constructor(e, t, n = !1) {
|
|
5835
5864
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5836
5865
|
}
|
|
5837
|
-
},
|
|
5866
|
+
}, ma = (e, t) => {
|
|
5838
5867
|
let n = t?.trim();
|
|
5839
|
-
if (!n) throw new
|
|
5868
|
+
if (!n) throw new pa(e, "A verification code is required");
|
|
5840
5869
|
return n;
|
|
5841
|
-
},
|
|
5870
|
+
}, ha = {
|
|
5842
5871
|
type: "totp",
|
|
5843
5872
|
requiresPrepare: !1,
|
|
5844
5873
|
input: "code",
|
|
5845
|
-
assert: async ({ code: e }) => ({ code:
|
|
5846
|
-
},
|
|
5874
|
+
assert: async ({ code: e }) => ({ code: ma("totp", e) })
|
|
5875
|
+
}, ga = {
|
|
5847
5876
|
type: "recovery_codes",
|
|
5848
5877
|
requiresPrepare: !1,
|
|
5849
5878
|
input: "code",
|
|
5850
|
-
assert: async ({ code: e }) => ({ code:
|
|
5851
|
-
},
|
|
5879
|
+
assert: async ({ code: e }) => ({ code: ma("recovery_codes", e) })
|
|
5880
|
+
}, _a = {
|
|
5852
5881
|
type: "passkey",
|
|
5853
5882
|
requiresPrepare: !0,
|
|
5854
5883
|
input: "none",
|
|
5855
5884
|
assert: async ({ prepared: e, platform: t }) => {
|
|
5856
|
-
if (!e?.webauthn) throw new
|
|
5885
|
+
if (!e?.webauthn) throw new pa("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
5857
5886
|
let n = t.passkeys;
|
|
5858
|
-
if (!n) throw new
|
|
5887
|
+
if (!n) throw new pa("passkey", "This platform does not support passkeys");
|
|
5859
5888
|
let r;
|
|
5860
5889
|
try {
|
|
5861
5890
|
r = await n.startAuthentication(e.webauthn);
|
|
5862
5891
|
} catch (e) {
|
|
5863
|
-
throw new
|
|
5892
|
+
throw new pa("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
5864
5893
|
}
|
|
5865
|
-
if (!r) throw new
|
|
5894
|
+
if (!r) throw new pa("passkey", "Passkey verification was cancelled", !0);
|
|
5866
5895
|
return {
|
|
5867
5896
|
challenge_id: e.challengeId,
|
|
5868
5897
|
credential: r
|
|
5869
5898
|
};
|
|
5870
5899
|
}
|
|
5871
|
-
},
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
]),
|
|
5900
|
+
}, va = Object.freeze([
|
|
5901
|
+
ha,
|
|
5902
|
+
_a,
|
|
5903
|
+
ga
|
|
5904
|
+
]), ya = (e = va) => new Map(e.map((e) => [e.type, e])), ba = 3, xa = {
|
|
5876
5905
|
totp: 0,
|
|
5877
5906
|
passkey: 1,
|
|
5878
5907
|
email_otp: 2,
|
|
5879
5908
|
sms_otp: 3,
|
|
5880
5909
|
recovery_codes: 9
|
|
5881
|
-
},
|
|
5882
|
-
let n =
|
|
5910
|
+
}, Sa = (e) => e.requiredLevel ?? _e(e.acrValues), Ca = (e, t) => {
|
|
5911
|
+
let n = xa[e.type] ?? 5, r = t !== void 0 && t >= ba, i = e.type === "passkey";
|
|
5883
5912
|
return (r && !i ? 100 : 0) + n;
|
|
5884
|
-
},
|
|
5913
|
+
}, wa = (e, t) => {
|
|
5885
5914
|
if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
|
|
5886
|
-
let n =
|
|
5887
|
-
return [...e].sort((e, t) =>
|
|
5888
|
-
},
|
|
5915
|
+
let n = Sa(t);
|
|
5916
|
+
return [...e].sort((e, t) => Ca(e, n) - Ca(t, n));
|
|
5917
|
+
}, Ta = class extends Error {
|
|
5889
5918
|
constructor(e) {
|
|
5890
5919
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
5891
5920
|
}
|
|
5892
|
-
},
|
|
5921
|
+
}, Ea = class extends Error {
|
|
5893
5922
|
constructor(e = "Only a fresh sign-in can meet this challenge") {
|
|
5894
5923
|
super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
|
|
5895
5924
|
}
|
|
5896
|
-
},
|
|
5897
|
-
if (
|
|
5898
|
-
if (
|
|
5899
|
-
},
|
|
5925
|
+
}, Da = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Oa = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, ka = "This account has no factor that reaches the required level (it may need a device-bound passkey)", Aa = (e) => {
|
|
5926
|
+
if (Da(e)) return new Ea();
|
|
5927
|
+
if (Oa(e)) return new ja(ka);
|
|
5928
|
+
}, ja = class extends Error {
|
|
5900
5929
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
5901
5930
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
5902
5931
|
}
|
|
5903
|
-
},
|
|
5932
|
+
}, Ma = 4, Na = 3e4, Pa = () => {
|
|
5904
5933
|
let e = () => void 0, t = () => void 0;
|
|
5905
5934
|
return {
|
|
5906
5935
|
promise: new Promise((n, r) => {
|
|
@@ -5909,12 +5938,12 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5909
5938
|
resolve: e,
|
|
5910
5939
|
reject: t
|
|
5911
5940
|
};
|
|
5912
|
-
},
|
|
5941
|
+
}, Fa = (e) => ({
|
|
5913
5942
|
acrValues: e.acrValues,
|
|
5914
5943
|
level: e.requiredLevel,
|
|
5915
5944
|
maxAge: e.maxAge
|
|
5916
|
-
}),
|
|
5917
|
-
let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } =
|
|
5945
|
+
}), Ia = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, La = (e, t) => {
|
|
5946
|
+
let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = Ra(t, e) && !Ra(e, t) || !t.availableFactors ? e : t;
|
|
5918
5947
|
return {
|
|
5919
5948
|
acrValues: r,
|
|
5920
5949
|
requiredLevel: n,
|
|
@@ -5924,12 +5953,12 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5924
5953
|
...o ? { availableFactors: o } : {},
|
|
5925
5954
|
...s === void 0 ? {} : { signInRequired: s }
|
|
5926
5955
|
};
|
|
5927
|
-
},
|
|
5956
|
+
}, Ra = (e, t) => {
|
|
5928
5957
|
let n = t.requiredLevel !== void 0 && (e.requiredLevel === void 0 || t.requiredLevel > e.requiredLevel), r = t.maxAge !== void 0 && (e.maxAge === void 0 || t.maxAge < e.maxAge);
|
|
5929
5958
|
return n || r;
|
|
5930
|
-
},
|
|
5959
|
+
}, za = class {
|
|
5931
5960
|
constructor(e) {
|
|
5932
|
-
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ??
|
|
5961
|
+
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? va, this.registry = ya(this.available), this.maxAttempts = e.maxAttempts ?? Ma, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Na;
|
|
5933
5962
|
}
|
|
5934
5963
|
get currentState() {
|
|
5935
5964
|
return this.state;
|
|
@@ -5949,9 +5978,9 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5949
5978
|
}
|
|
5950
5979
|
register(e, t) {
|
|
5951
5980
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
5952
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5981
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : Fa(e),
|
|
5953
5982
|
statedBar: n,
|
|
5954
|
-
settlement:
|
|
5983
|
+
settlement: Pa(),
|
|
5955
5984
|
reported: !1,
|
|
5956
5985
|
entry: {
|
|
5957
5986
|
...t,
|
|
@@ -5967,15 +5996,15 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
5967
5996
|
this.requirement = e;
|
|
5968
5997
|
return;
|
|
5969
5998
|
}
|
|
5970
|
-
let n =
|
|
5971
|
-
this.requirement =
|
|
5999
|
+
let n = Ra(t, e);
|
|
6000
|
+
this.requirement = La(t, e), Aa(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
5972
6001
|
challenge: this.requirement,
|
|
5973
6002
|
factors: this.offeredFactors()
|
|
5974
6003
|
});
|
|
5975
6004
|
}
|
|
5976
6005
|
offeredFactors() {
|
|
5977
6006
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
5978
|
-
return t ?
|
|
6007
|
+
return t ? wa(e, t) : e;
|
|
5979
6008
|
}
|
|
5980
6009
|
receiveReport(e, t) {
|
|
5981
6010
|
e.reported || (e.reported = !0, e.entry.outcome = t.outcome, t.obtained && (e.entry.obtained = t.obtained), t.required && (e.entry.required = t.required), this.notifyReportsSettled());
|
|
@@ -6010,7 +6039,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6010
6039
|
}
|
|
6011
6040
|
release(e, t) {
|
|
6012
6041
|
if (e.entry.kind === "imperative") {
|
|
6013
|
-
if (e.statedBar && !
|
|
6042
|
+
if (e.statedBar && !Ia(t, e.demanded)) {
|
|
6014
6043
|
this.receiveReport(e, {
|
|
6015
6044
|
outcome: "insufficient",
|
|
6016
6045
|
obtained: t,
|
|
@@ -6085,7 +6114,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6085
6114
|
async prove() {
|
|
6086
6115
|
let e;
|
|
6087
6116
|
for (let t = 0; t < this.maxAttempts; t++) {
|
|
6088
|
-
let t =
|
|
6117
|
+
let t = Aa(this.requirement);
|
|
6089
6118
|
if (t) return {
|
|
6090
6119
|
status: "failed",
|
|
6091
6120
|
reason: t
|
|
@@ -6093,7 +6122,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6093
6122
|
let n = this.offeredFactors();
|
|
6094
6123
|
if (n.length === 0) return {
|
|
6095
6124
|
status: "failed",
|
|
6096
|
-
reason: new
|
|
6125
|
+
reason: new ja()
|
|
6097
6126
|
};
|
|
6098
6127
|
let r = this.requirement, i;
|
|
6099
6128
|
try {
|
|
@@ -6101,29 +6130,29 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6101
6130
|
} catch (e) {
|
|
6102
6131
|
return {
|
|
6103
6132
|
status: "failed",
|
|
6104
|
-
reason: new
|
|
6133
|
+
reason: new Ta(e)
|
|
6105
6134
|
};
|
|
6106
6135
|
}
|
|
6107
|
-
let a =
|
|
6136
|
+
let a = Aa(this.requirement);
|
|
6108
6137
|
if (a) return {
|
|
6109
6138
|
status: "failed",
|
|
6110
6139
|
reason: a
|
|
6111
6140
|
};
|
|
6112
6141
|
if (i.type === "cancel") return {
|
|
6113
6142
|
status: "failed",
|
|
6114
|
-
reason: new
|
|
6143
|
+
reason: new Ta()
|
|
6115
6144
|
};
|
|
6116
6145
|
let o = this.registry.get(i.factor);
|
|
6117
|
-
if (!o) e = new
|
|
6146
|
+
if (!o) e = new ja(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
|
|
6118
6147
|
else try {
|
|
6119
6148
|
return await this.proveAndCommit(o, i.code), {
|
|
6120
6149
|
status: "proven",
|
|
6121
|
-
obtained: this.readObtainedBar?.() ??
|
|
6150
|
+
obtained: this.readObtainedBar?.() ?? Fa(this.rankedRequirement ?? r)
|
|
6122
6151
|
};
|
|
6123
6152
|
} catch (t) {
|
|
6124
|
-
if (t instanceof
|
|
6153
|
+
if (t instanceof pa && t.cancelled) return {
|
|
6125
6154
|
status: "failed",
|
|
6126
|
-
reason: new
|
|
6155
|
+
reason: new Ta()
|
|
6127
6156
|
};
|
|
6128
6157
|
let n = this.classifyProofFailure(t);
|
|
6129
6158
|
if (n) return {
|
|
@@ -6180,28 +6209,28 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6180
6209
|
});
|
|
6181
6210
|
await this.transport.commit(e.type, r);
|
|
6182
6211
|
}
|
|
6183
|
-
},
|
|
6212
|
+
}, Ba = (e) => typeof e == "function" ? e() : e, Va = (e) => {
|
|
6184
6213
|
try {
|
|
6185
6214
|
return new URL(e);
|
|
6186
6215
|
} catch {
|
|
6187
6216
|
return;
|
|
6188
6217
|
}
|
|
6189
|
-
},
|
|
6218
|
+
}, Ha = (e, t) => {
|
|
6190
6219
|
if (!t || t === "/") return !0;
|
|
6191
6220
|
let n = t.replace(/\/+$/, "");
|
|
6192
6221
|
return e === n || e.startsWith(`${n}/`);
|
|
6193
|
-
},
|
|
6222
|
+
}, Ua = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Ha(e.pathname, t.pathPrefix), Wa = (e, t) => {
|
|
6194
6223
|
for (let n of t) {
|
|
6195
6224
|
if (n === "") continue;
|
|
6196
6225
|
if (n.startsWith("/")) {
|
|
6197
|
-
if (e.relativeToBase &&
|
|
6226
|
+
if (e.relativeToBase && Ha(e.pathname, n)) return !0;
|
|
6198
6227
|
continue;
|
|
6199
6228
|
}
|
|
6200
|
-
let t =
|
|
6201
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
6229
|
+
let t = Va(n) ?? Va(`https://${n}`);
|
|
6230
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && Ha(e.pathname, t.pathname)) return !0;
|
|
6202
6231
|
}
|
|
6203
6232
|
return !1;
|
|
6204
|
-
},
|
|
6233
|
+
}, Ga = (e, t, n) => Ua(e, t.passflow) || Wa(e, t.backend) ? !n || n(e.href) !== !1 : !1, Ka = (e) => {
|
|
6205
6234
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
6206
6235
|
console.warn(n, {
|
|
6207
6236
|
status: e.status,
|
|
@@ -6209,8 +6238,8 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6209
6238
|
reason: e.reason,
|
|
6210
6239
|
detail: t
|
|
6211
6240
|
});
|
|
6212
|
-
},
|
|
6213
|
-
let n = t.onUpgradeDiagnostic ??
|
|
6241
|
+
}, qa = (e, t) => {
|
|
6242
|
+
let n = t.onUpgradeDiagnostic ?? Ka;
|
|
6214
6243
|
return (t, r) => {
|
|
6215
6244
|
n({
|
|
6216
6245
|
status: e.status,
|
|
@@ -6222,8 +6251,8 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6222
6251
|
}
|
|
6223
6252
|
});
|
|
6224
6253
|
};
|
|
6225
|
-
},
|
|
6226
|
-
let r = n.onUpgradeDiagnostic ??
|
|
6254
|
+
}, Ja = (e, t, n) => {
|
|
6255
|
+
let r = n.onUpgradeDiagnostic ?? Ka;
|
|
6227
6256
|
for (let n of e) r({
|
|
6228
6257
|
...n,
|
|
6229
6258
|
url: t.request.href,
|
|
@@ -6232,14 +6261,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6232
6261
|
...n.detail ?? {}
|
|
6233
6262
|
}
|
|
6234
6263
|
});
|
|
6235
|
-
},
|
|
6236
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
6264
|
+
}, Ya = /\bjson\b/i, Xa = async (e, t) => {
|
|
6265
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Ya.test(r), a;
|
|
6237
6266
|
if (i) try {
|
|
6238
6267
|
a = await e.readBody();
|
|
6239
6268
|
} catch {
|
|
6240
6269
|
a = void 0;
|
|
6241
6270
|
}
|
|
6242
|
-
return
|
|
6271
|
+
return ke(i ? {
|
|
6243
6272
|
status: e.status,
|
|
6244
6273
|
getHeader: (t) => e.getHeader(t) ?? void 0,
|
|
6245
6274
|
body: a
|
|
@@ -6247,10 +6276,10 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6247
6276
|
status: e.status,
|
|
6248
6277
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6249
6278
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
6250
|
-
},
|
|
6279
|
+
}, Za = (e) => ke({
|
|
6251
6280
|
status: e.status,
|
|
6252
6281
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6253
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
6282
|
+
}, { requireChallengeChannel: "header" }).challenge, Qa = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, $a = (e, t) => e instanceof Ta ? { kind: "cancelled" } : e instanceof Ea ? { kind: "sign-in-required" } : e instanceof ja ? {
|
|
6254
6283
|
kind: "unsatisfiable",
|
|
6255
6284
|
error: e
|
|
6256
6285
|
} : e instanceof Fi ? { kind: "unavailable" } : e instanceof Ii ? { kind: "session-changed" } : e instanceof Pi ? {
|
|
@@ -6269,26 +6298,26 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6269
6298
|
kind: "transport-failure",
|
|
6270
6299
|
retryable: !1,
|
|
6271
6300
|
error: e instanceof Error ? e : Error(String(e))
|
|
6272
|
-
},
|
|
6301
|
+
}, eo = async (e, t, n, r) => {
|
|
6273
6302
|
if (e.status !== 401 && e.status !== 403) return {
|
|
6274
6303
|
kind: "replayed",
|
|
6275
6304
|
response: e
|
|
6276
6305
|
};
|
|
6277
|
-
let { challenge: i, diagnostics: a } = await
|
|
6278
|
-
if (
|
|
6306
|
+
let { challenge: i, diagnostics: a } = await Xa(e, t);
|
|
6307
|
+
if (Ja(a, e, t), !i) return {
|
|
6279
6308
|
kind: "replayed",
|
|
6280
6309
|
response: e
|
|
6281
6310
|
};
|
|
6282
|
-
if (
|
|
6311
|
+
if (Da(i)) return {
|
|
6283
6312
|
kind: "sign-in-required",
|
|
6284
6313
|
response: e
|
|
6285
6314
|
};
|
|
6286
|
-
if (
|
|
6315
|
+
if (Oa(i)) return {
|
|
6287
6316
|
kind: "unsatisfiable",
|
|
6288
|
-
error:
|
|
6317
|
+
error: Aa(i),
|
|
6289
6318
|
response: e
|
|
6290
6319
|
};
|
|
6291
|
-
let o =
|
|
6320
|
+
let o = Fa(i);
|
|
6292
6321
|
return r("elevated-insufficient", {
|
|
6293
6322
|
obtained: n,
|
|
6294
6323
|
required: o
|
|
@@ -6298,7 +6327,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6298
6327
|
required: o,
|
|
6299
6328
|
response: e
|
|
6300
6329
|
};
|
|
6301
|
-
},
|
|
6330
|
+
}, to = async (e, t) => {
|
|
6302
6331
|
if (!t) return {
|
|
6303
6332
|
aborted: !1,
|
|
6304
6333
|
value: await e
|
|
@@ -6325,14 +6354,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6325
6354
|
} finally {
|
|
6326
6355
|
n && t.removeEventListener?.("abort", n);
|
|
6327
6356
|
}
|
|
6328
|
-
},
|
|
6357
|
+
}, no = async (e, t) => {
|
|
6329
6358
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
6330
|
-
let n =
|
|
6359
|
+
let n = qa(e, t);
|
|
6331
6360
|
if (e.markers.replayed) {
|
|
6332
|
-
if (!
|
|
6333
|
-
let { challenge: r, diagnostics: i } = await
|
|
6334
|
-
if (
|
|
6335
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
6361
|
+
if (!Ga(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
6362
|
+
let { challenge: r, diagnostics: i } = await Xa(e, t);
|
|
6363
|
+
if (Ja(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
6364
|
+
let a = t.readObtainedBar?.() ?? {}, o = Fa(r);
|
|
6336
6365
|
return n("elevated-insufficient", {
|
|
6337
6366
|
obtained: a,
|
|
6338
6367
|
required: o
|
|
@@ -6343,12 +6372,12 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6343
6372
|
response: e
|
|
6344
6373
|
};
|
|
6345
6374
|
}
|
|
6346
|
-
if (!
|
|
6375
|
+
if (!Ga(e.request, t.scope, t.shouldIntercept)) return Za(e) ? (n("challenge-out-of-scope", {
|
|
6347
6376
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
6348
|
-
message:
|
|
6377
|
+
message: Qa(e.request.href, t.scope)
|
|
6349
6378
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
6350
|
-
let { challenge: r, diagnostics: i } = await
|
|
6351
|
-
if (
|
|
6379
|
+
let { challenge: r, diagnostics: i } = await Xa(e, t);
|
|
6380
|
+
if (Ja(i, e, t), !r) {
|
|
6352
6381
|
let r = e.getHeader("www-authenticate");
|
|
6353
6382
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
6354
6383
|
...r ? { header: r } : {},
|
|
@@ -6362,9 +6391,9 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6362
6391
|
method: e.request.method
|
|
6363
6392
|
}, s, c;
|
|
6364
6393
|
try {
|
|
6365
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
6394
|
+
s = Promise.resolve(t.elevate(r, o)), c = await to(s, e.signal);
|
|
6366
6395
|
} catch (e) {
|
|
6367
|
-
return
|
|
6396
|
+
return $a(e, void 0);
|
|
6368
6397
|
}
|
|
6369
6398
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
6370
6399
|
kind: "aborted",
|
|
@@ -6375,7 +6404,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6375
6404
|
kind: "aborted",
|
|
6376
6405
|
reason: e.signal.reason
|
|
6377
6406
|
};
|
|
6378
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
6407
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? Fa(r), d = t.authorizationSwap?.(), f = d ? {
|
|
6379
6408
|
from: a?.from ?? d.from,
|
|
6380
6409
|
to: d.to
|
|
6381
6410
|
} : void 0;
|
|
@@ -6402,7 +6431,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6402
6431
|
};
|
|
6403
6432
|
throw t;
|
|
6404
6433
|
}
|
|
6405
|
-
let m = await
|
|
6434
|
+
let m = await eo(p, t, u, n);
|
|
6406
6435
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6407
6436
|
outcome: "insufficient",
|
|
6408
6437
|
obtained: m.obtained,
|
|
@@ -6411,11 +6440,11 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6411
6440
|
outcome: "replayed",
|
|
6412
6441
|
obtained: u
|
|
6413
6442
|
}), m;
|
|
6414
|
-
},
|
|
6443
|
+
}, ro = (e) => {
|
|
6415
6444
|
switch (e.kind) {
|
|
6416
|
-
case "cancelled": return new
|
|
6417
|
-
case "unsatisfiable": return e.error ?? new
|
|
6418
|
-
case "sign-in-required": return new
|
|
6445
|
+
case "cancelled": return new Ta();
|
|
6446
|
+
case "unsatisfiable": return e.error ?? new ja();
|
|
6447
|
+
case "sign-in-required": return new Ea();
|
|
6419
6448
|
case "unavailable": return new Fi();
|
|
6420
6449
|
case "session-changed": return new Ii();
|
|
6421
6450
|
case "insufficient": return new Pi(e.obtained, e.required);
|
|
@@ -6423,7 +6452,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6423
6452
|
case "transport-failure": return e.error;
|
|
6424
6453
|
default: return;
|
|
6425
6454
|
}
|
|
6426
|
-
},
|
|
6455
|
+
}, io = (e, t, n) => {
|
|
6427
6456
|
switch (e.kind) {
|
|
6428
6457
|
case "replayed": return {
|
|
6429
6458
|
settle: "resolve",
|
|
@@ -6441,26 +6470,26 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6441
6470
|
};
|
|
6442
6471
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6443
6472
|
settle: "reject",
|
|
6444
|
-
error: new
|
|
6473
|
+
error: new Ta()
|
|
6445
6474
|
} : {
|
|
6446
6475
|
settle: "resolve",
|
|
6447
|
-
value:
|
|
6476
|
+
value: ho(t, e)
|
|
6448
6477
|
};
|
|
6449
6478
|
case "unsatisfiable":
|
|
6450
6479
|
case "sign-in-required": return {
|
|
6451
6480
|
settle: "resolve",
|
|
6452
|
-
value:
|
|
6481
|
+
value: ho(e.response?.raw ?? t, e)
|
|
6453
6482
|
};
|
|
6454
6483
|
case "insufficient": return {
|
|
6455
6484
|
settle: "resolve",
|
|
6456
|
-
value:
|
|
6485
|
+
value: ho(e.response?.raw ?? t, e)
|
|
6457
6486
|
};
|
|
6458
6487
|
default: return {
|
|
6459
6488
|
settle: "resolve",
|
|
6460
|
-
value:
|
|
6489
|
+
value: ho(t, e)
|
|
6461
6490
|
};
|
|
6462
6491
|
}
|
|
6463
|
-
},
|
|
6492
|
+
}, ao = (e, t) => {
|
|
6464
6493
|
switch (e.kind) {
|
|
6465
6494
|
case "replayed": return e.response.rejected ? {
|
|
6466
6495
|
settle: "reject",
|
|
@@ -6475,42 +6504,42 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6475
6504
|
};
|
|
6476
6505
|
default: return {
|
|
6477
6506
|
settle: "reject",
|
|
6478
|
-
error:
|
|
6507
|
+
error: ro(e) ?? t
|
|
6479
6508
|
};
|
|
6480
6509
|
}
|
|
6481
|
-
},
|
|
6510
|
+
}, oo = /* @__PURE__ */ new WeakSet(), so = /* @__PURE__ */ new WeakSet(), co = /* @__PURE__ */ new WeakSet(), lo = /* @__PURE__ */ new WeakSet(), uo = /* @__PURE__ */ new WeakSet(), fo = /* @__PURE__ */ new WeakSet(), po = /* @__PURE__ */ new WeakSet(), mo = /* @__PURE__ */ new WeakSet(), ho = (e, t) => {
|
|
6482
6511
|
switch (t.kind) {
|
|
6483
6512
|
case "cancelled":
|
|
6484
|
-
|
|
6513
|
+
oo.add(e);
|
|
6485
6514
|
break;
|
|
6486
6515
|
case "exhausted":
|
|
6487
|
-
|
|
6516
|
+
so.add(e);
|
|
6488
6517
|
break;
|
|
6489
6518
|
case "insufficient":
|
|
6490
|
-
|
|
6519
|
+
co.add(e);
|
|
6491
6520
|
break;
|
|
6492
6521
|
case "unsatisfiable":
|
|
6493
|
-
|
|
6522
|
+
lo.add(e);
|
|
6494
6523
|
break;
|
|
6495
6524
|
case "sign-in-required":
|
|
6496
|
-
|
|
6525
|
+
uo.add(e);
|
|
6497
6526
|
break;
|
|
6498
6527
|
case "unavailable":
|
|
6499
|
-
|
|
6528
|
+
fo.add(e);
|
|
6500
6529
|
break;
|
|
6501
6530
|
case "session-changed":
|
|
6502
|
-
|
|
6531
|
+
po.add(e);
|
|
6503
6532
|
break;
|
|
6504
|
-
case "transport-failure":
|
|
6533
|
+
case "transport-failure": mo.add(e);
|
|
6505
6534
|
}
|
|
6506
6535
|
return e;
|
|
6507
|
-
},
|
|
6536
|
+
}, go = (e) => oo.has(e), _o = (e) => so.has(e), vo = (e) => co.has(e), yo = (e) => lo.has(e), bo = (e) => uo.has(e), xo = (e) => fo.has(e), So = (e) => po.has(e), Co = (e) => mo.has(e), wo = "https://passflow-relative.invalid", To = () => {
|
|
6508
6537
|
let e = globalThis, t = e.document?.baseURI;
|
|
6509
6538
|
if (typeof t == "string" && t !== "") return t;
|
|
6510
6539
|
let n = e.location?.href;
|
|
6511
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6512
|
-
},
|
|
6513
|
-
let n = t ===
|
|
6540
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : wo;
|
|
6541
|
+
}, Eo = (e, t = To()) => {
|
|
6542
|
+
let n = t === wo, r;
|
|
6514
6543
|
try {
|
|
6515
6544
|
r = new URL(t).origin;
|
|
6516
6545
|
} catch {
|
|
@@ -6536,28 +6565,28 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6536
6565
|
relativeToBase: !1,
|
|
6537
6566
|
sentinelBase: n
|
|
6538
6567
|
};
|
|
6539
|
-
},
|
|
6568
|
+
}, Do = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Oo = (e) => {
|
|
6540
6569
|
let t = [];
|
|
6541
6570
|
if (e == null) return Object.freeze(t);
|
|
6542
6571
|
let n = e;
|
|
6543
6572
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6544
|
-
let r =
|
|
6573
|
+
let r = Do(n, e);
|
|
6545
6574
|
r && t.push(r);
|
|
6546
6575
|
}), Object.freeze(t);
|
|
6547
6576
|
if (Array.isArray(e)) {
|
|
6548
6577
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6549
|
-
let e =
|
|
6578
|
+
let e = Do(String(n[0]), n[1]);
|
|
6550
6579
|
e && t.push(e);
|
|
6551
6580
|
}
|
|
6552
6581
|
return Object.freeze(t);
|
|
6553
6582
|
}
|
|
6554
6583
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6555
|
-
let e =
|
|
6584
|
+
let e = Do(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6556
6585
|
e && t.push(e);
|
|
6557
6586
|
}
|
|
6558
6587
|
return Object.freeze(t);
|
|
6559
|
-
},
|
|
6560
|
-
let t = e.base === void 0 ?
|
|
6588
|
+
}, ko = (e) => {
|
|
6589
|
+
let t = e.base === void 0 ? Eo(e.url) : Eo(e.url, e.base), n = {
|
|
6561
6590
|
raw: e.url,
|
|
6562
6591
|
href: t.href,
|
|
6563
6592
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6566,29 +6595,29 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6566
6595
|
resolved: t.resolved,
|
|
6567
6596
|
relativeToBase: t.relativeToBase,
|
|
6568
6597
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6569
|
-
headers:
|
|
6598
|
+
headers: Oo(e.headers),
|
|
6570
6599
|
bodyKind: e.bodyKind,
|
|
6571
6600
|
..."body" in e ? { body: e.body } : {}
|
|
6572
6601
|
};
|
|
6573
6602
|
return Object.freeze(n);
|
|
6574
|
-
},
|
|
6603
|
+
}, Ao = (e, t) => {
|
|
6575
6604
|
if (!t || t.from === t.to) return e;
|
|
6576
6605
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6577
6606
|
return n ? Object.freeze(r) : e;
|
|
6578
|
-
},
|
|
6607
|
+
}, jo = (e) => {
|
|
6579
6608
|
let t = {};
|
|
6580
6609
|
for (let [n, r] of e) t[n] = r;
|
|
6581
6610
|
return t;
|
|
6582
|
-
},
|
|
6611
|
+
}, Mo = /* @__PURE__ */ new Set([
|
|
6583
6612
|
"GET",
|
|
6584
6613
|
"HEAD",
|
|
6585
6614
|
"OPTIONS"
|
|
6586
|
-
]),
|
|
6615
|
+
]), No = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Po = (e) => typeof e == "string" ? e : No(e) ? e.url : String(e), Fo = (e, t) => (t?.method ?? (No(e) ? e.method : void 0) ?? "GET").toUpperCase(), Io = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Lo = (e) => {
|
|
6587
6616
|
if (typeof e == "string") return e.length;
|
|
6588
6617
|
let t = e;
|
|
6589
6618
|
if (typeof t?.size == "number") return t.size;
|
|
6590
6619
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6591
|
-
},
|
|
6620
|
+
}, Ro = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Mo.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), zo = (e, t, n, r, i) => ({
|
|
6592
6621
|
replayable: !1,
|
|
6593
6622
|
bodyKind: e,
|
|
6594
6623
|
reason: t,
|
|
@@ -6596,11 +6625,11 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6596
6625
|
forwardInit: i,
|
|
6597
6626
|
snapshot: r,
|
|
6598
6627
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6599
|
-
}),
|
|
6628
|
+
}), Bo = (e, t) => jo(Ao(e.headers, t?.authorizationSwap)), Vo = (e) => {
|
|
6600
6629
|
if (!e || !("headers" in e)) return e;
|
|
6601
6630
|
let { headers: t, ...n } = e;
|
|
6602
6631
|
return n;
|
|
6603
|
-
},
|
|
6632
|
+
}, Ho = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : No(e) ? e.headers : void 0, Uo = (e) => {
|
|
6604
6633
|
if (e === null || typeof e == "string") return e;
|
|
6605
6634
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6606
6635
|
let t = new FormData();
|
|
@@ -6608,18 +6637,18 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6608
6637
|
return t;
|
|
6609
6638
|
}
|
|
6610
6639
|
return typeof URLSearchParams < "u" && e instanceof URLSearchParams ? new URLSearchParams(e) : e instanceof ArrayBuffer ? e.slice(0) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength).slice() : e;
|
|
6611
|
-
},
|
|
6612
|
-
let r =
|
|
6640
|
+
}, Wo = (e, t, n) => new Request(e, { headers: Bo(t, n) }), Go = (e, t, n) => {
|
|
6641
|
+
let r = Po(e), i = Fo(e, t), a = Ho(e, t), o = (e, t) => ko({
|
|
6613
6642
|
url: r,
|
|
6614
6643
|
method: i,
|
|
6615
6644
|
headers: a,
|
|
6616
6645
|
bodyKind: e,
|
|
6617
6646
|
...t === void 0 ? {} : { body: t }
|
|
6618
6647
|
});
|
|
6619
|
-
if (
|
|
6648
|
+
if (No(e)) {
|
|
6620
6649
|
if (e.body === null || e.body === void 0) {
|
|
6621
6650
|
let a = o("none");
|
|
6622
|
-
return
|
|
6651
|
+
return Ro(n, {
|
|
6623
6652
|
url: r,
|
|
6624
6653
|
method: i,
|
|
6625
6654
|
bodyKind: "none"
|
|
@@ -6629,20 +6658,20 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6629
6658
|
forwardInput: e,
|
|
6630
6659
|
forwardInit: t,
|
|
6631
6660
|
snapshot: a,
|
|
6632
|
-
replay: (n, r) => n(
|
|
6633
|
-
} :
|
|
6661
|
+
replay: (n, r) => n(Wo(e, a, r), Vo(t))
|
|
6662
|
+
} : zo("none", "the replay policy refused this request", e, a, t);
|
|
6634
6663
|
}
|
|
6635
6664
|
let a = o("request-clone");
|
|
6636
|
-
if (!
|
|
6665
|
+
if (!Ro(n, {
|
|
6637
6666
|
url: r,
|
|
6638
6667
|
method: i,
|
|
6639
6668
|
bodyKind: "request-clone"
|
|
6640
|
-
})) return
|
|
6669
|
+
})) return zo("request-clone", "the replay policy refused this request", e, a, t);
|
|
6641
6670
|
let s;
|
|
6642
6671
|
try {
|
|
6643
6672
|
s = e.clone();
|
|
6644
6673
|
} catch {
|
|
6645
|
-
return
|
|
6674
|
+
return zo("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6646
6675
|
}
|
|
6647
6676
|
return {
|
|
6648
6677
|
replayable: !0,
|
|
@@ -6650,17 +6679,17 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6650
6679
|
forwardInput: e,
|
|
6651
6680
|
forwardInit: t,
|
|
6652
6681
|
snapshot: a,
|
|
6653
|
-
replay: (e, n) => e(
|
|
6682
|
+
replay: (e, n) => e(Wo(s, a, n), Vo(t))
|
|
6654
6683
|
};
|
|
6655
6684
|
}
|
|
6656
|
-
let s =
|
|
6657
|
-
if (s === "one-shot") return
|
|
6658
|
-
if (!
|
|
6685
|
+
let s = Io(t?.body);
|
|
6686
|
+
if (s === "one-shot") return zo("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6687
|
+
if (!Ro(n, {
|
|
6659
6688
|
url: r,
|
|
6660
6689
|
method: i,
|
|
6661
6690
|
bodyKind: s
|
|
6662
|
-
},
|
|
6663
|
-
let c = t && "body" in t ?
|
|
6691
|
+
}, Lo(t?.body))) return zo(s, "the replay policy refused this request", e, o(s), t);
|
|
6692
|
+
let c = t && "body" in t ? Uo(t.body ?? null) : void 0, l = o(s, c);
|
|
6664
6693
|
return {
|
|
6665
6694
|
replayable: !0,
|
|
6666
6695
|
bodyKind: s,
|
|
@@ -6668,21 +6697,21 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6668
6697
|
forwardInit: t,
|
|
6669
6698
|
snapshot: l,
|
|
6670
6699
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6671
|
-
...
|
|
6700
|
+
...Vo(t),
|
|
6672
6701
|
...c === void 0 ? {} : { body: c },
|
|
6673
|
-
headers:
|
|
6702
|
+
headers: Bo(l, n),
|
|
6674
6703
|
method: l.method
|
|
6675
6704
|
})
|
|
6676
6705
|
};
|
|
6677
|
-
},
|
|
6678
|
-
if (!
|
|
6706
|
+
}, Ko = (e) => typeof e == "object" && !!e, qo = (e) => (t) => {
|
|
6707
|
+
if (!Ko(e)) return;
|
|
6679
6708
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6680
6709
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6681
|
-
},
|
|
6710
|
+
}, Jo = (e) => {
|
|
6682
6711
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6683
6712
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6684
|
-
},
|
|
6685
|
-
let r = Ao(
|
|
6713
|
+
}, Yo = (e) => (e?.method ?? "GET").toUpperCase(), Xo = (e) => e == null ? "none" : Ko(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", Zo = (e, t, n) => {
|
|
6714
|
+
let r = jo(Ao(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6686
6715
|
return {
|
|
6687
6716
|
...e,
|
|
6688
6717
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6691,10 +6720,10 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6691
6720
|
headers: r,
|
|
6692
6721
|
..."body" in t ? { data: t.body } : {}
|
|
6693
6722
|
};
|
|
6694
|
-
},
|
|
6695
|
-
let o = t ?? e?.config, s =
|
|
6696
|
-
url:
|
|
6697
|
-
method:
|
|
6723
|
+
}, Qo = (e, t, n, r, i, a) => {
|
|
6724
|
+
let o = t ?? e?.config, s = Xo(o?.data), c = a ?? ko({
|
|
6725
|
+
url: Jo(o),
|
|
6726
|
+
method: Yo(o),
|
|
6698
6727
|
headers: o?.headers,
|
|
6699
6728
|
bodyKind: s,
|
|
6700
6729
|
body: o?.data
|
|
@@ -6702,59 +6731,59 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6702
6731
|
url: c.href,
|
|
6703
6732
|
method: c.method,
|
|
6704
6733
|
bodyKind: s
|
|
6705
|
-
}, u = s !== "one-shot" &&
|
|
6734
|
+
}, u = s !== "one-shot" && Ro(i.replay, l);
|
|
6706
6735
|
return {
|
|
6707
6736
|
status: e?.status ?? 0,
|
|
6708
|
-
getHeader:
|
|
6737
|
+
getHeader: qo(e?.headers),
|
|
6709
6738
|
readBody: async () => e?.data,
|
|
6710
6739
|
request: c,
|
|
6711
6740
|
replay: async (e) => {
|
|
6712
|
-
let t =
|
|
6741
|
+
let t = Ie(Zo(o ?? {}, c, e));
|
|
6713
6742
|
try {
|
|
6714
6743
|
let e = await r(t);
|
|
6715
|
-
return
|
|
6744
|
+
return Qo(e, e?.config ?? t, e, r, i, c);
|
|
6716
6745
|
} catch (e) {
|
|
6717
|
-
let n =
|
|
6746
|
+
let n = Ko(e) ? e : {};
|
|
6718
6747
|
if (!n.response || typeof n.response.status != "number" || wi(e)) throw e;
|
|
6719
6748
|
return {
|
|
6720
|
-
...
|
|
6749
|
+
...Qo(n.response, n.config ?? t, e, r, i, c),
|
|
6721
6750
|
rejected: !0
|
|
6722
6751
|
};
|
|
6723
6752
|
}
|
|
6724
6753
|
},
|
|
6725
6754
|
markers: {
|
|
6726
|
-
...
|
|
6727
|
-
...
|
|
6755
|
+
...Fe(o) ? { upgradeTransaction: !0 } : {},
|
|
6756
|
+
...Le(o) ? { replayed: !0 } : {}
|
|
6728
6757
|
},
|
|
6729
6758
|
raw: n,
|
|
6730
6759
|
replayable: u,
|
|
6731
6760
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6732
6761
|
signal: o?.signal
|
|
6733
6762
|
};
|
|
6734
|
-
},
|
|
6735
|
-
let r =
|
|
6763
|
+
}, $o = (e, t) => async (n) => {
|
|
6764
|
+
let r = Ba(e), i = Ko(n) ? n : {}, a = ao(await no(Qo(i.response, i.config, i.response, t, r), r), n);
|
|
6736
6765
|
if (a.settle === "reject") throw a.error;
|
|
6737
6766
|
return a.value;
|
|
6738
|
-
},
|
|
6739
|
-
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0,
|
|
6767
|
+
}, es = (e, t, n) => {
|
|
6768
|
+
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, $o(t, i)), o = !1;
|
|
6740
6769
|
return () => {
|
|
6741
6770
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6742
6771
|
};
|
|
6743
|
-
},
|
|
6772
|
+
}, ts = (t, n) => {
|
|
6744
6773
|
let r = e.create(t);
|
|
6745
6774
|
return n(r), r;
|
|
6746
|
-
},
|
|
6775
|
+
}, ns = () => {
|
|
6747
6776
|
let e = typeof location > "u" ? void 0 : location.origin;
|
|
6748
6777
|
return e && e !== "null" ? e : void 0;
|
|
6749
|
-
},
|
|
6778
|
+
}, rs = (e) => {
|
|
6750
6779
|
let t = new URL(e).origin;
|
|
6751
6780
|
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
6752
6781
|
return t;
|
|
6753
|
-
},
|
|
6754
|
-
let n = (t?.origins ?? []).map(
|
|
6782
|
+
}, is = (e, t) => {
|
|
6783
|
+
let n = (t?.origins ?? []).map(rs);
|
|
6755
6784
|
return (t, r) => {
|
|
6756
6785
|
if (r) return Promise.resolve(void 0);
|
|
6757
|
-
let i =
|
|
6786
|
+
let i = ns(), a;
|
|
6758
6787
|
try {
|
|
6759
6788
|
a = new URL(t, i).origin;
|
|
6760
6789
|
} catch {
|
|
@@ -6762,22 +6791,22 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6762
6791
|
}
|
|
6763
6792
|
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
6764
6793
|
};
|
|
6765
|
-
},
|
|
6766
|
-
let r =
|
|
6794
|
+
}, as = (e) => typeof Request < "u" && e instanceof Request, os = (e, t) => new Headers(t?.headers === void 0 ? as(e) ? e.headers : void 0 : t.headers), ss = (e, t, n) => {
|
|
6795
|
+
let r = is(t, n);
|
|
6767
6796
|
return async (t, n) => {
|
|
6768
|
-
let i =
|
|
6797
|
+
let i = as(t) ? t.url : t instanceof URL ? t.href : String(t), a = os(t, n), o = await r(i, a.has("authorization"));
|
|
6769
6798
|
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
6770
6799
|
...n,
|
|
6771
6800
|
headers: a
|
|
6772
6801
|
})) : e(t, n);
|
|
6773
6802
|
};
|
|
6774
|
-
},
|
|
6803
|
+
}, cs = (e) => {
|
|
6775
6804
|
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
6776
6805
|
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
6777
|
-
},
|
|
6778
|
-
let n =
|
|
6806
|
+
}, ls = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, us = (e, t) => {
|
|
6807
|
+
let n = is(e, t);
|
|
6779
6808
|
return async (e) => {
|
|
6780
|
-
let t = e.headers, r = await n(
|
|
6809
|
+
let t = e.headers, r = await n(cs(e), ls(t));
|
|
6781
6810
|
if (!r) return e;
|
|
6782
6811
|
let i = `Bearer ${r}`;
|
|
6783
6812
|
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
@@ -6785,7 +6814,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6785
6814
|
Authorization: i
|
|
6786
6815
|
}, e;
|
|
6787
6816
|
};
|
|
6788
|
-
},
|
|
6817
|
+
}, ds = 0, fs = (e, t) => {
|
|
6789
6818
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6790
6819
|
if (n) return {
|
|
6791
6820
|
get aborted() {
|
|
@@ -6799,34 +6828,34 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6799
6828
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6800
6829
|
} : {}
|
|
6801
6830
|
};
|
|
6802
|
-
},
|
|
6831
|
+
}, ps = (e) => (t) => e.headers?.get(t), ms = (e, t, n, r, i) => ({
|
|
6803
6832
|
status: e.status,
|
|
6804
|
-
getHeader:
|
|
6833
|
+
getHeader: ps(e),
|
|
6805
6834
|
readBody: () => e.clone().json(),
|
|
6806
6835
|
request: t.snapshot,
|
|
6807
|
-
replay: async (e) =>
|
|
6836
|
+
replay: async (e) => ms(await t.replay(n, e), t, n, r, i),
|
|
6808
6837
|
markers: r,
|
|
6809
6838
|
raw: e,
|
|
6810
6839
|
replayable: t.replayable,
|
|
6811
6840
|
replayUnsupportedReason: t.reason,
|
|
6812
6841
|
signal: i,
|
|
6813
6842
|
responseType: e.type
|
|
6814
|
-
}),
|
|
6843
|
+
}), hs = (e, t) => {
|
|
6815
6844
|
let n = (t, n) => {
|
|
6816
|
-
|
|
6845
|
+
ds += 1;
|
|
6817
6846
|
try {
|
|
6818
6847
|
return e(t, n);
|
|
6819
6848
|
} finally {
|
|
6820
|
-
--
|
|
6849
|
+
--ds;
|
|
6821
6850
|
}
|
|
6822
6851
|
};
|
|
6823
6852
|
return async (e, r) => {
|
|
6824
|
-
if (
|
|
6825
|
-
let i =
|
|
6853
|
+
if (ds > 0) return n(e, r);
|
|
6854
|
+
let i = Ba(t), a = Go(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = io(await no(ms(o, a, n, {}, fs(e, r)), i), o, i);
|
|
6826
6855
|
if (s.settle === "reject") throw s.error;
|
|
6827
6856
|
return s.value;
|
|
6828
6857
|
};
|
|
6829
|
-
},
|
|
6858
|
+
}, gs = new Set(va.filter((e) => !e.requiresPrepare).map((e) => e.type)), _s = (e) => {
|
|
6830
6859
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6831
6860
|
kind: "protocol",
|
|
6832
6861
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6838,16 +6867,16 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6838
6867
|
webauthn: e.webauthn,
|
|
6839
6868
|
codeSentTo: e.code_sent_to
|
|
6840
6869
|
};
|
|
6841
|
-
},
|
|
6870
|
+
}, vs = (e) => wi(e) && !Ti(e), ys = (e) => ({
|
|
6842
6871
|
async prepare(t) {
|
|
6843
|
-
if (!
|
|
6872
|
+
if (!gs.has(t)) try {
|
|
6844
6873
|
let n = e.relyingPartyId?.();
|
|
6845
|
-
return
|
|
6874
|
+
return _s(await e.startUpgrade(n ? {
|
|
6846
6875
|
method: t,
|
|
6847
6876
|
relying_party_id: n
|
|
6848
6877
|
} : { method: t }));
|
|
6849
6878
|
} catch (e) {
|
|
6850
|
-
if (
|
|
6879
|
+
if (vs(e)) throw e;
|
|
6851
6880
|
let t = ji(e, "start");
|
|
6852
6881
|
if (t.kind === "prepare_not_required") return;
|
|
6853
6882
|
throw t;
|
|
@@ -6865,17 +6894,17 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6865
6894
|
assertion: n
|
|
6866
6895
|
});
|
|
6867
6896
|
} catch (t) {
|
|
6868
|
-
if (
|
|
6897
|
+
if (vs(t)) throw t;
|
|
6869
6898
|
let n = ji(t, "refresh");
|
|
6870
6899
|
throw n.status === 401 && Ni(n) && e.markSessionInvalid?.(), n;
|
|
6871
6900
|
}
|
|
6872
6901
|
}
|
|
6873
|
-
}),
|
|
6902
|
+
}), bs = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), xs = (e) => {
|
|
6874
6903
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6875
6904
|
let i = () => {
|
|
6876
6905
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6877
6906
|
};
|
|
6878
|
-
return
|
|
6907
|
+
return ys({
|
|
6879
6908
|
...e,
|
|
6880
6909
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6881
6910
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6886,7 +6915,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6886
6915
|
});
|
|
6887
6916
|
}, i = (t, n) => {
|
|
6888
6917
|
let i = {}, a = {
|
|
6889
|
-
controller: new
|
|
6918
|
+
controller: new za({
|
|
6890
6919
|
transport: r(() => i.current),
|
|
6891
6920
|
prompt: t.prompt,
|
|
6892
6921
|
platform: e.platform,
|
|
@@ -6898,7 +6927,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6898
6927
|
options: t,
|
|
6899
6928
|
scope: {
|
|
6900
6929
|
passflow: e.passflowDomain,
|
|
6901
|
-
backend:
|
|
6930
|
+
backend: bs(t.backend)
|
|
6902
6931
|
},
|
|
6903
6932
|
generation: n
|
|
6904
6933
|
};
|
|
@@ -6908,14 +6937,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6908
6937
|
s = void 0;
|
|
6909
6938
|
});
|
|
6910
6939
|
let c = (e) => {
|
|
6911
|
-
if (!s ||
|
|
6940
|
+
if (!s || Ra(s.challenge, e)) return;
|
|
6912
6941
|
let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
|
|
6913
6942
|
if (!(Date.now() - s.at > t)) return s.challenge;
|
|
6914
6943
|
}, l = async (r, i) => {
|
|
6915
6944
|
let o = t;
|
|
6916
6945
|
if (!o) throw new Fi("Step-up verification is not enabled on this Passflow instance");
|
|
6917
6946
|
let l = e.stopRepeatedElevation ? c(r) : void 0;
|
|
6918
|
-
if (l) throw new Pi(
|
|
6947
|
+
if (l) throw new Pi(Fa(l), Fa(r), "This requirement was already proved and the server still refused it: sign the user in again");
|
|
6919
6948
|
o.controller.active || (o.pin = e.readSessionPin?.());
|
|
6920
6949
|
let u = await o.controller.elevate(r, i);
|
|
6921
6950
|
if (!n(o)) throw new Ii();
|
|
@@ -6941,7 +6970,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6941
6970
|
};
|
|
6942
6971
|
}, d;
|
|
6943
6972
|
return Object.defineProperties(async (e) => {
|
|
6944
|
-
let t = e?.acrValues === void 0 ? void 0 :
|
|
6973
|
+
let t = e?.acrValues === void 0 ? void 0 : ge(e.acrValues).level, n = {
|
|
6945
6974
|
status: 401,
|
|
6946
6975
|
...e?.acrValues === void 0 ? {} : { acrValues: e.acrValues },
|
|
6947
6976
|
...t === void 0 ? {} : { requiredLevel: t },
|
|
@@ -6965,9 +6994,9 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6965
6994
|
let r = [];
|
|
6966
6995
|
if (e.attachInternalSeam) {
|
|
6967
6996
|
let t = e.attachInternalSeam;
|
|
6968
|
-
t((e) =>
|
|
6997
|
+
t((e) => $o(u, e)), r.push(() => t(void 0));
|
|
6969
6998
|
}
|
|
6970
|
-
n.interceptFetch && r.push(nn((e, t, n) =>
|
|
6999
|
+
n.interceptFetch && r.push(nn((e, t, n) => hs(e, u)(t, n), {
|
|
6971
7000
|
priority: 20,
|
|
6972
7001
|
name: "passflow-upgrade"
|
|
6973
7002
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -6999,8 +7028,8 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
6999
7028
|
enumerable: !0,
|
|
7000
7029
|
value: (t, n) => {
|
|
7001
7030
|
let r = (t) => {
|
|
7002
|
-
let r =
|
|
7003
|
-
return e.readAccessToken ?
|
|
7031
|
+
let r = hs(t, u);
|
|
7032
|
+
return e.readAccessToken ? ss(r, e.readAccessToken, n) : r;
|
|
7004
7033
|
};
|
|
7005
7034
|
if (t) return r(t);
|
|
7006
7035
|
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
@@ -7011,14 +7040,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7011
7040
|
attachAuth: {
|
|
7012
7041
|
enumerable: !0,
|
|
7013
7042
|
value: (t, n) => {
|
|
7014
|
-
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(
|
|
7043
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(us(e.readAccessToken, n)), a = es(t, u);
|
|
7015
7044
|
return () => {
|
|
7016
7045
|
a(), r && i !== void 0 && r.eject(i);
|
|
7017
7046
|
};
|
|
7018
7047
|
}
|
|
7019
7048
|
}
|
|
7020
7049
|
});
|
|
7021
|
-
},
|
|
7050
|
+
}, Ss, Cs = class {
|
|
7022
7051
|
get origin() {
|
|
7023
7052
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
7024
7053
|
}
|
|
@@ -7027,13 +7056,13 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7027
7056
|
this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
|
|
7028
7057
|
};
|
|
7029
7058
|
let { url: t, appId: n, scopes: r } = e;
|
|
7030
|
-
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ??
|
|
7059
|
+
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? R, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new ue({
|
|
7031
7060
|
prefix: e.keyStoragePrefix ?? "",
|
|
7032
7061
|
storage: this.platform.storage,
|
|
7033
7062
|
appId: n
|
|
7034
|
-
}), this.deviceService = new
|
|
7063
|
+
}), this.deviceService = new de(this.storageManager), this.authApi = new jt(e, this.storageManager, this.deviceService), this.appApi = new wt(e, this.storageManager, this.deviceService), this.userApi = new Ht(e, this.storageManager, this.deviceService), this.settingApi = new Pt(e, this.storageManager, this.deviceService), this.tenantApi = new Ft(e, this.storageManager, this.deviceService), this.invitationApi = new Nt(e, this.storageManager, this.deviceService), this.twoFactorApi = new Bt(e, this.storageManager, this.deviceService), this.upgradeApi = new Vt(e, this.storageManager, this.deviceService), this.upgradeDomain = Be(e.url), this.subscribeStore = new Rn(), this.tokenCacheService = new ua(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? _, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
7035
7064
|
let i = Mr(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
7036
|
-
this.authService = new
|
|
7065
|
+
this.authService = new oa(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
7037
7066
|
createSession: async (e) => {
|
|
7038
7067
|
await this.createSessionCallback?.(e);
|
|
7039
7068
|
},
|
|
@@ -7053,7 +7082,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7053
7082
|
...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
|
|
7054
7083
|
}), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
7055
7084
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
7056
|
-
this.userService = new
|
|
7085
|
+
this.userService = new fa(this.userApi, this.deviceService, this.platform), this.tenantService = new la(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new sa(this.invitationApi), this.twoFactorService = new da(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = xs({
|
|
7057
7086
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
7058
7087
|
commitRefresh: async (e, t) => {
|
|
7059
7088
|
await this.authService.refreshToken(e, t);
|
|
@@ -7082,7 +7111,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7082
7111
|
let e = (await this.getTokens(!0))?.access_token;
|
|
7083
7112
|
return e && !A(j(e)) ? e : void 0;
|
|
7084
7113
|
}
|
|
7085
|
-
}), this.hostedUpgrade =
|
|
7114
|
+
}), this.hostedUpgrade = xs({
|
|
7086
7115
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
7087
7116
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
7088
7117
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -7119,14 +7148,14 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7119
7148
|
return this.upgrade.attachAuth(e, t);
|
|
7120
7149
|
}
|
|
7121
7150
|
createClient(e, t) {
|
|
7122
|
-
return
|
|
7151
|
+
return ts(e, (e) => this.upgrade.attachAuth(e, t));
|
|
7123
7152
|
}
|
|
7124
7153
|
readAssuranceBar() {
|
|
7125
7154
|
let e = this.storageManager.getToken(M.access_token);
|
|
7126
7155
|
if (e) try {
|
|
7127
7156
|
let t = j(e), n = typeof t.acr == "string" ? t.acr : void 0;
|
|
7128
7157
|
if (!n) return;
|
|
7129
|
-
let r =
|
|
7158
|
+
let r = ge(n).level;
|
|
7130
7159
|
return r === void 0 ? { acrValues: n } : {
|
|
7131
7160
|
acrValues: n,
|
|
7132
7161
|
level: r
|
|
@@ -7168,7 +7197,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7168
7197
|
} catch (t) {
|
|
7169
7198
|
let n = {
|
|
7170
7199
|
operation: "session.check",
|
|
7171
|
-
message: t instanceof Error || t instanceof
|
|
7200
|
+
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
7172
7201
|
originalError: t
|
|
7173
7202
|
};
|
|
7174
7203
|
W(this.subscribeStore, n), e = void 0;
|
|
@@ -7236,7 +7265,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7236
7265
|
if (e?.pkce_enabled !== !1) throw wn();
|
|
7237
7266
|
return _i(this.url, this.appId, t);
|
|
7238
7267
|
}).then(() => {
|
|
7239
|
-
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
7268
|
+
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t, void 0, { replace: !0 }), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
7240
7269
|
}).then(() => (this.subscribeStore.notify(G.SignIn, {
|
|
7241
7270
|
tokens: t,
|
|
7242
7271
|
parsedTokens: this.getParsedTokens(),
|
|
@@ -7395,7 +7424,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7395
7424
|
operation: t,
|
|
7396
7425
|
message: e instanceof Error ? e.message : `${n} failed`,
|
|
7397
7426
|
originalError: e,
|
|
7398
|
-
code: e instanceof
|
|
7427
|
+
code: e instanceof B ? e.id : void 0
|
|
7399
7428
|
};
|
|
7400
7429
|
throw W(this.subscribeStore, r), e;
|
|
7401
7430
|
}
|
|
@@ -7482,7 +7511,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7482
7511
|
}
|
|
7483
7512
|
setTokens(e) {
|
|
7484
7513
|
let t = this.getDeliveryMode(), n = t === N.Cookie || t === N.BFF;
|
|
7485
|
-
this.storageManager.saveTokens(e, n ? t : void 0), this.tokenCacheService.setTokensCache(e), this.authService.refresh.sessionStarted(), this.subscribeStore.notify(G.SignIn, {
|
|
7514
|
+
this.storageManager.saveTokens(e, n ? t : void 0, { replace: !0 }), this.tokenCacheService.setTokensCache(e), this.authService.refresh.sessionStarted(), this.subscribeStore.notify(G.SignIn, {
|
|
7486
7515
|
tokens: e,
|
|
7487
7516
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
7488
7517
|
});
|
|
@@ -7732,7 +7761,7 @@ var Ki = (e) => e ? [e] : [], qi = "passflow_2fa_pkce", Ji = 3e5, Yi = "passflow
|
|
|
7732
7761
|
this.twoFactorService.clearMagicLinkSession();
|
|
7733
7762
|
}
|
|
7734
7763
|
};
|
|
7735
|
-
|
|
7736
|
-
export { p as AGENT_TOOL_HEADER_KEY, m as ANTI_BOT_ACTION,
|
|
7764
|
+
Ss = Cs, Ss.version = h;
|
|
7765
|
+
export { p as AGENT_TOOL_HEADER_KEY, m as ANTI_BOT_ACTION, Ke as ANTI_BOT_FAILED_ERROR_ID, f as ANTI_BOT_HEADER_KEY, Ye as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Je as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, Ge as ANTI_BOT_REQUIRED_ERROR_ID, Xe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, qe as ANTI_BOT_UNAVAILABLE_ERROR_ID, c as APP_ID_HEADER_KEY, $e as APP_SECRET_NAMES, l as AUTHORIZATION_HEADER_KEY, wt as AppAPI, jt as AuthAPI, oa as AuthService, Mt as CLIAuthAPI, y as DEFAULT_GROUP_NAME, _ as DEFAULT_SCOPES, va as DEFAULT_UPGRADE_FACTORS, u as DEVICE_ID_HEADER_KEY, d as DEVICE_TYPE_HEADER_KEY, E as ERROR_MESSAGE_MAX_LENGTH, Ut as FETCH_PRIORITY_OIDC, Wt as FETCH_PRIORITY_UPGRADE, Gt as FetchMiddlewareContractError, ve as INSUFFICIENT_USER_AUTHENTICATION, Nt as InvitationAPI, sa as InvitationService, fn as M2MClient, sn as M2MConfigError, H as M2MError, cn as M2MErrorCodes, an as M2MNetworkError, on as M2MTokenParseError, ln as M2M_DEFAULTS, et as MASKED_SECRET_PREFIX, g as MINIMAL_DEFAULT_SCOPES, rt as OS, v as PASSFLOW_CLOUD_URL, We as PASSWORD_CHANGE_REQUIRED_ERROR_ID, x as POPUP_HEIGHT, ee as POPUP_POLL_INTERVAL_MS, S as POPUP_TIMEOUT_MS, b as POPUP_WIDTH, Cs as Passflow, ze as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, G as PassflowEvent, U as PassflowOidcError, Ze as PassflowPasswordChangeRequiredError, Y as PassflowRefreshError, fe as PopupClosedError, Qe as Providers, vi as RECOVERABLE_COMMIT_ERROR_IDS, Fr as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Re as RequestMethod, h as SDK_VERSION, He as SERVICE_UNAVAILABLE_ERROR_ID, Ue as SERVICE_UNAVAILABLE_MESSAGE, yi as SESSION_INVALIDATING_COMMIT_ERROR_IDS, tt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, se as SessionState, Pt as SettingAPI, C as TOKEN_EXPIRY_BUFFER_SECONDS, Ft as TenantAPI, la as TenantService, ca as TenantUserMembership, ua as TokenCacheService, N as TokenDeliveryMode, M as TokenType, Bt as TwoFactorApiClient, ot as TwoFactorPolicy, da as TwoFactorService, ye as UPGRADE_REQUIRED, T as USERNAME_MAX_LENGTH, w as USERNAME_MIN_LENGTH, Vt as UpgradeAPI, Ta as UpgradeCancelledError, qr as UpgradeCommitInterruptedError, za as UpgradeController, Q as UpgradeErrorIds, pa as UpgradeFactorError, Pi as UpgradeInsufficientError, Ii as UpgradeSessionChangedError, Ea as UpgradeSignInRequiredError, $ as UpgradeTransportError, Fi as UpgradeUnavailableError, ja as UpgradeUnsatisfiableError, Ht as UserAPI, fa as UserService, L as WebAdapter, ji as classifyUpgradeError, ya as factorRegistry, rn as fetchRegistryState, it as getOSFromDeviceType, Ni as invalidatesSessionOnCommit, Ve as isEmailVerificationStep, nt as isMaskedSecret, Mi as isRecoverableCommitFailure, xi as isRetryableUpgradeKind, A as isTokenExpired, go as isUpgradeCancelled, _o as isUpgradeExhausted, vo as isUpgradeInsufficient, So as isUpgradeSessionChanged, bo as isUpgradeSignInRequired, Ti as isUpgradeTransportError, Co as isUpgradeTransportFailure, xo as isUpgradeUnavailable, yo as isUpgradeUnsatisfiable, Vi as isValidEmail, zi as isValidJWTFormat, Hi as isValidPhoneNumber, Ui as isValidUsername, Ee as parseChallengeBody, Te as parseChallengeHeader, j as parseToken, Ae as parseUpgradeChallenge, _a as passkeyFactor, at as pathWithParams, ga as recoveryCodesFactor, nn as registerFetchMiddleware, _e as requiredAcrLevel, Be as resolveUpgradeDomain, Bi as sanitizeErrorMessage, wa as selectFactors, ha as totpFactor, R as webAdapter };
|
|
7737
7766
|
|
|
7738
7767
|
//# sourceMappingURL=index.mjs.map
|