@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/README.md
CHANGED
|
@@ -271,6 +271,8 @@ app.get('/api/me', (c) => {
|
|
|
271
271
|
|
|
272
272
|
### Sessions ended everywhere
|
|
273
273
|
|
|
274
|
+
A *.ochk.io site that reads the family cookie (no `audience`) sees family sessions, which ochk.io ends on its own feed. Set `OC_REVOCATION_FEED_TOKEN` (the site's feed token from ochk.io) and the helpers check every family session against it, once a minute per process; while the feed can't be read, reads go on and writes answer 503. With it unset, a family session makes them throw rather than accept it by signature alone (0.44.0); `revocation: false` reads it by signature alone on purpose. The feed is read from `OC_AUTH_ISSUER` (default https://ochk.io), so set it too if you verify another issuer.
|
|
275
|
+
|
|
274
276
|
Set `OC_PROJECT_KEY` and `OC_SIGNING_SECRET` (from ochk.app/me/projects) and `getOcSession`, `withOcAuth`, `ocAuthExpress` and `ocAuthHono` refuse a session the person ended everywhere: sign out everywhere, a passkey removed, the account deleted. A sign-in token carries `rh`, its revocation handle for your origin; they look it up in me.ochk.io's list of ended handles for that origin, read once a minute per origin with a request signed by your secret, so a refusal lands within about two minutes. The handles name nobody, and another site's handles for the same person never match yours. If the list can't be read, or is more than ten minutes old by its own clock, reads go on and writes are refused until it can: the adapters answer such a write `503 { reason: 'revocations_unavailable' }` (0.38.0), not 401, so a client retries instead of signing the person out, and `checkOcSession(headers, options)` tells the same apart for your own code (`signed_in`, `signed_out` or `unavailable`). Every token while the two variables are unset is checked by its signature alone and stays valid until it expires. A token bound to your site without `rh` is refused (`no_session_handle`, 0.40.0 or later), since sign out everywhere can't reach it; every token from the sign-in popup carries one, and `requireHandle: false` accepts one minted some other way. Needs 0.35.0 or later.
|
|
275
277
|
|
|
276
278
|
## Keep your own login: OC Connect
|
package/dist/server.js
CHANGED
|
@@ -843,10 +843,13 @@ function vouch(session) {
|
|
|
843
843
|
VERIFIED.add(session);
|
|
844
844
|
return session;
|
|
845
845
|
}
|
|
846
|
+
function isFamily(session) {
|
|
847
|
+
const aud = session.aud;
|
|
848
|
+
return aud === void 0 || Array.isArray(aud) && aud.length === 0;
|
|
849
|
+
}
|
|
846
850
|
function lacksHandle(session, requireHandle) {
|
|
847
|
-
if (requireHandle === false) return false;
|
|
848
|
-
const
|
|
849
|
-
if (aud === void 0) return false;
|
|
851
|
+
if (requireHandle === false || isFamily(session)) return false;
|
|
852
|
+
const rh = session.rh;
|
|
850
853
|
return typeof rh !== "string" || rh.length === 0;
|
|
851
854
|
}
|
|
852
855
|
function checkRequireHandle(requireHandle) {
|
|
@@ -893,9 +896,18 @@ async function checkOcToken(token, options = {}) {
|
|
|
893
896
|
}
|
|
894
897
|
var sessionChecks = /* @__PURE__ */ new Map();
|
|
895
898
|
var warnedUnchecked = false;
|
|
896
|
-
function revocationFor(options) {
|
|
899
|
+
function revocationFor(options, session) {
|
|
897
900
|
if (options.revocation === false) return null;
|
|
898
901
|
if (options.revocation) return options.revocation;
|
|
902
|
+
if (isFamily(session)) {
|
|
903
|
+
const token = typeof process !== "undefined" ? process.env?.OC_REVOCATION_FEED_TOKEN?.trim() : void 0;
|
|
904
|
+
if (!token) {
|
|
905
|
+
throw new Error(
|
|
906
|
+
"@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."
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
return authCore.familyRevocationCheck();
|
|
910
|
+
}
|
|
899
911
|
const key = `${options.meOrigin ?? ""} ${options.projectKey ?? ""}`;
|
|
900
912
|
if (!sessionChecks.has(key)) {
|
|
901
913
|
sessionChecks.set(
|
|
@@ -941,7 +953,7 @@ async function checkOcSession(headers, options = {}) {
|
|
|
941
953
|
warnNoHandle(session);
|
|
942
954
|
return { status: "signed_out", reason: "no_session_handle" };
|
|
943
955
|
}
|
|
944
|
-
const check = revocationFor(options);
|
|
956
|
+
const check = revocationFor(options, session);
|
|
945
957
|
if (check) {
|
|
946
958
|
const state = await check.status(session);
|
|
947
959
|
if (state === "revoked") return { status: "signed_out" };
|