@passflow/core 0.32.0 → 0.32.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +931 -930
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e, { AxiosError as t } from "axios";
|
|
2
2
|
import { startAuthentication as n, startRegistration as r } from "@simplewebauthn/browser";
|
|
3
3
|
// package.json
|
|
4
|
-
var i = "0.32.
|
|
4
|
+
var i = "0.32.1", a = "X-Passflow-Clientid", o = "Authorization", s = "X-Passflow-DeviceId", c = "X-Passflow-DeviceType", l = i, u = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -182,9 +182,9 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
182
182
|
this.storageManager.storage.removeItem(this.SESSION_STATE_KEY);
|
|
183
183
|
} catch {}
|
|
184
184
|
}
|
|
185
|
-
}, ne = class {
|
|
185
|
+
}, ne = "tokens_scopes", re = "passflowDeviceId", ie = "passflowInvitationToken", F = "passflowPreviousRedirectUrl", ae = class {
|
|
186
186
|
constructor({ storage: e, prefix: t, appId: n } = {}) {
|
|
187
|
-
this.keyStoragePrefix = "", this.
|
|
187
|
+
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}${ne}`, this.deviceId = `${this.keyStoragePrefix}${re}`, this.invitationToken = `${this.keyStoragePrefix}${ie}`, this.previousRedirectUrl = `${this.keyStoragePrefix}${F}`, this.appId = n || void 0;
|
|
188
188
|
}
|
|
189
189
|
setAppId(e) {
|
|
190
190
|
this.appId = e || void 0;
|
|
@@ -200,6 +200,15 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
200
200
|
}
|
|
201
201
|
return t === void 0 || (Array.isArray(t) ? t : [t]).includes(this.appId) ? e : void 0;
|
|
202
202
|
}
|
|
203
|
+
readPrefixed(e, t) {
|
|
204
|
+
let n = this.storage.getItem(e);
|
|
205
|
+
if (n !== null || e === t) return n ?? void 0;
|
|
206
|
+
let r = this.storage.getItem(t);
|
|
207
|
+
if (r) return this.storage.setItem(e, r), this.storage.removeItem(t), r;
|
|
208
|
+
}
|
|
209
|
+
removePrefixed(e, t) {
|
|
210
|
+
this.storage.removeItem(e), e !== t && this.storage.removeItem(t);
|
|
211
|
+
}
|
|
203
212
|
readToken(e) {
|
|
204
213
|
return this.ownToken(this.storage.getItem(e));
|
|
205
214
|
}
|
|
@@ -242,11 +251,11 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
242
251
|
access_token: t,
|
|
243
252
|
id_token: this.readToken(this.getKeyForTokenType(M.id_token)),
|
|
244
253
|
refresh_token: this.readToken(this.getKeyForTokenType(M.refresh_token)),
|
|
245
|
-
scopes: this.
|
|
254
|
+
scopes: this.getScopes()
|
|
246
255
|
};
|
|
247
256
|
}
|
|
248
257
|
getScopes() {
|
|
249
|
-
return this.
|
|
258
|
+
return this.readPrefixed(this.scopes, ne)?.split(",");
|
|
250
259
|
}
|
|
251
260
|
hasJsonModeTokens() {
|
|
252
261
|
return !!this.readToken(this.getKeyForTokenType(M.access_token));
|
|
@@ -261,7 +270,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
261
270
|
deleteTokens() {
|
|
262
271
|
let e = this.holdsOnlyOtherAppSession();
|
|
263
272
|
for (let e of this.tokenValueKeys()) this.removeOwnToken(e);
|
|
264
|
-
e || (this.
|
|
273
|
+
e || (this.removePrefixed(this.scopes, ne), this.clearDeliveryMode(), this.removeCsrfToken()), this.appId && this.getHostedSignIn() === void 0 && this.storage.getItem(this.hostedSignInKey()) || this.storage.removeItem(this.hostedSignInKey());
|
|
265
274
|
}
|
|
266
275
|
setHostedSignIn(e) {
|
|
267
276
|
this.storage.setItem(this.hostedSignInKey(), JSON.stringify({
|
|
@@ -281,31 +290,31 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
281
290
|
return `${this.keyStoragePrefix}${this.STORAGE_PREFIX}hosted_sign_in`;
|
|
282
291
|
}
|
|
283
292
|
getDeviceId() {
|
|
284
|
-
return this.
|
|
293
|
+
return this.readPrefixed(this.deviceId, re);
|
|
285
294
|
}
|
|
286
295
|
setDeviceId(e) {
|
|
287
296
|
this.storage.setItem(this.deviceId, e);
|
|
288
297
|
}
|
|
289
298
|
deleteDeviceId() {
|
|
290
|
-
this.
|
|
299
|
+
this.removePrefixed(this.deviceId, re);
|
|
291
300
|
}
|
|
292
301
|
setInvitationToken(e) {
|
|
293
302
|
this.storage.setItem(this.invitationToken, e);
|
|
294
303
|
}
|
|
295
304
|
getInvitationToken() {
|
|
296
|
-
return this.
|
|
305
|
+
return this.readPrefixed(this.invitationToken, ie);
|
|
297
306
|
}
|
|
298
307
|
deleteInvitationToken() {
|
|
299
|
-
this.
|
|
308
|
+
this.removePrefixed(this.invitationToken, ie);
|
|
300
309
|
}
|
|
301
310
|
setPreviousRedirectUrl(e) {
|
|
302
311
|
this.storage.setItem(this.previousRedirectUrl, e);
|
|
303
312
|
}
|
|
304
313
|
getPreviousRedirectUrl() {
|
|
305
|
-
return this.
|
|
314
|
+
return this.readPrefixed(this.previousRedirectUrl, F);
|
|
306
315
|
}
|
|
307
316
|
deletePreviousRedirectUrl() {
|
|
308
|
-
this.
|
|
317
|
+
this.removePrefixed(this.previousRedirectUrl, F);
|
|
309
318
|
}
|
|
310
319
|
setDeliveryMode(e) {
|
|
311
320
|
try {
|
|
@@ -374,26 +383,21 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
374
383
|
getKeyForTokenType(e) {
|
|
375
384
|
return `${this.keyStoragePrefix}${e}`;
|
|
376
385
|
}
|
|
377
|
-
},
|
|
386
|
+
}, oe = class {
|
|
378
387
|
constructor(e) {
|
|
379
|
-
this.storageManager = e ?? new
|
|
388
|
+
this.storageManager = e ?? new ae();
|
|
380
389
|
}
|
|
381
390
|
getDeviceId() {
|
|
382
|
-
|
|
383
|
-
if (!e) {
|
|
384
|
-
let e = this.generateUniqueDeviceId();
|
|
385
|
-
return this.storageManager.setDeviceId(e), e;
|
|
386
|
-
}
|
|
387
|
-
return e;
|
|
391
|
+
return this.storageManager.getDeviceId() || (this.mintedDeviceId ?? (this.mintedDeviceId = this.generateUniqueDeviceId()), this.storageManager.setDeviceId(this.mintedDeviceId), this.mintedDeviceId);
|
|
388
392
|
}
|
|
389
393
|
generateUniqueDeviceId() {
|
|
390
394
|
return E();
|
|
391
395
|
}
|
|
392
|
-
},
|
|
396
|
+
}, I = class extends Error {
|
|
393
397
|
constructor(e = "Authentication popup was closed") {
|
|
394
398
|
super(e), this.name = "PopupClosedError";
|
|
395
399
|
}
|
|
396
|
-
},
|
|
400
|
+
}, L = class {
|
|
397
401
|
constructor() {
|
|
398
402
|
this.passkeys = {
|
|
399
403
|
startRegistration: (e) => r({ optionsJSON: e }),
|
|
@@ -457,7 +461,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
457
461
|
let r = t.width ?? 500, i = t.height ?? 600, a = t.expectedReturnOrigin ?? window.location.origin, o = window.open(e, "_blank", `width=${r},height=${i}`);
|
|
458
462
|
return o ? new Promise((e, t) => {
|
|
459
463
|
let n = Date.now(), r = setInterval(() => {
|
|
460
|
-
if (o.closed) clearInterval(r), t(new
|
|
464
|
+
if (o.closed) clearInterval(r), t(new I());
|
|
461
465
|
else if (Date.now() - n > 6e4) clearInterval(r), o.close(), t(/* @__PURE__ */ Error("Authentication popup timed out"));
|
|
462
466
|
else try {
|
|
463
467
|
if (o.location.href.startsWith(a)) {
|
|
@@ -492,16 +496,16 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
492
496
|
getDeviceType() {
|
|
493
497
|
return "web";
|
|
494
498
|
}
|
|
495
|
-
},
|
|
499
|
+
}, R = new L(), se = /^[0-9]+$/, ce = Object.freeze({
|
|
496
500
|
unorderable: !1,
|
|
497
501
|
zero: !1
|
|
498
|
-
}),
|
|
499
|
-
if (!e) return
|
|
502
|
+
}), le = (e) => se.test(e) ? Number.parseInt(e, 10) : void 0, ue = (e) => {
|
|
503
|
+
if (!e) return ce;
|
|
500
504
|
let t = e.split(/\s+/).filter((e) => e !== "");
|
|
501
|
-
if (t.length === 0) return
|
|
505
|
+
if (t.length === 0) return ce;
|
|
502
506
|
let n = [];
|
|
503
507
|
for (let e of t) {
|
|
504
|
-
let t =
|
|
508
|
+
let t = le(e);
|
|
505
509
|
t !== void 0 && n.push(t);
|
|
506
510
|
}
|
|
507
511
|
if (n.length === 0) return {
|
|
@@ -520,17 +524,17 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
520
524
|
unorderable: !1,
|
|
521
525
|
zero: !1
|
|
522
526
|
};
|
|
523
|
-
},
|
|
527
|
+
}, z = (e) => ue(e).level, de = "insufficient_user_authentication", fe = "upgrade_required", pe = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, me = (e) => e.replace(/\\(.)/g, "$1"), he = (e) => {
|
|
524
528
|
let t = {};
|
|
525
|
-
|
|
526
|
-
for (let n of e.matchAll(
|
|
529
|
+
pe.lastIndex = 0;
|
|
530
|
+
for (let n of e.matchAll(pe)) {
|
|
527
531
|
let e = n[1];
|
|
528
532
|
if (!e) continue;
|
|
529
533
|
let r = n[2], i = n[3];
|
|
530
|
-
t[e.toLowerCase()] = r === void 0 ? i ?? "" :
|
|
534
|
+
t[e.toLowerCase()] = r === void 0 ? i ?? "" : me(r);
|
|
531
535
|
}
|
|
532
536
|
return t;
|
|
533
|
-
},
|
|
537
|
+
}, ge = (e) => {
|
|
534
538
|
if (e == null || e === "") return { kind: "absent" };
|
|
535
539
|
let t = typeof e == "number" ? e : Number.parseInt(String(e), 10);
|
|
536
540
|
return Number.isFinite(t) && t > 0 ? {
|
|
@@ -540,38 +544,38 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
540
544
|
kind: "invalid",
|
|
541
545
|
raw: e
|
|
542
546
|
};
|
|
543
|
-
},
|
|
544
|
-
let t =
|
|
547
|
+
}, _e = (e) => {
|
|
548
|
+
let t = ge(e);
|
|
545
549
|
return t.kind === "valid" ? t.value : void 0;
|
|
546
|
-
},
|
|
550
|
+
}, ve = (e, t) => {
|
|
547
551
|
if (!e || !/(^|[\s,])Bearer\b/i.test(e)) return;
|
|
548
|
-
let n =
|
|
552
|
+
let n = he(e);
|
|
549
553
|
if (n.error === "insufficient_user_authentication") return {
|
|
550
554
|
acrValues: n.acr_values || void 0,
|
|
551
|
-
maxAge:
|
|
555
|
+
maxAge: _e(n.max_age),
|
|
552
556
|
status: t
|
|
553
557
|
};
|
|
554
|
-
},
|
|
558
|
+
}, ye = (e, t) => {
|
|
555
559
|
if (!e || typeof e != "object") return;
|
|
556
560
|
let n = e;
|
|
557
561
|
if (n.error !== "upgrade_required") return;
|
|
558
562
|
let r = Array.isArray(n.available_factors) ? n.available_factors.filter((e) => typeof e == "string") : void 0;
|
|
559
563
|
return {
|
|
560
564
|
acrValues: typeof n.acr_values == "string" && n.acr_values ? n.acr_values : void 0,
|
|
561
|
-
maxAge:
|
|
565
|
+
maxAge: _e(n.max_age),
|
|
562
566
|
status: t,
|
|
563
567
|
...r ? { availableFactors: r } : {},
|
|
564
568
|
...typeof n.sign_in_required == "boolean" ? { signInRequired: n.sign_in_required } : {}
|
|
565
569
|
};
|
|
566
|
-
},
|
|
570
|
+
}, be = (e, t, n) => ({
|
|
567
571
|
channel: e,
|
|
568
|
-
acr:
|
|
569
|
-
maxAge:
|
|
572
|
+
acr: ue(t.acrValues),
|
|
573
|
+
maxAge: ge(n),
|
|
570
574
|
raw: t.acrValues
|
|
571
|
-
}),
|
|
575
|
+
}), xe = (e) => e ? he(e) : {}, Se = (e, t) => {
|
|
572
576
|
let { status: n } = e;
|
|
573
577
|
if (n !== 401 && n !== 403) return { diagnostics: [] };
|
|
574
|
-
let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a =
|
|
578
|
+
let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a = ve(i, n), o = r ? void 0 : ye(e.body, n), s = [], c = (e, t) => {
|
|
575
579
|
s.push({
|
|
576
580
|
status: n,
|
|
577
581
|
url: "",
|
|
@@ -581,9 +585,9 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
581
585
|
};
|
|
582
586
|
if (!a && !o) return r && c("header-required-but-absent", i ? { header: i } : void 0), { diagnostics: s };
|
|
583
587
|
let l = [];
|
|
584
|
-
if (a && l.push(
|
|
588
|
+
if (a && l.push(be("header", a, xe(i).max_age)), o) {
|
|
585
589
|
let t = e.body;
|
|
586
|
-
l.push(
|
|
590
|
+
l.push(be("body", o, t?.max_age));
|
|
587
591
|
}
|
|
588
592
|
let u = (e) => e;
|
|
589
593
|
for (let e of l) e.acr.unorderable && c("channels-unorderable", { [u(e.channel)]: e.raw }), e.acr.zero && c("zero-constraint-ignored", {
|
|
@@ -619,23 +623,23 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
619
623
|
},
|
|
620
624
|
diagnostics: s
|
|
621
625
|
};
|
|
622
|
-
},
|
|
626
|
+
}, Ce = (e, t, n) => Se({
|
|
623
627
|
status: e,
|
|
624
628
|
getHeader: t,
|
|
625
629
|
body: n
|
|
626
|
-
}).challenge,
|
|
630
|
+
}).challenge, we = "__passflowUpgradeTransaction", Te = "__passflowUpgradeReplayed", Ee = (e, t) => typeof e == "object" && !!e && e[t] === !0, De = (e) => ({
|
|
627
631
|
...e ?? {},
|
|
628
|
-
[
|
|
629
|
-
}),
|
|
632
|
+
[we]: !0
|
|
633
|
+
}), Oe = (e) => Ee(e, we), ke = (e) => ({
|
|
630
634
|
...e,
|
|
631
|
-
[
|
|
632
|
-
}),
|
|
635
|
+
[Te]: !0
|
|
636
|
+
}), Ae = (e) => Ee(e, Te), je = /* @__PURE__ */ function(e) {
|
|
633
637
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
634
|
-
}({}), z = /* @__PURE__ */ function(e) {
|
|
635
|
-
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.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;
|
|
636
638
|
}({}), B = /* @__PURE__ */ function(e) {
|
|
639
|
+
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.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;
|
|
640
|
+
}({}), Me = /* @__PURE__ */ function(e) {
|
|
637
641
|
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;
|
|
638
|
-
}({}),
|
|
642
|
+
}({}), Ne = (e) => {
|
|
639
643
|
if (!e) return null;
|
|
640
644
|
try {
|
|
641
645
|
let t = new URL(e), n = t.pathname.replace(/\/+$/, "");
|
|
@@ -646,54 +650,54 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
646
650
|
} catch {
|
|
647
651
|
return null;
|
|
648
652
|
}
|
|
649
|
-
},
|
|
653
|
+
}, Pe = (e) => typeof e == "object" && !!e && e.email_verification_required === !0, Fe = "error.service.unavailable", Ie = "Passflow is temporarily unavailable. Please try again in a moment.", V = class extends Error {
|
|
650
654
|
constructor(e, t) {
|
|
651
655
|
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);
|
|
652
656
|
}
|
|
653
|
-
},
|
|
657
|
+
}, Le = "error.api.password.change.required", Re = class extends V {
|
|
654
658
|
constructor(e, t) {
|
|
655
659
|
super(e, t), this.name = "PassflowPasswordChangeRequiredError";
|
|
656
660
|
}
|
|
657
|
-
},
|
|
661
|
+
}, ze = /* @__PURE__ */ function(e) {
|
|
658
662
|
return e.google = "google", e.facebook = "facebook", e;
|
|
659
|
-
}({}),
|
|
663
|
+
}({}), Be = Object.freeze([
|
|
660
664
|
"debug_otp_code_for_registration",
|
|
661
665
|
"fcm_server_key",
|
|
662
666
|
"webpush_vapid_private_key"
|
|
663
|
-
]),
|
|
667
|
+
]), Ve = "mask://", He = "error.server.update.settings.masked.value.unknown", Ue = (e) => typeof e == "string" && e.startsWith("mask://"), We = /* @__PURE__ */ function(e) {
|
|
664
668
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
665
669
|
}({});
|
|
666
|
-
function
|
|
670
|
+
function Ge(e) {
|
|
667
671
|
return e;
|
|
668
672
|
}
|
|
669
|
-
function
|
|
673
|
+
function Ke(e, t) {
|
|
670
674
|
let n = e;
|
|
671
675
|
return Object.entries(t).forEach(([e, t]) => {
|
|
672
676
|
n = n.replace(`:${e}`, t);
|
|
673
677
|
}), n;
|
|
674
678
|
}
|
|
675
|
-
var
|
|
679
|
+
var qe = /* @__PURE__ */ function(e) {
|
|
676
680
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
677
|
-
}({}),
|
|
681
|
+
}({}), Je = 3, Ye = 1e3, Xe = (e) => (t) => {
|
|
678
682
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
679
683
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
680
|
-
},
|
|
684
|
+
}, Ze = (e) => Ce(e.status, Xe(e), e.data), Qe = (e) => Ze(e) !== void 0, $e = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), et = [
|
|
681
685
|
502,
|
|
682
686
|
503,
|
|
683
687
|
504
|
|
684
|
-
],
|
|
688
|
+
], tt = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, nt = (e, n) => {
|
|
685
689
|
let r = new t(e.message, e.code);
|
|
686
690
|
return e.cause instanceof TypeError && (r.cause = e.cause), new V({
|
|
687
|
-
id:
|
|
688
|
-
message:
|
|
691
|
+
id: Fe,
|
|
692
|
+
message: Ie,
|
|
689
693
|
status: n,
|
|
690
694
|
location: e.config?.url ?? "unknown",
|
|
691
695
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
692
696
|
}, { cause: r });
|
|
693
|
-
},
|
|
697
|
+
}, rt = (e) => e?.includes(B.refresh) ?? !1, it = (e) => e?.includes("/auth/session/") ?? !1, at = (e) => e?.includes("logout") ?? !1, ot = "__passflowOwnBearer", st = (e) => typeof e == "object" && !!e && e[ot] === !0, ct = (e) => e ? {
|
|
694
698
|
headers: { [o]: `Bearer ${e}` },
|
|
695
|
-
[
|
|
696
|
-
} : {},
|
|
699
|
+
[ot]: !0
|
|
700
|
+
} : {}, lt = class {
|
|
697
701
|
get origin() {
|
|
698
702
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
699
703
|
}
|
|
@@ -711,33 +715,30 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
711
715
|
"upgrade"
|
|
712
716
|
];
|
|
713
717
|
let { url: i, appId: l, keyStoragePrefix: u } = t;
|
|
714
|
-
this._platform = t.platform ??
|
|
718
|
+
this._platform = t.platform ?? R, this.url = i || "https://auth.passflow.cloud", this.upgradeDomain = Ne(i), this.storageManager = n ?? new ae({
|
|
715
719
|
prefix: u ?? "",
|
|
716
720
|
appId: l
|
|
717
|
-
}), this.deviceService = r ?? new
|
|
721
|
+
}), this.deviceService = r ?? new oe(this.storageManager), this.tokenService = new k(this.storageManager), this.tokenDeliveryManager = new P(this.storageManager), l && (this.appId = l, this.defaultHeaders = {
|
|
718
722
|
...this.defaultHeaders,
|
|
719
723
|
[a]: l
|
|
720
|
-
})
|
|
721
|
-
let d = this.deviceService.getDeviceId();
|
|
722
|
-
this.defaultHeaders = {
|
|
724
|
+
}), this.defaultHeaders = {
|
|
723
725
|
...this.defaultHeaders,
|
|
724
|
-
[s]: d,
|
|
725
726
|
[c]: this._platform.getDeviceType()
|
|
726
727
|
}, this.detectCookieSupport(), this.instance = e.create({
|
|
727
728
|
baseURL: this.url,
|
|
728
729
|
headers: { ...this.defaultHeaders }
|
|
729
730
|
}), this.instance.interceptors.request.use(async (e) => {
|
|
730
|
-
if (this.isNonAuthEndpoint(e.url) ||
|
|
731
|
+
if (e.headers[s] = this.deviceService.getDeviceId(), this.isNonAuthEndpoint(e.url) || st(e) || it(e.url)) return e;
|
|
731
732
|
if (this.tokenDeliveryManager.isCookieMode()) {
|
|
732
733
|
e.withCredentials = !0;
|
|
733
734
|
let t = this.storageManager.getCsrfToken();
|
|
734
735
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
735
736
|
}
|
|
736
|
-
if (
|
|
737
|
+
if (rt(e.url)) return e;
|
|
737
738
|
let t = this.storageManager.getTokens();
|
|
738
739
|
if (!t?.access_token) return e;
|
|
739
740
|
let n = t.access_token;
|
|
740
|
-
if (this.refreshHandler && t.refresh_token && !
|
|
741
|
+
if (this.refreshHandler && t.refresh_token && !at(e.url)) {
|
|
741
742
|
let e = j(t.access_token);
|
|
742
743
|
if (A(e, 30)) {
|
|
743
744
|
let t = !A(e, 0);
|
|
@@ -753,8 +754,8 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
753
754
|
}
|
|
754
755
|
return e.headers[o] = `Bearer ${n}`, e;
|
|
755
756
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
756
|
-
if (e.response?.status !== 401 ||
|
|
757
|
-
let t =
|
|
757
|
+
if (e.response?.status !== 401 || rt(e.config?.url) || it(e.config?.url) || st(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler && !it(e.config?.url)) {
|
|
758
|
+
let t = Ze(e.response);
|
|
758
759
|
if (t) try {
|
|
759
760
|
return await this.upgradeHandler(e, t);
|
|
760
761
|
} catch (t) {
|
|
@@ -765,7 +766,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
765
766
|
});
|
|
766
767
|
}
|
|
767
768
|
isUpgradeTransactionError(e) {
|
|
768
|
-
return
|
|
769
|
+
return Oe(e.config) || e.response !== void 0 && Qe(e.response);
|
|
769
770
|
}
|
|
770
771
|
setUpgradeInterceptor(e) {
|
|
771
772
|
this.upgradeHandler = e;
|
|
@@ -787,7 +788,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
787
788
|
}
|
|
788
789
|
async handleRateLimitError(e) {
|
|
789
790
|
let t = e.config;
|
|
790
|
-
if (!t ||
|
|
791
|
+
if (!t || rt(t.url)) return Promise.reject(e);
|
|
791
792
|
let n = t.method?.toUpperCase();
|
|
792
793
|
if (![
|
|
793
794
|
"GET",
|
|
@@ -795,8 +796,8 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
795
796
|
"OPTIONS"
|
|
796
797
|
].includes(n || "")) return Promise.reject(e);
|
|
797
798
|
let r = t._retryCount || 0;
|
|
798
|
-
if (r >=
|
|
799
|
-
let i =
|
|
799
|
+
if (r >= Je) return Promise.reject(e);
|
|
800
|
+
let i = Ye * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
800
801
|
if (a) {
|
|
801
802
|
let e = Number.parseInt(a, 10);
|
|
802
803
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -808,14 +809,14 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
808
809
|
return await new Promise((e) => setTimeout(e, i)), t._retryCount = r + 1, this.instance.request(t);
|
|
809
810
|
}
|
|
810
811
|
async handleAxiosError(e) {
|
|
811
|
-
if (
|
|
812
|
+
if ($e(e)) return Promise.reject(nt(e, 0));
|
|
812
813
|
if (!e.response) return Promise.reject(e);
|
|
813
814
|
let t = e.response.status;
|
|
814
|
-
if (
|
|
815
|
+
if (et.includes(t) && !tt(e.response.data)) return Promise.reject(nt(e, t));
|
|
815
816
|
let n = e.response.data;
|
|
816
817
|
if ("error" in n && typeof n.error == "object" && n.error !== null) {
|
|
817
818
|
let { error: e } = n;
|
|
818
|
-
return e.id === "error.api.password.change.required" ? Promise.reject(new
|
|
819
|
+
return e.id === "error.api.password.change.required" ? Promise.reject(new Re(e)) : Promise.reject(new V(e));
|
|
819
820
|
}
|
|
820
821
|
return Promise.reject(new V({
|
|
821
822
|
id: `error.http.${t}`,
|
|
@@ -833,28 +834,28 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
833
834
|
})).data;
|
|
834
835
|
}
|
|
835
836
|
get(e, t) {
|
|
836
|
-
return this.send(
|
|
837
|
+
return this.send(je.GET, e, t);
|
|
837
838
|
}
|
|
838
839
|
post(e, t, n) {
|
|
839
|
-
return this.send(
|
|
840
|
+
return this.send(je.POST, e, {
|
|
840
841
|
data: t,
|
|
841
842
|
...n
|
|
842
843
|
});
|
|
843
844
|
}
|
|
844
845
|
put(e, t, n) {
|
|
845
|
-
return this.send(
|
|
846
|
+
return this.send(je.PUT, e, {
|
|
846
847
|
data: t,
|
|
847
848
|
...n
|
|
848
849
|
});
|
|
849
850
|
}
|
|
850
851
|
patch(e, t, n) {
|
|
851
|
-
return this.send(
|
|
852
|
+
return this.send(je.PATCH, e, {
|
|
852
853
|
data: t,
|
|
853
854
|
...n
|
|
854
855
|
});
|
|
855
856
|
}
|
|
856
857
|
delete(e, t) {
|
|
857
|
-
return this.send(
|
|
858
|
+
return this.send(je.DELETE, e, t);
|
|
858
859
|
}
|
|
859
860
|
setAppId(e) {
|
|
860
861
|
this.appId = e, this.defaultHeaders = {
|
|
@@ -862,17 +863,17 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
862
863
|
[a]: e
|
|
863
864
|
}, this.instance.defaults.headers[a] = e;
|
|
864
865
|
}
|
|
865
|
-
},
|
|
866
|
+
}, ut = class {
|
|
866
867
|
constructor(e, t, n) {
|
|
867
|
-
this.axiosClient = new
|
|
868
|
+
this.axiosClient = new lt(e, t, n);
|
|
868
869
|
}
|
|
869
870
|
setAppId(e) {
|
|
870
871
|
this.axiosClient.setAppId(e);
|
|
871
872
|
}
|
|
872
873
|
getAppSettings() {
|
|
873
|
-
return this.axiosClient.get(
|
|
874
|
+
return this.axiosClient.get(B.appSettings);
|
|
874
875
|
}
|
|
875
|
-
},
|
|
876
|
+
}, dt = { withCredentials: !0 }, ft = 15e3, pt = "Sign-in failed. Start again.", mt = "Something went wrong. Try again later.", ht = (e, t, n, r) => {
|
|
876
877
|
if (e instanceof V) return e;
|
|
877
878
|
let i = e?.response?.data?.error;
|
|
878
879
|
return new V({
|
|
@@ -882,9 +883,9 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
882
883
|
location: t,
|
|
883
884
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
884
885
|
});
|
|
885
|
-
},
|
|
886
|
+
}, gt = class {
|
|
886
887
|
constructor(e, t, n) {
|
|
887
|
-
this.axiosClient = new
|
|
888
|
+
this.axiosClient = new lt(e, t, n);
|
|
888
889
|
}
|
|
889
890
|
setAppId(e) {
|
|
890
891
|
this.axiosClient.setAppId(e);
|
|
@@ -895,7 +896,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
895
896
|
scopes: t,
|
|
896
897
|
...r ? { upgrade: r } : {}
|
|
897
898
|
}, a = { headers: { [o]: `Bearer ${e}` } };
|
|
898
|
-
return this.axiosClient.post(
|
|
899
|
+
return this.axiosClient.post(B.refresh, i, r ? De(a) : a);
|
|
899
900
|
}
|
|
900
901
|
signIn(e, t, n) {
|
|
901
902
|
let r = {
|
|
@@ -903,7 +904,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
903
904
|
device: t,
|
|
904
905
|
os: n
|
|
905
906
|
};
|
|
906
|
-
return this.axiosClient.post(
|
|
907
|
+
return this.axiosClient.post(B.signin, r, dt);
|
|
907
908
|
}
|
|
908
909
|
signUp(e) {
|
|
909
910
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -911,16 +912,16 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
911
912
|
create_tenant: t ?? !1,
|
|
912
913
|
anonymous: n ?? !1
|
|
913
914
|
};
|
|
914
|
-
return this.axiosClient.post(
|
|
915
|
+
return this.axiosClient.post(B.signup, r, dt);
|
|
915
916
|
}
|
|
916
917
|
async pkceExchange(e, t) {
|
|
917
918
|
try {
|
|
918
|
-
return await this.axiosClient.post(
|
|
919
|
+
return await this.axiosClient.post(B.pkceExchange, {
|
|
919
920
|
authz_code: e,
|
|
920
921
|
verifier: t
|
|
921
|
-
},
|
|
922
|
+
}, dt);
|
|
922
923
|
} catch (e) {
|
|
923
|
-
throw
|
|
924
|
+
throw ht(e, B.pkceExchange, "error.pkce.exchange", pt);
|
|
924
925
|
}
|
|
925
926
|
}
|
|
926
927
|
async passwordlessSignIn(e, t, n) {
|
|
@@ -931,68 +932,68 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
931
932
|
os: n
|
|
932
933
|
};
|
|
933
934
|
try {
|
|
934
|
-
return await this.axiosClient.post(
|
|
935
|
+
return await this.axiosClient.post(B.passwordless, i);
|
|
935
936
|
} catch (e) {
|
|
936
|
-
throw
|
|
937
|
+
throw ht(e, B.passwordless, "error.passwordless.start", mt);
|
|
937
938
|
}
|
|
938
939
|
}
|
|
939
940
|
async passwordlessSignInComplete(e) {
|
|
940
941
|
try {
|
|
941
|
-
return await this.axiosClient.post(
|
|
942
|
+
return await this.axiosClient.post(B.passwordlessComplete, e, dt);
|
|
942
943
|
} catch (e) {
|
|
943
|
-
throw
|
|
944
|
+
throw ht(e, B.passwordlessComplete, "error.passwordless.complete", mt);
|
|
944
945
|
}
|
|
945
946
|
}
|
|
946
947
|
async passwordlessStatus(e, t) {
|
|
947
948
|
try {
|
|
948
|
-
return await this.axiosClient.post(
|
|
949
|
-
...
|
|
950
|
-
timeout:
|
|
949
|
+
return await this.axiosClient.post(B.passwordlessStatus, e, {
|
|
950
|
+
...dt,
|
|
951
|
+
timeout: ft,
|
|
951
952
|
signal: t?.signal
|
|
952
953
|
});
|
|
953
954
|
} catch (e) {
|
|
954
|
-
throw
|
|
955
|
+
throw ht(e, B.passwordlessStatus, "error.passwordless.status", pt);
|
|
955
956
|
}
|
|
956
957
|
}
|
|
957
958
|
async checkRedirectUrl(e) {
|
|
958
959
|
try {
|
|
959
|
-
return (await this.axiosClient.post(
|
|
960
|
+
return (await this.axiosClient.post(B.redirectCheck, { redirect_url: e })).redirect_url;
|
|
960
961
|
} catch (e) {
|
|
961
|
-
throw
|
|
962
|
+
throw ht(e, B.redirectCheck, "error.redirect.check", mt);
|
|
962
963
|
}
|
|
963
964
|
}
|
|
964
965
|
async passwordlessApprovalInfo(e) {
|
|
965
966
|
try {
|
|
966
|
-
return await this.axiosClient.post(
|
|
967
|
+
return await this.axiosClient.post(B.passwordlessApprovalInfo, e);
|
|
967
968
|
} catch (e) {
|
|
968
|
-
throw
|
|
969
|
+
throw ht(e, B.passwordlessApprovalInfo, "error.passwordless.approval", mt);
|
|
969
970
|
}
|
|
970
971
|
}
|
|
971
972
|
async passwordlessApprovalDecide(e) {
|
|
972
973
|
try {
|
|
973
|
-
return await this.axiosClient.post(
|
|
974
|
+
return await this.axiosClient.post(B.passwordlessApprovalDecide, e);
|
|
974
975
|
} catch (e) {
|
|
975
|
-
throw
|
|
976
|
+
throw ht(e, B.passwordlessApprovalDecide, "error.passwordless.approval", mt);
|
|
976
977
|
}
|
|
977
978
|
}
|
|
978
979
|
validateEmailCode(e) {
|
|
979
|
-
return this.axiosClient.post(
|
|
980
|
+
return this.axiosClient.post(B.passkeyValidate, {
|
|
980
981
|
challenge_id: e.challenge_id,
|
|
981
982
|
otp: e.otp
|
|
982
|
-
},
|
|
983
|
+
}, dt);
|
|
983
984
|
}
|
|
984
985
|
logOut(e, t, n = !1) {
|
|
985
986
|
let r = n ? void 0 : {
|
|
986
987
|
refresh_token: t,
|
|
987
988
|
device: e
|
|
988
|
-
}, i = n ?
|
|
989
|
+
}, i = n ? Me.logout : B.logout;
|
|
989
990
|
return this.axiosClient.post(i, r);
|
|
990
991
|
}
|
|
991
992
|
validateSession() {
|
|
992
|
-
return this.axiosClient.get(
|
|
993
|
+
return this.axiosClient.get(B.validateSession);
|
|
993
994
|
}
|
|
994
995
|
sendPasswordResetEmail(e) {
|
|
995
|
-
return this.axiosClient.post(
|
|
996
|
+
return this.axiosClient.post(B.sendPasswordResetEmail, e);
|
|
996
997
|
}
|
|
997
998
|
resetPassword(e, t, n, r) {
|
|
998
999
|
let i = {
|
|
@@ -1000,7 +1001,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1000
1001
|
scopes: t,
|
|
1001
1002
|
...r ? { code_challenge: r } : {}
|
|
1002
1003
|
};
|
|
1003
|
-
return this.axiosClient.post(
|
|
1004
|
+
return this.axiosClient.post(B.resetPassword, i, { headers: {
|
|
1004
1005
|
[o]: `Bearer ${n}`,
|
|
1005
1006
|
[a]: void 0
|
|
1006
1007
|
} });
|
|
@@ -1011,7 +1012,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1011
1012
|
create_tenant: i ?? !1,
|
|
1012
1013
|
device: t,
|
|
1013
1014
|
os: n
|
|
1014
|
-
}, o = r ?
|
|
1015
|
+
}, o = r ? Me.passkeyRegisterStart : B.passkeyRegisterStart;
|
|
1015
1016
|
return this.axiosClient.post(o, a);
|
|
1016
1017
|
}
|
|
1017
1018
|
passkeyRegisterComplete(e, t, n, r = !1) {
|
|
@@ -1019,8 +1020,8 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1019
1020
|
challenge_id: n,
|
|
1020
1021
|
device: t,
|
|
1021
1022
|
passkey_data: e
|
|
1022
|
-
}, a = r ?
|
|
1023
|
-
return this.axiosClient.post(a, i,
|
|
1023
|
+
}, a = r ? Me.passkeyRegisterComplete : B.passkeyRegisterComplete;
|
|
1024
|
+
return this.axiosClient.post(a, i, dt);
|
|
1024
1025
|
}
|
|
1025
1026
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
1026
1027
|
let i = {
|
|
@@ -1028,7 +1029,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1028
1029
|
user_id: e.user_id ?? "",
|
|
1029
1030
|
device: t,
|
|
1030
1031
|
os: n
|
|
1031
|
-
}, a = r ?
|
|
1032
|
+
}, a = r ? Me.passkeyAuthenticateStart : B.passkeyAuthenticateStart;
|
|
1032
1033
|
return this.axiosClient.post(a, i);
|
|
1033
1034
|
}
|
|
1034
1035
|
passkeyAuthenticateComplete(e, t, n, r = !1) {
|
|
@@ -1036,83 +1037,83 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1036
1037
|
challenge_id: n,
|
|
1037
1038
|
device: t,
|
|
1038
1039
|
passkey_data: e
|
|
1039
|
-
}, a = r ?
|
|
1040
|
-
return this.axiosClient.post(a, i,
|
|
1040
|
+
}, a = r ? Me.passkeyAuthenticateComplete : B.passkeyAuthenticateComplete;
|
|
1041
|
+
return this.axiosClient.post(a, i, dt);
|
|
1041
1042
|
}
|
|
1042
1043
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
1043
1044
|
let o = {
|
|
1044
1045
|
otp: e,
|
|
1045
1046
|
device: t,
|
|
1046
1047
|
challenge_id: n
|
|
1047
|
-
}, s =
|
|
1048
|
-
!i && r && (s =
|
|
1048
|
+
}, s = B.passkeyValidate;
|
|
1049
|
+
!i && r && (s = Me.passkeyValidate);
|
|
1049
1050
|
let c = i ? { [a]: i } : {};
|
|
1050
1051
|
return this.axiosClient.post(s, o, { headers: c });
|
|
1051
1052
|
}
|
|
1052
|
-
},
|
|
1053
|
+
}, _t = class {
|
|
1053
1054
|
constructor(e, t, n) {
|
|
1054
|
-
this.axiosClient = new
|
|
1055
|
+
this.axiosClient = new lt(e, t, n);
|
|
1055
1056
|
}
|
|
1056
1057
|
setAppId(e) {
|
|
1057
1058
|
this.axiosClient.setAppId(e);
|
|
1058
1059
|
}
|
|
1059
1060
|
getCLIAuthStatus(e) {
|
|
1060
|
-
let t =
|
|
1061
|
+
let t = Ke(B.cliAuthStatus, { sessionId: e });
|
|
1061
1062
|
return this.axiosClient.get(t);
|
|
1062
1063
|
}
|
|
1063
1064
|
completeCLIAuth(e) {
|
|
1064
|
-
return this.axiosClient.post(
|
|
1065
|
+
return this.axiosClient.post(B.cliAuthComplete, e);
|
|
1065
1066
|
}
|
|
1066
|
-
},
|
|
1067
|
+
}, vt = class {
|
|
1067
1068
|
constructor(e, t, n) {
|
|
1068
|
-
this.axiosClient = new
|
|
1069
|
+
this.axiosClient = new lt(e, t, n);
|
|
1069
1070
|
}
|
|
1070
1071
|
setAppId(e) {
|
|
1071
1072
|
this.axiosClient.setAppId(e);
|
|
1072
1073
|
}
|
|
1073
1074
|
requestInviteLink(e) {
|
|
1074
|
-
return this.axiosClient.post(
|
|
1075
|
+
return this.axiosClient.post(B.requestInvitation, e);
|
|
1075
1076
|
}
|
|
1076
1077
|
getInvitations(e) {
|
|
1077
1078
|
let t = {};
|
|
1078
1079
|
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());
|
|
1079
|
-
let n =
|
|
1080
|
+
let n = Ke(B.invitationsPath, { tenantID: e.tenantID });
|
|
1080
1081
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
1081
1082
|
invites: e.invites,
|
|
1082
1083
|
nextPageSkip: e.next_page_skip
|
|
1083
1084
|
}));
|
|
1084
1085
|
}
|
|
1085
1086
|
deleteInvitation(e) {
|
|
1086
|
-
let t =
|
|
1087
|
+
let t = Ke(B.invitationDelete, { invitationID: e });
|
|
1087
1088
|
return this.axiosClient.delete(t);
|
|
1088
1089
|
}
|
|
1089
1090
|
resendInvitation(e) {
|
|
1090
|
-
let t =
|
|
1091
|
+
let t = Ke(B.invitationResend, { invitationID: e });
|
|
1091
1092
|
return this.axiosClient.post(t, {});
|
|
1092
1093
|
}
|
|
1093
1094
|
getInvitationLink(e) {
|
|
1094
|
-
let t =
|
|
1095
|
+
let t = Ke(B.invitationGetLink, { invitationID: e });
|
|
1095
1096
|
return this.axiosClient.get(t);
|
|
1096
1097
|
}
|
|
1097
|
-
},
|
|
1098
|
+
}, yt = class {
|
|
1098
1099
|
constructor(e, t, n) {
|
|
1099
|
-
this.axiosClient = new
|
|
1100
|
+
this.axiosClient = new lt(e, t, n);
|
|
1100
1101
|
}
|
|
1101
1102
|
setAppId(e) {
|
|
1102
1103
|
this.axiosClient.setAppId(e);
|
|
1103
1104
|
}
|
|
1104
1105
|
getSettingsAll() {
|
|
1105
|
-
return this.axiosClient.get(
|
|
1106
|
+
return this.axiosClient.get(B.settingsAll);
|
|
1106
1107
|
}
|
|
1107
1108
|
getPasswordPolicySettings() {
|
|
1108
|
-
return this.axiosClient.get(
|
|
1109
|
+
return this.axiosClient.get(B.settingsPasswordPolicy);
|
|
1109
1110
|
}
|
|
1110
1111
|
getPasskeySettings() {
|
|
1111
|
-
return this.axiosClient.get(
|
|
1112
|
+
return this.axiosClient.get(B.settingsPasskey);
|
|
1112
1113
|
}
|
|
1113
|
-
},
|
|
1114
|
+
}, bt = class {
|
|
1114
1115
|
constructor(e, t, n) {
|
|
1115
|
-
this.axiosClient = new
|
|
1116
|
+
this.axiosClient = new lt(e, t, n);
|
|
1116
1117
|
}
|
|
1117
1118
|
setAppId(e) {
|
|
1118
1119
|
this.axiosClient.setAppId(e);
|
|
@@ -1122,171 +1123,171 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1122
1123
|
invite_token: e,
|
|
1123
1124
|
scopes: t
|
|
1124
1125
|
};
|
|
1125
|
-
return this.axiosClient.post(
|
|
1126
|
+
return this.axiosClient.post(B.joinInvitation, n);
|
|
1126
1127
|
}
|
|
1127
1128
|
createTenant(e) {
|
|
1128
1129
|
let t = { name: e };
|
|
1129
|
-
return this.axiosClient.post(
|
|
1130
|
+
return this.axiosClient.post(B.tenantPath, t);
|
|
1130
1131
|
}
|
|
1131
1132
|
getTenantDetails(e) {
|
|
1132
|
-
let t = `${
|
|
1133
|
+
let t = `${B.tenantPath}/${e}`;
|
|
1133
1134
|
return this.axiosClient.get(t);
|
|
1134
1135
|
}
|
|
1135
1136
|
updateTenant(e, t) {
|
|
1136
|
-
let n = `${
|
|
1137
|
+
let n = `${B.tenantPath}/${e}`, r = { name: t };
|
|
1137
1138
|
return this.axiosClient.put(n, r);
|
|
1138
1139
|
}
|
|
1139
1140
|
deleteTenant(e) {
|
|
1140
|
-
let t = `${
|
|
1141
|
+
let t = `${B.tenantPath}/${e}`;
|
|
1141
1142
|
return this.axiosClient.delete(t);
|
|
1142
1143
|
}
|
|
1143
1144
|
getUserTenantMembership() {
|
|
1144
|
-
return this.axiosClient.get(
|
|
1145
|
+
return this.axiosClient.get(B.tenantPath);
|
|
1145
1146
|
}
|
|
1146
1147
|
createGroup(e, t) {
|
|
1147
|
-
let n = `${
|
|
1148
|
+
let n = `${B.tenantPath}/${e}/group`, r = { name: t };
|
|
1148
1149
|
return this.axiosClient.post(n, r);
|
|
1149
1150
|
}
|
|
1150
1151
|
getGroupInfo(e, t) {
|
|
1151
|
-
let n = `${
|
|
1152
|
+
let n = `${B.tenantPath}/${e}/group/${t}`;
|
|
1152
1153
|
return this.axiosClient.get(n);
|
|
1153
1154
|
}
|
|
1154
1155
|
updateGroup(e, t, n) {
|
|
1155
|
-
let r = `${
|
|
1156
|
+
let r = `${B.tenantPath}/${e}/group/${t}`, i = { name: n };
|
|
1156
1157
|
return this.axiosClient.put(r, i);
|
|
1157
1158
|
}
|
|
1158
1159
|
deleteGroup(e, t) {
|
|
1159
|
-
let n = `${
|
|
1160
|
+
let n = `${B.tenantPath}/${e}/group/${t}`;
|
|
1160
1161
|
return this.axiosClient.delete(n);
|
|
1161
1162
|
}
|
|
1162
1163
|
addUserToGroup(e, t, n, r) {
|
|
1163
|
-
let i = `${
|
|
1164
|
+
let i = `${B.tenantPath}/${e}/group/${t}/add`, a = {
|
|
1164
1165
|
user_id: n,
|
|
1165
1166
|
role: r
|
|
1166
1167
|
};
|
|
1167
1168
|
return this.axiosClient.post(i, a);
|
|
1168
1169
|
}
|
|
1169
1170
|
removeUserRolesFromGroup(e, t, n, r) {
|
|
1170
|
-
let i = `${
|
|
1171
|
+
let i = `${B.tenantPath}/${e}/group/${t}/remove_roles`, a = {
|
|
1171
1172
|
user_id: n,
|
|
1172
1173
|
roles: r
|
|
1173
1174
|
};
|
|
1174
1175
|
return this.axiosClient.post(i, a);
|
|
1175
1176
|
}
|
|
1176
1177
|
changeUserRoles(e, t, n, r) {
|
|
1177
|
-
let i = `${
|
|
1178
|
+
let i = `${B.tenantPath}/${e}/group/${t}/change`, a = {
|
|
1178
1179
|
user_id: n,
|
|
1179
1180
|
roles: r
|
|
1180
1181
|
};
|
|
1181
1182
|
return this.axiosClient.post(i, a);
|
|
1182
1183
|
}
|
|
1183
1184
|
deleteUserFromGroup(e, t, n) {
|
|
1184
|
-
let r = `${
|
|
1185
|
+
let r = `${B.tenantPath}/${e}/group/${t}/${n}`;
|
|
1185
1186
|
return this.axiosClient.delete(r);
|
|
1186
1187
|
}
|
|
1187
1188
|
getRolesForTenant(e) {
|
|
1188
|
-
let t = `${
|
|
1189
|
+
let t = `${B.tenantPath}/${e}/role`;
|
|
1189
1190
|
return this.axiosClient.get(t);
|
|
1190
1191
|
}
|
|
1191
1192
|
createRoleForTenant(e, t) {
|
|
1192
|
-
let n = `${
|
|
1193
|
+
let n = `${B.tenantPath}/${e}/role`, r = { name: t };
|
|
1193
1194
|
return this.axiosClient.post(n, r);
|
|
1194
1195
|
}
|
|
1195
1196
|
updateRole(e, t, n) {
|
|
1196
|
-
let r = `${
|
|
1197
|
+
let r = `${B.tenantPath}/${e}/role/${t}`, i = { name: n };
|
|
1197
1198
|
return this.axiosClient.put(r, i);
|
|
1198
1199
|
}
|
|
1199
1200
|
deleteRole(e, t) {
|
|
1200
|
-
let n = `${
|
|
1201
|
+
let n = `${B.tenantPath}/${e}/role/${t}`;
|
|
1201
1202
|
return this.axiosClient.delete(n);
|
|
1202
1203
|
}
|
|
1203
1204
|
deleteUserFromTenant(e, t) {
|
|
1204
|
-
let n = `${
|
|
1205
|
+
let n = `${B.tenantPath}/${e}/user/${t}`;
|
|
1205
1206
|
return this.axiosClient.delete(n);
|
|
1206
1207
|
}
|
|
1207
1208
|
getGroupInvitations(e, t, n, r) {
|
|
1208
|
-
let i = `${
|
|
1209
|
+
let i = `${B.tenantPath}/${e}/group/${t}/invitations`;
|
|
1209
1210
|
return this.axiosClient.get(i, { params: {
|
|
1210
1211
|
limit: n,
|
|
1211
1212
|
skip: r
|
|
1212
1213
|
} });
|
|
1213
1214
|
}
|
|
1214
1215
|
getTenantInvitations(e, t, n) {
|
|
1215
|
-
let r = `${
|
|
1216
|
+
let r = `${B.tenantPath}/${e}/invitations`;
|
|
1216
1217
|
return this.axiosClient.get(r, { params: {
|
|
1217
1218
|
limit: t,
|
|
1218
1219
|
skip: n
|
|
1219
1220
|
} });
|
|
1220
1221
|
}
|
|
1221
1222
|
invalidateInviteById(e, t, n) {
|
|
1222
|
-
let r = `${
|
|
1223
|
+
let r = `${B.tenantPath}/${e}/group/${t}/invite/${n}`;
|
|
1223
1224
|
return this.axiosClient.delete(r);
|
|
1224
1225
|
}
|
|
1225
1226
|
invalidateInviteByEmail(e, t, n) {
|
|
1226
|
-
let r = `${
|
|
1227
|
+
let r = `${B.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1227
1228
|
return this.axiosClient.delete(r);
|
|
1228
1229
|
}
|
|
1229
|
-
},
|
|
1230
|
+
}, xt = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, St = (e) => ({
|
|
1230
1231
|
withCredentials: !0,
|
|
1231
|
-
...
|
|
1232
|
-
}),
|
|
1232
|
+
...xt(e)
|
|
1233
|
+
}), Ct = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1233
1234
|
...n,
|
|
1234
1235
|
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1235
|
-
}),
|
|
1236
|
+
}), wt = {
|
|
1236
1237
|
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1237
1238
|
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1238
1239
|
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1239
1240
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1240
|
-
},
|
|
1241
|
+
}, Tt = class {
|
|
1241
1242
|
constructor(e, t, n) {
|
|
1242
|
-
this.axiosClient = new
|
|
1243
|
+
this.axiosClient = new lt(e, t, n);
|
|
1243
1244
|
}
|
|
1244
1245
|
setAppId(e) {
|
|
1245
1246
|
this.axiosClient.setAppId(e);
|
|
1246
1247
|
}
|
|
1247
1248
|
getStatus(e) {
|
|
1248
|
-
return this.axiosClient.get(
|
|
1249
|
+
return this.axiosClient.get(B.twoFactorStatus, ct(e));
|
|
1249
1250
|
}
|
|
1250
1251
|
async beginSetup(e) {
|
|
1251
|
-
return
|
|
1252
|
+
return Ct(await this.axiosClient.post(B.twoFactorSetupBegin, {}, ct(e)));
|
|
1252
1253
|
}
|
|
1253
1254
|
confirmSetup(e, t) {
|
|
1254
|
-
return this.axiosClient.post(
|
|
1255
|
+
return this.axiosClient.post(B.twoFactorSetupConfirm, e, ct(t));
|
|
1255
1256
|
}
|
|
1256
1257
|
getEnrollment(e) {
|
|
1257
|
-
return this.axiosClient.get(
|
|
1258
|
+
return this.axiosClient.get(B.twoFactorEnrollment, ct(e));
|
|
1258
1259
|
}
|
|
1259
1260
|
sendSetupLink(e) {
|
|
1260
|
-
return this.axiosClient.post(
|
|
1261
|
+
return this.axiosClient.post(B.twoFactorEnrollmentEmailLink, void 0, ct(e));
|
|
1261
1262
|
}
|
|
1262
1263
|
async beginEnrollment(e) {
|
|
1263
|
-
return
|
|
1264
|
+
return Ct(await this.axiosClient.post(B.twoFactorEnrollmentBegin, void 0, ct(e)));
|
|
1264
1265
|
}
|
|
1265
1266
|
confirmEnrollment(e, t) {
|
|
1266
|
-
return this.axiosClient.post(
|
|
1267
|
+
return this.axiosClient.post(B.twoFactorEnrollmentConfirm, t, ct(e));
|
|
1267
1268
|
}
|
|
1268
1269
|
verify(e) {
|
|
1269
1270
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1270
|
-
return this.axiosClient.post(
|
|
1271
|
+
return this.axiosClient.post(B.twoFactorVerify, {
|
|
1271
1272
|
code: n,
|
|
1272
1273
|
...r ? { trust_device: !0 } : {}
|
|
1273
|
-
},
|
|
1274
|
+
}, St(t));
|
|
1274
1275
|
}
|
|
1275
1276
|
useRecoveryCode(e) {
|
|
1276
1277
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1277
|
-
return this.axiosClient.post(
|
|
1278
|
+
return this.axiosClient.post(B.twoFactorRecovery, {
|
|
1278
1279
|
recovery_code: n,
|
|
1279
1280
|
...r ? { trust_device: !0 } : {}
|
|
1280
|
-
},
|
|
1281
|
+
}, St(t));
|
|
1281
1282
|
}
|
|
1282
1283
|
disable(e) {
|
|
1283
|
-
return this.axiosClient.delete(
|
|
1284
|
+
return this.axiosClient.delete(B.twoFactor, { data: e });
|
|
1284
1285
|
}
|
|
1285
1286
|
regenerateRecoveryCodes(e) {
|
|
1286
|
-
return this.axiosClient.post(
|
|
1287
|
+
return this.axiosClient.post(B.twoFactorRegenerateCodes, e);
|
|
1287
1288
|
}
|
|
1288
1289
|
validateTwoFactorSetupMagicLink(e) {
|
|
1289
|
-
let t = `${
|
|
1290
|
+
let t = `${B.twoFactorSetupMagicLink}/${e}`;
|
|
1290
1291
|
return this.axiosClient.get(t, { transformRequest: [(e, t) => (t && delete t.Authorization, e)] }).then((e) => {
|
|
1291
1292
|
let t = e;
|
|
1292
1293
|
return t.valid === !1 ? {
|
|
@@ -1306,7 +1307,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1306
1307
|
if (e instanceof V) return {
|
|
1307
1308
|
success: !1,
|
|
1308
1309
|
error: {
|
|
1309
|
-
code:
|
|
1310
|
+
code: wt[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1310
1311
|
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1311
1312
|
}
|
|
1312
1313
|
};
|
|
@@ -1349,78 +1350,78 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1349
1350
|
}
|
|
1350
1351
|
}
|
|
1351
1352
|
async getAvailableMethods() {
|
|
1352
|
-
return (await this.axiosClient.get(
|
|
1353
|
+
return (await this.axiosClient.get(B.TwoFactorMethodsAvailable))?.available_methods ?? [];
|
|
1353
1354
|
}
|
|
1354
1355
|
async getRegisteredMethods() {
|
|
1355
|
-
return (await this.axiosClient.get(
|
|
1356
|
+
return (await this.axiosClient.get(B.TwoFactorMethodsRegistered))?.registered_methods ?? [];
|
|
1356
1357
|
}
|
|
1357
1358
|
startMethodSetup(e, t) {
|
|
1358
|
-
return this.axiosClient.post(
|
|
1359
|
+
return this.axiosClient.post(B.TwoFactorSetupStart, {
|
|
1359
1360
|
...t,
|
|
1360
1361
|
method: e
|
|
1361
1362
|
});
|
|
1362
1363
|
}
|
|
1363
1364
|
completeMethodSetup(e, t) {
|
|
1364
|
-
return this.axiosClient.post(
|
|
1365
|
+
return this.axiosClient.post(B.TwoFactorSetupComplete, {
|
|
1365
1366
|
...t,
|
|
1366
1367
|
method: e
|
|
1367
1368
|
});
|
|
1368
1369
|
}
|
|
1369
1370
|
removeMethod(e) {
|
|
1370
|
-
let t =
|
|
1371
|
+
let t = Ke(B.TwoFactorMethodRemove, { id: e });
|
|
1371
1372
|
return this.axiosClient.delete(t);
|
|
1372
1373
|
}
|
|
1373
1374
|
requestChallenge(e, t) {
|
|
1374
|
-
return this.axiosClient.post(
|
|
1375
|
+
return this.axiosClient.post(B.TwoFactorChallenge, e, xt(t));
|
|
1375
1376
|
}
|
|
1376
1377
|
verifyV2(e, t) {
|
|
1377
1378
|
let { trust_device: n, ...r } = e;
|
|
1378
|
-
return this.axiosClient.post(
|
|
1379
|
+
return this.axiosClient.post(B.TwoFactorVerifyV2, {
|
|
1379
1380
|
...r,
|
|
1380
1381
|
...n ? { trust_device: !0 } : {}
|
|
1381
|
-
},
|
|
1382
|
+
}, St(t));
|
|
1382
1383
|
}
|
|
1383
1384
|
switchToAlternative(e, t) {
|
|
1384
|
-
return this.axiosClient.post(
|
|
1385
|
+
return this.axiosClient.post(B.TwoFactorAlternative, e, xt(t));
|
|
1385
1386
|
}
|
|
1386
1387
|
async getTrustedDevices() {
|
|
1387
|
-
return (await this.axiosClient.get(
|
|
1388
|
+
return (await this.axiosClient.get(B.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1388
1389
|
}
|
|
1389
1390
|
revokeTrustedDevice(e) {
|
|
1390
|
-
let t =
|
|
1391
|
+
let t = Ke(B.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1391
1392
|
return this.axiosClient.delete(t);
|
|
1392
1393
|
}
|
|
1393
|
-
},
|
|
1394
|
+
}, Et = class {
|
|
1394
1395
|
constructor(e, t, n) {
|
|
1395
|
-
this.axiosClient = new
|
|
1396
|
+
this.axiosClient = new lt(e, t, n);
|
|
1396
1397
|
}
|
|
1397
1398
|
setAppId(e) {
|
|
1398
1399
|
this.axiosClient.setAppId(e);
|
|
1399
1400
|
}
|
|
1400
1401
|
startUpgrade(e) {
|
|
1401
|
-
return this.axiosClient.post(
|
|
1402
|
+
return this.axiosClient.post(B.upgradeStart, e, De({}));
|
|
1402
1403
|
}
|
|
1403
1404
|
startHostedUpgrade(e) {
|
|
1404
|
-
return this.axiosClient.post(
|
|
1405
|
+
return this.axiosClient.post(B.hostedUpgradeStart, e, { withCredentials: !0 });
|
|
1405
1406
|
}
|
|
1406
1407
|
async commitHostedUpgrade(e) {
|
|
1407
|
-
await this.axiosClient.post(
|
|
1408
|
+
await this.axiosClient.post(B.hostedUpgrade, e, { withCredentials: !0 });
|
|
1408
1409
|
}
|
|
1409
|
-
},
|
|
1410
|
+
}, Dt = class {
|
|
1410
1411
|
constructor(e, t, n) {
|
|
1411
|
-
this.axiosClient = new
|
|
1412
|
+
this.axiosClient = new lt(e, t, n);
|
|
1412
1413
|
}
|
|
1413
1414
|
setAppId(e) {
|
|
1414
1415
|
this.axiosClient.setAppId(e);
|
|
1415
1416
|
}
|
|
1416
1417
|
getUserPasskeys() {
|
|
1417
|
-
return this.axiosClient.get(
|
|
1418
|
+
return this.axiosClient.get(B.userPasskey);
|
|
1418
1419
|
}
|
|
1419
1420
|
renameUserPasskey(e, t) {
|
|
1420
|
-
return this.axiosClient.patch(`${
|
|
1421
|
+
return this.axiosClient.patch(`${B.userPasskey}/${t}`, { name: e });
|
|
1421
1422
|
}
|
|
1422
1423
|
deleteUserPasskey(e) {
|
|
1423
|
-
return this.axiosClient.delete(`${
|
|
1424
|
+
return this.axiosClient.delete(`${B.userPasskey}/${e}`);
|
|
1424
1425
|
}
|
|
1425
1426
|
addUserPasskeyStart({ relyingPartyId: e, deviceId: t, os: n, passkeyDisplayName: r, passkeyUsername: i }) {
|
|
1426
1427
|
let a = {
|
|
@@ -1430,57 +1431,57 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1430
1431
|
deviceId: t,
|
|
1431
1432
|
os: n
|
|
1432
1433
|
};
|
|
1433
|
-
return this.axiosClient.post(
|
|
1434
|
+
return this.axiosClient.post(B.addUserPasskey, a);
|
|
1434
1435
|
}
|
|
1435
1436
|
addUserPasskeyComplete(e, t, n) {
|
|
1436
|
-
return this.axiosClient.post(
|
|
1437
|
+
return this.axiosClient.post(B.completeAddUserPasskey, {
|
|
1437
1438
|
challenge_id: n,
|
|
1438
1439
|
device: t,
|
|
1439
1440
|
passkey_data: e
|
|
1440
1441
|
});
|
|
1441
1442
|
}
|
|
1442
|
-
},
|
|
1443
|
+
}, Ot = 10, kt = 20, At = class extends Error {
|
|
1443
1444
|
constructor(e) {
|
|
1444
1445
|
super(`Passflow fetch middleware '${e}' resolved without calling next(). Every registered middleware must delegate exactly once; swallowing a request would drop a caller's fetch inside the Passflow wrapper.`), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
|
|
1445
1446
|
}
|
|
1446
|
-
},
|
|
1447
|
+
}, jt = [], Mt = 0, Nt = !1, Pt, Ft, It = (e, t) => e.priority - t.priority || e.seq - t.seq, Lt = () => typeof globalThis > "u" ? void 0 : globalThis, Rt = async (e, t, n, r) => {
|
|
1447
1448
|
if (t >= e.length) {
|
|
1448
|
-
let e =
|
|
1449
|
+
let e = Pt;
|
|
1449
1450
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1450
1451
|
return e(n, r);
|
|
1451
1452
|
}
|
|
1452
1453
|
let i = e[t];
|
|
1453
|
-
if (!i) return
|
|
1454
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1455
|
-
if (!a) throw new
|
|
1454
|
+
if (!i) return Rt(e, e.length, n, r);
|
|
1455
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, Rt(e, t + 1, n, r)), n, r);
|
|
1456
|
+
if (!a) throw new At(i.name);
|
|
1456
1457
|
return o;
|
|
1457
|
-
},
|
|
1458
|
-
let e =
|
|
1458
|
+
}, zt = () => {
|
|
1459
|
+
let e = Lt();
|
|
1459
1460
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1460
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1461
|
-
return
|
|
1462
|
-
},
|
|
1463
|
-
let e =
|
|
1464
|
-
e &&
|
|
1465
|
-
},
|
|
1466
|
-
if (!
|
|
1461
|
+
let t = e.fetch.bind(e), n = (e, t) => Rt([...jt].sort(It), 0, e, t);
|
|
1462
|
+
return Pt = t, Ft = n, e.fetch = n, Nt = !0, !0;
|
|
1463
|
+
}, Bt = () => {
|
|
1464
|
+
let e = Lt();
|
|
1465
|
+
e && Ft && e.fetch === Ft && (Pt && (e.fetch = Pt), Nt = !1, Ft = void 0, Pt = void 0);
|
|
1466
|
+
}, Vt = (e, t) => {
|
|
1467
|
+
if (!Nt && !zt()) return () => {};
|
|
1467
1468
|
let n = {
|
|
1468
1469
|
middleware: e,
|
|
1469
1470
|
name: t.name,
|
|
1470
1471
|
priority: t.priority,
|
|
1471
|
-
seq:
|
|
1472
|
+
seq: Mt++
|
|
1472
1473
|
};
|
|
1473
|
-
|
|
1474
|
+
jt.push(n);
|
|
1474
1475
|
let r = !1;
|
|
1475
1476
|
return () => {
|
|
1476
|
-
r || (r = !0,
|
|
1477
|
+
r || (r = !0, jt = jt.filter((e) => e !== n), jt.length === 0 && Bt());
|
|
1477
1478
|
};
|
|
1478
|
-
},
|
|
1479
|
-
let e =
|
|
1479
|
+
}, Ht = () => {
|
|
1480
|
+
let e = Lt();
|
|
1480
1481
|
return {
|
|
1481
|
-
installed:
|
|
1482
|
-
names: [...
|
|
1483
|
-
foreignPatch:
|
|
1482
|
+
installed: Nt,
|
|
1483
|
+
names: [...jt].sort(It).map((e) => e.name),
|
|
1484
|
+
foreignPatch: Nt && !!e && !!Ft && e.fetch !== Ft
|
|
1484
1485
|
};
|
|
1485
1486
|
}, H = class e extends Error {
|
|
1486
1487
|
constructor(t) {
|
|
@@ -1551,7 +1552,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1551
1552
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1552
1553
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1553
1554
|
}
|
|
1554
|
-
},
|
|
1555
|
+
}, Ut = class extends H {
|
|
1555
1556
|
constructor(e, t) {
|
|
1556
1557
|
super({
|
|
1557
1558
|
code: "temporarily_unavailable",
|
|
@@ -1560,7 +1561,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1560
1561
|
cause: t
|
|
1561
1562
|
}), this.name = "M2MNetworkError";
|
|
1562
1563
|
}
|
|
1563
|
-
},
|
|
1564
|
+
}, Wt = class extends H {
|
|
1564
1565
|
constructor(e, t) {
|
|
1565
1566
|
super({
|
|
1566
1567
|
code: "invalid_request",
|
|
@@ -1569,7 +1570,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1569
1570
|
cause: t
|
|
1570
1571
|
}), this.name = "M2MTokenParseError";
|
|
1571
1572
|
}
|
|
1572
|
-
},
|
|
1573
|
+
}, Gt = class extends H {
|
|
1573
1574
|
constructor(e) {
|
|
1574
1575
|
super({
|
|
1575
1576
|
code: "invalid_request",
|
|
@@ -1577,7 +1578,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1577
1578
|
status: 400
|
|
1578
1579
|
}), this.name = "M2MConfigError";
|
|
1579
1580
|
}
|
|
1580
|
-
},
|
|
1581
|
+
}, Kt = {
|
|
1581
1582
|
InvalidRequest: "invalid_request",
|
|
1582
1583
|
InvalidClient: "invalid_client",
|
|
1583
1584
|
InvalidGrant: "invalid_grant",
|
|
@@ -1587,14 +1588,14 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1587
1588
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1588
1589
|
ServerError: "server_error",
|
|
1589
1590
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1590
|
-
},
|
|
1591
|
+
}, qt = {
|
|
1591
1592
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1592
1593
|
TIMEOUT: 1e4,
|
|
1593
1594
|
RETRIES: 3,
|
|
1594
1595
|
RETRY_DELAY: 1e3,
|
|
1595
1596
|
REFRESH_THRESHOLD: 30,
|
|
1596
1597
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1597
|
-
},
|
|
1598
|
+
}, Jt = class {
|
|
1598
1599
|
constructor() {
|
|
1599
1600
|
this.cache = /* @__PURE__ */ new Map();
|
|
1600
1601
|
}
|
|
@@ -1611,18 +1612,18 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1611
1612
|
delete(e) {
|
|
1612
1613
|
return this.cache.delete(e), Promise.resolve();
|
|
1613
1614
|
}
|
|
1614
|
-
},
|
|
1615
|
+
}, Yt = {
|
|
1615
1616
|
shouldRetry(e, t) {
|
|
1616
1617
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1617
1618
|
},
|
|
1618
1619
|
getDelay(e) {
|
|
1619
1620
|
return 2 ** (e - 1) * 1e3;
|
|
1620
1621
|
}
|
|
1621
|
-
},
|
|
1622
|
+
}, Xt = class {
|
|
1622
1623
|
constructor(e) {
|
|
1623
|
-
if (!e.url) throw new
|
|
1624
|
-
if (!e.clientId) throw new
|
|
1625
|
-
if (!e.clientSecret) throw new
|
|
1624
|
+
if (!e.url) throw new Gt("M2M client requires a URL");
|
|
1625
|
+
if (!e.clientId) throw new Gt("M2M client requires a clientId");
|
|
1626
|
+
if (!e.clientSecret) throw new Gt("M2M client requires a clientSecret");
|
|
1626
1627
|
let t = e.url.replace(/\/$/, "");
|
|
1627
1628
|
this.config = {
|
|
1628
1629
|
url: t,
|
|
@@ -1631,16 +1632,16 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1631
1632
|
scopes: e.scopes,
|
|
1632
1633
|
audience: e.audience,
|
|
1633
1634
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1634
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1635
|
-
timeout: e.timeout ??
|
|
1636
|
-
retries: e.retries ??
|
|
1637
|
-
retryDelay: e.retryDelay ??
|
|
1635
|
+
refreshThreshold: e.refreshThreshold ?? qt.REFRESH_THRESHOLD,
|
|
1636
|
+
timeout: e.timeout ?? qt.TIMEOUT,
|
|
1637
|
+
retries: e.retries ?? qt.RETRIES,
|
|
1638
|
+
retryDelay: e.retryDelay ?? qt.RETRY_DELAY,
|
|
1638
1639
|
retryStrategy: e.retryStrategy,
|
|
1639
1640
|
cache: e.cache,
|
|
1640
1641
|
onTokenRequest: e.onTokenRequest,
|
|
1641
1642
|
onTokenResponse: e.onTokenResponse,
|
|
1642
1643
|
onError: e.onError
|
|
1643
|
-
}, this.cache = e.cache ?? new
|
|
1644
|
+
}, this.cache = e.cache ?? new Jt(), this.retryStrategy = e.retryStrategy ?? Yt, this.tokenEndpoint = `${t}${qt.TOKEN_ENDPOINT}`;
|
|
1644
1645
|
}
|
|
1645
1646
|
getCacheKey(e, t) {
|
|
1646
1647
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1685,7 +1686,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1685
1686
|
let e = await fetch(this.tokenEndpoint, {
|
|
1686
1687
|
method: "POST",
|
|
1687
1688
|
headers: {
|
|
1688
|
-
"Content-Type":
|
|
1689
|
+
"Content-Type": qt.CONTENT_TYPE,
|
|
1689
1690
|
Accept: "application/json"
|
|
1690
1691
|
},
|
|
1691
1692
|
body: t.toString(),
|
|
@@ -1710,7 +1711,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1710
1711
|
}
|
|
1711
1712
|
return a;
|
|
1712
1713
|
} catch (e) {
|
|
1713
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1714
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new Ut(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new Ut(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1714
1715
|
}
|
|
1715
1716
|
}
|
|
1716
1717
|
async executeWithRetry(e) {
|
|
@@ -1753,13 +1754,13 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1753
1754
|
parseToken(e) {
|
|
1754
1755
|
try {
|
|
1755
1756
|
let t = e.split(".");
|
|
1756
|
-
if (t.length !== 3) throw new
|
|
1757
|
+
if (t.length !== 3) throw new Wt("Invalid JWT format: expected 3 parts");
|
|
1757
1758
|
let n = t[1];
|
|
1758
|
-
if (!n) throw new
|
|
1759
|
+
if (!n) throw new Wt("Invalid JWT format: missing payload");
|
|
1759
1760
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1760
1761
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1761
1762
|
} catch (e) {
|
|
1762
|
-
throw e instanceof
|
|
1763
|
+
throw e instanceof Wt ? e : new Wt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1763
1764
|
}
|
|
1764
1765
|
}
|
|
1765
1766
|
clearCache() {
|
|
@@ -1774,7 +1775,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1774
1775
|
try {
|
|
1775
1776
|
let e = await fetch(t, {
|
|
1776
1777
|
method: "POST",
|
|
1777
|
-
headers: { "Content-Type":
|
|
1778
|
+
headers: { "Content-Type": qt.CONTENT_TYPE },
|
|
1778
1779
|
body: n.toString()
|
|
1779
1780
|
});
|
|
1780
1781
|
if (!e.ok && e.status !== 200) {
|
|
@@ -1801,50 +1802,50 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1801
1802
|
get audience() {
|
|
1802
1803
|
return this.config.audience;
|
|
1803
1804
|
}
|
|
1804
|
-
},
|
|
1805
|
+
}, Zt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Qt = 32, $t = (e) => {
|
|
1805
1806
|
let t = "";
|
|
1806
1807
|
for (let n = 0; n < e.length; n += 3) {
|
|
1807
1808
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1808
|
-
t +=
|
|
1809
|
+
t += Zt.charAt(r >> 2), t += Zt.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Zt.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Zt.charAt(a & 63));
|
|
1809
1810
|
}
|
|
1810
1811
|
return t;
|
|
1811
|
-
},
|
|
1812
|
+
}, en = () => {
|
|
1812
1813
|
let e = globalThis.crypto;
|
|
1813
1814
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1814
1815
|
return e;
|
|
1815
|
-
},
|
|
1816
|
-
let t = await
|
|
1817
|
-
return
|
|
1818
|
-
},
|
|
1819
|
-
let e = Qt
|
|
1816
|
+
}, tn = async (e) => {
|
|
1817
|
+
let t = await en().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1818
|
+
return $t(new Uint8Array(t));
|
|
1819
|
+
}, nn = (e = Qt) => $t(en().getRandomValues(new Uint8Array(e))), rn = async () => {
|
|
1820
|
+
let e = nn(Qt);
|
|
1820
1821
|
return {
|
|
1821
1822
|
verifier: e,
|
|
1822
|
-
challenge: await
|
|
1823
|
+
challenge: await tn(e)
|
|
1823
1824
|
};
|
|
1824
|
-
},
|
|
1825
|
+
}, an = () => !!globalThis.crypto?.subtle, U = class extends Error {
|
|
1825
1826
|
constructor(e, t) {
|
|
1826
1827
|
super(t), this.code = e, this.name = "PassflowOidcError";
|
|
1827
1828
|
}
|
|
1828
|
-
},
|
|
1829
|
+
}, on = "Sign in again.", sn = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, cn = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", ln = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), un = "passflow_oidc_pkce", dn = 6e5, fn = (e) => {
|
|
1829
1830
|
try {
|
|
1830
1831
|
let t = new URL(e);
|
|
1831
1832
|
return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
|
|
1832
1833
|
} catch {
|
|
1833
1834
|
return e;
|
|
1834
1835
|
}
|
|
1835
|
-
},
|
|
1836
|
-
if (!
|
|
1837
|
-
let t =
|
|
1836
|
+
}, pn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], mn = async (e) => {
|
|
1837
|
+
if (!an()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1838
|
+
let t = pn(e.scopes), n = await rn(), r = {
|
|
1838
1839
|
verifier: n.verifier,
|
|
1839
|
-
state:
|
|
1840
|
-
...t.includes("openid") ? { nonce:
|
|
1840
|
+
state: nn(),
|
|
1841
|
+
...t.includes("openid") ? { nonce: nn() } : {},
|
|
1841
1842
|
clientId: e.clientId,
|
|
1842
1843
|
redirectUri: e.redirectUri,
|
|
1843
1844
|
scopes: t,
|
|
1844
|
-
expiresAt: Date.now() +
|
|
1845
|
+
expiresAt: Date.now() + dn
|
|
1845
1846
|
};
|
|
1846
1847
|
try {
|
|
1847
|
-
sessionStorage.setItem(
|
|
1848
|
+
sessionStorage.setItem(un, JSON.stringify(r));
|
|
1848
1849
|
} catch {
|
|
1849
1850
|
throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
|
|
1850
1851
|
}
|
|
@@ -1859,37 +1860,37 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1859
1860
|
code_challenge_method: "S256",
|
|
1860
1861
|
...r.nonce ? { nonce: r.nonce } : {}
|
|
1861
1862
|
}).toString(), i.toString();
|
|
1862
|
-
},
|
|
1863
|
+
}, hn = (e) => {
|
|
1863
1864
|
let t = e;
|
|
1864
1865
|
return typeof t == "object" && !!t && typeof t.verifier == "string" && typeof t.state == "string" && typeof t.clientId == "string" && typeof t.redirectUri == "string" && Array.isArray(t.scopes) && typeof t.expiresAt == "number";
|
|
1865
|
-
},
|
|
1866
|
+
}, gn = () => {
|
|
1866
1867
|
let e;
|
|
1867
1868
|
try {
|
|
1868
|
-
e = sessionStorage.getItem(
|
|
1869
|
+
e = sessionStorage.getItem(un);
|
|
1869
1870
|
} catch {
|
|
1870
1871
|
return { status: "none" };
|
|
1871
1872
|
}
|
|
1872
1873
|
if (!e) return { status: "none" };
|
|
1873
1874
|
try {
|
|
1874
1875
|
let t = JSON.parse(e);
|
|
1875
|
-
if (
|
|
1876
|
+
if (hn(t) && Date.now() < t.expiresAt) return {
|
|
1876
1877
|
status: "live",
|
|
1877
1878
|
slot: t
|
|
1878
1879
|
};
|
|
1879
1880
|
} catch {}
|
|
1880
1881
|
return { status: "unusable" };
|
|
1881
|
-
},
|
|
1882
|
+
}, _n = () => {
|
|
1882
1883
|
try {
|
|
1883
|
-
sessionStorage.removeItem(
|
|
1884
|
+
sessionStorage.removeItem(un);
|
|
1884
1885
|
} catch {}
|
|
1885
|
-
},
|
|
1886
|
+
}, vn = async (e) => {
|
|
1886
1887
|
try {
|
|
1887
1888
|
let t = await e.json();
|
|
1888
1889
|
return typeof t == "object" && t ? t : void 0;
|
|
1889
1890
|
} catch {
|
|
1890
1891
|
return;
|
|
1891
1892
|
}
|
|
1892
|
-
},
|
|
1893
|
+
}, yn = async (e, t, n) => {
|
|
1893
1894
|
let r;
|
|
1894
1895
|
try {
|
|
1895
1896
|
r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
|
|
@@ -1904,11 +1905,11 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1904
1905
|
}).toString()
|
|
1905
1906
|
});
|
|
1906
1907
|
} catch {
|
|
1907
|
-
throw new U("TOKEN_EXCHANGE_FAILED",
|
|
1908
|
+
throw new U("TOKEN_EXCHANGE_FAILED", on);
|
|
1908
1909
|
}
|
|
1909
|
-
let i = await
|
|
1910
|
-
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client",
|
|
1911
|
-
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED",
|
|
1910
|
+
let i = await vn(r);
|
|
1911
|
+
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", cn) : i?.error === "invalid_grant" ? new U("invalid_grant", on) : new U("TOKEN_EXCHANGE_FAILED", on);
|
|
1912
|
+
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", on);
|
|
1912
1913
|
let a = typeof i.id_token == "string" ? i.id_token : void 0;
|
|
1913
1914
|
if (n.scopes.includes("openid")) {
|
|
1914
1915
|
let e;
|
|
@@ -1917,7 +1918,7 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1917
1918
|
} catch {
|
|
1918
1919
|
e = void 0;
|
|
1919
1920
|
}
|
|
1920
|
-
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${
|
|
1921
|
+
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${on}`);
|
|
1921
1922
|
}
|
|
1922
1923
|
return {
|
|
1923
1924
|
access_token: i.access_token,
|
|
@@ -1925,101 +1926,101 @@ var Ue = /* @__PURE__ */ function(e) {
|
|
|
1925
1926
|
...a ? { id_token: a } : {},
|
|
1926
1927
|
scopes: n.scopes
|
|
1927
1928
|
};
|
|
1928
|
-
},
|
|
1929
|
+
}, bn = "error", xn = /* @__PURE__ */ new WeakMap(), Sn = (e, t) => {
|
|
1929
1930
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1930
|
-
let n =
|
|
1931
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1932
|
-
}, W = (e, t) =>
|
|
1931
|
+
let n = xn.get(e);
|
|
1932
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), xn.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1933
|
+
}, W = (e, t) => Sn(e, t.originalError) ? (e.notify(bn, t), !0) : !1, Cn = "passflow-refresh", wn = "passflow-refresh-takeover", Tn = "passflow-auth", En = Object.freeze([
|
|
1933
1934
|
1e3,
|
|
1934
1935
|
3e3,
|
|
1935
1936
|
1e4,
|
|
1936
1937
|
3e4,
|
|
1937
1938
|
6e4
|
|
1938
|
-
]),
|
|
1939
|
+
]), Dn = .2, On = 6e5, kn = 5e3, G = 2e4, An = 2e4, jn = 1e3, Mn = 2e3, Nn = 1e3, Pn = 1e4, Fn = 5e3;
|
|
1939
1940
|
// lib/refresh/protocol.ts
|
|
1940
|
-
function
|
|
1941
|
+
function In(e) {
|
|
1941
1942
|
let t = e ? `:${e}` : "";
|
|
1942
1943
|
return {
|
|
1943
|
-
lock: `${
|
|
1944
|
-
takeoverLock: `${
|
|
1945
|
-
channel: `${
|
|
1944
|
+
lock: `${Cn}${t}`,
|
|
1945
|
+
takeoverLock: `${wn}${t}`,
|
|
1946
|
+
channel: `${Tn}${t}`
|
|
1946
1947
|
};
|
|
1947
1948
|
}
|
|
1948
1949
|
function K(e) {
|
|
1949
1950
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1950
1951
|
}
|
|
1951
|
-
function
|
|
1952
|
+
function Ln(e) {
|
|
1952
1953
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1953
1954
|
}
|
|
1954
|
-
function
|
|
1955
|
+
function Rn(e) {
|
|
1955
1956
|
return typeof e == "object" && !!e;
|
|
1956
1957
|
}
|
|
1957
|
-
function
|
|
1958
|
+
function zn(e, t) {
|
|
1958
1959
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1959
1960
|
return e;
|
|
1960
1961
|
}
|
|
1961
|
-
function
|
|
1962
|
-
if (!
|
|
1962
|
+
function Bn(e) {
|
|
1963
|
+
if (!Rn(e)) return null;
|
|
1963
1964
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1964
|
-
return
|
|
1965
|
+
return zn({}, {
|
|
1965
1966
|
access_token: K(e.access_token),
|
|
1966
1967
|
refresh_token: K(e.refresh_token),
|
|
1967
1968
|
id_token: K(e.id_token),
|
|
1968
1969
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1969
1970
|
});
|
|
1970
1971
|
}
|
|
1971
|
-
function
|
|
1972
|
-
if (!
|
|
1972
|
+
function Vn(e) {
|
|
1973
|
+
if (!Rn(e)) return null;
|
|
1973
1974
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1974
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1975
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Ln(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : zn({
|
|
1975
1976
|
kind: t,
|
|
1976
1977
|
attempt: n,
|
|
1977
1978
|
nextAt: r,
|
|
1978
1979
|
strikes: i
|
|
1979
1980
|
}, {
|
|
1980
1981
|
from: K(e.from),
|
|
1981
|
-
failingSince:
|
|
1982
|
+
failingSince: Ln(e.failingSince)
|
|
1982
1983
|
});
|
|
1983
1984
|
}
|
|
1984
|
-
function
|
|
1985
|
-
return
|
|
1985
|
+
function Hn(e) {
|
|
1986
|
+
return zn({}, {
|
|
1986
1987
|
fp: K(e.fp),
|
|
1987
1988
|
sub: K(e.sub),
|
|
1988
1989
|
sid: K(e.sid),
|
|
1989
|
-
iat:
|
|
1990
|
+
iat: Ln(e.iat)
|
|
1990
1991
|
});
|
|
1991
1992
|
}
|
|
1992
|
-
function
|
|
1993
|
-
if (!
|
|
1993
|
+
function Un(e) {
|
|
1994
|
+
if (!Rn(e)) return null;
|
|
1994
1995
|
let t = e;
|
|
1995
1996
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1996
1997
|
let n = K(t.tabId);
|
|
1997
1998
|
if (!n) return null;
|
|
1998
1999
|
switch (t.type) {
|
|
1999
2000
|
case "tokens-refreshed": {
|
|
2000
|
-
let e =
|
|
2001
|
-
return !e || !r || !i ? null :
|
|
2001
|
+
let e = Bn(t.tokens), r = K(t.from), i = K(t.to);
|
|
2002
|
+
return !e || !r || !i ? null : zn({
|
|
2002
2003
|
type: t.type,
|
|
2003
2004
|
tabId: n,
|
|
2004
2005
|
tokens: e,
|
|
2005
2006
|
from: r,
|
|
2006
2007
|
to: i
|
|
2007
2008
|
}, {
|
|
2008
|
-
fromIat:
|
|
2009
|
+
fromIat: Ln(t.fromIat),
|
|
2009
2010
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
2010
|
-
sentAt:
|
|
2011
|
+
sentAt: Ln(t.sentAt)
|
|
2011
2012
|
});
|
|
2012
2013
|
}
|
|
2013
2014
|
case "session-refreshed": {
|
|
2014
|
-
let e =
|
|
2015
|
-
return e === void 0 ? null :
|
|
2015
|
+
let e = Ln(t.at);
|
|
2016
|
+
return e === void 0 ? null : zn({
|
|
2016
2017
|
type: t.type,
|
|
2017
2018
|
tabId: n,
|
|
2018
2019
|
at: e
|
|
2019
2020
|
}, { sub: K(t.sub) });
|
|
2020
2021
|
}
|
|
2021
2022
|
case "still-refreshing": {
|
|
2022
|
-
let e = t.retry === void 0 ? null :
|
|
2023
|
+
let e = t.retry === void 0 ? null : Vn(t.retry);
|
|
2023
2024
|
return e ? {
|
|
2024
2025
|
type: t.type,
|
|
2025
2026
|
tabId: n,
|
|
@@ -2030,7 +2031,7 @@ function zn(e) {
|
|
|
2030
2031
|
};
|
|
2031
2032
|
}
|
|
2032
2033
|
case "retry-scheduled": {
|
|
2033
|
-
let e =
|
|
2034
|
+
let e = Vn(t);
|
|
2034
2035
|
return e ? {
|
|
2035
2036
|
type: t.type,
|
|
2036
2037
|
tabId: n,
|
|
@@ -2051,10 +2052,10 @@ function zn(e) {
|
|
|
2051
2052
|
case "signed-out": return {
|
|
2052
2053
|
type: t.type,
|
|
2053
2054
|
tabId: n,
|
|
2054
|
-
...
|
|
2055
|
+
...Hn(t)
|
|
2055
2056
|
};
|
|
2056
2057
|
case "rate-limited": {
|
|
2057
|
-
let e =
|
|
2058
|
+
let e = Ln(t.until);
|
|
2058
2059
|
return e === void 0 ? null : {
|
|
2059
2060
|
type: t.type,
|
|
2060
2061
|
tabId: n,
|
|
@@ -2073,22 +2074,22 @@ function zn(e) {
|
|
|
2073
2074
|
default: return null;
|
|
2074
2075
|
}
|
|
2075
2076
|
}
|
|
2076
|
-
function
|
|
2077
|
+
function Wn(e, t) {
|
|
2077
2078
|
let n = {
|
|
2078
2079
|
v: 1,
|
|
2079
2080
|
tabId: e
|
|
2080
2081
|
};
|
|
2081
2082
|
if (t.type === "retry-scheduled") {
|
|
2082
2083
|
let { retry: e, ...r } = t;
|
|
2083
|
-
return
|
|
2084
|
+
return zn(n, {
|
|
2084
2085
|
...r,
|
|
2085
2086
|
...e
|
|
2086
2087
|
});
|
|
2087
2088
|
}
|
|
2088
|
-
return
|
|
2089
|
+
return zn(n, { ...t });
|
|
2089
2090
|
}
|
|
2090
2091
|
// lib/refresh/resolve.ts
|
|
2091
|
-
var
|
|
2092
|
+
var Gn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Kn = {
|
|
2092
2093
|
now: () => Date.now(),
|
|
2093
2094
|
random: () => Math.random(),
|
|
2094
2095
|
setTimeout: (e, t) => {
|
|
@@ -2096,28 +2097,28 @@ var Vn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
2096
2097
|
return n.unref?.(), () => clearTimeout(n);
|
|
2097
2098
|
}
|
|
2098
2099
|
};
|
|
2099
|
-
function
|
|
2100
|
+
function qn() {
|
|
2100
2101
|
let e = globalThis.crypto;
|
|
2101
2102
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
2102
2103
|
}
|
|
2103
|
-
function
|
|
2104
|
+
function Jn(e) {
|
|
2104
2105
|
return e ? {
|
|
2105
2106
|
now: () => e.now(),
|
|
2106
2107
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
2107
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
2108
|
-
} :
|
|
2108
|
+
random: e.random ? () => e.random?.() ?? Math.random() : Kn.random
|
|
2109
|
+
} : Kn;
|
|
2109
2110
|
}
|
|
2110
|
-
function
|
|
2111
|
+
function Yn(e) {
|
|
2111
2112
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
2112
2113
|
}
|
|
2113
|
-
function
|
|
2114
|
+
function Xn(e) {
|
|
2114
2115
|
try {
|
|
2115
2116
|
return e.storageSharedAcrossTabs === !0;
|
|
2116
2117
|
} catch {
|
|
2117
2118
|
return !1;
|
|
2118
2119
|
}
|
|
2119
2120
|
}
|
|
2120
|
-
function
|
|
2121
|
+
function Zn() {
|
|
2121
2122
|
try {
|
|
2122
2123
|
let e = globalThis.navigator?.locks;
|
|
2123
2124
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -2125,7 +2126,7 @@ function qn() {
|
|
|
2125
2126
|
return;
|
|
2126
2127
|
}
|
|
2127
2128
|
}
|
|
2128
|
-
function
|
|
2129
|
+
function Qn(e) {
|
|
2129
2130
|
return (t) => {
|
|
2130
2131
|
let n = (n) => {
|
|
2131
2132
|
let r = n.key;
|
|
@@ -2134,20 +2135,20 @@ function Jn(e) {
|
|
|
2134
2135
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
2135
2136
|
};
|
|
2136
2137
|
}
|
|
2137
|
-
function
|
|
2138
|
+
function $n(e) {
|
|
2138
2139
|
return {
|
|
2139
2140
|
transports: null,
|
|
2140
|
-
names:
|
|
2141
|
-
clock:
|
|
2141
|
+
names: In(e),
|
|
2142
|
+
clock: Kn,
|
|
2142
2143
|
warnOnFirstCycle: !1
|
|
2143
2144
|
};
|
|
2144
2145
|
}
|
|
2145
|
-
function
|
|
2146
|
-
let i =
|
|
2146
|
+
function er(e, t, n, r) {
|
|
2147
|
+
let i = In(n), a = Yn(t), o = a ? Qn(r.tokenKeys) : void 0, s = (e) => {
|
|
2147
2148
|
let t = {
|
|
2148
2149
|
transports: null,
|
|
2149
2150
|
names: i,
|
|
2150
|
-
clock:
|
|
2151
|
+
clock: Kn,
|
|
2151
2152
|
warnOnFirstCycle: e
|
|
2152
2153
|
};
|
|
2153
2154
|
return o && (t.onStorageChange = o), t;
|
|
@@ -2157,16 +2158,16 @@ function Xn(e, t, n, r) {
|
|
|
2157
2158
|
transports: {
|
|
2158
2159
|
locks: e.locks,
|
|
2159
2160
|
channel: e.channel,
|
|
2160
|
-
tabId: e.tabId ??
|
|
2161
|
+
tabId: e.tabId ?? qn()
|
|
2161
2162
|
},
|
|
2162
2163
|
names: i,
|
|
2163
|
-
clock:
|
|
2164
|
+
clock: Jn(e.clock),
|
|
2164
2165
|
warnOnFirstCycle: !1
|
|
2165
2166
|
};
|
|
2166
2167
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
2167
2168
|
}
|
|
2168
|
-
if (e === "none" || !a || !
|
|
2169
|
-
let c =
|
|
2169
|
+
if (e === "none" || !a || !Xn(t)) return s(!1);
|
|
2170
|
+
let c = Zn();
|
|
2170
2171
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
2171
2172
|
let l;
|
|
2172
2173
|
try {
|
|
@@ -2178,16 +2179,16 @@ function Xn(e, t, n, r) {
|
|
|
2178
2179
|
transports: {
|
|
2179
2180
|
locks: c,
|
|
2180
2181
|
channel: l,
|
|
2181
|
-
tabId:
|
|
2182
|
+
tabId: qn()
|
|
2182
2183
|
},
|
|
2183
2184
|
names: i,
|
|
2184
|
-
clock:
|
|
2185
|
+
clock: Kn,
|
|
2185
2186
|
warnOnFirstCycle: !1
|
|
2186
2187
|
};
|
|
2187
2188
|
return o && (u.onStorageChange = o), u;
|
|
2188
2189
|
}
|
|
2189
2190
|
// lib/services/logger.ts
|
|
2190
|
-
var
|
|
2191
|
+
var tr = class {
|
|
2191
2192
|
error(e, ...t) {
|
|
2192
2193
|
console.error(e, ...t);
|
|
2193
2194
|
}
|
|
@@ -2201,10 +2202,10 @@ var Zn = class {
|
|
|
2201
2202
|
console.debug(e, ...t);
|
|
2202
2203
|
}
|
|
2203
2204
|
};
|
|
2204
|
-
function
|
|
2205
|
-
return new
|
|
2205
|
+
function nr() {
|
|
2206
|
+
return new tr();
|
|
2206
2207
|
}
|
|
2207
|
-
var
|
|
2208
|
+
var rr = Object.freeze([
|
|
2208
2209
|
"error.token.invalid.error",
|
|
2209
2210
|
"error.api.token.parse.error",
|
|
2210
2211
|
"error.api.user.blocked",
|
|
@@ -2212,25 +2213,25 @@ var $n = Object.freeze([
|
|
|
2212
2213
|
"error.validation.token.invalid.subject",
|
|
2213
2214
|
"error.not.found"
|
|
2214
2215
|
]);
|
|
2215
|
-
function
|
|
2216
|
+
function ir(e) {
|
|
2216
2217
|
if (typeof e != "object" || !e) return;
|
|
2217
2218
|
let t = e;
|
|
2218
2219
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
2219
2220
|
}
|
|
2220
|
-
function
|
|
2221
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2221
|
+
function ar(e, t) {
|
|
2222
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(On, Math.floor(e) * 1e3);
|
|
2222
2223
|
if (typeof e != "string") return;
|
|
2223
2224
|
let n = e.trim();
|
|
2224
2225
|
if (n === "") return;
|
|
2225
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2226
|
+
if (/^\d+$/.test(n)) return Math.min(On, Number.parseInt(n, 10) * 1e3);
|
|
2226
2227
|
if (!/[a-z]/i.test(n)) return;
|
|
2227
2228
|
let r = Date.parse(n);
|
|
2228
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2229
|
+
if (!Number.isNaN(r)) return Math.min(On, Math.max(0, r - t));
|
|
2229
2230
|
}
|
|
2230
|
-
function
|
|
2231
|
+
function or(e) {
|
|
2231
2232
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
2232
2233
|
}
|
|
2233
|
-
function
|
|
2234
|
+
function sr(e) {
|
|
2234
2235
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
2235
2236
|
let t = e.response?.data;
|
|
2236
2237
|
if (typeof t != "object" || !t) return;
|
|
@@ -2239,14 +2240,14 @@ function rr(e) {
|
|
|
2239
2240
|
let r = n.id;
|
|
2240
2241
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2241
2242
|
}
|
|
2242
|
-
function
|
|
2243
|
+
function cr(e, t = Date.now()) {
|
|
2243
2244
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2244
|
-
let n = e, r =
|
|
2245
|
+
let n = e, r = sr(n), i = or(n.response?.status) ?? or(n.status), a = {};
|
|
2245
2246
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2246
2247
|
kind: "blocked",
|
|
2247
2248
|
...a
|
|
2248
2249
|
};
|
|
2249
|
-
if (r !== void 0 &&
|
|
2250
|
+
if (r !== void 0 && rr.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2250
2251
|
kind: "auth",
|
|
2251
2252
|
...a
|
|
2252
2253
|
};
|
|
@@ -2254,7 +2255,7 @@ function ir(e, t = Date.now()) {
|
|
|
2254
2255
|
kind: "transient",
|
|
2255
2256
|
...a
|
|
2256
2257
|
};
|
|
2257
|
-
let o =
|
|
2258
|
+
let o = ar(n.retryAfter ?? ir(n.response?.headers), t);
|
|
2258
2259
|
return o === void 0 ? {
|
|
2259
2260
|
kind: "transient",
|
|
2260
2261
|
...a
|
|
@@ -2264,19 +2265,19 @@ function ir(e, t = Date.now()) {
|
|
|
2264
2265
|
retryAfterMs: o
|
|
2265
2266
|
};
|
|
2266
2267
|
}
|
|
2267
|
-
function
|
|
2268
|
-
let r =
|
|
2269
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2268
|
+
function lr(e, t, n) {
|
|
2269
|
+
let r = En.length, i = En[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? En[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Dn * a);
|
|
2270
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), On) : 0);
|
|
2270
2271
|
}
|
|
2271
2272
|
// lib/refresh/coordinator.ts
|
|
2272
|
-
var
|
|
2273
|
+
var ur = {
|
|
2273
2274
|
onGranted: () => !1,
|
|
2274
2275
|
onLockLost: () => void 0,
|
|
2275
2276
|
onMessage: () => void 0
|
|
2276
2277
|
};
|
|
2277
|
-
function
|
|
2278
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2279
|
-
g || n.postMessage(
|
|
2278
|
+
function dr(e) {
|
|
2279
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = ur, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2280
|
+
g || n.postMessage(Wn(r, e));
|
|
2280
2281
|
}, v = () => s !== null && c === null, y = () => {
|
|
2281
2282
|
f?.(), f = null;
|
|
2282
2283
|
}, b = (e) => {
|
|
@@ -2291,7 +2292,7 @@ function sr(e) {
|
|
|
2291
2292
|
type: "still-refreshing",
|
|
2292
2293
|
retry: m
|
|
2293
2294
|
} : { type: "still-refreshing" }), S());
|
|
2294
|
-
},
|
|
2295
|
+
}, kn);
|
|
2295
2296
|
}, C = () => {
|
|
2296
2297
|
y(), x(), u?.(), u = null;
|
|
2297
2298
|
let e = s;
|
|
@@ -2342,7 +2343,7 @@ function sr(e) {
|
|
|
2342
2343
|
});
|
|
2343
2344
|
}, ee = (e) => {
|
|
2344
2345
|
if (g) return;
|
|
2345
|
-
let t =
|
|
2346
|
+
let t = Un(e.data);
|
|
2346
2347
|
if (t && t.tabId !== r) {
|
|
2347
2348
|
switch (t.type) {
|
|
2348
2349
|
case "still-refreshing":
|
|
@@ -2385,8 +2386,8 @@ function sr(e) {
|
|
|
2385
2386
|
}
|
|
2386
2387
|
};
|
|
2387
2388
|
}
|
|
2388
|
-
function
|
|
2389
|
-
let t =
|
|
2389
|
+
function fr(e = "local") {
|
|
2390
|
+
let t = ur, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2390
2391
|
n = !1, r = !1, i += 1;
|
|
2391
2392
|
};
|
|
2392
2393
|
return {
|
|
@@ -2434,7 +2435,7 @@ var q = {
|
|
|
2434
2435
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2435
2436
|
identityChanged: "error.refresh.identity_changed",
|
|
2436
2437
|
disposed: "error.refresh.disposed"
|
|
2437
|
-
},
|
|
2438
|
+
}, pr = {
|
|
2438
2439
|
"error.refresh.unavailable": 503,
|
|
2439
2440
|
"error.refresh.auth_retry": 401,
|
|
2440
2441
|
"error.refresh.session_ended": 401,
|
|
@@ -2442,7 +2443,7 @@ var q = {
|
|
|
2442
2443
|
"error.refresh.successor_timeout": 401,
|
|
2443
2444
|
"error.refresh.identity_changed": 401,
|
|
2444
2445
|
"error.refresh.disposed": 499
|
|
2445
|
-
},
|
|
2446
|
+
}, mr = {
|
|
2446
2447
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2447
2448
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2448
2449
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2454,19 +2455,19 @@ var q = {
|
|
|
2454
2455
|
constructor(e, t = {}) {
|
|
2455
2456
|
super({
|
|
2456
2457
|
id: e,
|
|
2457
|
-
message: t.message ??
|
|
2458
|
-
status:
|
|
2458
|
+
message: t.message ?? mr[e],
|
|
2459
|
+
status: pr[e],
|
|
2459
2460
|
location: "/auth/refresh",
|
|
2460
2461
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2461
2462
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2462
2463
|
}
|
|
2463
|
-
},
|
|
2464
|
+
}, hr = class extends Error {
|
|
2464
2465
|
constructor(e, t) {
|
|
2465
2466
|
super(t ?? (e === "lock-timeout" ? "Step-up commit could not take the refresh lock in time" : "Step-up commit answer arrived after the stored session moved on")), this.name = "UpgradeCommitInterruptedError", this.reason = e;
|
|
2466
2467
|
}
|
|
2467
2468
|
};
|
|
2468
2469
|
// lib/refresh/lineage.ts
|
|
2469
|
-
function
|
|
2470
|
+
function gr(e) {
|
|
2470
2471
|
if (!e) return;
|
|
2471
2472
|
let t = 3735928559, n = 1103547991;
|
|
2472
2473
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2475,24 +2476,24 @@ function fr(e) {
|
|
|
2475
2476
|
}
|
|
2476
2477
|
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
|
|
2477
2478
|
}
|
|
2478
|
-
function
|
|
2479
|
+
function _r(e) {
|
|
2479
2480
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2480
2481
|
}
|
|
2481
2482
|
function Y(e) {
|
|
2482
|
-
let t =
|
|
2483
|
+
let t = gr(e);
|
|
2483
2484
|
if (!e || !t) return;
|
|
2484
2485
|
let n = {};
|
|
2485
2486
|
try {
|
|
2486
2487
|
let t = j(e);
|
|
2487
2488
|
typeof t == "object" && t && (n = t);
|
|
2488
2489
|
} catch {}
|
|
2489
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2490
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = _r(n.sub), o = _r(n.sid);
|
|
2490
2491
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2491
2492
|
}
|
|
2492
|
-
var
|
|
2493
|
-
function
|
|
2493
|
+
var vr = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2494
|
+
function yr(e = (e) => nr().warn(e)) {
|
|
2494
2495
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2495
|
-
a || (a = !0, e(
|
|
2496
|
+
a || (a = !0, e(vr));
|
|
2496
2497
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2497
2498
|
if (!e) return;
|
|
2498
2499
|
if (e.iat === void 0) {
|
|
@@ -2533,16 +2534,16 @@ function hr(e = (e) => Qn().warn(e)) {
|
|
|
2533
2534
|
};
|
|
2534
2535
|
}
|
|
2535
2536
|
// lib/refresh/fence.ts
|
|
2536
|
-
var
|
|
2537
|
+
var br = class extends Error {
|
|
2537
2538
|
constructor(e) {
|
|
2538
2539
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2539
2540
|
}
|
|
2540
|
-
},
|
|
2541
|
+
}, xr = class extends Error {
|
|
2541
2542
|
constructor() {
|
|
2542
2543
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2543
2544
|
}
|
|
2544
2545
|
};
|
|
2545
|
-
function
|
|
2546
|
+
function Sr(e) {
|
|
2546
2547
|
if (e) try {
|
|
2547
2548
|
let t = j(e).sub;
|
|
2548
2549
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2551,20 +2552,20 @@ function vr(e) {
|
|
|
2551
2552
|
}
|
|
2552
2553
|
}
|
|
2553
2554
|
function X(e) {
|
|
2554
|
-
return
|
|
2555
|
+
return Sr(e?.access_token) ?? Sr(e?.refresh_token) ?? Sr(e?.id_token);
|
|
2555
2556
|
}
|
|
2556
|
-
function
|
|
2557
|
+
function Cr(e, t) {
|
|
2557
2558
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2558
2559
|
}
|
|
2559
|
-
function
|
|
2560
|
+
function wr(e) {
|
|
2560
2561
|
return typeof e == "object" && !!e;
|
|
2561
2562
|
}
|
|
2562
|
-
function
|
|
2563
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2563
|
+
function Tr(e) {
|
|
2564
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => nr().warn(e)), o = e.lineage ?? yr(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2564
2565
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2565
2566
|
if (!n) return p = l, e;
|
|
2566
2567
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2567
|
-
let r =
|
|
2568
|
+
let r = gr(n) ?? "";
|
|
2568
2569
|
return r !== c?.fp && (c = {
|
|
2569
2570
|
fp: r,
|
|
2570
2571
|
seq: l
|
|
@@ -2597,7 +2598,7 @@ function xr(e) {
|
|
|
2597
2598
|
let t = E();
|
|
2598
2599
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2599
2600
|
h = void 0, y()?.refresh_token ? P() : O(!0) === "end" && s?.("emptied");
|
|
2600
|
-
},
|
|
2601
|
+
}, Mn));
|
|
2601
2602
|
let n = t === "keep" ? T() : void 0;
|
|
2602
2603
|
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;
|
|
2603
2604
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2610,7 +2611,7 @@ function xr(e) {
|
|
|
2610
2611
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2611
2612
|
}, j = (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), M = (e) => {
|
|
2612
2613
|
let t = b();
|
|
2613
|
-
t && t.fp !==
|
|
2614
|
+
t && t.fp !== gr(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2614
2615
|
}, N = (e) => {
|
|
2615
2616
|
let t = y(), n = t?.refresh_token;
|
|
2616
2617
|
if (n === e.refreshToken) return null;
|
|
@@ -2621,7 +2622,7 @@ function xr(e) {
|
|
|
2621
2622
|
kind: "superseded",
|
|
2622
2623
|
adopted: !1
|
|
2623
2624
|
};
|
|
2624
|
-
let r =
|
|
2625
|
+
let r = Sr(t.access_token) ?? Sr(n);
|
|
2625
2626
|
if (e.sub && r && e.sub !== r) return {
|
|
2626
2627
|
kind: "identity-changed",
|
|
2627
2628
|
saved: !1
|
|
@@ -2661,22 +2662,22 @@ function xr(e) {
|
|
|
2661
2662
|
}, ne = !!s || !!e.onStoredSessionSeen, re = ne && e.onStorageChange ? e.onStorageChange(P) : void 0, ie = ne && e.onWake ? e.onWake(P) : void 0, F = () => {
|
|
2662
2663
|
let e = y();
|
|
2663
2664
|
if (!e?.refresh_token) {
|
|
2664
|
-
if (O() === "end") throw new
|
|
2665
|
+
if (O() === "end") throw new br("emptied");
|
|
2665
2666
|
return "held";
|
|
2666
2667
|
}
|
|
2667
2668
|
let t = n.getTokens();
|
|
2668
2669
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2669
2670
|
let r = i() ?? X(t), a = X(e);
|
|
2670
|
-
if (r && a && r !== a) throw new
|
|
2671
|
+
if (r && a && r !== a) throw new xr();
|
|
2671
2672
|
let s = Y(e.refresh_token);
|
|
2672
2673
|
if (o.isEnded(s)) {
|
|
2673
2674
|
if (s && C(s)) return "held";
|
|
2674
|
-
throw new
|
|
2675
|
+
throw new br("ended");
|
|
2675
2676
|
}
|
|
2676
2677
|
let c = Y(t?.refresh_token);
|
|
2677
2678
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2678
2679
|
}, ae = (e) => {
|
|
2679
|
-
let t = i(), r =
|
|
2680
|
+
let t = i(), r = Sr(e);
|
|
2680
2681
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2681
2682
|
let a = Y(e) ?? { fp: e };
|
|
2682
2683
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2684,7 +2685,7 @@ function xr(e) {
|
|
|
2684
2685
|
let s = {
|
|
2685
2686
|
refreshToken: e,
|
|
2686
2687
|
order: a
|
|
2687
|
-
}, c = t ?? r ??
|
|
2688
|
+
}, c = t ?? r ?? Sr(n.getTokens()?.access_token);
|
|
2688
2689
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2689
2690
|
kind: "send",
|
|
2690
2691
|
sent: s
|
|
@@ -2693,7 +2694,7 @@ function xr(e) {
|
|
|
2693
2694
|
if (o.isEnded(e.order)) return te(e.order);
|
|
2694
2695
|
let i = N(e);
|
|
2695
2696
|
if (i) return i;
|
|
2696
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2697
|
+
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${gr(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.`), {
|
|
2697
2698
|
kind: "superseded",
|
|
2698
2699
|
adopted: !1
|
|
2699
2700
|
};
|
|
@@ -2703,7 +2704,7 @@ function xr(e) {
|
|
|
2703
2704
|
saved: !0
|
|
2704
2705
|
};
|
|
2705
2706
|
let c = Y(r.refresh_token);
|
|
2706
|
-
return c && (
|
|
2707
|
+
return c && (Cr(c, e.order) || Cr(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
|
|
2707
2708
|
kind: "superseded",
|
|
2708
2709
|
adopted: !1
|
|
2709
2710
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2715,7 +2716,7 @@ function xr(e) {
|
|
|
2715
2716
|
kind: "superseded",
|
|
2716
2717
|
adopted: !1
|
|
2717
2718
|
};
|
|
2718
|
-
let r =
|
|
2719
|
+
let r = cr(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2719
2720
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2720
2721
|
kind: "own",
|
|
2721
2722
|
failure: r,
|
|
@@ -2725,12 +2726,12 @@ function xr(e) {
|
|
|
2725
2726
|
failure: r,
|
|
2726
2727
|
heldRefused: !1
|
|
2727
2728
|
});
|
|
2728
|
-
},
|
|
2729
|
-
if (!
|
|
2729
|
+
}, L = (e) => {
|
|
2730
|
+
if (!wr(e)) return !1;
|
|
2730
2731
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2731
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2732
|
+
if (typeof t != "string" || typeof c != "string" || !wr(l)) return !1;
|
|
2732
2733
|
let u = l;
|
|
2733
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2734
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || gr(u.refresh_token) !== c) return !1;
|
|
2734
2735
|
let d = y();
|
|
2735
2736
|
if (!d?.refresh_token) return !1;
|
|
2736
2737
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2747,20 +2748,20 @@ function xr(e) {
|
|
|
2747
2748
|
}
|
|
2748
2749
|
return !0;
|
|
2749
2750
|
};
|
|
2750
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2751
|
-
},
|
|
2751
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && gr(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2752
|
+
}, R = (e) => {
|
|
2752
2753
|
if (!e || !_) return !1;
|
|
2753
2754
|
let t = _;
|
|
2754
2755
|
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);
|
|
2755
|
-
},
|
|
2756
|
+
}, se = () => {
|
|
2756
2757
|
let e = b();
|
|
2757
2758
|
if (!e) return !1;
|
|
2758
|
-
if (
|
|
2759
|
+
if (R(e)) return !0;
|
|
2759
2760
|
let t = y(), r = Y(t?.refresh_token);
|
|
2760
|
-
if (!t || !r || r.fp === e.fp || !
|
|
2761
|
+
if (!t || !r || r.fp === e.fp || !R(r) || !j(r, e)) return !1;
|
|
2761
2762
|
let a = i() ?? X(n.getTokens()), o = X(t);
|
|
2762
2763
|
return a && o && a !== o ? (s?.("identity-changed"), !1) : (M(t), !0);
|
|
2763
|
-
},
|
|
2764
|
+
}, ce = (e) => {
|
|
2764
2765
|
let t = Y(e?.refresh_token), n = {}, r = i() ?? X(e);
|
|
2765
2766
|
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;
|
|
2766
2767
|
};
|
|
@@ -2770,8 +2771,8 @@ function xr(e) {
|
|
|
2770
2771
|
beginSend: ae,
|
|
2771
2772
|
commitSave: oe,
|
|
2772
2773
|
judgeFailure: I,
|
|
2773
|
-
adoptTokens:
|
|
2774
|
-
adoptSuccessor:
|
|
2774
|
+
adoptTokens: L,
|
|
2775
|
+
adoptSuccessor: se,
|
|
2775
2776
|
beginHeldSend: () => {
|
|
2776
2777
|
let e = Y(y()?.refresh_token);
|
|
2777
2778
|
if (!e || o.isRetired(e) || o.isEnded(e)) return v = void 0, !1;
|
|
@@ -2796,8 +2797,8 @@ function xr(e) {
|
|
|
2796
2797
|
seq: l
|
|
2797
2798
|
}), u.length > 4 && u.shift()), b() && n && O() === "end" && s?.("emptied");
|
|
2798
2799
|
},
|
|
2799
|
-
session: () =>
|
|
2800
|
-
storedSession: () =>
|
|
2800
|
+
session: () => ce(n.getTokens()),
|
|
2801
|
+
storedSession: () => ce(y()),
|
|
2801
2802
|
dropSession: () => {
|
|
2802
2803
|
n.setTokensCache(void 0), n.stopTokenCheck?.();
|
|
2803
2804
|
},
|
|
@@ -2813,7 +2814,7 @@ function xr(e) {
|
|
|
2813
2814
|
};
|
|
2814
2815
|
}
|
|
2815
2816
|
// lib/refresh/controller.ts
|
|
2816
|
-
function
|
|
2817
|
+
function Er() {
|
|
2817
2818
|
let e, t, n = new Promise((n, r) => {
|
|
2818
2819
|
e = n, t = r;
|
|
2819
2820
|
});
|
|
@@ -2823,7 +2824,7 @@ function Sr() {
|
|
|
2823
2824
|
reject: t
|
|
2824
2825
|
};
|
|
2825
2826
|
}
|
|
2826
|
-
var
|
|
2827
|
+
var Dr = {
|
|
2827
2828
|
strikes: q.sessionEnded,
|
|
2828
2829
|
"session-ended": q.sessionEnded,
|
|
2829
2830
|
"stored-ended": q.sessionEnded,
|
|
@@ -2834,72 +2835,72 @@ var Cr = {
|
|
|
2834
2835
|
"identity-changed": q.identityChanged,
|
|
2835
2836
|
disposed: q.disposed
|
|
2836
2837
|
};
|
|
2837
|
-
function
|
|
2838
|
+
function Or(e) {
|
|
2838
2839
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2839
2840
|
}
|
|
2840
|
-
function
|
|
2841
|
+
function kr(e) {
|
|
2841
2842
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2842
2843
|
let t = Math.floor(e);
|
|
2843
2844
|
return t >= 1 ? t : 3;
|
|
2844
2845
|
}
|
|
2845
|
-
function
|
|
2846
|
+
function Ar(e, t) {
|
|
2846
2847
|
return e instanceof Error && e.message ? e.message : t;
|
|
2847
2848
|
}
|
|
2848
|
-
function
|
|
2849
|
+
function jr(e) {
|
|
2849
2850
|
if (typeof e != "object" || !e) return;
|
|
2850
2851
|
let t = e.id;
|
|
2851
2852
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2852
2853
|
}
|
|
2853
|
-
function
|
|
2854
|
+
function Mr(e) {
|
|
2854
2855
|
let t = {};
|
|
2855
2856
|
return e?.access_token && (t.access_token = e.access_token), e?.refresh_token && (t.refresh_token = e.refresh_token), e?.id_token && (t.id_token = e.id_token), e?.scopes && (t.scopes = [...e.scopes]), t;
|
|
2856
2857
|
}
|
|
2857
|
-
function
|
|
2858
|
+
function Nr(e, t) {
|
|
2858
2859
|
let n = {};
|
|
2859
2860
|
e.access_token && (n.access_token = e.access_token), e.refresh_token && (n.refresh_token = e.refresh_token), e.id_token && (n.id_token = e.id_token);
|
|
2860
2861
|
let r = t?.scopes ?? e.scopes;
|
|
2861
2862
|
return r && (n.scopes = r), n;
|
|
2862
2863
|
}
|
|
2863
|
-
function
|
|
2864
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2864
|
+
function Pr(e) {
|
|
2865
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? nr(), c = kr(e.strikes), l = a.transports ? dr({
|
|
2865
2866
|
locks: a.transports.locks,
|
|
2866
2867
|
channel: a.transports.channel,
|
|
2867
2868
|
tabId: a.transports.tabId,
|
|
2868
2869
|
names: a.names,
|
|
2869
2870
|
clock: o
|
|
2870
|
-
}) :
|
|
2871
|
+
}) : fr(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => gr(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
|
|
2871
2872
|
for (let t of Array.from(e)) t();
|
|
2872
|
-
}, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P =
|
|
2873
|
+
}, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P = Tr({
|
|
2873
2874
|
storage: n,
|
|
2874
2875
|
cache: r,
|
|
2875
2876
|
identity: k,
|
|
2876
2877
|
schedule: (e, t) => o.setTimeout(e, t),
|
|
2877
2878
|
onStorageChange: (e) => (A.add(e), () => A.delete(e)),
|
|
2878
2879
|
onWake: (e) => (j.add(e), () => j.delete(e)),
|
|
2879
|
-
onSessionLost: (e) =>
|
|
2880
|
+
onSessionLost: (e) => fe(e),
|
|
2880
2881
|
onStoredSessionSeen: () => {
|
|
2881
|
-
u.kind === "blocked-wait" &&
|
|
2882
|
+
u.kind === "blocked-wait" && ke();
|
|
2882
2883
|
},
|
|
2883
2884
|
warn: (e) => s.warn(e)
|
|
2884
2885
|
}), ne = (e) => ({
|
|
2885
2886
|
trigger: e,
|
|
2886
2887
|
startedAt: T(),
|
|
2887
|
-
plain:
|
|
2888
|
+
plain: Er(),
|
|
2888
2889
|
fresh: []
|
|
2889
2890
|
}), re = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ie = (e, t) => {
|
|
2890
2891
|
if (t === void 0) return e.plain.promise;
|
|
2891
2892
|
let n = {
|
|
2892
2893
|
callTime: t,
|
|
2893
|
-
deferred:
|
|
2894
|
+
deferred: Er()
|
|
2894
2895
|
};
|
|
2895
2896
|
return e.fresh.push(n), n.deferred.promise;
|
|
2896
2897
|
}, F = (e, t, n = !1) => {
|
|
2897
2898
|
e.plain.resolve(O());
|
|
2898
|
-
for (let r of e.fresh) n || t !== void 0 && t >= r.callTime ? r.deferred.resolve(O()) :
|
|
2899
|
+
for (let r of e.fresh) n || t !== void 0 && t >= r.callTime ? r.deferred.resolve(O()) : V("refresh-token", r.callTime).then(r.deferred.resolve, r.deferred.reject);
|
|
2899
2900
|
e.fresh = [];
|
|
2900
2901
|
}, ae = (e, t, n) => {
|
|
2901
2902
|
e.plain.reject(t);
|
|
2902
|
-
for (let r of e.fresh) n !== void 0 && n < r.callTime ?
|
|
2903
|
+
for (let r of e.fresh) n !== void 0 && n < r.callTime ? V("refresh-token", r.callTime).then(r.deferred.resolve, r.deferred.reject) : r.deferred.reject(t);
|
|
2903
2904
|
e.fresh = [];
|
|
2904
2905
|
}, oe = (e, t) => {
|
|
2905
2906
|
if (e) {
|
|
@@ -2909,13 +2910,13 @@ function Ar(e) {
|
|
|
2909
2910
|
}
|
|
2910
2911
|
}, I = (e, n, r, i) => {
|
|
2911
2912
|
let a = {
|
|
2912
|
-
message:
|
|
2913
|
+
message: Ar(r, "Token refresh failed"),
|
|
2913
2914
|
originalError: r,
|
|
2914
2915
|
operation: e,
|
|
2915
2916
|
source: n
|
|
2916
|
-
}, o =
|
|
2917
|
+
}, o = jr(r);
|
|
2917
2918
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2918
|
-
},
|
|
2919
|
+
}, L = (e, t) => {
|
|
2919
2920
|
let n = {
|
|
2920
2921
|
classification: e,
|
|
2921
2922
|
willRetry: t !== void 0,
|
|
@@ -2923,7 +2924,7 @@ function Ar(e) {
|
|
|
2923
2924
|
maxStrikes: c
|
|
2924
2925
|
};
|
|
2925
2926
|
return t !== void 0 && (n.nextRetryAt = t), n;
|
|
2926
|
-
},
|
|
2927
|
+
}, R = (e, n) => {
|
|
2927
2928
|
if (u.kind === "refreshing" && (u.request.outcome = !0), m = 0, h = 0, g = void 0, v = void 0, l.setRetryInfo(void 0), r.tokenExpiredFlag !== void 0 && (r.tokenExpiredFlag = !1), r.startTokenCheck?.(), t("refresh", {
|
|
2928
2929
|
tokens: r.getTokens(),
|
|
2929
2930
|
source: e
|
|
@@ -2934,7 +2935,7 @@ function Ar(e) {
|
|
|
2934
2935
|
origin: n
|
|
2935
2936
|
});
|
|
2936
2937
|
}
|
|
2937
|
-
},
|
|
2938
|
+
}, se = (e, n, r) => {
|
|
2938
2939
|
if (_) return;
|
|
2939
2940
|
_ = { since: e };
|
|
2940
2941
|
let i = {
|
|
@@ -2942,25 +2943,25 @@ function Ar(e) {
|
|
|
2942
2943
|
origin: r
|
|
2943
2944
|
};
|
|
2944
2945
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2945
|
-
},
|
|
2946
|
-
let n = r.getTokens(), i =
|
|
2946
|
+
}, ce = (e, t) => {
|
|
2947
|
+
let n = r.getTokens(), i = gr(n?.refresh_token);
|
|
2947
2948
|
e.fp && i && l.post({
|
|
2948
2949
|
type: "tokens-refreshed",
|
|
2949
|
-
tokens:
|
|
2950
|
+
tokens: Mr(n),
|
|
2950
2951
|
from: e.fp,
|
|
2951
2952
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2952
2953
|
fromSid: e.sid ?? "",
|
|
2953
2954
|
to: i,
|
|
2954
2955
|
...t === void 0 ? {} : { sentAt: t }
|
|
2955
2956
|
});
|
|
2956
|
-
},
|
|
2957
|
-
p || (p = !0, s.warn(
|
|
2958
|
-
},
|
|
2957
|
+
}, le = () => {
|
|
2958
|
+
p || (p = !0, s.warn(Gn));
|
|
2959
|
+
}, ue = (e) => {
|
|
2959
2960
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2960
|
-
},
|
|
2961
|
+
}, z = (e, n) => {
|
|
2961
2962
|
if (u.kind === "ended") return;
|
|
2962
2963
|
let r = re(u);
|
|
2963
|
-
|
|
2964
|
+
ue(u);
|
|
2964
2965
|
let a = P.session(), o = k();
|
|
2965
2966
|
switch (d += 1, m = 0, h = 0, g = void 0, _ = void 0, v = void 0, l.setRetryInfo(void 0), w || l.release(), b = {
|
|
2966
2967
|
...a,
|
|
@@ -2968,7 +2969,7 @@ function Ar(e) {
|
|
|
2968
2969
|
}, e !== "disposed" && P.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2969
2970
|
kind: "ended",
|
|
2970
2971
|
cause: e
|
|
2971
|
-
}, oe(r, n ?? new J(
|
|
2972
|
+
}, oe(r, n ?? new J(Dr[e])), e) {
|
|
2972
2973
|
case "strikes":
|
|
2973
2974
|
t("session:expired", {
|
|
2974
2975
|
reason: "refresh_failed",
|
|
@@ -3003,9 +3004,9 @@ function Ar(e) {
|
|
|
3003
3004
|
break;
|
|
3004
3005
|
case "signed-out-here":
|
|
3005
3006
|
case "disposed": break;
|
|
3006
|
-
default:
|
|
3007
|
+
default: Or(e);
|
|
3007
3008
|
}
|
|
3008
|
-
},
|
|
3009
|
+
}, de = () => {
|
|
3009
3010
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
3010
3011
|
let e = n.getTokens(), i = Y(e?.refresh_token);
|
|
3011
3012
|
if (!e?.refresh_token || !e.access_token || !i || P.lineage.isEnded(i) || P.lineage.isRetired(i)) return;
|
|
@@ -3017,13 +3018,13 @@ function Ar(e) {
|
|
|
3017
3018
|
tokens: s,
|
|
3018
3019
|
origin: "other-tab"
|
|
3019
3020
|
});
|
|
3021
|
+
}, fe = (e) => {
|
|
3022
|
+
u.kind === "ended" || f || E() === "json" && (z(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && de());
|
|
3020
3023
|
}, pe = (e) => {
|
|
3021
|
-
|
|
3022
|
-
}, me = (
|
|
3023
|
-
e instanceof _r ? (R("identity-changed"), fe()) : e instanceof gr ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
3024
|
-
}, he = () => {
|
|
3024
|
+
e instanceof xr ? (z("identity-changed"), de()) : e instanceof br ? z(e.cause === "emptied" ? "emptied" : "stored-ended") : z("stored-ended", e);
|
|
3025
|
+
}, me = () => {
|
|
3025
3026
|
u = { kind: "idle" }, w || l.release();
|
|
3026
|
-
},
|
|
3027
|
+
}, he = (e) => !e.from || E() !== "json" || e.from === D() || e.from === gr(n.getTokens()?.refresh_token), ge = (e) => {
|
|
3027
3028
|
let t = g;
|
|
3028
3029
|
if (!t) return;
|
|
3029
3030
|
if (!l.holding) {
|
|
@@ -3040,10 +3041,10 @@ function Ar(e) {
|
|
|
3040
3041
|
pending: e,
|
|
3041
3042
|
dueAt: r,
|
|
3042
3043
|
cancel: o.setTimeout(() => {
|
|
3043
|
-
n === d &&
|
|
3044
|
+
n === d && _e();
|
|
3044
3045
|
}, Math.max(0, r - T()))
|
|
3045
3046
|
};
|
|
3046
|
-
},
|
|
3047
|
+
}, _e = () => {
|
|
3047
3048
|
if (u.kind !== "backoff" || w) return;
|
|
3048
3049
|
let { pending: e, dueAt: t } = u;
|
|
3049
3050
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
@@ -3052,18 +3053,18 @@ function Ar(e) {
|
|
|
3052
3053
|
}, l.request((g?.nextAt ?? T()) + G)) : (u = {
|
|
3053
3054
|
kind: "waiting",
|
|
3054
3055
|
pending: e
|
|
3055
|
-
},
|
|
3056
|
-
},
|
|
3056
|
+
}, ye() || ve());
|
|
3057
|
+
}, ve = () => {
|
|
3057
3058
|
u.kind === "idle" && l.release();
|
|
3058
|
-
},
|
|
3059
|
+
}, ye = () => {
|
|
3059
3060
|
if (u.kind !== "waiting") return !1;
|
|
3060
3061
|
let e = u.pending;
|
|
3061
|
-
if (E() !== "json") return
|
|
3062
|
+
if (E() !== "json") return be(e);
|
|
3062
3063
|
let t = P.session(), n;
|
|
3063
3064
|
try {
|
|
3064
3065
|
n = P.checkStoredBeforeSend();
|
|
3065
3066
|
} catch (e) {
|
|
3066
|
-
return
|
|
3067
|
+
return pe(e), !1;
|
|
3067
3068
|
}
|
|
3068
3069
|
if (n === "held") {
|
|
3069
3070
|
let t = D();
|
|
@@ -3073,30 +3074,30 @@ function Ar(e) {
|
|
|
3073
3074
|
}), u = { kind: "idle" }, F(e, void 0, !0), !1) : (v = {
|
|
3074
3075
|
fp: t,
|
|
3075
3076
|
at: T()
|
|
3076
|
-
}, P.beginHeldSend() ?
|
|
3077
|
+
}, P.beginHeldSend() ? xe(e, "held") : (u = { kind: "idle" }, F(e, void 0, !0), !1));
|
|
3077
3078
|
}
|
|
3078
3079
|
if (v = void 0, n === "adopted") {
|
|
3079
|
-
if (
|
|
3080
|
+
if (R("adopted", "other-tab"), ce(t), e.fresh.length === 0) return u = { kind: "idle" }, F(e, void 0), !1;
|
|
3080
3081
|
e.plain.resolve(O());
|
|
3081
3082
|
}
|
|
3082
|
-
return g && !
|
|
3083
|
-
},
|
|
3083
|
+
return g && !he(g) && (g = void 0), g && g.nextAt > T() ? (m = g.attempt, h = g.strikes, g.failingSince !== void 0 && se(g.failingSince, g.nextAt, "other-tab"), ge(e), !0) : (g && (m = g.attempt, h = g.strikes), xe(e, e.trigger === "held" ? "refresh-token" : e.trigger));
|
|
3084
|
+
}, be = (e) => y !== void 0 && y >= e.startedAt ? (r.setTokensCache(n.getTokens()), R("adopted", "other-tab"), u = { kind: "idle" }, F(e, y), !1) : g && g.nextAt > T() ? (m = g.attempt, h = g.strikes, ge(e), !0) : Se(e, e.trigger, void 0, void 0), xe = (e, t) => {
|
|
3084
3085
|
let r = n.getTokens(), i = r?.refresh_token;
|
|
3085
3086
|
if (!i) return u = { kind: "idle" }, F(e, void 0, !0), !1;
|
|
3086
3087
|
let a = P.beginSend(i);
|
|
3087
3088
|
switch (a.kind) {
|
|
3088
|
-
case "superseded": return P.endHeldSend(),
|
|
3089
|
-
case "ended": return P.endHeldSend(),
|
|
3090
|
-
case "identity-changed": return P.endHeldSend(),
|
|
3091
|
-
case "send": return
|
|
3092
|
-
default: return
|
|
3089
|
+
case "superseded": return P.endHeldSend(), R("adopted", "other-tab"), u = { kind: "idle" }, F(e, void 0), !1;
|
|
3090
|
+
case "ended": return P.endHeldSend(), z("stored-ended"), !1;
|
|
3091
|
+
case "identity-changed": return P.endHeldSend(), z("identity-changed"), de(), !1;
|
|
3092
|
+
case "send": return Se(e, t, a.sent, r);
|
|
3093
|
+
default: return Or(a);
|
|
3093
3094
|
}
|
|
3094
|
-
},
|
|
3095
|
+
}, Se = (e, n, r, a) => {
|
|
3095
3096
|
let o = {
|
|
3096
3097
|
generation: d,
|
|
3097
3098
|
sentAt: T(),
|
|
3098
3099
|
trigger: n,
|
|
3099
|
-
settled:
|
|
3100
|
+
settled: Er()
|
|
3100
3101
|
};
|
|
3101
3102
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
3102
3103
|
kind: "refreshing",
|
|
@@ -3110,31 +3111,31 @@ function Ar(e) {
|
|
|
3110
3111
|
c = Promise.reject(e);
|
|
3111
3112
|
}
|
|
3112
3113
|
return c.then((e) => {
|
|
3113
|
-
|
|
3114
|
+
we(o, e).catch((e) => s.error("[passflow] Applying a refresh result failed", e)).finally(() => o.settled.resolve());
|
|
3114
3115
|
}, (e) => {
|
|
3115
|
-
|
|
3116
|
+
Te(o, e), o.settled.resolve();
|
|
3116
3117
|
}), !0;
|
|
3117
|
-
},
|
|
3118
|
-
if (e.sent?.held && P.endHeldSend(), !
|
|
3118
|
+
}, Ce = (e) => !f && e.generation === d && u.kind === "refreshing" && u.request === e, we = async (e, t) => {
|
|
3119
|
+
if (e.sent?.held && P.endHeldSend(), !Ce(e) || u.kind !== "refreshing") return;
|
|
3119
3120
|
let { pending: a } = u;
|
|
3120
3121
|
if (!e.sent) {
|
|
3121
3122
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
3122
3123
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
3123
3124
|
let t = new J(q.identityChanged);
|
|
3124
|
-
I("refresh", e.trigger, t,
|
|
3125
|
+
I("refresh", e.trigger, t, L("auth")), z("identity-changed", t);
|
|
3125
3126
|
return;
|
|
3126
3127
|
}
|
|
3127
3128
|
try {
|
|
3128
3129
|
await i.applyOpaque(t);
|
|
3129
3130
|
} catch (t) {
|
|
3130
|
-
|
|
3131
|
+
Te(e, t);
|
|
3131
3132
|
return;
|
|
3132
3133
|
}
|
|
3133
|
-
if (!
|
|
3134
|
+
if (!Ce(e)) return;
|
|
3134
3135
|
r.setTokensCache({
|
|
3135
3136
|
...n.getTokens() ?? {},
|
|
3136
|
-
...
|
|
3137
|
-
}),
|
|
3137
|
+
...Nr(t, void 0)
|
|
3138
|
+
}), R("refresh", "this-tab");
|
|
3138
3139
|
let c = k();
|
|
3139
3140
|
l.post(c === void 0 ? {
|
|
3140
3141
|
type: "session-refreshed",
|
|
@@ -3143,70 +3144,70 @@ function Ar(e) {
|
|
|
3143
3144
|
type: "session-refreshed",
|
|
3144
3145
|
at: T(),
|
|
3145
3146
|
sub: c
|
|
3146
|
-
}),
|
|
3147
|
+
}), me(), F(a, e.sentAt);
|
|
3147
3148
|
return;
|
|
3148
3149
|
}
|
|
3149
|
-
let o = D(), s = P.commitSave(e.sent,
|
|
3150
|
+
let o = D(), s = P.commitSave(e.sent, Nr(t, e.stored));
|
|
3150
3151
|
switch (s.kind) {
|
|
3151
3152
|
case "saved":
|
|
3152
|
-
|
|
3153
|
+
R("refresh", "this-tab"), ce(e.sent.order, e.sentAt), me(), F(a, e.sentAt);
|
|
3153
3154
|
return;
|
|
3154
3155
|
case "superseded":
|
|
3155
|
-
e.outcome && D() === o ||
|
|
3156
|
+
e.outcome && D() === o || R("adopted", "other-tab"), s.adopted && ce(e.sent.order), me(), F(a, e.sentAt);
|
|
3156
3157
|
return;
|
|
3157
3158
|
case "ended": {
|
|
3158
3159
|
let t = new J(s.cause === "emptied" ? q.signedOut : q.sessionEnded);
|
|
3159
|
-
I("refresh", e.trigger, t,
|
|
3160
|
+
I("refresh", e.trigger, t, L("auth")), z(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
3160
3161
|
return;
|
|
3161
3162
|
}
|
|
3162
3163
|
case "identity-changed": {
|
|
3163
3164
|
let t = new J(q.identityChanged);
|
|
3164
|
-
I("refresh", e.trigger, t,
|
|
3165
|
+
I("refresh", e.trigger, t, L("auth")), z("identity-changed", t), de();
|
|
3165
3166
|
return;
|
|
3166
3167
|
}
|
|
3167
|
-
default:
|
|
3168
|
+
default: Or(s);
|
|
3168
3169
|
}
|
|
3169
|
-
},
|
|
3170
|
-
if (e.sent?.held && P.endHeldSend(), !
|
|
3170
|
+
}, Te = (e, t) => {
|
|
3171
|
+
if (e.sent?.held && P.endHeldSend(), !Ce(e) || u.kind !== "refreshing") return;
|
|
3171
3172
|
let { pending: n } = u, r, i = !1;
|
|
3172
3173
|
if (e.sent) {
|
|
3173
3174
|
let a = D(), o = P.judgeFailure(e.sent, t);
|
|
3174
3175
|
switch (o.kind) {
|
|
3175
3176
|
case "superseded":
|
|
3176
|
-
e.outcome && D() === a ||
|
|
3177
|
+
e.outcome && D() === a || R("adopted", "other-tab"), me(), F(n, e.sentAt);
|
|
3177
3178
|
return;
|
|
3178
3179
|
case "ended":
|
|
3179
|
-
I("refresh", e.trigger, t,
|
|
3180
|
+
I("refresh", e.trigger, t, L("auth")), z(o.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
3180
3181
|
return;
|
|
3181
3182
|
case "identity-changed":
|
|
3182
|
-
I("refresh", e.trigger, t,
|
|
3183
|
+
I("refresh", e.trigger, t, L("auth")), z("identity-changed", t), de();
|
|
3183
3184
|
return;
|
|
3184
3185
|
case "own":
|
|
3185
3186
|
r = o.failure, i = o.heldRefused;
|
|
3186
3187
|
break;
|
|
3187
|
-
default:
|
|
3188
|
+
default: Or(o);
|
|
3188
3189
|
}
|
|
3189
|
-
} else r =
|
|
3190
|
-
if (i) I("refresh", e.trigger, t,
|
|
3190
|
+
} else r = cr(t, T());
|
|
3191
|
+
if (i) I("refresh", e.trigger, t, L(r.kind)), R("adopted", "other-tab"), me(), F(n, void 0, !0);
|
|
3191
3192
|
else switch (r.kind) {
|
|
3192
3193
|
case "blocked":
|
|
3193
|
-
I("refresh", e.trigger, t,
|
|
3194
|
+
I("refresh", e.trigger, t, L("blocked")), Oe(n, e.sentAt, t, e.marker);
|
|
3194
3195
|
return;
|
|
3195
3196
|
case "auth":
|
|
3196
3197
|
if (h += 1, m += 1, h >= c) {
|
|
3197
|
-
I("refresh", e.trigger, t,
|
|
3198
|
+
I("refresh", e.trigger, t, L("auth")), De(e, t);
|
|
3198
3199
|
return;
|
|
3199
3200
|
}
|
|
3200
|
-
|
|
3201
|
+
Ee(e, n, t, r);
|
|
3201
3202
|
return;
|
|
3202
3203
|
case "transient":
|
|
3203
|
-
m += 1,
|
|
3204
|
+
m += 1, Ee(e, n, t, r);
|
|
3204
3205
|
return;
|
|
3205
|
-
default:
|
|
3206
|
+
default: Or(r.kind);
|
|
3206
3207
|
}
|
|
3207
|
-
},
|
|
3208
|
-
let i = T() +
|
|
3209
|
-
I("refresh", e.trigger, n,
|
|
3208
|
+
}, Ee = (e, t, n, r) => {
|
|
3209
|
+
let i = T() + lr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3210
|
+
I("refresh", e.trigger, n, L(a, i)), a === "transient" && se(T(), i, "this-tab");
|
|
3210
3211
|
let s = {
|
|
3211
3212
|
kind: a,
|
|
3212
3213
|
attempt: m,
|
|
@@ -3215,10 +3216,10 @@ function Ar(e) {
|
|
|
3215
3216
|
}, c = e.sent?.order.fp;
|
|
3216
3217
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
3217
3218
|
type: "retry-scheduled",
|
|
3218
|
-
message:
|
|
3219
|
+
message: Ar(n, "Token refresh failed"),
|
|
3219
3220
|
retry: s
|
|
3220
|
-
}),
|
|
3221
|
-
},
|
|
3221
|
+
}), ge(ne("retry")), ae(t, n, e.sentAt);
|
|
3222
|
+
}, De = (e, t) => {
|
|
3222
3223
|
let n = e.sent?.sub ?? k(), r = e.sent?.order, i = {};
|
|
3223
3224
|
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({
|
|
3224
3225
|
type: "session-ended",
|
|
@@ -3226,10 +3227,10 @@ function Ar(e) {
|
|
|
3226
3227
|
}), i.fp && (x = i.fp, P.endLineage({
|
|
3227
3228
|
...i,
|
|
3228
3229
|
fp: i.fp
|
|
3229
|
-
})), r && P.deleteIfStillDead(r),
|
|
3230
|
-
},
|
|
3231
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
3232
|
-
let i = d, a = T() +
|
|
3230
|
+
})), r && P.deleteIfStillDead(r), z("strikes", t);
|
|
3231
|
+
}, Oe = (e, t, n, r) => {
|
|
3232
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Ar(n, "blocked")}`);
|
|
3233
|
+
let i = d, a = T() + An, c = {
|
|
3233
3234
|
kind: "blocked-wait",
|
|
3234
3235
|
pending: e,
|
|
3235
3236
|
deadline: a,
|
|
@@ -3237,15 +3238,15 @@ function Ar(e) {
|
|
|
3237
3238
|
cancel: () => void 0,
|
|
3238
3239
|
marker: r
|
|
3239
3240
|
};
|
|
3240
|
-
if (u = c,
|
|
3241
|
+
if (u = c, ke()) return;
|
|
3241
3242
|
let f = E() !== "json" && !l.coordinated && !e.cookieRetried, p = () => {
|
|
3242
|
-
i === d && u === c && (
|
|
3243
|
+
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
3243
3244
|
kind: "waiting",
|
|
3244
3245
|
pending: e
|
|
3245
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."),
|
|
3246
|
+
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), z("successor-timeout")) : c.cancel = o.setTimeout(p, jn)));
|
|
3246
3247
|
};
|
|
3247
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3248
|
-
},
|
|
3248
|
+
c.cancel = o.setTimeout(p, f ? Nn : jn);
|
|
3249
|
+
}, ke = () => {
|
|
3249
3250
|
if (u.kind !== "blocked-wait") return !1;
|
|
3250
3251
|
let e = u;
|
|
3251
3252
|
if (E() === "json") {
|
|
@@ -3255,29 +3256,29 @@ function Ar(e) {
|
|
|
3255
3256
|
if (!t && !a) return !1;
|
|
3256
3257
|
r.setTokensCache(n.getTokens());
|
|
3257
3258
|
}
|
|
3258
|
-
return u === e && (e.cancel(),
|
|
3259
|
-
},
|
|
3259
|
+
return u === e && (e.cancel(), R("adopted", "other-tab"), u = { kind: "idle" }, F(e.pending, void 0, !0), !0);
|
|
3260
|
+
}, Ae = (e) => {
|
|
3260
3261
|
let t = k(), n = !e.sub || !t || e.sub === t;
|
|
3261
3262
|
return E() === "json" ? !!e.fp && e.fp === D() && n : !e.fp && n;
|
|
3262
|
-
},
|
|
3263
|
+
}, je = (e, t) => {
|
|
3263
3264
|
if (e !== "signed-out" || !t.sub) return !1;
|
|
3264
3265
|
let n = k();
|
|
3265
3266
|
return n !== void 0 && t.sub === n;
|
|
3266
|
-
},
|
|
3267
|
-
if (u.kind === "ended" || !
|
|
3267
|
+
}, B = (e, t, n) => {
|
|
3268
|
+
if (u.kind === "ended" || !he(e)) return;
|
|
3268
3269
|
let r = g?.nextAt;
|
|
3269
|
-
if (g = e, e.failingSince !== void 0 &&
|
|
3270
|
+
if (g = e, e.failingSince !== void 0 && se(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
3270
3271
|
let i = new J(e.kind === "transient" ? q.unavailable : q.authRetry, {
|
|
3271
3272
|
nextRetryAt: e.nextAt,
|
|
3272
3273
|
cause: n || void 0
|
|
3273
3274
|
}), a = u.pending;
|
|
3274
3275
|
u.pending = ne(a.trigger), ae(a, i, r);
|
|
3275
3276
|
}, Me = (e, t) => {
|
|
3276
|
-
switch (t &&
|
|
3277
|
+
switch (t && R("adopted", "other-tab"), u.kind) {
|
|
3277
3278
|
case "waiting":
|
|
3278
3279
|
case "backoff": {
|
|
3279
3280
|
let t = u.pending;
|
|
3280
|
-
|
|
3281
|
+
ue(u), me(), F(t, e);
|
|
3281
3282
|
return;
|
|
3282
3283
|
}
|
|
3283
3284
|
case "blocked-wait": {
|
|
@@ -3288,21 +3289,21 @@ function Ar(e) {
|
|
|
3288
3289
|
case "idle":
|
|
3289
3290
|
case "refreshing":
|
|
3290
3291
|
case "ended": return;
|
|
3291
|
-
default:
|
|
3292
|
+
default: Or(u);
|
|
3292
3293
|
}
|
|
3293
|
-
},
|
|
3294
|
+
}, Ne = (e) => {
|
|
3294
3295
|
let t = {};
|
|
3295
3296
|
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);
|
|
3296
|
-
let n = u.kind !== "ended" && (
|
|
3297
|
+
let n = u.kind !== "ended" && (Ae(t) || je(e.type, t));
|
|
3297
3298
|
t.fp && P.endLineage({
|
|
3298
3299
|
...t,
|
|
3299
3300
|
fp: t.fp
|
|
3300
|
-
}), n &&
|
|
3301
|
-
},
|
|
3301
|
+
}), n && z(e.type === "signed-out" ? "signed-out" : "session-ended"), P.endedElsewhere(e.type, t);
|
|
3302
|
+
}, Pe = (e) => {
|
|
3302
3303
|
if (!f) switch (e.type) {
|
|
3303
3304
|
case "tokens-refreshed": {
|
|
3304
3305
|
if (u.kind === "ended") {
|
|
3305
|
-
|
|
3306
|
+
de();
|
|
3306
3307
|
return;
|
|
3307
3308
|
}
|
|
3308
3309
|
if (E() !== "json") return;
|
|
@@ -3318,21 +3319,21 @@ function Ar(e) {
|
|
|
3318
3319
|
let t = k();
|
|
3319
3320
|
if (e.sub && t && e.sub !== t || (y = Math.max(y ?? 0, e.at), u.kind === "refreshing")) return;
|
|
3320
3321
|
if (r.setTokensCache(n.getTokens()), g = void 0, u.kind === "blocked-wait") {
|
|
3321
|
-
|
|
3322
|
+
ke();
|
|
3322
3323
|
return;
|
|
3323
3324
|
}
|
|
3324
3325
|
Me(e.at, !0);
|
|
3325
3326
|
return;
|
|
3326
3327
|
}
|
|
3327
3328
|
case "still-refreshing":
|
|
3328
|
-
e.retry &&
|
|
3329
|
+
e.retry && B(e.retry, !1, ""), Fe();
|
|
3329
3330
|
return;
|
|
3330
3331
|
case "retry-scheduled":
|
|
3331
|
-
|
|
3332
|
+
B(e.retry, !0, e.message), Fe();
|
|
3332
3333
|
return;
|
|
3333
3334
|
case "refresh-failed":
|
|
3334
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3335
|
-
if (
|
|
3335
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== gr(n.getTokens()?.refresh_token)) return;
|
|
3336
|
+
if (se(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3336
3337
|
let t = u.pending;
|
|
3337
3338
|
u.pending = ne(t.trigger), ae(t, new J(q.unavailable, { cause: e.message }), void 0);
|
|
3338
3339
|
}
|
|
@@ -3348,13 +3349,13 @@ function Ar(e) {
|
|
|
3348
3349
|
return;
|
|
3349
3350
|
case "session-ended":
|
|
3350
3351
|
case "signed-out":
|
|
3351
|
-
|
|
3352
|
+
Ne(e);
|
|
3352
3353
|
return;
|
|
3353
3354
|
case "takeover":
|
|
3354
3355
|
case "rate-limited": return;
|
|
3355
|
-
default:
|
|
3356
|
+
default: Or(e);
|
|
3356
3357
|
}
|
|
3357
|
-
},
|
|
3358
|
+
}, Fe = () => {
|
|
3358
3359
|
C && !l.holding && l.post({
|
|
3359
3360
|
type: "lock-wanted",
|
|
3360
3361
|
purpose: C.purpose
|
|
@@ -3367,7 +3368,7 @@ function Ar(e) {
|
|
|
3367
3368
|
let e = C;
|
|
3368
3369
|
return C = void 0, e.granted(), !0;
|
|
3369
3370
|
}
|
|
3370
|
-
return u.kind === "waiting" &&
|
|
3371
|
+
return u.kind === "waiting" && ye();
|
|
3371
3372
|
},
|
|
3372
3373
|
onLockLost: () => {
|
|
3373
3374
|
if (u.kind === "backoff") {
|
|
@@ -3378,16 +3379,16 @@ function Ar(e) {
|
|
|
3378
3379
|
}, l.request((g?.nextAt ?? T()) + G);
|
|
3379
3380
|
}
|
|
3380
3381
|
},
|
|
3381
|
-
onMessage:
|
|
3382
|
+
onMessage: Pe
|
|
3382
3383
|
});
|
|
3383
|
-
let
|
|
3384
|
+
let Ie = () => {
|
|
3384
3385
|
if (f) return;
|
|
3385
3386
|
if (u.kind === "ended") {
|
|
3386
|
-
|
|
3387
|
+
de();
|
|
3387
3388
|
return;
|
|
3388
3389
|
}
|
|
3389
3390
|
if (u.kind === "blocked-wait" && E() !== "json") {
|
|
3390
|
-
|
|
3391
|
+
ke();
|
|
3391
3392
|
return;
|
|
3392
3393
|
}
|
|
3393
3394
|
if (u.kind !== "idle" || E() !== "json" || w) return;
|
|
@@ -3397,10 +3398,10 @@ function Ar(e) {
|
|
|
3397
3398
|
} catch {
|
|
3398
3399
|
return;
|
|
3399
3400
|
}
|
|
3400
|
-
|
|
3401
|
+
R("adopted", "other-tab"), l.coordinated && ce(e);
|
|
3401
3402
|
};
|
|
3402
|
-
A.add(
|
|
3403
|
-
let
|
|
3403
|
+
A.add(Ie), j.add(Ie);
|
|
3404
|
+
let V = (e, t) => {
|
|
3404
3405
|
if (f) return Promise.reject(new J(q.disposed));
|
|
3405
3406
|
switch (u.kind) {
|
|
3406
3407
|
case "ended": return Promise.reject(new J(q.sessionEnded));
|
|
@@ -3411,17 +3412,17 @@ function Ar(e) {
|
|
|
3411
3412
|
pending: n
|
|
3412
3413
|
};
|
|
3413
3414
|
let r = ie(n, t);
|
|
3414
|
-
return l.holding && !w ?
|
|
3415
|
+
return l.holding && !w ? ye() || ve() : l.request(g ? g.nextAt + G : void 0), r;
|
|
3415
3416
|
}
|
|
3416
3417
|
case "waiting":
|
|
3417
3418
|
case "refreshing":
|
|
3418
3419
|
case "backoff":
|
|
3419
3420
|
case "blocked-wait": return ie(u.pending, t);
|
|
3420
|
-
default: return
|
|
3421
|
+
default: return Or(u);
|
|
3421
3422
|
}
|
|
3422
3423
|
}, Le = (e) => {
|
|
3423
3424
|
if (f) return Promise.reject(new J(q.disposed));
|
|
3424
|
-
if (
|
|
3425
|
+
if (le(), u.kind === "ended") return Promise.reject(new J(q.sessionEnded));
|
|
3425
3426
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3426
3427
|
let t = n.getTokens();
|
|
3427
3428
|
if (!t?.refresh_token) {
|
|
@@ -3429,7 +3430,7 @@ function Ar(e) {
|
|
|
3429
3430
|
return I("refresh", e.trigger, n), Promise.reject(n);
|
|
3430
3431
|
}
|
|
3431
3432
|
}
|
|
3432
|
-
return
|
|
3433
|
+
return V(e.trigger, e.fresh ? T() : void 0);
|
|
3433
3434
|
}, Re = (e) => {
|
|
3434
3435
|
if (f) return Promise.reject(new J(q.disposed));
|
|
3435
3436
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
@@ -3459,18 +3460,18 @@ function Ar(e) {
|
|
|
3459
3460
|
});
|
|
3460
3461
|
}, Ve = () => {
|
|
3461
3462
|
if (w = !1, !f && l.holding) {
|
|
3462
|
-
if (u.kind === "waiting")
|
|
3463
|
+
if (u.kind === "waiting") ye() || ve();
|
|
3463
3464
|
else if (u.kind === "backoff") {
|
|
3464
3465
|
let e = u.pending;
|
|
3465
|
-
u.cancel(),
|
|
3466
|
-
} else u.kind === "idle" && g && g.nextAt > T() &&
|
|
3466
|
+
u.cancel(), ge(e);
|
|
3467
|
+
} else u.kind === "idle" && g && g.nextAt > T() && he(g) ? (m = g.attempt, h = g.strikes, ge(ne("retry"))) : u.kind === "idle" && l.release();
|
|
3467
3468
|
}
|
|
3468
3469
|
}, He = async (e, t) => {
|
|
3469
3470
|
if (f) throw new J(q.disposed);
|
|
3470
|
-
|
|
3471
|
-
let n = T() +
|
|
3471
|
+
le();
|
|
3472
|
+
let n = T() + Pn;
|
|
3472
3473
|
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3473
|
-
let e = new
|
|
3474
|
+
let e = new hr("lock-timeout");
|
|
3474
3475
|
throw I("upgrade.commit", "upgrade", e), e;
|
|
3475
3476
|
}
|
|
3476
3477
|
w = !0;
|
|
@@ -3484,7 +3485,7 @@ function Ar(e) {
|
|
|
3484
3485
|
if (E() === "json") {
|
|
3485
3486
|
let e = P.session();
|
|
3486
3487
|
try {
|
|
3487
|
-
P.checkStoredBeforeSend() === "adopted" && (
|
|
3488
|
+
P.checkStoredBeforeSend() === "adopted" && (R("adopted", "other-tab"), ce(e));
|
|
3488
3489
|
} catch {}
|
|
3489
3490
|
s = n.getTokens();
|
|
3490
3491
|
let t = s?.refresh_token;
|
|
@@ -3517,7 +3518,7 @@ function Ar(e) {
|
|
|
3517
3518
|
if (!o) {
|
|
3518
3519
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3519
3520
|
...n.getTokens() ?? {},
|
|
3520
|
-
...
|
|
3521
|
+
...Nr(u, void 0)
|
|
3521
3522
|
}), We(c);
|
|
3522
3523
|
let e = k();
|
|
3523
3524
|
return l.post(e === void 0 ? {
|
|
@@ -3529,14 +3530,14 @@ function Ar(e) {
|
|
|
3529
3530
|
sub: e
|
|
3530
3531
|
}), O();
|
|
3531
3532
|
}
|
|
3532
|
-
let d = P.commitSave(o,
|
|
3533
|
-
if (d.kind === "saved") return We(c),
|
|
3534
|
-
let f = new
|
|
3535
|
-
throw I("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted &&
|
|
3533
|
+
let d = P.commitSave(o, Nr(u, s));
|
|
3534
|
+
if (d.kind === "saved") return We(c), ce(o.order, c), O();
|
|
3535
|
+
let f = new hr("superseded");
|
|
3536
|
+
throw I("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && R("adopted", "other-tab"), f;
|
|
3536
3537
|
}, We = (e) => {
|
|
3537
|
-
if (
|
|
3538
|
+
if (R("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
3538
3539
|
let t = u.pending;
|
|
3539
|
-
|
|
3540
|
+
ue(u), u = { kind: "idle" }, F(t, e);
|
|
3540
3541
|
}
|
|
3541
3542
|
}, Ge = () => {
|
|
3542
3543
|
let e = P.storedSession(), t = e.fp ? e : P.session();
|
|
@@ -3549,7 +3550,7 @@ function Ar(e) {
|
|
|
3549
3550
|
}));
|
|
3550
3551
|
}, Ke = () => {
|
|
3551
3552
|
let e = re(u);
|
|
3552
|
-
oe(e, new J(q.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (
|
|
3553
|
+
oe(e, new J(q.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (ue(u), u = { kind: "idle" });
|
|
3553
3554
|
};
|
|
3554
3555
|
return {
|
|
3555
3556
|
refresh: Le,
|
|
@@ -3557,12 +3558,12 @@ function Ar(e) {
|
|
|
3557
3558
|
commitUpgrade: He,
|
|
3558
3559
|
signOut: async (e) => {
|
|
3559
3560
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3560
|
-
let t = T() +
|
|
3561
|
+
let t = T() + Fn;
|
|
3561
3562
|
Ke(), await Be(t - T()), Ke(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3562
3563
|
try {
|
|
3563
3564
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3564
3565
|
} finally {
|
|
3565
|
-
u.kind !== "ended" &&
|
|
3566
|
+
u.kind !== "ended" && z("signed-out-here"), x = void 0, l.release();
|
|
3566
3567
|
}
|
|
3567
3568
|
},
|
|
3568
3569
|
signOutNow: (e) => {
|
|
@@ -3571,13 +3572,13 @@ function Ar(e) {
|
|
|
3571
3572
|
try {
|
|
3572
3573
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3573
3574
|
} finally {
|
|
3574
|
-
u.kind !== "ended" &&
|
|
3575
|
+
u.kind !== "ended" && z("signed-out-here"), x = void 0;
|
|
3575
3576
|
}
|
|
3576
3577
|
},
|
|
3577
3578
|
sessionStarted: () => {
|
|
3578
3579
|
if (f) return;
|
|
3579
3580
|
let e = re(u);
|
|
3580
|
-
|
|
3581
|
+
ue(u), d += 1, m = 0, h = 0, g = void 0, _ = void 0, v = void 0, b = void 0, x = void 0, S = void 0, l.setRetryInfo(void 0), u = { kind: "idle" }, w || l.release(), e && F(e, void 0, !0);
|
|
3581
3582
|
},
|
|
3582
3583
|
identity: k,
|
|
3583
3584
|
get coordinated() {
|
|
@@ -3592,7 +3593,7 @@ function Ar(e) {
|
|
|
3592
3593
|
dispose: () => {
|
|
3593
3594
|
if (f) return;
|
|
3594
3595
|
let e = re(u);
|
|
3595
|
-
|
|
3596
|
+
ue(u), f = !0, d += 1, u = {
|
|
3596
3597
|
kind: "ended",
|
|
3597
3598
|
cause: "disposed"
|
|
3598
3599
|
}, oe(e, new J(q.disposed)), C = void 0, P.stop(), l.dispose(), N?.(), te?.();
|
|
@@ -3602,7 +3603,7 @@ function Ar(e) {
|
|
|
3602
3603
|
// lib/store.ts
|
|
3603
3604
|
var Z = /* @__PURE__ */ function(e) {
|
|
3604
3605
|
return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", e.EmailVerificationRequired = "email-verification:required", e.SignOut = "signout", e.SessionRestored = "session:restored", e.SessionExpired = "session:expired", e.Error = "error", e.Refresh = "refresh", e.RefreshStart = "refresh:start", e.TokenCacheExpired = "token-cache-expired", e.TwoFactorRequired = "2fa:required", e.TwoFactorSetupStarted = "2fa:setup_started", e.TwoFactorEnabled = "2fa:enabled", e.TwoFactorDisabled = "2fa:disabled", e.TwoFactorVerified = "2fa:verified", e.TwoFactorRecoveryUsed = "2fa:recovery_used", e.TwoFactorRecoveryCodesLow = "2fa:recovery_low", e.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", e.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", e.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", e.TwoFactorChallengeReceived = "two_factor_challenge_received", e.TwoFactorMethodSwitched = "two_factor_method_switched", e.TwoFactorDeviceTrusted = "two_factor_device_trusted", e.RefreshFailing = "refresh:failing", e.RefreshRecovered = "refresh:recovered", e;
|
|
3605
|
-
}({}),
|
|
3606
|
+
}({}), Fr = class {
|
|
3606
3607
|
constructor() {
|
|
3607
3608
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3608
3609
|
}
|
|
@@ -3621,14 +3622,14 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3621
3622
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3622
3623
|
}
|
|
3623
3624
|
notify(e, t) {
|
|
3624
|
-
e === "error" &&
|
|
3625
|
+
e === "error" && Sn(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3625
3626
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3626
3627
|
});
|
|
3627
3628
|
}
|
|
3628
3629
|
notifyError(e) {
|
|
3629
3630
|
return W(this, e);
|
|
3630
3631
|
}
|
|
3631
|
-
},
|
|
3632
|
+
}, Ir = {
|
|
3632
3633
|
ES256: {
|
|
3633
3634
|
kty: "EC",
|
|
3634
3635
|
key: (e) => ({
|
|
@@ -3659,34 +3660,34 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3659
3660
|
},
|
|
3660
3661
|
signature: { name: "RSASSA-PKCS1-v1_5" }
|
|
3661
3662
|
}
|
|
3662
|
-
},
|
|
3663
|
+
}, Lr = (e) => {
|
|
3663
3664
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
|
|
3664
3665
|
return Uint8Array.from(n, (e) => e.charCodeAt(0));
|
|
3665
|
-
},
|
|
3666
|
+
}, Rr = () => {
|
|
3666
3667
|
let e = globalThis.crypto;
|
|
3667
3668
|
if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
|
|
3668
3669
|
return e;
|
|
3669
3670
|
};
|
|
3670
|
-
async function
|
|
3671
|
-
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(
|
|
3671
|
+
async function zr(e, t, n, r, i) {
|
|
3672
|
+
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(Lr(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Ir[c.alg] : void 0;
|
|
3672
3673
|
if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
|
|
3673
3674
|
let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
|
|
3674
3675
|
if (!u) throw Error("Token signing key is not published by the server");
|
|
3675
|
-
let d =
|
|
3676
|
-
if (!await d.verify(l.signature, f,
|
|
3676
|
+
let d = Rr().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
|
|
3677
|
+
if (!await d.verify(l.signature, f, Lr(s), p)) throw Error("Token signature is not valid");
|
|
3677
3678
|
let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
|
|
3678
3679
|
if (m.iss !== n) throw Error("Token issuer does not match the server");
|
|
3679
3680
|
if (!h.includes(r)) throw Error("Token is not issued for this app");
|
|
3680
3681
|
if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
|
|
3681
3682
|
if (i && m.type !== i) throw Error("Token type is not valid");
|
|
3682
3683
|
}
|
|
3683
|
-
async function
|
|
3684
|
+
async function Br(t, n, r) {
|
|
3684
3685
|
if (!n) throw Error("An app id is required to accept tokens from the URL");
|
|
3685
3686
|
if (!r.access_token) throw Error("No access token received");
|
|
3686
|
-
|
|
3687
|
+
Rr();
|
|
3687
3688
|
let i = t.replace(/\/+$/, ""), [a, o] = await Promise.all([e.get(`${i}/.well-known/openid-configuration`), e.get(`${i}/.well-known/jwks.json`)]), s = a.data?.issuer, c = o.data?.keys ?? [];
|
|
3688
3689
|
if (!s) throw Error("The server did not publish an issuer");
|
|
3689
|
-
await
|
|
3690
|
+
await zr(r.access_token, c, s, n, M.access_token), r.refresh_token && await zr(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await zr(r.id_token, c, s, n);
|
|
3690
3691
|
}
|
|
3691
3692
|
// lib/upgrade/errors.ts
|
|
3692
3693
|
var Q = {
|
|
@@ -3703,18 +3704,18 @@ var Q = {
|
|
|
3703
3704
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3704
3705
|
notImplemented: "error.not.implemented",
|
|
3705
3706
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3706
|
-
},
|
|
3707
|
+
}, Vr = Object.freeze([
|
|
3707
3708
|
Q.twoFactorCodeInvalid,
|
|
3708
3709
|
Q.twoFactorNotEnabled,
|
|
3709
3710
|
Q.challengeInvalid,
|
|
3710
3711
|
Q.challengeSessionMismatch,
|
|
3711
3712
|
Q.challengeTooManyAttempts
|
|
3712
|
-
]),
|
|
3713
|
+
]), Hr = Object.freeze([Q.tokenInvalid]), Ur = Object.freeze([
|
|
3713
3714
|
"wrong_code",
|
|
3714
3715
|
"challenge_spent",
|
|
3715
3716
|
"not_registered",
|
|
3716
3717
|
"prepare_not_required"
|
|
3717
|
-
]),
|
|
3718
|
+
]), Wr = (e) => Ur.includes(e), Gr = {
|
|
3718
3719
|
wrong_code: "That code was not accepted. Try again.",
|
|
3719
3720
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3720
3721
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3729,9 +3730,9 @@ var Q = {
|
|
|
3729
3730
|
session_changed: "The session ended during verification."
|
|
3730
3731
|
}, $ = class extends Error {
|
|
3731
3732
|
constructor(e) {
|
|
3732
|
-
super(e.message ||
|
|
3733
|
+
super(e.message || Gr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, e.retryAfter !== void 0 && (this.retryAfter = e.retryAfter), this.retryable = Wr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3733
3734
|
}
|
|
3734
|
-
},
|
|
3735
|
+
}, Kr = Object.freeze([
|
|
3735
3736
|
"upgrade_transport",
|
|
3736
3737
|
"upgrade_insufficient",
|
|
3737
3738
|
"upgrade_unavailable",
|
|
@@ -3739,14 +3740,14 @@ var Q = {
|
|
|
3739
3740
|
"upgrade_cancelled",
|
|
3740
3741
|
"upgrade_unsatisfiable",
|
|
3741
3742
|
"upgrade_sign_in_required"
|
|
3742
|
-
]),
|
|
3743
|
+
]), qr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Kr.includes(e.code), Jr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Yr = (e) => {
|
|
3743
3744
|
let t = e?.error, n = typeof t == "string" ? t : t?.message;
|
|
3744
3745
|
if (typeof n == "string" && n && !n.startsWith("localized error:")) return n;
|
|
3745
|
-
},
|
|
3746
|
+
}, Xr = (e) => {
|
|
3746
3747
|
if (!e || typeof e != "object") return;
|
|
3747
3748
|
let t = e["retry-after"];
|
|
3748
3749
|
return typeof t == "string" && /^\d+$/.test(t.trim()) ? Number(t.trim()) : void 0;
|
|
3749
|
-
},
|
|
3750
|
+
}, Zr = (e) => {
|
|
3750
3751
|
if (typeof e != "object" || !e) return {
|
|
3751
3752
|
hasResponse: !1,
|
|
3752
3753
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3757,10 +3758,10 @@ var Q = {
|
|
|
3757
3758
|
errorId: typeof t.id == "string" ? t.id : i,
|
|
3758
3759
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3759
3760
|
hasResponse: n !== void 0 || typeof t.status == "number",
|
|
3760
|
-
serverText:
|
|
3761
|
-
retryAfter:
|
|
3761
|
+
serverText: Yr(n?.data),
|
|
3762
|
+
retryAfter: Xr(n?.headers)
|
|
3762
3763
|
};
|
|
3763
|
-
},
|
|
3764
|
+
}, Qr = (e, t) => {
|
|
3764
3765
|
switch (e) {
|
|
3765
3766
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3766
3767
|
case Q.challengeInvalid:
|
|
@@ -3778,15 +3779,15 @@ var Q = {
|
|
|
3778
3779
|
case "error.service.unavailable": return "network";
|
|
3779
3780
|
default: return;
|
|
3780
3781
|
}
|
|
3781
|
-
},
|
|
3782
|
+
}, $r = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 429 ? "rate_limited" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", ei = (e, t) => {
|
|
3782
3783
|
if (e instanceof $) return e;
|
|
3783
|
-
let n =
|
|
3784
|
+
let n = Zr(e);
|
|
3784
3785
|
if (!n.hasResponse) return new $({
|
|
3785
3786
|
kind: "network",
|
|
3786
3787
|
message: n.message,
|
|
3787
3788
|
cause: e
|
|
3788
3789
|
});
|
|
3789
|
-
let r =
|
|
3790
|
+
let r = Qr(n.errorId, t) ?? $r(n.status, t);
|
|
3790
3791
|
return r === "rate_limited" ? new $({
|
|
3791
3792
|
kind: r,
|
|
3792
3793
|
message: n.serverText,
|
|
@@ -3801,60 +3802,60 @@ var Q = {
|
|
|
3801
3802
|
errorId: n.errorId,
|
|
3802
3803
|
cause: e
|
|
3803
3804
|
});
|
|
3804
|
-
},
|
|
3805
|
+
}, ti = (e) => e.errorId !== void 0 && Vr.includes(e.errorId), ni = (e) => e.errorId !== void 0 && Hr.includes(e.errorId), ri = class extends Error {
|
|
3805
3806
|
constructor(e, t, n) {
|
|
3806
3807
|
super(n ?? "The session was elevated, but this action requires a higher assurance level"), this.name = "UpgradeInsufficientError", this.code = "upgrade_insufficient", this.obtained = e, this.required = t;
|
|
3807
3808
|
}
|
|
3808
|
-
},
|
|
3809
|
+
}, ii = class extends Error {
|
|
3809
3810
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3810
3811
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3811
3812
|
}
|
|
3812
|
-
},
|
|
3813
|
+
}, ai = class extends Error {
|
|
3813
3814
|
constructor(e = "The session changed during verification") {
|
|
3814
3815
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3815
3816
|
}
|
|
3816
|
-
},
|
|
3817
|
+
}, oi = (e) => {
|
|
3817
3818
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3818
3819
|
sub: e.sub,
|
|
3819
3820
|
sid: e.sid
|
|
3820
3821
|
} : { sub: e.sub };
|
|
3821
|
-
},
|
|
3822
|
+
}, si = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3822
3823
|
// lib/utils/validation.ts
|
|
3823
|
-
function
|
|
3824
|
+
function ci(e) {
|
|
3824
3825
|
if (!e || typeof e != "string") return !1;
|
|
3825
3826
|
let t = e.split(".");
|
|
3826
3827
|
if (t.length !== 3) return !1;
|
|
3827
3828
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3828
3829
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3829
3830
|
}
|
|
3830
|
-
function
|
|
3831
|
+
function li(e) {
|
|
3831
3832
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3832
3833
|
}
|
|
3833
|
-
function
|
|
3834
|
+
function ui(e) {
|
|
3834
3835
|
if (!e || typeof e != "string") return !1;
|
|
3835
3836
|
let t = e.trim();
|
|
3836
3837
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3837
3838
|
}
|
|
3838
|
-
function
|
|
3839
|
+
function di(e) {
|
|
3839
3840
|
if (!e || typeof e != "string") return !1;
|
|
3840
3841
|
let t = e.trim();
|
|
3841
3842
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3842
3843
|
}
|
|
3843
|
-
function
|
|
3844
|
+
function fi(e) {
|
|
3844
3845
|
if (!e || typeof e != "string") return !1;
|
|
3845
3846
|
let t = e.trim();
|
|
3846
3847
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3847
3848
|
}
|
|
3848
|
-
function
|
|
3849
|
+
function pi(e, t = 6) {
|
|
3849
3850
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3850
3851
|
}
|
|
3851
|
-
function
|
|
3852
|
+
function mi(e) {
|
|
3852
3853
|
if (!e || typeof e != "string") return null;
|
|
3853
3854
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3854
3855
|
return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
|
|
3855
3856
|
}
|
|
3856
3857
|
// lib/services/auth-service.ts
|
|
3857
|
-
var
|
|
3858
|
+
var hi = "passflow_2fa_pkce", gi = 3e5, _i = "passflow_pwless_pending", vi = 3e3, yi = "passflow_federated_pkce", bi = 6e5, xi = "AppId is required for federated auth", Si = 10, Ci = "The sign-in answered with a PKCE code, but its verifier is gone", wi = (e, t) => new Promise((n, r) => {
|
|
3858
3859
|
if (t?.aborted) {
|
|
3859
3860
|
r(t.reason);
|
|
3860
3861
|
return;
|
|
@@ -3865,21 +3866,21 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3865
3866
|
t?.removeEventListener("abort", i), n();
|
|
3866
3867
|
}, e);
|
|
3867
3868
|
t?.addEventListener("abort", i, { once: !0 });
|
|
3868
|
-
}),
|
|
3869
|
+
}), Ti = (e) => {
|
|
3869
3870
|
if (!e) return;
|
|
3870
3871
|
let t = new URLSearchParams(e.search).get("token");
|
|
3871
3872
|
if (t) return t;
|
|
3872
3873
|
let n = e.hash.indexOf("?");
|
|
3873
3874
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3874
|
-
},
|
|
3875
|
+
}, Ei = (e) => {
|
|
3875
3876
|
if (e) try {
|
|
3876
3877
|
return j(e).email;
|
|
3877
3878
|
} catch {
|
|
3878
3879
|
return;
|
|
3879
3880
|
}
|
|
3880
|
-
},
|
|
3881
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d =
|
|
3882
|
-
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 P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh =
|
|
3881
|
+
}, Di = class {
|
|
3882
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination: $n() }, m) {
|
|
3883
|
+
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 P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh = Pr({
|
|
3883
3884
|
emit: this.createRefreshEmit(),
|
|
3884
3885
|
storage: n,
|
|
3885
3886
|
cache: i,
|
|
@@ -3887,7 +3888,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3887
3888
|
coordination: p.coordination,
|
|
3888
3889
|
platform: d,
|
|
3889
3890
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3890
|
-
logger:
|
|
3891
|
+
logger: nr()
|
|
3891
3892
|
}), this.initializeSession();
|
|
3892
3893
|
}
|
|
3893
3894
|
setAppId(e) {
|
|
@@ -3944,7 +3945,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3944
3945
|
}), !0) : !1;
|
|
3945
3946
|
}
|
|
3946
3947
|
handleEmailVerificationStep(e, t, n, r, i) {
|
|
3947
|
-
if (!
|
|
3948
|
+
if (!Pe(e)) return !1;
|
|
3948
3949
|
let a = e.challenge_id || void 0;
|
|
3949
3950
|
return a && r ? this.rememberPkceSignIn(r.verifier, i) : this.forgetPkceSignIn(), a && this.rememberEmailChallenge(a, {
|
|
3950
3951
|
operation: t,
|
|
@@ -3960,7 +3961,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3960
3961
|
rememberEmailChallenge(e, t) {
|
|
3961
3962
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3962
3963
|
for (let e of this.emailChallenges.keys()) {
|
|
3963
|
-
if (this.emailChallenges.size <=
|
|
3964
|
+
if (this.emailChallenges.size <= Si) break;
|
|
3964
3965
|
this.emailChallenges.delete(e);
|
|
3965
3966
|
}
|
|
3966
3967
|
}
|
|
@@ -3968,14 +3969,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3968
3969
|
if (this.pendingPkce = {
|
|
3969
3970
|
verifier: e,
|
|
3970
3971
|
scopes: t,
|
|
3971
|
-
expiresAt: Date.now() +
|
|
3972
|
+
expiresAt: Date.now() + gi
|
|
3972
3973
|
}, typeof sessionStorage < "u") try {
|
|
3973
|
-
sessionStorage.setItem(
|
|
3974
|
+
sessionStorage.setItem(hi, JSON.stringify(this.pendingPkce));
|
|
3974
3975
|
} catch {}
|
|
3975
3976
|
}
|
|
3976
3977
|
readPendingPkce() {
|
|
3977
3978
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3978
|
-
let e = sessionStorage.getItem(
|
|
3979
|
+
let e = sessionStorage.getItem(hi);
|
|
3979
3980
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3980
3981
|
} catch {
|
|
3981
3982
|
this.pendingPkce = void 0;
|
|
@@ -3987,17 +3988,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
3987
3988
|
}
|
|
3988
3989
|
forgetPkceSignIn() {
|
|
3989
3990
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3990
|
-
sessionStorage.removeItem(
|
|
3991
|
+
sessionStorage.removeItem(hi);
|
|
3991
3992
|
} catch {}
|
|
3992
3993
|
}
|
|
3993
3994
|
rememberPendingPasswordless(e) {
|
|
3994
3995
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3995
|
-
sessionStorage.setItem(
|
|
3996
|
+
sessionStorage.setItem(_i, JSON.stringify(e));
|
|
3996
3997
|
} catch {}
|
|
3997
3998
|
}
|
|
3998
3999
|
readPendingPasswordless() {
|
|
3999
4000
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
4000
|
-
let e = sessionStorage.getItem(
|
|
4001
|
+
let e = sessionStorage.getItem(_i);
|
|
4001
4002
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
4002
4003
|
} catch {
|
|
4003
4004
|
this.pendingPasswordless = void 0;
|
|
@@ -4006,21 +4007,21 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4006
4007
|
}
|
|
4007
4008
|
forgetPendingPasswordless() {
|
|
4008
4009
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
4009
|
-
sessionStorage.removeItem(
|
|
4010
|
+
sessionStorage.removeItem(_i);
|
|
4010
4011
|
} catch {}
|
|
4011
4012
|
}
|
|
4012
4013
|
rememberFederatedSlot(e, t) {
|
|
4013
4014
|
if (this.federatedSlot = {
|
|
4014
4015
|
verifier: e,
|
|
4015
4016
|
scopes: t,
|
|
4016
|
-
expiresAt: Date.now() +
|
|
4017
|
+
expiresAt: Date.now() + bi
|
|
4017
4018
|
}, typeof sessionStorage < "u") try {
|
|
4018
|
-
sessionStorage.setItem(
|
|
4019
|
+
sessionStorage.setItem(yi, JSON.stringify(this.federatedSlot));
|
|
4019
4020
|
} catch {}
|
|
4020
4021
|
}
|
|
4021
4022
|
readFederatedSlot() {
|
|
4022
4023
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
4023
|
-
let e = sessionStorage.getItem(
|
|
4024
|
+
let e = sessionStorage.getItem(yi);
|
|
4024
4025
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
4025
4026
|
} catch {
|
|
4026
4027
|
this.federatedSlot = void 0;
|
|
@@ -4029,7 +4030,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4029
4030
|
}
|
|
4030
4031
|
forgetFederatedSlot() {
|
|
4031
4032
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
4032
|
-
sessionStorage.removeItem(
|
|
4033
|
+
sessionStorage.removeItem(yi);
|
|
4033
4034
|
} catch {}
|
|
4034
4035
|
}
|
|
4035
4036
|
async startPkce() {
|
|
@@ -4037,17 +4038,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4037
4038
|
try {
|
|
4038
4039
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
4039
4040
|
} catch (e) {
|
|
4040
|
-
|
|
4041
|
+
nr().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
4041
4042
|
return;
|
|
4042
4043
|
}
|
|
4043
|
-
return e ?
|
|
4044
|
+
return e ? rn() : void 0;
|
|
4044
4045
|
}
|
|
4045
4046
|
async exchangeCode(e, t) {
|
|
4046
4047
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
4047
4048
|
}
|
|
4048
4049
|
async completePkceSignIn(e) {
|
|
4049
4050
|
let t = this.readPendingPkce();
|
|
4050
|
-
if (!t) throw Error(
|
|
4051
|
+
if (!t) throw Error(Ci);
|
|
4051
4052
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4052
4053
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
4053
4054
|
}
|
|
@@ -4077,7 +4078,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4077
4078
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
4078
4079
|
}
|
|
4079
4080
|
async signIn(e) {
|
|
4080
|
-
if ("email" in e && e.email && !
|
|
4081
|
+
if ("email" in e && e.email && !ui(e.email)) {
|
|
4081
4082
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4082
4083
|
operation: "sign-in",
|
|
4083
4084
|
message: "Invalid email format",
|
|
@@ -4086,7 +4087,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4086
4087
|
};
|
|
4087
4088
|
throw W(this.subscribeStore, t), e;
|
|
4088
4089
|
}
|
|
4089
|
-
if ("username" in e && e.username && !
|
|
4090
|
+
if ("username" in e && e.username && !fi(e.username)) {
|
|
4090
4091
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
4091
4092
|
operation: "sign-in",
|
|
4092
4093
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -4095,7 +4096,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4095
4096
|
};
|
|
4096
4097
|
throw W(this.subscribeStore, t), e;
|
|
4097
4098
|
}
|
|
4098
|
-
if ("phone" in e && e.phone && !
|
|
4099
|
+
if ("phone" in e && e.phone && !di(e.phone)) {
|
|
4099
4100
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4100
4101
|
operation: "sign-in",
|
|
4101
4102
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4105,7 +4106,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4105
4106
|
throw W(this.subscribeStore, t), e;
|
|
4106
4107
|
}
|
|
4107
4108
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
4108
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4109
|
+
let t = this.deviceService.getDeviceId(), n = Ge(this.platform.getDeviceType());
|
|
4109
4110
|
e.scopes = e.scopes ?? this.scopes;
|
|
4110
4111
|
try {
|
|
4111
4112
|
let r = await this.startPkce(), i = await this.authApi.signIn(r ? {
|
|
@@ -4129,7 +4130,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4129
4130
|
}
|
|
4130
4131
|
}
|
|
4131
4132
|
async signUp(e) {
|
|
4132
|
-
if (e.user.email && !
|
|
4133
|
+
if (e.user.email && !ui(e.user.email)) {
|
|
4133
4134
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4134
4135
|
operation: "sign-up",
|
|
4135
4136
|
message: "Invalid email format",
|
|
@@ -4138,7 +4139,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4138
4139
|
};
|
|
4139
4140
|
throw W(this.subscribeStore, t), e;
|
|
4140
4141
|
}
|
|
4141
|
-
if (e.user.phone_number && !
|
|
4142
|
+
if (e.user.phone_number && !di(e.user.phone_number)) {
|
|
4142
4143
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4143
4144
|
operation: "sign-up",
|
|
4144
4145
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4167,7 +4168,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4167
4168
|
}
|
|
4168
4169
|
}
|
|
4169
4170
|
async passwordlessSignIn(e) {
|
|
4170
|
-
if (e.email && !
|
|
4171
|
+
if (e.email && !ui(e.email)) {
|
|
4171
4172
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4172
4173
|
operation: "passwordless.start",
|
|
4173
4174
|
message: "Invalid email format",
|
|
@@ -4176,7 +4177,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4176
4177
|
};
|
|
4177
4178
|
throw W(this.subscribeStore, t), e;
|
|
4178
4179
|
}
|
|
4179
|
-
if (e.phone && !
|
|
4180
|
+
if (e.phone && !di(e.phone)) {
|
|
4180
4181
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4181
4182
|
operation: "passwordless.start",
|
|
4182
4183
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4186,7 +4187,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4186
4187
|
throw W(this.subscribeStore, t), e;
|
|
4187
4188
|
}
|
|
4188
4189
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
4189
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r =
|
|
4190
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = Ge(this.platform.getDeviceType());
|
|
4190
4191
|
try {
|
|
4191
4192
|
let i = await this.startPkce(), a = await this.authApi.passwordlessSignIn({
|
|
4192
4193
|
...e,
|
|
@@ -4220,7 +4221,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4220
4221
|
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
4221
4222
|
let i = t;
|
|
4222
4223
|
if (t.code) {
|
|
4223
|
-
if (!n) throw Error(
|
|
4224
|
+
if (!n) throw Error(Ci);
|
|
4224
4225
|
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
4225
4226
|
...i,
|
|
4226
4227
|
redirect_url: t.redirect_url ?? ""
|
|
@@ -4252,11 +4253,11 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4252
4253
|
let n = t?.signal;
|
|
4253
4254
|
try {
|
|
4254
4255
|
let t = this.readPendingPasswordless();
|
|
4255
|
-
if (t?.challengeId !== e) throw Error(
|
|
4256
|
+
if (t?.challengeId !== e) throw Error(Ci);
|
|
4256
4257
|
for (;;) {
|
|
4257
4258
|
if (n?.aborted) throw n.reason;
|
|
4258
4259
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4259
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4260
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Ci);
|
|
4260
4261
|
let r;
|
|
4261
4262
|
try {
|
|
4262
4263
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4274,7 +4275,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4274
4275
|
status: "signed-in",
|
|
4275
4276
|
tokens: { redirect_url: r.redirect_url }
|
|
4276
4277
|
};
|
|
4277
|
-
await
|
|
4278
|
+
await wi(vi, n);
|
|
4278
4279
|
}
|
|
4279
4280
|
} catch (e) {
|
|
4280
4281
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4343,14 +4344,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4343
4344
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4344
4345
|
try {
|
|
4345
4346
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4346
|
-
if (t?.pkce && !r) throw Error(
|
|
4347
|
+
if (t?.pkce && !r) throw Error(Ci);
|
|
4347
4348
|
let i = await this.authApi.validateEmailCode(e);
|
|
4348
4349
|
this.emailChallenges.delete(e.challenge_id);
|
|
4349
4350
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4350
4351
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4351
4352
|
let o = i;
|
|
4352
4353
|
if (i.code) {
|
|
4353
|
-
if (!r) throw Error(
|
|
4354
|
+
if (!r) throw Error(Ci);
|
|
4354
4355
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4355
4356
|
}
|
|
4356
4357
|
let s = i.redirect_url ? {
|
|
@@ -4413,13 +4414,13 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4413
4414
|
readSessionPin() {
|
|
4414
4415
|
try {
|
|
4415
4416
|
let e = this.storageManager.getToken(M.access_token);
|
|
4416
|
-
return e ?
|
|
4417
|
+
return e ? oi(j(e)) : void 0;
|
|
4417
4418
|
} catch {
|
|
4418
4419
|
return;
|
|
4419
4420
|
}
|
|
4420
4421
|
}
|
|
4421
4422
|
assertSessionPin(e) {
|
|
4422
|
-
if (e && !
|
|
4423
|
+
if (e && !si(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new ai("The session changed during verification, so the elevated tokens were discarded");
|
|
4423
4424
|
}
|
|
4424
4425
|
refreshMode() {
|
|
4425
4426
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4467,7 +4468,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4467
4468
|
case "signout":
|
|
4468
4469
|
n.notify(Z.SignOut, t);
|
|
4469
4470
|
return;
|
|
4470
|
-
default:
|
|
4471
|
+
default: nr().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4471
4472
|
}
|
|
4472
4473
|
};
|
|
4473
4474
|
}
|
|
@@ -4553,10 +4554,10 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4553
4554
|
}
|
|
4554
4555
|
async resetPassword(e, t, n) {
|
|
4555
4556
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4556
|
-
let r = n ??
|
|
4557
|
+
let r = n ?? Ti(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4557
4558
|
try {
|
|
4558
4559
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4559
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4560
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Ei(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4560
4561
|
let a = await this.exchangeCode(n, t);
|
|
4561
4562
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4562
4563
|
let o = n.redirect_url ? {
|
|
@@ -4580,7 +4581,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4580
4581
|
async passkeyRegister(e) {
|
|
4581
4582
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4582
4583
|
this.subscribeStore.notify(Z.RegisterStart, {});
|
|
4583
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4584
|
+
let t = this.deviceService.getDeviceId(), n = Ge(this.platform.getDeviceType());
|
|
4584
4585
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4585
4586
|
try {
|
|
4586
4587
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyRegisterStart(r ? {
|
|
@@ -4607,7 +4608,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4607
4608
|
async passkeyAuthenticate(e) {
|
|
4608
4609
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4609
4610
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4610
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4611
|
+
let t = this.deviceService.getDeviceId(), n = Ge(this.platform.getDeviceType());
|
|
4611
4612
|
e.scopes = e.scopes ?? this.scopes;
|
|
4612
4613
|
try {
|
|
4613
4614
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyAuthenticateStart(r ? {
|
|
@@ -4634,7 +4635,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4634
4635
|
}
|
|
4635
4636
|
createFederatedAuthUrl(e) {
|
|
4636
4637
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4637
|
-
if (!this.appId) throw Error(
|
|
4638
|
+
if (!this.appId) throw Error(xi);
|
|
4638
4639
|
let n = {
|
|
4639
4640
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4640
4641
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
@@ -4650,7 +4651,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4650
4651
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4651
4652
|
}
|
|
4652
4653
|
async federatedAuthWithPopup(e) {
|
|
4653
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4654
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(xi);
|
|
4654
4655
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4655
4656
|
try {
|
|
4656
4657
|
this.forgetFederatedSlot();
|
|
@@ -4678,11 +4679,11 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4678
4679
|
scopes: t
|
|
4679
4680
|
};
|
|
4680
4681
|
if (r) {
|
|
4681
|
-
if (!l) throw
|
|
4682
|
+
if (!l) throw ln();
|
|
4682
4683
|
if (m = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(m)) return;
|
|
4683
4684
|
} else {
|
|
4684
|
-
if (!await this.isSimpleModeApp()) throw
|
|
4685
|
-
await
|
|
4685
|
+
if (!await this.isSimpleModeApp()) throw ln();
|
|
4686
|
+
await Br(this.url, this.appId, m);
|
|
4686
4687
|
}
|
|
4687
4688
|
await this.processAuthResponse(m, t), this.subscribeStore.notify(Z.SignIn, {
|
|
4688
4689
|
tokens: m,
|
|
@@ -4701,14 +4702,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4701
4702
|
let t = {
|
|
4702
4703
|
operation: "federated.popup",
|
|
4703
4704
|
message: e instanceof Error ? e.message : "Authentication failed",
|
|
4704
|
-
code: e instanceof
|
|
4705
|
+
code: e instanceof I ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4705
4706
|
originalError: e
|
|
4706
4707
|
};
|
|
4707
4708
|
W(this.subscribeStore, t);
|
|
4708
4709
|
}
|
|
4709
4710
|
}
|
|
4710
4711
|
federatedAuthWithRedirect(e) {
|
|
4711
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4712
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(xi);
|
|
4712
4713
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4713
4714
|
this.startPkce().then((r) => {
|
|
4714
4715
|
let i = this.createFederatedAuthUrl({
|
|
@@ -4772,7 +4773,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4772
4773
|
async authRedirect(e = {}) {
|
|
4773
4774
|
try {
|
|
4774
4775
|
let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
|
|
4775
|
-
if (t !== void 0 &&
|
|
4776
|
+
if (t !== void 0 && fn(t) !== fn(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
|
|
4776
4777
|
let o = await this.readAppSettings?.();
|
|
4777
4778
|
if (o?.pkce_enabled !== !0) {
|
|
4778
4779
|
let e = this.authRedirectUrl({
|
|
@@ -4782,8 +4783,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4782
4783
|
this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
|
|
4783
4784
|
return;
|
|
4784
4785
|
}
|
|
4785
|
-
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT",
|
|
4786
|
-
let s = this.platform.getCurrentUrl(), c = await
|
|
4786
|
+
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", sn(o.type));
|
|
4787
|
+
let s = this.platform.getCurrentUrl(), c = await mn({
|
|
4787
4788
|
url: this.url,
|
|
4788
4789
|
clientId: this.appId ?? "",
|
|
4789
4790
|
redirectUri: r ?? (s ? s.origin + s.pathname : ""),
|
|
@@ -4804,9 +4805,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4804
4805
|
if (!this.appId) return !1;
|
|
4805
4806
|
let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
|
|
4806
4807
|
if (t.get("user_state") || r === null || !n && !i) return !1;
|
|
4807
|
-
let o =
|
|
4808
|
+
let o = gn();
|
|
4808
4809
|
if (o.status === "none") return !1;
|
|
4809
|
-
|
|
4810
|
+
_n();
|
|
4810
4811
|
for (let e of [
|
|
4811
4812
|
"code",
|
|
4812
4813
|
"state",
|
|
@@ -4818,9 +4819,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4818
4819
|
return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
|
|
4819
4820
|
if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
|
|
4820
4821
|
if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
|
|
4821
|
-
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED",
|
|
4822
|
+
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", li(a || i || "Sign in again."));
|
|
4822
4823
|
return {
|
|
4823
|
-
tokens: await
|
|
4824
|
+
tokens: await yn(this.url, n, o.slot),
|
|
4824
4825
|
scopes: o.slot.scopes,
|
|
4825
4826
|
returnUrl: o.slot.redirectUri
|
|
4826
4827
|
};
|
|
@@ -4901,7 +4902,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4901
4902
|
return;
|
|
4902
4903
|
}
|
|
4903
4904
|
}
|
|
4904
|
-
},
|
|
4905
|
+
}, Oi = class {
|
|
4905
4906
|
constructor(e) {
|
|
4906
4907
|
this.invitationApi = e;
|
|
4907
4908
|
}
|
|
@@ -4920,7 +4921,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4920
4921
|
getInvitationLink(e) {
|
|
4921
4922
|
return this.invitationApi.getInvitationLink(e);
|
|
4922
4923
|
}
|
|
4923
|
-
},
|
|
4924
|
+
}, ki = class {
|
|
4924
4925
|
constructor(e) {
|
|
4925
4926
|
this.data = this.normalize(e);
|
|
4926
4927
|
}
|
|
@@ -4977,9 +4978,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
4977
4978
|
getData() {
|
|
4978
4979
|
return this.data;
|
|
4979
4980
|
}
|
|
4980
|
-
},
|
|
4981
|
+
}, Ai = class {
|
|
4981
4982
|
constructor(e, t, n) {
|
|
4982
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4983
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || nr();
|
|
4983
4984
|
}
|
|
4984
4985
|
handlePassflowError(t, n) {
|
|
4985
4986
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -5015,7 +5016,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5015
5016
|
}
|
|
5016
5017
|
async getTenantUserMembership(e) {
|
|
5017
5018
|
try {
|
|
5018
|
-
return new
|
|
5019
|
+
return new ki(await this.tenantApi.getTenantDetails(e));
|
|
5019
5020
|
} catch (t) {
|
|
5020
5021
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
5021
5022
|
}
|
|
@@ -5160,8 +5161,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5160
5161
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5161
5162
|
}
|
|
5162
5163
|
}
|
|
5163
|
-
},
|
|
5164
|
-
constructor(e, t, n, r =
|
|
5164
|
+
}, ji = class {
|
|
5165
|
+
constructor(e, t, n, r = R) {
|
|
5165
5166
|
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();
|
|
5166
5167
|
}
|
|
5167
5168
|
get isRefreshing() {
|
|
@@ -5240,7 +5241,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5240
5241
|
isExpired() {
|
|
5241
5242
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5242
5243
|
}
|
|
5243
|
-
},
|
|
5244
|
+
}, Mi = class {
|
|
5244
5245
|
constructor(e, t, n) {
|
|
5245
5246
|
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) => {
|
|
5246
5247
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -5320,8 +5321,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5320
5321
|
assertTotpCode(e) {
|
|
5321
5322
|
let t = this.totpDigits;
|
|
5322
5323
|
if (t) {
|
|
5323
|
-
if (!
|
|
5324
|
-
} else if (!
|
|
5324
|
+
if (!pi(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
|
|
5325
|
+
} else if (!pi(e, 6) && !pi(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
|
|
5325
5326
|
}
|
|
5326
5327
|
requirePendingTfaToken() {
|
|
5327
5328
|
let e = this.pendingTfaToken();
|
|
@@ -5359,7 +5360,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5359
5360
|
}
|
|
5360
5361
|
async useRecoveryCode(e, t) {
|
|
5361
5362
|
try {
|
|
5362
|
-
let n =
|
|
5363
|
+
let n = mi(e);
|
|
5363
5364
|
if (!n) throw Error("Invalid recovery code format. Expected letters, digits and dashes, such as XXXX-XXXX-XXXX.");
|
|
5364
5365
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5365
5366
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -5571,8 +5572,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5571
5572
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5572
5573
|
}
|
|
5573
5574
|
}
|
|
5574
|
-
},
|
|
5575
|
-
constructor(e, t, n =
|
|
5575
|
+
}, Ni = class {
|
|
5576
|
+
constructor(e, t, n = R) {
|
|
5576
5577
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5577
5578
|
}
|
|
5578
5579
|
getUserPasskeys() {
|
|
@@ -5586,7 +5587,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5586
5587
|
}
|
|
5587
5588
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
5588
5589
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
5589
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
5590
|
+
let r = this.deviceService.getDeviceId(), i = Ge(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
5590
5591
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
5591
5592
|
deviceId: r,
|
|
5592
5593
|
os: i,
|
|
@@ -5598,77 +5599,77 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5598
5599
|
if (!s) throw Error("Passkey registration was not completed");
|
|
5599
5600
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
5600
5601
|
}
|
|
5601
|
-
},
|
|
5602
|
+
}, Pi = class extends Error {
|
|
5602
5603
|
constructor(e, t, n = !1) {
|
|
5603
5604
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5604
5605
|
}
|
|
5605
|
-
},
|
|
5606
|
+
}, Fi = (e, t) => {
|
|
5606
5607
|
let n = t?.trim();
|
|
5607
|
-
if (!n) throw new
|
|
5608
|
+
if (!n) throw new Pi(e, "A verification code is required");
|
|
5608
5609
|
return n;
|
|
5609
|
-
},
|
|
5610
|
+
}, Ii = {
|
|
5610
5611
|
type: "totp",
|
|
5611
5612
|
requiresPrepare: !1,
|
|
5612
5613
|
input: "code",
|
|
5613
|
-
assert: async ({ code: e }) => ({ code:
|
|
5614
|
-
},
|
|
5614
|
+
assert: async ({ code: e }) => ({ code: Fi("totp", e) })
|
|
5615
|
+
}, Li = {
|
|
5615
5616
|
type: "recovery_codes",
|
|
5616
5617
|
requiresPrepare: !1,
|
|
5617
5618
|
input: "code",
|
|
5618
|
-
assert: async ({ code: e }) => ({ code:
|
|
5619
|
-
},
|
|
5619
|
+
assert: async ({ code: e }) => ({ code: Fi("recovery_codes", e) })
|
|
5620
|
+
}, Ri = {
|
|
5620
5621
|
type: "passkey",
|
|
5621
5622
|
requiresPrepare: !0,
|
|
5622
5623
|
input: "none",
|
|
5623
5624
|
assert: async ({ prepared: e, platform: t }) => {
|
|
5624
|
-
if (!e?.webauthn) throw new
|
|
5625
|
+
if (!e?.webauthn) throw new Pi("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
5625
5626
|
let n = t.passkeys;
|
|
5626
|
-
if (!n) throw new
|
|
5627
|
+
if (!n) throw new Pi("passkey", "This platform does not support passkeys");
|
|
5627
5628
|
let r;
|
|
5628
5629
|
try {
|
|
5629
5630
|
r = await n.startAuthentication(e.webauthn);
|
|
5630
5631
|
} catch (e) {
|
|
5631
|
-
throw new
|
|
5632
|
+
throw new Pi("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
5632
5633
|
}
|
|
5633
|
-
if (!r) throw new
|
|
5634
|
+
if (!r) throw new Pi("passkey", "Passkey verification was cancelled", !0);
|
|
5634
5635
|
return {
|
|
5635
5636
|
challenge_id: e.challengeId,
|
|
5636
5637
|
credential: r
|
|
5637
5638
|
};
|
|
5638
5639
|
}
|
|
5639
|
-
},
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
]),
|
|
5640
|
+
}, zi = Object.freeze([
|
|
5641
|
+
Ii,
|
|
5642
|
+
Ri,
|
|
5643
|
+
Li
|
|
5644
|
+
]), Bi = (e = zi) => new Map(e.map((e) => [e.type, e])), Vi = 3, Hi = {
|
|
5644
5645
|
totp: 0,
|
|
5645
5646
|
passkey: 1,
|
|
5646
5647
|
email_otp: 2,
|
|
5647
5648
|
sms_otp: 3,
|
|
5648
5649
|
recovery_codes: 9
|
|
5649
|
-
},
|
|
5650
|
-
let n =
|
|
5650
|
+
}, Ui = (e) => e.requiredLevel ?? z(e.acrValues), Wi = (e, t) => {
|
|
5651
|
+
let n = Hi[e.type] ?? 5, r = t !== void 0 && t >= Vi, i = e.type === "passkey";
|
|
5651
5652
|
return (r && !i ? 100 : 0) + n;
|
|
5652
|
-
},
|
|
5653
|
+
}, Gi = (e, t) => {
|
|
5653
5654
|
if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
|
|
5654
|
-
let n =
|
|
5655
|
-
return [...e].sort((e, t) =>
|
|
5656
|
-
},
|
|
5655
|
+
let n = Ui(t);
|
|
5656
|
+
return [...e].sort((e, t) => Wi(e, n) - Wi(t, n));
|
|
5657
|
+
}, Ki = class extends Error {
|
|
5657
5658
|
constructor(e) {
|
|
5658
5659
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
5659
5660
|
}
|
|
5660
|
-
},
|
|
5661
|
+
}, qi = class extends Error {
|
|
5661
5662
|
constructor(e = "Only a fresh sign-in can meet this challenge") {
|
|
5662
5663
|
super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
|
|
5663
5664
|
}
|
|
5664
|
-
},
|
|
5665
|
-
if (
|
|
5666
|
-
if (
|
|
5667
|
-
},
|
|
5665
|
+
}, Ji = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Yi = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Xi = "This account has no factor that reaches the required level (it may need a device-bound passkey)", Zi = (e) => {
|
|
5666
|
+
if (Ji(e)) return new qi();
|
|
5667
|
+
if (Yi(e)) return new Qi(Xi);
|
|
5668
|
+
}, Qi = class extends Error {
|
|
5668
5669
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
5669
5670
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
5670
5671
|
}
|
|
5671
|
-
},
|
|
5672
|
+
}, $i = 4, ea = 3e4, ta = () => {
|
|
5672
5673
|
let e = () => void 0, t = () => void 0;
|
|
5673
5674
|
return {
|
|
5674
5675
|
promise: new Promise((n, r) => {
|
|
@@ -5677,12 +5678,12 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5677
5678
|
resolve: e,
|
|
5678
5679
|
reject: t
|
|
5679
5680
|
};
|
|
5680
|
-
},
|
|
5681
|
+
}, na = (e) => ({
|
|
5681
5682
|
acrValues: e.acrValues,
|
|
5682
5683
|
level: e.requiredLevel,
|
|
5683
5684
|
maxAge: e.maxAge
|
|
5684
|
-
}),
|
|
5685
|
-
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 } =
|
|
5685
|
+
}), ra = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ia = (e, t) => {
|
|
5686
|
+
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 } = aa(t, e) && !aa(e, t) || !t.availableFactors ? e : t;
|
|
5686
5687
|
return {
|
|
5687
5688
|
acrValues: r,
|
|
5688
5689
|
requiredLevel: n,
|
|
@@ -5692,12 +5693,12 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5692
5693
|
...o ? { availableFactors: o } : {},
|
|
5693
5694
|
...s === void 0 ? {} : { signInRequired: s }
|
|
5694
5695
|
};
|
|
5695
|
-
},
|
|
5696
|
+
}, aa = (e, t) => {
|
|
5696
5697
|
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);
|
|
5697
5698
|
return n || r;
|
|
5698
|
-
},
|
|
5699
|
+
}, oa = class {
|
|
5699
5700
|
constructor(e) {
|
|
5700
|
-
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 ??
|
|
5701
|
+
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 ?? zi, this.registry = Bi(this.available), this.maxAttempts = e.maxAttempts ?? $i, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? ea;
|
|
5701
5702
|
}
|
|
5702
5703
|
get currentState() {
|
|
5703
5704
|
return this.state;
|
|
@@ -5717,9 +5718,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5717
5718
|
}
|
|
5718
5719
|
register(e, t) {
|
|
5719
5720
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
5720
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5721
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : na(e),
|
|
5721
5722
|
statedBar: n,
|
|
5722
|
-
settlement:
|
|
5723
|
+
settlement: ta(),
|
|
5723
5724
|
reported: !1,
|
|
5724
5725
|
entry: {
|
|
5725
5726
|
...t,
|
|
@@ -5735,15 +5736,15 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5735
5736
|
this.requirement = e;
|
|
5736
5737
|
return;
|
|
5737
5738
|
}
|
|
5738
|
-
let n =
|
|
5739
|
-
this.requirement =
|
|
5739
|
+
let n = aa(t, e);
|
|
5740
|
+
this.requirement = ia(t, e), Zi(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
5740
5741
|
challenge: this.requirement,
|
|
5741
5742
|
factors: this.offeredFactors()
|
|
5742
5743
|
});
|
|
5743
5744
|
}
|
|
5744
5745
|
offeredFactors() {
|
|
5745
5746
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
5746
|
-
return t ?
|
|
5747
|
+
return t ? Gi(e, t) : e;
|
|
5747
5748
|
}
|
|
5748
5749
|
receiveReport(e, t) {
|
|
5749
5750
|
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());
|
|
@@ -5778,12 +5779,12 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5778
5779
|
}
|
|
5779
5780
|
release(e, t) {
|
|
5780
5781
|
if (e.entry.kind === "imperative") {
|
|
5781
|
-
if (e.statedBar &&
|
|
5782
|
+
if (e.statedBar && !ra(t, e.demanded)) {
|
|
5782
5783
|
this.receiveReport(e, {
|
|
5783
5784
|
outcome: "insufficient",
|
|
5784
5785
|
obtained: t,
|
|
5785
5786
|
required: e.demanded
|
|
5786
|
-
}), e.settlement.reject(new
|
|
5787
|
+
}), e.settlement.reject(new ri(t, e.demanded));
|
|
5787
5788
|
return;
|
|
5788
5789
|
}
|
|
5789
5790
|
this.receiveReport(e, {
|
|
@@ -5853,7 +5854,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5853
5854
|
async prove() {
|
|
5854
5855
|
let e;
|
|
5855
5856
|
for (let t = 0; t < this.maxAttempts; t++) {
|
|
5856
|
-
let t =
|
|
5857
|
+
let t = Zi(this.requirement);
|
|
5857
5858
|
if (t) return {
|
|
5858
5859
|
status: "failed",
|
|
5859
5860
|
reason: t
|
|
@@ -5861,7 +5862,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5861
5862
|
let n = this.offeredFactors();
|
|
5862
5863
|
if (n.length === 0) return {
|
|
5863
5864
|
status: "failed",
|
|
5864
|
-
reason: new
|
|
5865
|
+
reason: new Qi()
|
|
5865
5866
|
};
|
|
5866
5867
|
let r = this.requirement, i;
|
|
5867
5868
|
try {
|
|
@@ -5869,29 +5870,29 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5869
5870
|
} catch (e) {
|
|
5870
5871
|
return {
|
|
5871
5872
|
status: "failed",
|
|
5872
|
-
reason: new
|
|
5873
|
+
reason: new Ki(e)
|
|
5873
5874
|
};
|
|
5874
5875
|
}
|
|
5875
|
-
let a =
|
|
5876
|
+
let a = Zi(this.requirement);
|
|
5876
5877
|
if (a) return {
|
|
5877
5878
|
status: "failed",
|
|
5878
5879
|
reason: a
|
|
5879
5880
|
};
|
|
5880
5881
|
if (i.type === "cancel") return {
|
|
5881
5882
|
status: "failed",
|
|
5882
|
-
reason: new
|
|
5883
|
+
reason: new Ki()
|
|
5883
5884
|
};
|
|
5884
5885
|
let o = this.registry.get(i.factor);
|
|
5885
|
-
if (!o) e = new
|
|
5886
|
+
if (!o) e = new Qi(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
|
|
5886
5887
|
else try {
|
|
5887
5888
|
return await this.proveAndCommit(o, i.code), {
|
|
5888
5889
|
status: "proven",
|
|
5889
|
-
obtained: this.readObtainedBar?.() ??
|
|
5890
|
+
obtained: this.readObtainedBar?.() ?? na(this.rankedRequirement ?? r)
|
|
5890
5891
|
};
|
|
5891
5892
|
} catch (t) {
|
|
5892
|
-
if (t instanceof
|
|
5893
|
+
if (t instanceof Pi && t.cancelled) return {
|
|
5893
5894
|
status: "failed",
|
|
5894
|
-
reason: new
|
|
5895
|
+
reason: new Ki()
|
|
5895
5896
|
};
|
|
5896
5897
|
let n = this.classifyProofFailure(t);
|
|
5897
5898
|
if (n) return {
|
|
@@ -5927,16 +5928,16 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5927
5928
|
});
|
|
5928
5929
|
}
|
|
5929
5930
|
classifyProofFailure(e) {
|
|
5930
|
-
if (e instanceof
|
|
5931
|
+
if (e instanceof ri || e instanceof ii || e instanceof ai) return e;
|
|
5931
5932
|
if (e instanceof $) switch (e.kind) {
|
|
5932
|
-
case "unavailable": return new
|
|
5933
|
+
case "unavailable": return new ii(e.message);
|
|
5933
5934
|
case "exhausted":
|
|
5934
5935
|
case "attempts_exhausted":
|
|
5935
5936
|
case "rate_limited":
|
|
5936
5937
|
case "fatal":
|
|
5937
5938
|
case "protocol":
|
|
5938
5939
|
case "network": return e;
|
|
5939
|
-
case "session_changed": return new
|
|
5940
|
+
case "session_changed": return new ai(e.message);
|
|
5940
5941
|
default: return;
|
|
5941
5942
|
}
|
|
5942
5943
|
}
|
|
@@ -5948,28 +5949,28 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5948
5949
|
});
|
|
5949
5950
|
await this.transport.commit(e.type, r);
|
|
5950
5951
|
}
|
|
5951
|
-
},
|
|
5952
|
+
}, sa = (e) => typeof e == "function" ? e() : e, ca = (e) => {
|
|
5952
5953
|
try {
|
|
5953
5954
|
return new URL(e);
|
|
5954
5955
|
} catch {
|
|
5955
5956
|
return;
|
|
5956
5957
|
}
|
|
5957
|
-
},
|
|
5958
|
+
}, la = (e, t) => {
|
|
5958
5959
|
if (!t || t === "/") return !0;
|
|
5959
5960
|
let n = t.replace(/\/+$/, "");
|
|
5960
5961
|
return e === n || e.startsWith(`${n}/`);
|
|
5961
|
-
},
|
|
5962
|
+
}, ua = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && la(e.pathname, t.pathPrefix), da = (e, t) => {
|
|
5962
5963
|
for (let n of t) {
|
|
5963
5964
|
if (n === "") continue;
|
|
5964
5965
|
if (n.startsWith("/")) {
|
|
5965
|
-
if (e.relativeToBase &&
|
|
5966
|
+
if (e.relativeToBase && la(e.pathname, n)) return !0;
|
|
5966
5967
|
continue;
|
|
5967
5968
|
}
|
|
5968
|
-
let t =
|
|
5969
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5969
|
+
let t = ca(n) ?? ca(`https://${n}`);
|
|
5970
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && la(e.pathname, t.pathname)) return !0;
|
|
5970
5971
|
}
|
|
5971
5972
|
return !1;
|
|
5972
|
-
},
|
|
5973
|
+
}, fa = (e, t, n) => ua(e, t.passflow) || da(e, t.backend) ? !n || n(e.href) !== !1 : !1, pa = (e) => {
|
|
5973
5974
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5974
5975
|
console.warn(n, {
|
|
5975
5976
|
status: e.status,
|
|
@@ -5977,8 +5978,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5977
5978
|
reason: e.reason,
|
|
5978
5979
|
detail: t
|
|
5979
5980
|
});
|
|
5980
|
-
},
|
|
5981
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5981
|
+
}, ma = (e, t) => {
|
|
5982
|
+
let n = t.onUpgradeDiagnostic ?? pa;
|
|
5982
5983
|
return (t, r) => {
|
|
5983
5984
|
n({
|
|
5984
5985
|
status: e.status,
|
|
@@ -5990,8 +5991,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
5990
5991
|
}
|
|
5991
5992
|
});
|
|
5992
5993
|
};
|
|
5993
|
-
},
|
|
5994
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5994
|
+
}, ha = (e, t, n) => {
|
|
5995
|
+
let r = n.onUpgradeDiagnostic ?? pa;
|
|
5995
5996
|
for (let n of e) r({
|
|
5996
5997
|
...n,
|
|
5997
5998
|
url: t.request.href,
|
|
@@ -6000,14 +6001,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6000
6001
|
...n.detail ?? {}
|
|
6001
6002
|
}
|
|
6002
6003
|
});
|
|
6003
|
-
},
|
|
6004
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
6004
|
+
}, ga = /\bjson\b/i, _a = async (e, t) => {
|
|
6005
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && ga.test(r), a;
|
|
6005
6006
|
if (i) try {
|
|
6006
6007
|
a = await e.readBody();
|
|
6007
6008
|
} catch {
|
|
6008
6009
|
a = void 0;
|
|
6009
6010
|
}
|
|
6010
|
-
return
|
|
6011
|
+
return Se(i ? {
|
|
6011
6012
|
status: e.status,
|
|
6012
6013
|
getHeader: (t) => e.getHeader(t) ?? void 0,
|
|
6013
6014
|
body: a
|
|
@@ -6015,13 +6016,13 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6015
6016
|
status: e.status,
|
|
6016
6017
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6017
6018
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
6018
|
-
},
|
|
6019
|
+
}, va = (e) => Se({
|
|
6019
6020
|
status: e.status,
|
|
6020
6021
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6021
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
6022
|
+
}, { requireChallengeChannel: "header" }).challenge, ya = (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.`, ba = (e, t) => e instanceof Ki ? { kind: "cancelled" } : e instanceof qi ? { kind: "sign-in-required" } : e instanceof Qi ? {
|
|
6022
6023
|
kind: "unsatisfiable",
|
|
6023
6024
|
error: e
|
|
6024
|
-
} : e instanceof
|
|
6025
|
+
} : e instanceof ii ? { kind: "unavailable" } : e instanceof ai ? { kind: "session-changed" } : e instanceof ri ? {
|
|
6025
6026
|
kind: "insufficient",
|
|
6026
6027
|
obtained: e.obtained,
|
|
6027
6028
|
required: e.required
|
|
@@ -6037,26 +6038,26 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6037
6038
|
kind: "transport-failure",
|
|
6038
6039
|
retryable: !1,
|
|
6039
6040
|
error: e instanceof Error ? e : Error(String(e))
|
|
6040
|
-
},
|
|
6041
|
+
}, xa = async (e, t, n, r) => {
|
|
6041
6042
|
if (e.status !== 401 && e.status !== 403) return {
|
|
6042
6043
|
kind: "replayed",
|
|
6043
6044
|
response: e
|
|
6044
6045
|
};
|
|
6045
|
-
let { challenge: i, diagnostics: a } = await
|
|
6046
|
-
if (
|
|
6046
|
+
let { challenge: i, diagnostics: a } = await _a(e, t);
|
|
6047
|
+
if (ha(a, e, t), !i) return {
|
|
6047
6048
|
kind: "replayed",
|
|
6048
6049
|
response: e
|
|
6049
6050
|
};
|
|
6050
|
-
if (
|
|
6051
|
+
if (Ji(i)) return {
|
|
6051
6052
|
kind: "sign-in-required",
|
|
6052
6053
|
response: e
|
|
6053
6054
|
};
|
|
6054
|
-
if (
|
|
6055
|
+
if (Yi(i)) return {
|
|
6055
6056
|
kind: "unsatisfiable",
|
|
6056
|
-
error:
|
|
6057
|
+
error: Zi(i),
|
|
6057
6058
|
response: e
|
|
6058
6059
|
};
|
|
6059
|
-
let o =
|
|
6060
|
+
let o = na(i);
|
|
6060
6061
|
return r("elevated-insufficient", {
|
|
6061
6062
|
obtained: n,
|
|
6062
6063
|
required: o
|
|
@@ -6066,7 +6067,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6066
6067
|
required: o,
|
|
6067
6068
|
response: e
|
|
6068
6069
|
};
|
|
6069
|
-
},
|
|
6070
|
+
}, Sa = async (e, t) => {
|
|
6070
6071
|
if (!t) return {
|
|
6071
6072
|
aborted: !1,
|
|
6072
6073
|
value: await e
|
|
@@ -6093,14 +6094,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6093
6094
|
} finally {
|
|
6094
6095
|
n && t.removeEventListener?.("abort", n);
|
|
6095
6096
|
}
|
|
6096
|
-
},
|
|
6097
|
+
}, Ca = async (e, t) => {
|
|
6097
6098
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
6098
|
-
let n =
|
|
6099
|
+
let n = ma(e, t);
|
|
6099
6100
|
if (e.markers.replayed) {
|
|
6100
|
-
if (!
|
|
6101
|
-
let { challenge: r, diagnostics: i } = await
|
|
6102
|
-
if (
|
|
6103
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
6101
|
+
if (!fa(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
6102
|
+
let { challenge: r, diagnostics: i } = await _a(e, t);
|
|
6103
|
+
if (ha(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
6104
|
+
let a = t.readObtainedBar?.() ?? {}, o = na(r);
|
|
6104
6105
|
return n("elevated-insufficient", {
|
|
6105
6106
|
obtained: a,
|
|
6106
6107
|
required: o
|
|
@@ -6111,12 +6112,12 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6111
6112
|
response: e
|
|
6112
6113
|
};
|
|
6113
6114
|
}
|
|
6114
|
-
if (!
|
|
6115
|
+
if (!fa(e.request, t.scope, t.shouldIntercept)) return va(e) ? (n("challenge-out-of-scope", {
|
|
6115
6116
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
6116
|
-
message:
|
|
6117
|
+
message: ya(e.request.href, t.scope)
|
|
6117
6118
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
6118
|
-
let { challenge: r, diagnostics: i } = await
|
|
6119
|
-
if (
|
|
6119
|
+
let { challenge: r, diagnostics: i } = await _a(e, t);
|
|
6120
|
+
if (ha(i, e, t), !r) {
|
|
6120
6121
|
let r = e.getHeader("www-authenticate");
|
|
6121
6122
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
6122
6123
|
...r ? { header: r } : {},
|
|
@@ -6130,9 +6131,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6130
6131
|
method: e.request.method
|
|
6131
6132
|
}, s, c;
|
|
6132
6133
|
try {
|
|
6133
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
6134
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Sa(s, e.signal);
|
|
6134
6135
|
} catch (e) {
|
|
6135
|
-
return
|
|
6136
|
+
return ba(e, void 0);
|
|
6136
6137
|
}
|
|
6137
6138
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
6138
6139
|
kind: "aborted",
|
|
@@ -6143,7 +6144,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6143
6144
|
kind: "aborted",
|
|
6144
6145
|
reason: e.signal.reason
|
|
6145
6146
|
};
|
|
6146
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
6147
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? na(r), d = t.authorizationSwap?.(), f = d ? {
|
|
6147
6148
|
from: a?.from ?? d.from,
|
|
6148
6149
|
to: d.to
|
|
6149
6150
|
} : void 0;
|
|
@@ -6152,7 +6153,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6152
6153
|
try {
|
|
6153
6154
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
6154
6155
|
} catch (t) {
|
|
6155
|
-
if (t instanceof
|
|
6156
|
+
if (t instanceof ri) return l?.waiter.report({
|
|
6156
6157
|
outcome: "insufficient",
|
|
6157
6158
|
obtained: t.obtained,
|
|
6158
6159
|
required: t.required
|
|
@@ -6170,7 +6171,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6170
6171
|
};
|
|
6171
6172
|
throw t;
|
|
6172
6173
|
}
|
|
6173
|
-
let m = await
|
|
6174
|
+
let m = await xa(p, t, u, n);
|
|
6174
6175
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6175
6176
|
outcome: "insufficient",
|
|
6176
6177
|
obtained: m.obtained,
|
|
@@ -6179,19 +6180,19 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6179
6180
|
outcome: "replayed",
|
|
6180
6181
|
obtained: u
|
|
6181
6182
|
}), m;
|
|
6182
|
-
},
|
|
6183
|
+
}, wa = (e) => {
|
|
6183
6184
|
switch (e.kind) {
|
|
6184
|
-
case "cancelled": return new
|
|
6185
|
-
case "unsatisfiable": return e.error ?? new
|
|
6186
|
-
case "sign-in-required": return new
|
|
6187
|
-
case "unavailable": return new
|
|
6188
|
-
case "session-changed": return new
|
|
6189
|
-
case "insufficient": return new
|
|
6185
|
+
case "cancelled": return new Ki();
|
|
6186
|
+
case "unsatisfiable": return e.error ?? new Qi();
|
|
6187
|
+
case "sign-in-required": return new qi();
|
|
6188
|
+
case "unavailable": return new ii();
|
|
6189
|
+
case "session-changed": return new ai();
|
|
6190
|
+
case "insufficient": return new ri(e.obtained, e.required);
|
|
6190
6191
|
case "exhausted": return e.error;
|
|
6191
6192
|
case "transport-failure": return e.error;
|
|
6192
6193
|
default: return;
|
|
6193
6194
|
}
|
|
6194
|
-
},
|
|
6195
|
+
}, Ta = (e, t, n) => {
|
|
6195
6196
|
switch (e.kind) {
|
|
6196
6197
|
case "replayed": return {
|
|
6197
6198
|
settle: "resolve",
|
|
@@ -6209,26 +6210,26 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6209
6210
|
};
|
|
6210
6211
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6211
6212
|
settle: "reject",
|
|
6212
|
-
error: new
|
|
6213
|
+
error: new Ki()
|
|
6213
6214
|
} : {
|
|
6214
6215
|
settle: "resolve",
|
|
6215
|
-
value:
|
|
6216
|
+
value: Fa(t, e)
|
|
6216
6217
|
};
|
|
6217
6218
|
case "unsatisfiable":
|
|
6218
6219
|
case "sign-in-required": return {
|
|
6219
6220
|
settle: "resolve",
|
|
6220
|
-
value:
|
|
6221
|
+
value: Fa(e.response?.raw ?? t, e)
|
|
6221
6222
|
};
|
|
6222
6223
|
case "insufficient": return {
|
|
6223
6224
|
settle: "resolve",
|
|
6224
|
-
value:
|
|
6225
|
+
value: Fa(e.response?.raw ?? t, e)
|
|
6225
6226
|
};
|
|
6226
6227
|
default: return {
|
|
6227
6228
|
settle: "resolve",
|
|
6228
|
-
value:
|
|
6229
|
+
value: Fa(t, e)
|
|
6229
6230
|
};
|
|
6230
6231
|
}
|
|
6231
|
-
},
|
|
6232
|
+
}, Ea = (e, t) => {
|
|
6232
6233
|
switch (e.kind) {
|
|
6233
6234
|
case "replayed": return e.response.rejected ? {
|
|
6234
6235
|
settle: "reject",
|
|
@@ -6243,42 +6244,42 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6243
6244
|
};
|
|
6244
6245
|
default: return {
|
|
6245
6246
|
settle: "reject",
|
|
6246
|
-
error:
|
|
6247
|
+
error: wa(e) ?? t
|
|
6247
6248
|
};
|
|
6248
6249
|
}
|
|
6249
|
-
},
|
|
6250
|
+
}, Da = /* @__PURE__ */ new WeakSet(), Oa = /* @__PURE__ */ new WeakSet(), ka = /* @__PURE__ */ new WeakSet(), Aa = /* @__PURE__ */ new WeakSet(), ja = /* @__PURE__ */ new WeakSet(), Ma = /* @__PURE__ */ new WeakSet(), Na = /* @__PURE__ */ new WeakSet(), Pa = /* @__PURE__ */ new WeakSet(), Fa = (e, t) => {
|
|
6250
6251
|
switch (t.kind) {
|
|
6251
6252
|
case "cancelled":
|
|
6252
|
-
|
|
6253
|
+
Da.add(e);
|
|
6253
6254
|
break;
|
|
6254
6255
|
case "exhausted":
|
|
6255
|
-
|
|
6256
|
+
Oa.add(e);
|
|
6256
6257
|
break;
|
|
6257
6258
|
case "insufficient":
|
|
6258
|
-
|
|
6259
|
+
ka.add(e);
|
|
6259
6260
|
break;
|
|
6260
6261
|
case "unsatisfiable":
|
|
6261
|
-
|
|
6262
|
+
Aa.add(e);
|
|
6262
6263
|
break;
|
|
6263
6264
|
case "sign-in-required":
|
|
6264
|
-
|
|
6265
|
+
ja.add(e);
|
|
6265
6266
|
break;
|
|
6266
6267
|
case "unavailable":
|
|
6267
|
-
|
|
6268
|
+
Ma.add(e);
|
|
6268
6269
|
break;
|
|
6269
6270
|
case "session-changed":
|
|
6270
|
-
|
|
6271
|
+
Na.add(e);
|
|
6271
6272
|
break;
|
|
6272
|
-
case "transport-failure":
|
|
6273
|
+
case "transport-failure": Pa.add(e);
|
|
6273
6274
|
}
|
|
6274
6275
|
return e;
|
|
6275
|
-
},
|
|
6276
|
+
}, Ia = (e) => Da.has(e), La = (e) => Oa.has(e), Ra = (e) => ka.has(e), za = (e) => Aa.has(e), Ba = (e) => ja.has(e), Va = (e) => Ma.has(e), Ha = (e) => Na.has(e), Ua = (e) => Pa.has(e), Wa = "https://passflow-relative.invalid", Ga = () => {
|
|
6276
6277
|
let e = globalThis, t = e.document?.baseURI;
|
|
6277
6278
|
if (typeof t == "string" && t !== "") return t;
|
|
6278
6279
|
let n = e.location?.href;
|
|
6279
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6280
|
-
},
|
|
6281
|
-
let n = t ===
|
|
6280
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Wa;
|
|
6281
|
+
}, Ka = (e, t = Ga()) => {
|
|
6282
|
+
let n = t === Wa, r;
|
|
6282
6283
|
try {
|
|
6283
6284
|
r = new URL(t).origin;
|
|
6284
6285
|
} catch {
|
|
@@ -6304,28 +6305,28 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6304
6305
|
relativeToBase: !1,
|
|
6305
6306
|
sentinelBase: n
|
|
6306
6307
|
};
|
|
6307
|
-
},
|
|
6308
|
+
}, qa = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Ja = (e) => {
|
|
6308
6309
|
let t = [];
|
|
6309
6310
|
if (e == null) return Object.freeze(t);
|
|
6310
6311
|
let n = e;
|
|
6311
6312
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6312
|
-
let r =
|
|
6313
|
+
let r = qa(n, e);
|
|
6313
6314
|
r && t.push(r);
|
|
6314
6315
|
}), Object.freeze(t);
|
|
6315
6316
|
if (Array.isArray(e)) {
|
|
6316
6317
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6317
|
-
let e =
|
|
6318
|
+
let e = qa(String(n[0]), n[1]);
|
|
6318
6319
|
e && t.push(e);
|
|
6319
6320
|
}
|
|
6320
6321
|
return Object.freeze(t);
|
|
6321
6322
|
}
|
|
6322
6323
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6323
|
-
let e =
|
|
6324
|
+
let e = qa(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6324
6325
|
e && t.push(e);
|
|
6325
6326
|
}
|
|
6326
6327
|
return Object.freeze(t);
|
|
6327
|
-
},
|
|
6328
|
-
let t = e.base === void 0 ?
|
|
6328
|
+
}, Ya = (e) => {
|
|
6329
|
+
let t = e.base === void 0 ? Ka(e.url) : Ka(e.url, e.base), n = {
|
|
6329
6330
|
raw: e.url,
|
|
6330
6331
|
href: t.href,
|
|
6331
6332
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6334,29 +6335,29 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6334
6335
|
resolved: t.resolved,
|
|
6335
6336
|
relativeToBase: t.relativeToBase,
|
|
6336
6337
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6337
|
-
headers:
|
|
6338
|
+
headers: Ja(e.headers),
|
|
6338
6339
|
bodyKind: e.bodyKind,
|
|
6339
6340
|
..."body" in e ? { body: e.body } : {}
|
|
6340
6341
|
};
|
|
6341
6342
|
return Object.freeze(n);
|
|
6342
|
-
},
|
|
6343
|
+
}, Xa = (e, t) => {
|
|
6343
6344
|
if (!t || t.from === t.to) return e;
|
|
6344
6345
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6345
6346
|
return n ? Object.freeze(r) : e;
|
|
6346
|
-
},
|
|
6347
|
+
}, Za = (e) => {
|
|
6347
6348
|
let t = {};
|
|
6348
6349
|
for (let [n, r] of e) t[n] = r;
|
|
6349
6350
|
return t;
|
|
6350
|
-
},
|
|
6351
|
+
}, Qa = /* @__PURE__ */ new Set([
|
|
6351
6352
|
"GET",
|
|
6352
6353
|
"HEAD",
|
|
6353
6354
|
"OPTIONS"
|
|
6354
|
-
]),
|
|
6355
|
+
]), $a = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, eo = (e) => typeof e == "string" ? e : $a(e) ? e.url : String(e), to = (e, t) => (t?.method ?? ($a(e) ? e.method : void 0) ?? "GET").toUpperCase(), no = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", ro = (e) => {
|
|
6355
6356
|
if (typeof e == "string") return e.length;
|
|
6356
6357
|
let t = e;
|
|
6357
6358
|
if (typeof t?.size == "number") return t.size;
|
|
6358
6359
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6359
|
-
},
|
|
6360
|
+
}, io = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Qa.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), ao = (e, t, n, r, i) => ({
|
|
6360
6361
|
replayable: !1,
|
|
6361
6362
|
bodyKind: e,
|
|
6362
6363
|
reason: t,
|
|
@@ -6364,11 +6365,11 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6364
6365
|
forwardInit: i,
|
|
6365
6366
|
snapshot: r,
|
|
6366
6367
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6367
|
-
}),
|
|
6368
|
+
}), oo = (e, t) => Za(Xa(e.headers, t?.authorizationSwap)), so = (e) => {
|
|
6368
6369
|
if (!e || !("headers" in e)) return e;
|
|
6369
6370
|
let { headers: t, ...n } = e;
|
|
6370
6371
|
return n;
|
|
6371
|
-
},
|
|
6372
|
+
}, co = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : $a(e) ? e.headers : void 0, lo = (e) => {
|
|
6372
6373
|
if (e === null || typeof e == "string") return e;
|
|
6373
6374
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6374
6375
|
let t = new FormData();
|
|
@@ -6376,18 +6377,18 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6376
6377
|
return t;
|
|
6377
6378
|
}
|
|
6378
6379
|
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;
|
|
6379
|
-
},
|
|
6380
|
-
let r =
|
|
6380
|
+
}, uo = (e, t, n) => new Request(e, { headers: oo(t, n) }), fo = (e, t, n) => {
|
|
6381
|
+
let r = eo(e), i = to(e, t), a = co(e, t), o = (e, t) => Ya({
|
|
6381
6382
|
url: r,
|
|
6382
6383
|
method: i,
|
|
6383
6384
|
headers: a,
|
|
6384
6385
|
bodyKind: e,
|
|
6385
6386
|
...t === void 0 ? {} : { body: t }
|
|
6386
6387
|
});
|
|
6387
|
-
if (
|
|
6388
|
+
if ($a(e)) {
|
|
6388
6389
|
if (e.body === null || e.body === void 0) {
|
|
6389
6390
|
let a = o("none");
|
|
6390
|
-
return
|
|
6391
|
+
return io(n, {
|
|
6391
6392
|
url: r,
|
|
6392
6393
|
method: i,
|
|
6393
6394
|
bodyKind: "none"
|
|
@@ -6397,20 +6398,20 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6397
6398
|
forwardInput: e,
|
|
6398
6399
|
forwardInit: t,
|
|
6399
6400
|
snapshot: a,
|
|
6400
|
-
replay: (n, r) => n(
|
|
6401
|
-
} :
|
|
6401
|
+
replay: (n, r) => n(uo(e, a, r), so(t))
|
|
6402
|
+
} : ao("none", "the replay policy refused this request", e, a, t);
|
|
6402
6403
|
}
|
|
6403
6404
|
let a = o("request-clone");
|
|
6404
|
-
if (!
|
|
6405
|
+
if (!io(n, {
|
|
6405
6406
|
url: r,
|
|
6406
6407
|
method: i,
|
|
6407
6408
|
bodyKind: "request-clone"
|
|
6408
|
-
})) return
|
|
6409
|
+
})) return ao("request-clone", "the replay policy refused this request", e, a, t);
|
|
6409
6410
|
let s;
|
|
6410
6411
|
try {
|
|
6411
6412
|
s = e.clone();
|
|
6412
6413
|
} catch {
|
|
6413
|
-
return
|
|
6414
|
+
return ao("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6414
6415
|
}
|
|
6415
6416
|
return {
|
|
6416
6417
|
replayable: !0,
|
|
@@ -6418,17 +6419,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6418
6419
|
forwardInput: e,
|
|
6419
6420
|
forwardInit: t,
|
|
6420
6421
|
snapshot: a,
|
|
6421
|
-
replay: (e, n) => e(
|
|
6422
|
+
replay: (e, n) => e(uo(s, a, n), so(t))
|
|
6422
6423
|
};
|
|
6423
6424
|
}
|
|
6424
|
-
let s =
|
|
6425
|
-
if (s === "one-shot") return
|
|
6426
|
-
if (!
|
|
6425
|
+
let s = no(t?.body);
|
|
6426
|
+
if (s === "one-shot") return ao("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6427
|
+
if (!io(n, {
|
|
6427
6428
|
url: r,
|
|
6428
6429
|
method: i,
|
|
6429
6430
|
bodyKind: s
|
|
6430
|
-
},
|
|
6431
|
-
let c = t && "body" in t ?
|
|
6431
|
+
}, ro(t?.body))) return ao(s, "the replay policy refused this request", e, o(s), t);
|
|
6432
|
+
let c = t && "body" in t ? lo(t.body ?? null) : void 0, l = o(s, c);
|
|
6432
6433
|
return {
|
|
6433
6434
|
replayable: !0,
|
|
6434
6435
|
bodyKind: s,
|
|
@@ -6436,21 +6437,21 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6436
6437
|
forwardInit: t,
|
|
6437
6438
|
snapshot: l,
|
|
6438
6439
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6439
|
-
...
|
|
6440
|
+
...so(t),
|
|
6440
6441
|
...c === void 0 ? {} : { body: c },
|
|
6441
|
-
headers:
|
|
6442
|
+
headers: oo(l, n),
|
|
6442
6443
|
method: l.method
|
|
6443
6444
|
})
|
|
6444
6445
|
};
|
|
6445
|
-
},
|
|
6446
|
-
if (!
|
|
6446
|
+
}, po = (e) => typeof e == "object" && !!e, mo = (e) => (t) => {
|
|
6447
|
+
if (!po(e)) return;
|
|
6447
6448
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6448
6449
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6449
|
-
},
|
|
6450
|
+
}, ho = (e) => {
|
|
6450
6451
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6451
6452
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6452
|
-
},
|
|
6453
|
-
let r =
|
|
6453
|
+
}, go = (e) => (e?.method ?? "GET").toUpperCase(), _o = (e) => e == null ? "none" : po(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", vo = (e, t, n) => {
|
|
6454
|
+
let r = Za(Xa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6454
6455
|
return {
|
|
6455
6456
|
...e,
|
|
6456
6457
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6459,10 +6460,10 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6459
6460
|
headers: r,
|
|
6460
6461
|
..."body" in t ? { data: t.body } : {}
|
|
6461
6462
|
};
|
|
6462
|
-
},
|
|
6463
|
-
let o = t ?? e?.config, s =
|
|
6464
|
-
url:
|
|
6465
|
-
method:
|
|
6463
|
+
}, yo = (e, t, n, r, i, a) => {
|
|
6464
|
+
let o = t ?? e?.config, s = _o(o?.data), c = a ?? Ya({
|
|
6465
|
+
url: ho(o),
|
|
6466
|
+
method: go(o),
|
|
6466
6467
|
headers: o?.headers,
|
|
6467
6468
|
bodyKind: s,
|
|
6468
6469
|
body: o?.data
|
|
@@ -6470,59 +6471,59 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6470
6471
|
url: c.href,
|
|
6471
6472
|
method: c.method,
|
|
6472
6473
|
bodyKind: s
|
|
6473
|
-
}, u = s !== "one-shot" &&
|
|
6474
|
+
}, u = s !== "one-shot" && io(i.replay, l);
|
|
6474
6475
|
return {
|
|
6475
6476
|
status: e?.status ?? 0,
|
|
6476
|
-
getHeader:
|
|
6477
|
+
getHeader: mo(e?.headers),
|
|
6477
6478
|
readBody: async () => e?.data,
|
|
6478
6479
|
request: c,
|
|
6479
6480
|
replay: async (e) => {
|
|
6480
|
-
let t =
|
|
6481
|
+
let t = ke(vo(o ?? {}, c, e));
|
|
6481
6482
|
try {
|
|
6482
6483
|
let e = await r(t);
|
|
6483
|
-
return
|
|
6484
|
+
return yo(e, e?.config ?? t, e, r, i, c);
|
|
6484
6485
|
} catch (e) {
|
|
6485
|
-
let n =
|
|
6486
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6486
|
+
let n = po(e) ? e : {};
|
|
6487
|
+
if (!n.response || typeof n.response.status != "number" || qr(e)) throw e;
|
|
6487
6488
|
return {
|
|
6488
|
-
...
|
|
6489
|
+
...yo(n.response, n.config ?? t, e, r, i, c),
|
|
6489
6490
|
rejected: !0
|
|
6490
6491
|
};
|
|
6491
6492
|
}
|
|
6492
6493
|
},
|
|
6493
6494
|
markers: {
|
|
6494
|
-
...
|
|
6495
|
-
...
|
|
6495
|
+
...Oe(o) ? { upgradeTransaction: !0 } : {},
|
|
6496
|
+
...Ae(o) ? { replayed: !0 } : {}
|
|
6496
6497
|
},
|
|
6497
6498
|
raw: n,
|
|
6498
6499
|
replayable: u,
|
|
6499
6500
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6500
6501
|
signal: o?.signal
|
|
6501
6502
|
};
|
|
6502
|
-
},
|
|
6503
|
-
let r =
|
|
6503
|
+
}, bo = (e, t) => async (n) => {
|
|
6504
|
+
let r = sa(e), i = po(n) ? n : {}, a = Ea(await Ca(yo(i.response, i.config, i.response, t, r), r), n);
|
|
6504
6505
|
if (a.settle === "reject") throw a.error;
|
|
6505
6506
|
return a.value;
|
|
6506
|
-
},
|
|
6507
|
-
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,
|
|
6507
|
+
}, xo = (e, t, n) => {
|
|
6508
|
+
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, bo(t, i)), o = !1;
|
|
6508
6509
|
return () => {
|
|
6509
6510
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6510
6511
|
};
|
|
6511
|
-
},
|
|
6512
|
+
}, So = (t, n) => {
|
|
6512
6513
|
let r = e.create(t);
|
|
6513
6514
|
return n(r), r;
|
|
6514
|
-
},
|
|
6515
|
+
}, Co = () => {
|
|
6515
6516
|
let e = typeof location > "u" ? void 0 : location.origin;
|
|
6516
6517
|
return e && e !== "null" ? e : void 0;
|
|
6517
|
-
},
|
|
6518
|
+
}, wo = (e) => {
|
|
6518
6519
|
let t = new URL(e).origin;
|
|
6519
6520
|
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
6520
6521
|
return t;
|
|
6521
|
-
},
|
|
6522
|
-
let n = (t?.origins ?? []).map(
|
|
6522
|
+
}, To = (e, t) => {
|
|
6523
|
+
let n = (t?.origins ?? []).map(wo);
|
|
6523
6524
|
return (t, r) => {
|
|
6524
6525
|
if (r) return Promise.resolve(void 0);
|
|
6525
|
-
let i =
|
|
6526
|
+
let i = Co(), a;
|
|
6526
6527
|
try {
|
|
6527
6528
|
a = new URL(t, i).origin;
|
|
6528
6529
|
} catch {
|
|
@@ -6530,22 +6531,22 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6530
6531
|
}
|
|
6531
6532
|
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
6532
6533
|
};
|
|
6533
|
-
},
|
|
6534
|
-
let r =
|
|
6534
|
+
}, Eo = (e) => typeof Request < "u" && e instanceof Request, Do = (e, t) => new Headers(t?.headers === void 0 ? Eo(e) ? e.headers : void 0 : t.headers), Oo = (e, t, n) => {
|
|
6535
|
+
let r = To(t, n);
|
|
6535
6536
|
return async (t, n) => {
|
|
6536
|
-
let i =
|
|
6537
|
+
let i = Eo(t) ? t.url : t instanceof URL ? t.href : String(t), a = Do(t, n), o = await r(i, a.has("authorization"));
|
|
6537
6538
|
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
6538
6539
|
...n,
|
|
6539
6540
|
headers: a
|
|
6540
6541
|
})) : e(t, n);
|
|
6541
6542
|
};
|
|
6542
|
-
},
|
|
6543
|
+
}, ko = (e) => {
|
|
6543
6544
|
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
6544
6545
|
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
6545
|
-
},
|
|
6546
|
-
let n =
|
|
6546
|
+
}, Ao = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, jo = (e, t) => {
|
|
6547
|
+
let n = To(e, t);
|
|
6547
6548
|
return async (e) => {
|
|
6548
|
-
let t = e.headers, r = await n(
|
|
6549
|
+
let t = e.headers, r = await n(ko(e), Ao(t));
|
|
6549
6550
|
if (!r) return e;
|
|
6550
6551
|
let i = `Bearer ${r}`;
|
|
6551
6552
|
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
@@ -6553,7 +6554,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6553
6554
|
Authorization: i
|
|
6554
6555
|
}, e;
|
|
6555
6556
|
};
|
|
6556
|
-
},
|
|
6557
|
+
}, Mo = 0, No = (e, t) => {
|
|
6557
6558
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6558
6559
|
if (n) return {
|
|
6559
6560
|
get aborted() {
|
|
@@ -6567,34 +6568,34 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6567
6568
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6568
6569
|
} : {}
|
|
6569
6570
|
};
|
|
6570
|
-
},
|
|
6571
|
+
}, Po = (e) => (t) => e.headers?.get(t), Fo = (e, t, n, r, i) => ({
|
|
6571
6572
|
status: e.status,
|
|
6572
|
-
getHeader:
|
|
6573
|
+
getHeader: Po(e),
|
|
6573
6574
|
readBody: () => e.clone().json(),
|
|
6574
6575
|
request: t.snapshot,
|
|
6575
|
-
replay: async (e) =>
|
|
6576
|
+
replay: async (e) => Fo(await t.replay(n, e), t, n, r, i),
|
|
6576
6577
|
markers: r,
|
|
6577
6578
|
raw: e,
|
|
6578
6579
|
replayable: t.replayable,
|
|
6579
6580
|
replayUnsupportedReason: t.reason,
|
|
6580
6581
|
signal: i,
|
|
6581
6582
|
responseType: e.type
|
|
6582
|
-
}),
|
|
6583
|
+
}), Io = (e, t) => {
|
|
6583
6584
|
let n = (t, n) => {
|
|
6584
|
-
|
|
6585
|
+
Mo += 1;
|
|
6585
6586
|
try {
|
|
6586
6587
|
return e(t, n);
|
|
6587
6588
|
} finally {
|
|
6588
|
-
--
|
|
6589
|
+
--Mo;
|
|
6589
6590
|
}
|
|
6590
6591
|
};
|
|
6591
6592
|
return async (e, r) => {
|
|
6592
|
-
if (
|
|
6593
|
-
let i =
|
|
6593
|
+
if (Mo > 0) return n(e, r);
|
|
6594
|
+
let i = sa(t), a = fo(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ta(await Ca(Fo(o, a, n, {}, No(e, r)), i), o, i);
|
|
6594
6595
|
if (s.settle === "reject") throw s.error;
|
|
6595
6596
|
return s.value;
|
|
6596
6597
|
};
|
|
6597
|
-
},
|
|
6598
|
+
}, Lo = new Set(zi.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ro = (e) => {
|
|
6598
6599
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6599
6600
|
kind: "protocol",
|
|
6600
6601
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6606,17 +6607,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6606
6607
|
webauthn: e.webauthn,
|
|
6607
6608
|
codeSentTo: e.code_sent_to
|
|
6608
6609
|
};
|
|
6609
|
-
},
|
|
6610
|
+
}, zo = (e) => qr(e) && !Jr(e), Bo = (e) => ({
|
|
6610
6611
|
async prepare(t) {
|
|
6611
|
-
if (!
|
|
6612
|
+
if (!Lo.has(t)) try {
|
|
6612
6613
|
let n = e.relyingPartyId?.();
|
|
6613
|
-
return
|
|
6614
|
+
return Ro(await e.startUpgrade(n ? {
|
|
6614
6615
|
method: t,
|
|
6615
6616
|
relying_party_id: n
|
|
6616
6617
|
} : { method: t }));
|
|
6617
6618
|
} catch (e) {
|
|
6618
|
-
if (
|
|
6619
|
-
let t =
|
|
6619
|
+
if (zo(e)) throw e;
|
|
6620
|
+
let t = ei(e, "start");
|
|
6620
6621
|
if (t.kind === "prepare_not_required") return;
|
|
6621
6622
|
throw t;
|
|
6622
6623
|
}
|
|
@@ -6633,17 +6634,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6633
6634
|
assertion: n
|
|
6634
6635
|
});
|
|
6635
6636
|
} catch (t) {
|
|
6636
|
-
if (
|
|
6637
|
-
let n =
|
|
6638
|
-
throw n.status === 401 &&
|
|
6637
|
+
if (zo(t)) throw t;
|
|
6638
|
+
let n = ei(t, "refresh");
|
|
6639
|
+
throw n.status === 401 && ni(n) && e.markSessionInvalid?.(), n;
|
|
6639
6640
|
}
|
|
6640
6641
|
}
|
|
6641
|
-
}),
|
|
6642
|
+
}), Vo = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ho = (e) => {
|
|
6642
6643
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6643
6644
|
let i = () => {
|
|
6644
6645
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6645
6646
|
};
|
|
6646
|
-
return
|
|
6647
|
+
return Bo({
|
|
6647
6648
|
...e,
|
|
6648
6649
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6649
6650
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6654,7 +6655,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6654
6655
|
});
|
|
6655
6656
|
}, i = (t, n) => {
|
|
6656
6657
|
let i = {}, a = {
|
|
6657
|
-
controller: new
|
|
6658
|
+
controller: new oa({
|
|
6658
6659
|
transport: r(() => i.current),
|
|
6659
6660
|
prompt: t.prompt,
|
|
6660
6661
|
platform: e.platform,
|
|
@@ -6666,7 +6667,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6666
6667
|
options: t,
|
|
6667
6668
|
scope: {
|
|
6668
6669
|
passflow: e.passflowDomain,
|
|
6669
|
-
backend:
|
|
6670
|
+
backend: Vo(t.backend)
|
|
6670
6671
|
},
|
|
6671
6672
|
generation: n
|
|
6672
6673
|
};
|
|
@@ -6676,17 +6677,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6676
6677
|
s = void 0;
|
|
6677
6678
|
});
|
|
6678
6679
|
let c = (e) => {
|
|
6679
|
-
if (!s ||
|
|
6680
|
+
if (!s || aa(s.challenge, e)) return;
|
|
6680
6681
|
let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
|
|
6681
6682
|
if (!(Date.now() - s.at > t)) return s.challenge;
|
|
6682
6683
|
}, l = async (r, i) => {
|
|
6683
6684
|
let o = t;
|
|
6684
|
-
if (!o) throw new
|
|
6685
|
+
if (!o) throw new ii("Step-up verification is not enabled on this Passflow instance");
|
|
6685
6686
|
let l = e.stopRepeatedElevation ? c(r) : void 0;
|
|
6686
|
-
if (l) throw new
|
|
6687
|
+
if (l) throw new ri(na(l), na(r), "This requirement was already proved and the server still refused it: sign the user in again");
|
|
6687
6688
|
o.controller.active || (o.pin = e.readSessionPin?.());
|
|
6688
6689
|
let u = await o.controller.elevate(r, i);
|
|
6689
|
-
if (!n(o)) throw new
|
|
6690
|
+
if (!n(o)) throw new ai();
|
|
6690
6691
|
return e.stopRepeatedElevation && (s = {
|
|
6691
6692
|
challenge: r,
|
|
6692
6693
|
at: a ?? Date.now()
|
|
@@ -6709,7 +6710,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6709
6710
|
};
|
|
6710
6711
|
}, d;
|
|
6711
6712
|
return Object.defineProperties(async (e) => {
|
|
6712
|
-
let t = e?.acrValues === void 0 ? void 0 :
|
|
6713
|
+
let t = e?.acrValues === void 0 ? void 0 : ue(e.acrValues).level, n = {
|
|
6713
6714
|
status: 401,
|
|
6714
6715
|
...e?.acrValues === void 0 ? {} : { acrValues: e.acrValues },
|
|
6715
6716
|
...t === void 0 ? {} : { requiredLevel: t },
|
|
@@ -6733,9 +6734,9 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6733
6734
|
let r = [];
|
|
6734
6735
|
if (e.attachInternalSeam) {
|
|
6735
6736
|
let t = e.attachInternalSeam;
|
|
6736
|
-
t((e) =>
|
|
6737
|
+
t((e) => bo(u, e)), r.push(() => t(void 0));
|
|
6737
6738
|
}
|
|
6738
|
-
n.interceptFetch && r.push(
|
|
6739
|
+
n.interceptFetch && r.push(Vt((e, t, n) => Io(e, u)(t, n), {
|
|
6739
6740
|
priority: 20,
|
|
6740
6741
|
name: "passflow-upgrade"
|
|
6741
6742
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -6767,8 +6768,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6767
6768
|
enumerable: !0,
|
|
6768
6769
|
value: (t, n) => {
|
|
6769
6770
|
let r = (t) => {
|
|
6770
|
-
let r =
|
|
6771
|
-
return e.readAccessToken ?
|
|
6771
|
+
let r = Io(t, u);
|
|
6772
|
+
return e.readAccessToken ? Oo(r, e.readAccessToken, n) : r;
|
|
6772
6773
|
};
|
|
6773
6774
|
if (t) return r(t);
|
|
6774
6775
|
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
@@ -6779,14 +6780,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6779
6780
|
attachAuth: {
|
|
6780
6781
|
enumerable: !0,
|
|
6781
6782
|
value: (t, n) => {
|
|
6782
|
-
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(
|
|
6783
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(jo(e.readAccessToken, n)), a = xo(t, u);
|
|
6783
6784
|
return () => {
|
|
6784
6785
|
a(), r && i !== void 0 && r.eject(i);
|
|
6785
6786
|
};
|
|
6786
6787
|
}
|
|
6787
6788
|
}
|
|
6788
6789
|
});
|
|
6789
|
-
},
|
|
6790
|
+
}, Uo, Wo = class {
|
|
6790
6791
|
get origin() {
|
|
6791
6792
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
6792
6793
|
}
|
|
@@ -6795,13 +6796,13 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6795
6796
|
this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
|
|
6796
6797
|
};
|
|
6797
6798
|
let { url: t, appId: n, scopes: r } = e;
|
|
6798
|
-
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ??
|
|
6799
|
+
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? R, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new ae({
|
|
6799
6800
|
prefix: e.keyStoragePrefix ?? "",
|
|
6800
6801
|
storage: this.platform.storage,
|
|
6801
6802
|
appId: n
|
|
6802
|
-
}), this.deviceService = new
|
|
6803
|
-
let i =
|
|
6804
|
-
this.authService = new
|
|
6803
|
+
}), this.deviceService = new oe(this.storageManager), this.authApi = new gt(e, this.storageManager, this.deviceService), this.appApi = new ut(e, this.storageManager, this.deviceService), this.userApi = new Dt(e, this.storageManager, this.deviceService), this.settingApi = new yt(e, this.storageManager, this.deviceService), this.tenantApi = new bt(e, this.storageManager, this.deviceService), this.invitationApi = new vt(e, this.storageManager, this.deviceService), this.twoFactorApi = new Tt(e, this.storageManager, this.deviceService), this.upgradeApi = new Et(e, this.storageManager, this.deviceService), this.upgradeDomain = Ne(e.url), this.subscribeStore = new Fr(), this.tokenCacheService = new ji(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? d, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
6804
|
+
let i = er(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
6805
|
+
this.authService = new Di(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
6805
6806
|
createSession: async (e) => {
|
|
6806
6807
|
await this.createSessionCallback?.(e);
|
|
6807
6808
|
},
|
|
@@ -6813,7 +6814,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6813
6814
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
6814
6815
|
}, () => this.readAppSettings()), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
6815
6816
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
6816
|
-
this.userService = new
|
|
6817
|
+
this.userService = new Ni(this.userApi, this.deviceService, this.platform), this.tenantService = new Ai(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Oi(this.invitationApi), this.twoFactorService = new Mi(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ho({
|
|
6817
6818
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
6818
6819
|
commitRefresh: async (e, t) => {
|
|
6819
6820
|
await this.authService.refreshToken(e, t);
|
|
@@ -6842,7 +6843,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6842
6843
|
let e = (await this.getTokens(!0))?.access_token;
|
|
6843
6844
|
return e && !A(j(e)) ? e : void 0;
|
|
6844
6845
|
}
|
|
6845
|
-
}), this.hostedUpgrade =
|
|
6846
|
+
}), this.hostedUpgrade = Ho({
|
|
6846
6847
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
6847
6848
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
6848
6849
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -6879,14 +6880,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6879
6880
|
return this.upgrade.attachAuth(e, t);
|
|
6880
6881
|
}
|
|
6881
6882
|
createClient(e, t) {
|
|
6882
|
-
return
|
|
6883
|
+
return So(e, (e) => this.upgrade.attachAuth(e, t));
|
|
6883
6884
|
}
|
|
6884
6885
|
readAssuranceBar() {
|
|
6885
6886
|
let e = this.storageManager.getToken(M.access_token);
|
|
6886
6887
|
if (e) try {
|
|
6887
6888
|
let t = j(e), n = typeof t.acr == "string" ? t.acr : void 0;
|
|
6888
6889
|
if (!n) return;
|
|
6889
|
-
let r =
|
|
6890
|
+
let r = ue(n).level;
|
|
6890
6891
|
return r === void 0 ? { acrValues: n } : {
|
|
6891
6892
|
acrValues: n,
|
|
6892
6893
|
level: r
|
|
@@ -6962,7 +6963,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6962
6963
|
}
|
|
6963
6964
|
let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("state") ?? void 0, o = t.get("scopes")?.split(",") ?? this.scopes;
|
|
6964
6965
|
if (n) {
|
|
6965
|
-
if (!
|
|
6966
|
+
if (!ci(n)) {
|
|
6966
6967
|
W(this.subscribeStore, {
|
|
6967
6968
|
operation: "tokens.from-url",
|
|
6968
6969
|
message: "Invalid access token format received",
|
|
@@ -6970,7 +6971,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6970
6971
|
}), this.cleanupUrlParams(e);
|
|
6971
6972
|
return;
|
|
6972
6973
|
}
|
|
6973
|
-
if (r && !
|
|
6974
|
+
if (r && !ci(r)) {
|
|
6974
6975
|
W(this.subscribeStore, {
|
|
6975
6976
|
operation: "tokens.from-url",
|
|
6976
6977
|
message: "Invalid refresh token format received",
|
|
@@ -6978,7 +6979,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6978
6979
|
}), this.cleanupUrlParams(e);
|
|
6979
6980
|
return;
|
|
6980
6981
|
}
|
|
6981
|
-
if (i && !
|
|
6982
|
+
if (i && !ci(i)) {
|
|
6982
6983
|
W(this.subscribeStore, {
|
|
6983
6984
|
operation: "tokens.from-url",
|
|
6984
6985
|
message: "Invalid ID token format received",
|
|
@@ -6993,8 +6994,8 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6993
6994
|
scopes: o
|
|
6994
6995
|
};
|
|
6995
6996
|
this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
|
|
6996
|
-
if (e?.pkce_enabled !== !1) throw
|
|
6997
|
-
return
|
|
6997
|
+
if (e?.pkce_enabled !== !1) throw ln();
|
|
6998
|
+
return Br(this.url, this.appId, t);
|
|
6998
6999
|
}).then(() => {
|
|
6999
7000
|
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
7000
7001
|
}).then(() => (this.subscribeStore.notify(Z.SignIn, {
|
|
@@ -7029,7 +7030,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
7029
7030
|
if (!n) return !1;
|
|
7030
7031
|
t.delete("tfa_token");
|
|
7031
7032
|
let r = t.toString();
|
|
7032
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
7033
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), ci(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
7033
7034
|
email: "",
|
|
7034
7035
|
challengeId: "",
|
|
7035
7036
|
tfaToken: n
|
|
@@ -7042,7 +7043,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
7042
7043
|
checkErrorsFromURL() {
|
|
7043
7044
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
7044
7045
|
if (e) {
|
|
7045
|
-
let t =
|
|
7046
|
+
let t = li(e);
|
|
7046
7047
|
return Error(t);
|
|
7047
7048
|
}
|
|
7048
7049
|
}
|
|
@@ -7452,7 +7453,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
7452
7453
|
this.twoFactorService.clearMagicLinkSession();
|
|
7453
7454
|
}
|
|
7454
7455
|
};
|
|
7455
|
-
|
|
7456
|
-
export { a as APP_ID_HEADER_KEY,
|
|
7456
|
+
Uo = Wo, Uo.version = l;
|
|
7457
|
+
export { a as APP_ID_HEADER_KEY, Be as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, ut as AppAPI, gt as AuthAPI, Di as AuthService, _t as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, zi as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, Ot as FETCH_PRIORITY_OIDC, kt as FETCH_PRIORITY_UPGRADE, At as FetchMiddlewareContractError, de as INSUFFICIENT_USER_AUTHENTICATION, vt as InvitationAPI, Oi as InvitationService, Xt as M2MClient, Gt as M2MConfigError, H as M2MError, Kt as M2MErrorCodes, Ut as M2MNetworkError, Wt as M2MTokenParseError, qt as M2M_DEFAULTS, Ve as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, We as OS, f as PASSFLOW_CLOUD_URL, Le as PASSWORD_CHANGE_REQUIRED_ERROR_ID, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH, Wo as Passflow, Me as PassflowAdminEndpointPaths, B as PassflowEndpointPaths, V as PassflowError, Z as PassflowEvent, U as PassflowOidcError, Re as PassflowPasswordChangeRequiredError, J as PassflowRefreshError, I as PopupClosedError, ze as Providers, Vr as RECOVERABLE_COMMIT_ERROR_IDS, rr as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, je as RequestMethod, l as SDK_VERSION, Fe as SERVICE_UNAVAILABLE_ERROR_ID, Ie as SERVICE_UNAVAILABLE_MESSAGE, Hr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, He as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, yt as SettingAPI, v as TOKEN_EXPIRY_BUFFER_SECONDS, bt as TenantAPI, Ai as TenantService, ki as TenantUserMembership, ji as TokenCacheService, N as TokenDeliveryMode, M as TokenType, Tt as TwoFactorApiClient, qe as TwoFactorPolicy, Mi as TwoFactorService, fe as UPGRADE_REQUIRED, b as USERNAME_MAX_LENGTH, y as USERNAME_MIN_LENGTH, Et as UpgradeAPI, Ki as UpgradeCancelledError, hr as UpgradeCommitInterruptedError, oa as UpgradeController, Q as UpgradeErrorIds, Pi as UpgradeFactorError, ri as UpgradeInsufficientError, ai as UpgradeSessionChangedError, qi as UpgradeSignInRequiredError, $ as UpgradeTransportError, ii as UpgradeUnavailableError, Qi as UpgradeUnsatisfiableError, Dt as UserAPI, Ni as UserService, L as WebAdapter, ei as classifyUpgradeError, Bi as factorRegistry, Ht as fetchRegistryState, Ge as getOSFromDeviceType, ni as invalidatesSessionOnCommit, Pe as isEmailVerificationStep, Ue as isMaskedSecret, ti as isRecoverableCommitFailure, Wr as isRetryableUpgradeKind, A as isTokenExpired, Ia as isUpgradeCancelled, La as isUpgradeExhausted, Ra as isUpgradeInsufficient, Ha as isUpgradeSessionChanged, Ba as isUpgradeSignInRequired, Jr as isUpgradeTransportError, Ua as isUpgradeTransportFailure, Va as isUpgradeUnavailable, za as isUpgradeUnsatisfiable, ui as isValidEmail, ci as isValidJWTFormat, di as isValidPhoneNumber, fi as isValidUsername, ye as parseChallengeBody, ve as parseChallengeHeader, j as parseToken, Ce as parseUpgradeChallenge, Ri as passkeyFactor, Ke as pathWithParams, Li as recoveryCodesFactor, Vt as registerFetchMiddleware, z as requiredAcrLevel, Ne as resolveUpgradeDomain, li as sanitizeErrorMessage, Gi as selectFactors, Ii as totpFactor, R as webAdapter };
|
|
7457
7458
|
|
|
7458
7459
|
//# sourceMappingURL=index.mjs.map
|