mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
meteor update --release 3.6-rc.1 failed with "No version of shell-server satisfies all constraints" (and the same for dynamic-import, allow-deny, ddp-server, facebook-oauth and google-oauth): those six are WeKan's forks in packages/, made because Meteor 3.6-rc.0 lacked the 3.5.3 security fixes, and pinned to rc.0's versions. Meteor 3.6-rc.1 carries the security fixes of 3.5.3 and 3.5.4, but not what is WeKan's own in the forks: the Admin Panel / Problems reports of refused attempts, and the crypto-RNG keys of dynamic-import and meteor shell (rc.1 still makes them with Math.random()). So the forks are kept and rebased: each is rc.1's package with WeKan's changes over rc.0's package merged three-way onto it. The 3.5.3 hunks merged away, as rc.1 has them; what remains over rc.1 is only the hooks and the keys. The versions are rc.1's with a _1 wrap number. @meteorjs/rspack moves to 3.0.0-rc.2 with the release. The Dockerfile's METEOR_RELEASE and the snap description follow. The experimental Bun build's Meteor patch applies unchanged to 3.6-rc.1; prepare-meteor.sh now checks for rc.1's tag commit and applies meteor-3.6-rc.1.patch, and the rc.0 copy is removed. tests/meteor353SecurityFixes.test.cjs and meteorForkRandomKeys.test.cjs are moved to rc.1 with their assertions kept; meteor-353-security.e2e.js passes on rc.1 in Chromium and Firefox. Thanks to xet7 !
106 lines
2.9 KiB
TypeScript
106 lines
2.9 KiB
TypeScript
interface PrecedenceItem {
|
|
subscriptionHandle: string;
|
|
value: any;
|
|
}
|
|
|
|
interface ChangeCollector {
|
|
[key: string]: any;
|
|
}
|
|
|
|
export class SessionDocumentView {
|
|
private existsIn: Set<string>;
|
|
private dataByKey: Map<string, PrecedenceItem[]>;
|
|
|
|
constructor() {
|
|
this.existsIn = new Set(); // set of subscriptionHandle
|
|
// Memory Growth
|
|
this.dataByKey = new Map(); // key-> [ {subscriptionHandle, value} by precedence]
|
|
}
|
|
|
|
getFields(): Record<string, any> {
|
|
const ret: Record<string, any> = Object.create(null);
|
|
this.dataByKey.forEach((precedenceList, key) => {
|
|
ret[key] = precedenceList[0].value;
|
|
});
|
|
return ret;
|
|
}
|
|
|
|
clearField(
|
|
subscriptionHandle: string,
|
|
key: string,
|
|
changeCollector: ChangeCollector
|
|
): void {
|
|
// Publish API ignores _id if present in fields
|
|
if (key === "_id") return;
|
|
|
|
const precedenceList = this.dataByKey.get(key);
|
|
// It's okay to clear fields that didn't exist. No need to throw
|
|
// an error.
|
|
if (!precedenceList) return;
|
|
|
|
let removedValue: any = undefined;
|
|
|
|
for (let i = 0; i < precedenceList.length; i++) {
|
|
const precedence = precedenceList[i];
|
|
if (precedence.subscriptionHandle === subscriptionHandle) {
|
|
// The view's value can only change if this subscription is the one that
|
|
// used to have precedence.
|
|
if (i === 0) removedValue = precedence.value;
|
|
precedenceList.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (precedenceList.length === 0) {
|
|
this.dataByKey.delete(key);
|
|
changeCollector[key] = undefined;
|
|
} else if (
|
|
removedValue !== undefined &&
|
|
!EJSON.equals(removedValue, precedenceList[0].value)
|
|
) {
|
|
changeCollector[key] = precedenceList[0].value;
|
|
}
|
|
}
|
|
|
|
changeField(
|
|
subscriptionHandle: string,
|
|
key: string,
|
|
value: any,
|
|
changeCollector: ChangeCollector,
|
|
isAdd: boolean = false
|
|
): void {
|
|
// Publish API ignores _id if present in fields
|
|
if (key === "_id") return;
|
|
|
|
// Don't share state with the data passed in by the user.
|
|
value = EJSON.clone(value);
|
|
|
|
if (!this.dataByKey.has(key)) {
|
|
this.dataByKey.set(key, [
|
|
{ subscriptionHandle: subscriptionHandle, value: value },
|
|
]);
|
|
changeCollector[key] = value;
|
|
return;
|
|
}
|
|
|
|
const precedenceList = this.dataByKey.get(key)!;
|
|
let elt: PrecedenceItem | undefined;
|
|
|
|
if (!isAdd) {
|
|
elt = precedenceList.find(
|
|
(precedence) => precedence.subscriptionHandle === subscriptionHandle
|
|
);
|
|
}
|
|
|
|
if (elt) {
|
|
if (elt === precedenceList[0] && !EJSON.equals(value, elt.value)) {
|
|
// this subscription is changing the value of this field.
|
|
changeCollector[key] = value;
|
|
}
|
|
elt.value = value;
|
|
} else {
|
|
// this subscription is newly caring about this field
|
|
precedenceList.push({ subscriptionHandle: subscriptionHandle, value: value });
|
|
}
|
|
}
|
|
} |