@passflow/core 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -107
- package/dist/index.d.ts +139 -107
- package/dist/index.mjs +93 -38
- 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.
|
|
4
|
+
var i = "0.32.0", 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"
|
|
@@ -6511,7 +6511,49 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6511
6511
|
}, vo = (t, n) => {
|
|
6512
6512
|
let r = e.create(t);
|
|
6513
6513
|
return n(r), r;
|
|
6514
|
-
}, yo =
|
|
6514
|
+
}, yo = () => {
|
|
6515
|
+
let e = typeof location > "u" ? void 0 : location.origin;
|
|
6516
|
+
return e && e !== "null" ? e : void 0;
|
|
6517
|
+
}, bo = (e) => {
|
|
6518
|
+
let t = new URL(e).origin;
|
|
6519
|
+
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
6520
|
+
return t;
|
|
6521
|
+
}, xo = (e, t) => {
|
|
6522
|
+
let n = (t?.origins ?? []).map(bo);
|
|
6523
|
+
return (t, r) => {
|
|
6524
|
+
if (r) return Promise.resolve(void 0);
|
|
6525
|
+
let i = yo(), a;
|
|
6526
|
+
try {
|
|
6527
|
+
a = new URL(t, i).origin;
|
|
6528
|
+
} catch {
|
|
6529
|
+
return Promise.resolve(void 0);
|
|
6530
|
+
}
|
|
6531
|
+
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
6532
|
+
};
|
|
6533
|
+
}, So = (e) => typeof Request < "u" && e instanceof Request, Co = (e, t) => new Headers(t?.headers === void 0 ? So(e) ? e.headers : void 0 : t.headers), wo = (e, t, n) => {
|
|
6534
|
+
let r = xo(t, n);
|
|
6535
|
+
return async (t, n) => {
|
|
6536
|
+
let i = So(t) ? t.url : t instanceof URL ? t.href : String(t), a = Co(t, n), o = await r(i, a.has("authorization"));
|
|
6537
|
+
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
6538
|
+
...n,
|
|
6539
|
+
headers: a
|
|
6540
|
+
})) : e(t, n);
|
|
6541
|
+
};
|
|
6542
|
+
}, To = (e) => {
|
|
6543
|
+
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
6544
|
+
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
6545
|
+
}, Eo = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Do = (e, t) => {
|
|
6546
|
+
let n = xo(e, t);
|
|
6547
|
+
return async (e) => {
|
|
6548
|
+
let t = e.headers, r = await n(To(e), Eo(t));
|
|
6549
|
+
if (!r) return e;
|
|
6550
|
+
let i = `Bearer ${r}`;
|
|
6551
|
+
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
6552
|
+
...t ?? {},
|
|
6553
|
+
Authorization: i
|
|
6554
|
+
}, e;
|
|
6555
|
+
};
|
|
6556
|
+
}, Oo = 0, ko = (e, t) => {
|
|
6515
6557
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6516
6558
|
if (n) return {
|
|
6517
6559
|
get aborted() {
|
|
@@ -6525,34 +6567,34 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6525
6567
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6526
6568
|
} : {}
|
|
6527
6569
|
};
|
|
6528
|
-
},
|
|
6570
|
+
}, Ao = (e) => (t) => e.headers?.get(t), jo = (e, t, n, r, i) => ({
|
|
6529
6571
|
status: e.status,
|
|
6530
|
-
getHeader:
|
|
6572
|
+
getHeader: Ao(e),
|
|
6531
6573
|
readBody: () => e.clone().json(),
|
|
6532
6574
|
request: t.snapshot,
|
|
6533
|
-
replay: async (e) =>
|
|
6575
|
+
replay: async (e) => jo(await t.replay(n, e), t, n, r, i),
|
|
6534
6576
|
markers: r,
|
|
6535
6577
|
raw: e,
|
|
6536
6578
|
replayable: t.replayable,
|
|
6537
6579
|
replayUnsupportedReason: t.reason,
|
|
6538
6580
|
signal: i,
|
|
6539
6581
|
responseType: e.type
|
|
6540
|
-
}),
|
|
6582
|
+
}), Mo = (e, t) => {
|
|
6541
6583
|
let n = (t, n) => {
|
|
6542
|
-
|
|
6584
|
+
Oo += 1;
|
|
6543
6585
|
try {
|
|
6544
6586
|
return e(t, n);
|
|
6545
6587
|
} finally {
|
|
6546
|
-
--
|
|
6588
|
+
--Oo;
|
|
6547
6589
|
}
|
|
6548
6590
|
};
|
|
6549
6591
|
return async (e, r) => {
|
|
6550
|
-
if (
|
|
6551
|
-
let i = ra(t), a = so(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = xa(await ya(
|
|
6592
|
+
if (Oo > 0) return n(e, r);
|
|
6593
|
+
let i = ra(t), a = so(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = xa(await ya(jo(o, a, n, {}, ko(e, r)), i), o, i);
|
|
6552
6594
|
if (s.settle === "reject") throw s.error;
|
|
6553
6595
|
return s.value;
|
|
6554
6596
|
};
|
|
6555
|
-
},
|
|
6597
|
+
}, No = new Set(Fi.filter((e) => !e.requiresPrepare).map((e) => e.type)), Po = (e) => {
|
|
6556
6598
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6557
6599
|
kind: "protocol",
|
|
6558
6600
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6564,16 +6606,16 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6564
6606
|
webauthn: e.webauthn,
|
|
6565
6607
|
codeSentTo: e.code_sent_to
|
|
6566
6608
|
};
|
|
6567
|
-
},
|
|
6609
|
+
}, Fo = (e) => Ur(e) && !Wr(e), Io = (e) => ({
|
|
6568
6610
|
async prepare(t) {
|
|
6569
|
-
if (!
|
|
6611
|
+
if (!No.has(t)) try {
|
|
6570
6612
|
let n = e.relyingPartyId?.();
|
|
6571
|
-
return
|
|
6613
|
+
return Po(await e.startUpgrade(n ? {
|
|
6572
6614
|
method: t,
|
|
6573
6615
|
relying_party_id: n
|
|
6574
6616
|
} : { method: t }));
|
|
6575
6617
|
} catch (e) {
|
|
6576
|
-
if (
|
|
6618
|
+
if (Fo(e)) throw e;
|
|
6577
6619
|
let t = Xr(e, "start");
|
|
6578
6620
|
if (t.kind === "prepare_not_required") return;
|
|
6579
6621
|
throw t;
|
|
@@ -6591,17 +6633,17 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6591
6633
|
assertion: n
|
|
6592
6634
|
});
|
|
6593
6635
|
} catch (t) {
|
|
6594
|
-
if (
|
|
6636
|
+
if (Fo(t)) throw t;
|
|
6595
6637
|
let n = Xr(t, "refresh");
|
|
6596
6638
|
throw n.status === 401 && Qr(n) && e.markSessionInvalid?.(), n;
|
|
6597
6639
|
}
|
|
6598
6640
|
}
|
|
6599
|
-
}),
|
|
6641
|
+
}), Lo = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ro = (e) => {
|
|
6600
6642
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6601
6643
|
let i = () => {
|
|
6602
6644
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6603
6645
|
};
|
|
6604
|
-
return
|
|
6646
|
+
return Io({
|
|
6605
6647
|
...e,
|
|
6606
6648
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6607
6649
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6624,7 +6666,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6624
6666
|
options: t,
|
|
6625
6667
|
scope: {
|
|
6626
6668
|
passflow: e.passflowDomain,
|
|
6627
|
-
backend:
|
|
6669
|
+
backend: Lo(t.backend)
|
|
6628
6670
|
},
|
|
6629
6671
|
generation: n
|
|
6630
6672
|
};
|
|
@@ -6693,7 +6735,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6693
6735
|
let t = e.attachInternalSeam;
|
|
6694
6736
|
t((e) => go(u, e)), r.push(() => t(void 0));
|
|
6695
6737
|
}
|
|
6696
|
-
n.interceptFetch && r.push(Lt((e, t, n) =>
|
|
6738
|
+
n.interceptFetch && r.push(Lt((e, t, n) => Mo(e, u)(t, n), {
|
|
6697
6739
|
priority: 20,
|
|
6698
6740
|
name: "passflow-upgrade"
|
|
6699
6741
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -6723,19 +6765,28 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6723
6765
|
},
|
|
6724
6766
|
withAuth: {
|
|
6725
6767
|
enumerable: !0,
|
|
6726
|
-
value: (
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6768
|
+
value: (t, n) => {
|
|
6769
|
+
let r = (t) => {
|
|
6770
|
+
let r = Mo(t, u);
|
|
6771
|
+
return e.readAccessToken ? wo(r, e.readAccessToken, n) : r;
|
|
6772
|
+
};
|
|
6773
|
+
if (t) return r(t);
|
|
6774
|
+
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
6775
|
+
if (!i || typeof i.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
6776
|
+
return r(i.fetch.bind(i));
|
|
6731
6777
|
}
|
|
6732
6778
|
},
|
|
6733
6779
|
attachAuth: {
|
|
6734
6780
|
enumerable: !0,
|
|
6735
|
-
value: (
|
|
6781
|
+
value: (t, n) => {
|
|
6782
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Do(e.readAccessToken, n)), a = _o(t, u);
|
|
6783
|
+
return () => {
|
|
6784
|
+
a(), r && i !== void 0 && r.eject(i);
|
|
6785
|
+
};
|
|
6786
|
+
}
|
|
6736
6787
|
}
|
|
6737
6788
|
});
|
|
6738
|
-
},
|
|
6789
|
+
}, zo, Bo = class {
|
|
6739
6790
|
get origin() {
|
|
6740
6791
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
6741
6792
|
}
|
|
@@ -6762,7 +6813,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6762
6813
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
6763
6814
|
}, () => this.readAppSettings()), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
6764
6815
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
6765
|
-
this.userService = new ki(this.userApi, this.deviceService, this.platform), this.tenantService = new Ei(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new wi(this.invitationApi), this.twoFactorService = new Oi(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade =
|
|
6816
|
+
this.userService = new ki(this.userApi, this.deviceService, this.platform), this.tenantService = new Ei(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new wi(this.invitationApi), this.twoFactorService = new Oi(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ro({
|
|
6766
6817
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
6767
6818
|
commitRefresh: async (e, t) => {
|
|
6768
6819
|
await this.authService.refreshToken(e, t);
|
|
@@ -6786,8 +6837,12 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6786
6837
|
} : void 0;
|
|
6787
6838
|
},
|
|
6788
6839
|
attachInternalSeam: (e) => this.attachUpgradeSeam(e),
|
|
6789
|
-
onSessionChange: (e) => this.subscribeToSessionChange(e)
|
|
6790
|
-
|
|
6840
|
+
onSessionChange: (e) => this.subscribeToSessionChange(e),
|
|
6841
|
+
readAccessToken: async () => {
|
|
6842
|
+
let e = (await this.getTokens(!0))?.access_token;
|
|
6843
|
+
return e && !A(j(e)) ? e : void 0;
|
|
6844
|
+
}
|
|
6845
|
+
}), this.hostedUpgrade = Ro({
|
|
6791
6846
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
6792
6847
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
6793
6848
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -6817,14 +6872,14 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
6817
6872
|
setAppId(e) {
|
|
6818
6873
|
this.appId = e, this.storageManager.setAppId(e), this.appSettingsRead = void 0, this.authApi.setAppId(e), this.appApi.setAppId(e), this.userApi.setAppId(e), this.settingApi.setAppId(e), this.tenantApi.setAppId(e), this.invitationApi.setAppId(e), this.twoFactorApi.setAppId(e), this.upgradeApi.setAppId(e), this.authService.setAppId(e);
|
|
6819
6874
|
}
|
|
6820
|
-
withAuth(e) {
|
|
6821
|
-
return this.upgrade.withAuth(e);
|
|
6875
|
+
withAuth(e, t) {
|
|
6876
|
+
return this.upgrade.withAuth(e, t);
|
|
6822
6877
|
}
|
|
6823
|
-
attachAuth(e) {
|
|
6824
|
-
return this.upgrade.attachAuth(e);
|
|
6878
|
+
attachAuth(e, t) {
|
|
6879
|
+
return this.upgrade.attachAuth(e, t);
|
|
6825
6880
|
}
|
|
6826
|
-
createClient(e) {
|
|
6827
|
-
return vo(e, (e) => this.upgrade.attachAuth(e));
|
|
6881
|
+
createClient(e, t) {
|
|
6882
|
+
return vo(e, (e) => this.upgrade.attachAuth(e, t));
|
|
6828
6883
|
}
|
|
6829
6884
|
readAssuranceBar() {
|
|
6830
6885
|
let e = this.storageManager.getToken(M.access_token);
|
|
@@ -7397,7 +7452,7 @@ var di = "passflow_2fa_pkce", fi = 3e5, pi = "passflow_pwless_pending", mi = 3e3
|
|
|
7397
7452
|
this.twoFactorService.clearMagicLinkSession();
|
|
7398
7453
|
}
|
|
7399
7454
|
};
|
|
7400
|
-
|
|
7401
|
-
export { a as APP_ID_HEADER_KEY, Ie as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, ot as AppAPI, ft as AuthAPI, Ci as AuthService, pt as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, Fi as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, wt as FETCH_PRIORITY_OIDC, Tt as FETCH_PRIORITY_UPGRADE, Et as FetchMiddlewareContractError, le as INSUFFICIENT_USER_AUTHENTICATION, mt as InvitationAPI, wi as InvitationService, Kt as M2MClient, Vt as M2MConfigError, H as M2MError, Ht as M2MErrorCodes, zt as M2MNetworkError, Bt as M2MTokenParseError, Ut as M2M_DEFAULTS, Le as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, Be as OS, f as PASSFLOW_CLOUD_URL, Ne as PASSWORD_CHANGE_REQUIRED_ERROR_ID, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH,
|
|
7455
|
+
zo = Bo, zo.version = l;
|
|
7456
|
+
export { a as APP_ID_HEADER_KEY, Ie as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, ot as AppAPI, ft as AuthAPI, Ci as AuthService, pt as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, Fi as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, wt as FETCH_PRIORITY_OIDC, Tt as FETCH_PRIORITY_UPGRADE, Et as FetchMiddlewareContractError, le as INSUFFICIENT_USER_AUTHENTICATION, mt as InvitationAPI, wi as InvitationService, Kt as M2MClient, Vt as M2MConfigError, H as M2MError, Ht as M2MErrorCodes, zt as M2MNetworkError, Bt as M2MTokenParseError, Ut as M2M_DEFAULTS, Le as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, Be as OS, f as PASSFLOW_CLOUD_URL, Ne as PASSWORD_CHANGE_REQUIRED_ERROR_ID, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH, Bo as Passflow, B as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, V as PassflowError, Z as PassflowEvent, U as PassflowOidcError, Pe as PassflowPasswordChangeRequiredError, J as PassflowRefreshError, ie as PopupClosedError, Fe as Providers, Lr as RECOVERABLE_COMMIT_ERROR_IDS, $n as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Oe as RequestMethod, l as SDK_VERSION, je as SERVICE_UNAVAILABLE_ERROR_ID, Me as SERVICE_UNAVAILABLE_MESSAGE, Rr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Re as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, ht as SettingAPI, v as TOKEN_EXPIRY_BUFFER_SECONDS, gt as TenantAPI, Ei as TenantService, Ti as TenantUserMembership, Di as TokenCacheService, N as TokenDeliveryMode, M as TokenType, xt as TwoFactorApiClient, Ue as TwoFactorPolicy, Oi as TwoFactorService, ue as UPGRADE_REQUIRED, b as USERNAME_MAX_LENGTH, y as USERNAME_MIN_LENGTH, St as UpgradeAPI, Hi as UpgradeCancelledError, dr as UpgradeCommitInterruptedError, na as UpgradeController, Q as UpgradeErrorIds, Ai as UpgradeFactorError, $r as UpgradeInsufficientError, ti as UpgradeSessionChangedError, Ui as UpgradeSignInRequiredError, $ as UpgradeTransportError, ei as UpgradeUnavailableError, Ji as UpgradeUnsatisfiableError, Ct as UserAPI, ki as UserService, F as WebAdapter, Xr as classifyUpgradeError, Ii as factorRegistry, Rt as fetchRegistryState, Ve as getOSFromDeviceType, Qr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, ze as isMaskedSecret, Zr as isRecoverableCommitFailure, Br as isRetryableUpgradeKind, A as isTokenExpired, Ma as isUpgradeCancelled, Na as isUpgradeExhausted, Pa as isUpgradeInsufficient, Ra as isUpgradeSessionChanged, Ia as isUpgradeSignInRequired, Wr as isUpgradeTransportError, za as isUpgradeTransportFailure, La as isUpgradeUnavailable, Fa as isUpgradeUnsatisfiable, oi as isValidEmail, ii as isValidJWTFormat, si as isValidPhoneNumber, ci as isValidUsername, ge as parseChallengeBody, he as parseChallengeHeader, j as parseToken, be as parseUpgradeChallenge, Pi as passkeyFactor, He as pathWithParams, Ni as recoveryCodesFactor, Lt as registerFetchMiddleware, ce as requiredAcrLevel, ke as resolveUpgradeDomain, ai as sanitizeErrorMessage, Vi as selectFactors, Mi as totpFactor, ae as webAdapter };
|
|
7402
7457
|
|
|
7403
7458
|
//# sourceMappingURL=index.mjs.map
|