@orangecheck/me-client 0.56.0 → 0.57.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/dist/server.mjs CHANGED
@@ -909,7 +909,8 @@ async function exchangeNativeCode(input, options = {}) {
909
909
  }
910
910
  );
911
911
  if (checked.status === "unavailable") {
912
- return { status: "unavailable", reason: checked.reason ?? "revocations_unavailable" };
912
+ const reason = checked.reason === "key_set_unavailable" ? checked.reason : "revocations_unavailable";
913
+ return { status: "unavailable", reason };
913
914
  }
914
915
  if (checked.status === "signed_out") return { status: "invalid", reason: checked.reason ?? "session_ended" };
915
916
  const rule = await checkSignInRule(checked.session, {
@@ -1049,15 +1050,21 @@ async function checkOcToken(token, options = {}) {
1049
1050
  }
1050
1051
  var sessionChecks = /* @__PURE__ */ new Map();
1051
1052
  var warnedUnchecked = false;
1053
+ var warnedNoFeed = false;
1054
+ var NO_FEED = "no_feed";
1052
1055
  function revocationFor(options, session) {
1053
1056
  if (options.revocation === false) return null;
1054
1057
  if (options.revocation) return options.revocation;
1055
1058
  if (isFamily(session)) {
1056
1059
  const token = typeof process !== "undefined" ? process.env?.OC_REVOCATION_FEED_TOKEN?.trim() : void 0;
1057
1060
  if (!token) {
1058
- throw new Error(
1059
- "@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."
1060
- );
1061
+ if (!warnedNoFeed) {
1062
+ warnedNoFeed = true;
1063
+ console.error(
1064
+ "[@orangecheck/me-client] a family session (no aud) is checked against ochk.io's revocation feed, and OC_REVOCATION_FEED_TOKEN is not set, so each one is refused (503 revocation_feed_unconfigured). Set it, or pass `revocation: false` to read family sessions by signature alone."
1065
+ );
1066
+ }
1067
+ return NO_FEED;
1061
1068
  }
1062
1069
  return familyRevocationCheck();
1063
1070
  }
@@ -1084,6 +1091,7 @@ function revocationFor(options, session) {
1084
1091
  function _resetSessionChecksForTests() {
1085
1092
  sessionChecks.clear();
1086
1093
  warnedUnchecked = false;
1094
+ warnedNoFeed = false;
1087
1095
  warnedHandle = false;
1088
1096
  }
1089
1097
  async function getOcSession(headers, options = {}) {
@@ -1107,6 +1115,7 @@ async function checkOcSession(headers, options = {}) {
1107
1115
  return { status: "signed_out", reason: "no_session_handle" };
1108
1116
  }
1109
1117
  const check = revocationFor(options, session);
1118
+ if (check === NO_FEED) return { status: "unavailable", reason: "revocation_feed_unconfigured" };
1110
1119
  if (check) {
1111
1120
  const state = await check.status(session);
1112
1121
  if (state === "revoked") return { status: "signed_out" };