@orangecheck/me-client 0.43.0 → 0.44.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 +2 -0
- package/dist/server.js +17 -5
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +18 -6
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { verifyOcToken as verifyOcToken$1, checkOcToken as checkOcToken$1, readOcSessionToken, SAFE_METHODS, integratorRevocationCheck, bondMeets, readBondClaim } from '@orangecheck/auth-core';
|
|
1
|
+
import { verifyOcToken as verifyOcToken$1, checkOcToken as checkOcToken$1, readOcSessionToken, SAFE_METHODS, familyRevocationCheck, integratorRevocationCheck, bondMeets, readBondClaim } from '@orangecheck/auth-core';
|
|
2
2
|
export { bondMeets, readBondClaim } from '@orangecheck/auth-core';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -842,10 +842,13 @@ function vouch(session) {
|
|
|
842
842
|
VERIFIED.add(session);
|
|
843
843
|
return session;
|
|
844
844
|
}
|
|
845
|
+
function isFamily(session) {
|
|
846
|
+
const aud = session.aud;
|
|
847
|
+
return aud === void 0 || Array.isArray(aud) && aud.length === 0;
|
|
848
|
+
}
|
|
845
849
|
function lacksHandle(session, requireHandle) {
|
|
846
|
-
if (requireHandle === false) return false;
|
|
847
|
-
const
|
|
848
|
-
if (aud === void 0) return false;
|
|
850
|
+
if (requireHandle === false || isFamily(session)) return false;
|
|
851
|
+
const rh = session.rh;
|
|
849
852
|
return typeof rh !== "string" || rh.length === 0;
|
|
850
853
|
}
|
|
851
854
|
function checkRequireHandle(requireHandle) {
|
|
@@ -892,9 +895,18 @@ async function checkOcToken(token, options = {}) {
|
|
|
892
895
|
}
|
|
893
896
|
var sessionChecks = /* @__PURE__ */ new Map();
|
|
894
897
|
var warnedUnchecked = false;
|
|
895
|
-
function revocationFor(options) {
|
|
898
|
+
function revocationFor(options, session) {
|
|
896
899
|
if (options.revocation === false) return null;
|
|
897
900
|
if (options.revocation) return options.revocation;
|
|
901
|
+
if (isFamily(session)) {
|
|
902
|
+
const token = typeof process !== "undefined" ? process.env?.OC_REVOCATION_FEED_TOKEN?.trim() : void 0;
|
|
903
|
+
if (!token) {
|
|
904
|
+
throw new Error(
|
|
905
|
+
"@orangecheck/me-client: a family session (no aud) is checked against ochk.io's revocation feed, and OC_REVOCATION_FEED_TOKEN is not set. Set it, or pass `revocation: false` to read family sessions by signature alone."
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
return familyRevocationCheck();
|
|
909
|
+
}
|
|
898
910
|
const key = `${options.meOrigin ?? ""} ${options.projectKey ?? ""}`;
|
|
899
911
|
if (!sessionChecks.has(key)) {
|
|
900
912
|
sessionChecks.set(
|
|
@@ -940,7 +952,7 @@ async function checkOcSession(headers, options = {}) {
|
|
|
940
952
|
warnNoHandle(session);
|
|
941
953
|
return { status: "signed_out", reason: "no_session_handle" };
|
|
942
954
|
}
|
|
943
|
-
const check = revocationFor(options);
|
|
955
|
+
const check = revocationFor(options, session);
|
|
944
956
|
if (check) {
|
|
945
957
|
const state = await check.status(session);
|
|
946
958
|
if (state === "revoked") return { status: "signed_out" };
|