Start every Rule private, with a rotating link and files that follow its readers.
New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
This commit is contained in:
1 parent
642551064c
commit
5cbda35e32
50 files changed
+2429
-219
No files matched your search
@@ -69,6 +69,33 @@ async function clearGuestRuleClaimCookie(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
/** True when this browser's claim cookie hashes to `claimTokenHash`. */
|
||||
export async function browserHoldsClaimForHash(
|
||||
claimTokenHash: string | null | undefined,
|
||||
): Promise<boolean> {
|
||||
if (typeof claimTokenHash !== "string" || claimTokenHash.length === 0) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const store = await cookies();
|
||||
const tokens = parseClaimTokens(
|
||||
store.get(GUEST_RULE_CLAIM_COOKIE_NAME)?.value,
|
||||
);
|
||||
if (tokens.length === 0) return false;
|
||||
let pepper: string;
|
||||
try {
|
||||
pepper = getSessionPepper();
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return tokens.some(
|
||||
(token) => hashRuleClaimToken(token, pepper) === claimTokenHash,
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach ownerless published rules whose claim secrets are in this browser's
|
||||
* cookie to `userId`, then drop the cookie. Never throws to the caller.
|
||||
|
||||
Reference in new issue
Block a user