@orangecheck/me-client 0.43.0 → 0.45.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.d.mts +17 -1
- package/dist/server.d.ts +17 -1
- package/dist/server.js +38 -5
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +38 -7
- 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;
|
|
@@ -836,16 +836,38 @@ async function post2(url, tokens, timeoutMs) {
|
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
|
|
839
|
+
// src/merged.ts
|
|
840
|
+
var MERGED_HANDLES_MAX = 16;
|
|
841
|
+
function mergedHandles(session) {
|
|
842
|
+
const v = session.merged_rh;
|
|
843
|
+
if (!Array.isArray(v) || v.length > MERGED_HANDLES_MAX) return [];
|
|
844
|
+
if (!v.every((h) => typeof h === "string" && h.length > 0)) return [];
|
|
845
|
+
return [...new Set(v)];
|
|
846
|
+
}
|
|
847
|
+
async function matchMergedUser(session, lookup) {
|
|
848
|
+
const users = /* @__PURE__ */ new Set();
|
|
849
|
+
for (const rh of mergedHandles(session)) {
|
|
850
|
+
const user = await lookup(rh);
|
|
851
|
+
if (typeof user === "string" && user.length > 0) users.add(user);
|
|
852
|
+
}
|
|
853
|
+
if (users.size === 0) return { kind: "none" };
|
|
854
|
+
if (users.size === 1) return { kind: "one", user: [...users][0] };
|
|
855
|
+
return { kind: "conflict", users: [...users].sort() };
|
|
856
|
+
}
|
|
857
|
+
|
|
839
858
|
// src/server.ts
|
|
840
859
|
var VERIFIED = /* @__PURE__ */ new WeakSet();
|
|
841
860
|
function vouch(session) {
|
|
842
861
|
VERIFIED.add(session);
|
|
843
862
|
return session;
|
|
844
863
|
}
|
|
864
|
+
function isFamily(session) {
|
|
865
|
+
const aud = session.aud;
|
|
866
|
+
return aud === void 0 || Array.isArray(aud) && aud.length === 0;
|
|
867
|
+
}
|
|
845
868
|
function lacksHandle(session, requireHandle) {
|
|
846
|
-
if (requireHandle === false) return false;
|
|
847
|
-
const
|
|
848
|
-
if (aud === void 0) return false;
|
|
869
|
+
if (requireHandle === false || isFamily(session)) return false;
|
|
870
|
+
const rh = session.rh;
|
|
849
871
|
return typeof rh !== "string" || rh.length === 0;
|
|
850
872
|
}
|
|
851
873
|
function checkRequireHandle(requireHandle) {
|
|
@@ -892,9 +914,18 @@ async function checkOcToken(token, options = {}) {
|
|
|
892
914
|
}
|
|
893
915
|
var sessionChecks = /* @__PURE__ */ new Map();
|
|
894
916
|
var warnedUnchecked = false;
|
|
895
|
-
function revocationFor(options) {
|
|
917
|
+
function revocationFor(options, session) {
|
|
896
918
|
if (options.revocation === false) return null;
|
|
897
919
|
if (options.revocation) return options.revocation;
|
|
920
|
+
if (isFamily(session)) {
|
|
921
|
+
const token = typeof process !== "undefined" ? process.env?.OC_REVOCATION_FEED_TOKEN?.trim() : void 0;
|
|
922
|
+
if (!token) {
|
|
923
|
+
throw new Error(
|
|
924
|
+
"@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."
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
return familyRevocationCheck();
|
|
928
|
+
}
|
|
898
929
|
const key = `${options.meOrigin ?? ""} ${options.projectKey ?? ""}`;
|
|
899
930
|
if (!sessionChecks.has(key)) {
|
|
900
931
|
sessionChecks.set(
|
|
@@ -940,7 +971,7 @@ async function checkOcSession(headers, options = {}) {
|
|
|
940
971
|
warnNoHandle(session);
|
|
941
972
|
return { status: "signed_out", reason: "no_session_handle" };
|
|
942
973
|
}
|
|
943
|
-
const check = revocationFor(options);
|
|
974
|
+
const check = revocationFor(options, session);
|
|
944
975
|
if (check) {
|
|
945
976
|
const state = await check.status(session);
|
|
946
977
|
if (state === "revoked") return { status: "signed_out" };
|
|
@@ -1208,6 +1239,6 @@ function ocAuthHono(options = {}) {
|
|
|
1208
1239
|
};
|
|
1209
1240
|
}
|
|
1210
1241
|
|
|
1211
|
-
export { BACK_ACCOUNT_URL, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, MemoryJtiStore, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, identity, ocAuthExpress, ocAuthHono, refreshEnvelopeJwks, revokeToken, spendOnce, verifyActivityAttestation, verifyOcToken, withOcAuth };
|
|
1242
|
+
export { BACK_ACCOUNT_URL, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, MemoryJtiStore, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, identity, matchMergedUser, mergedHandles, ocAuthExpress, ocAuthHono, refreshEnvelopeJwks, revokeToken, spendOnce, verifyActivityAttestation, verifyOcToken, withOcAuth };
|
|
1212
1243
|
//# sourceMappingURL=server.mjs.map
|
|
1213
1244
|
//# sourceMappingURL=server.mjs.map
|