@korajs/server 1.0.0-beta.6 → 1.0.0-beta.7
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/index.cjs +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2740,6 +2740,20 @@ function warnIfMultiTenantWithoutScopes(auth, resolvedScopes, schema) {
|
|
|
2740
2740
|
"[kora] An authenticated session resolved to no sync scopes, so every user will sync every other user's data. Return per-user sync scopes from your auth provider (for example KoraAuthProvider's resolveScopes) to isolate tenants. Note: declaring sync rules in your schema is not enough on its own \u2014 the per-user values come from the auth provider. (This warning is expected for single-tenant apps where all authenticated users are meant to share the same data.)"
|
|
2741
2741
|
);
|
|
2742
2742
|
}
|
|
2743
|
+
function stableStringify(value) {
|
|
2744
|
+
if (Array.isArray(value)) {
|
|
2745
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
2746
|
+
}
|
|
2747
|
+
if (value && typeof value === "object") {
|
|
2748
|
+
const record = value;
|
|
2749
|
+
const entries = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`);
|
|
2750
|
+
return `{${entries.join(",")}}`;
|
|
2751
|
+
}
|
|
2752
|
+
return JSON.stringify(value);
|
|
2753
|
+
}
|
|
2754
|
+
function sameScopeMap(a, b) {
|
|
2755
|
+
return stableStringify(a ?? null) === stableStringify(b ?? null);
|
|
2756
|
+
}
|
|
2743
2757
|
var ClientSession = class _ClientSession {
|
|
2744
2758
|
state = "connected";
|
|
2745
2759
|
clientNodeId = null;
|
|
@@ -3092,6 +3106,9 @@ var ClientSession = class _ClientSession {
|
|
|
3092
3106
|
}
|
|
3093
3107
|
this.resumeDeltaCursor = msg.deltaCursor ? (0, import_sync3.decodeDeltaCursor)(msg.deltaCursor) : null;
|
|
3094
3108
|
this.clientDeliveryWatermark = msg.lastDeliverySequence ?? null;
|
|
3109
|
+
if (this.clientDeliveryWatermark !== null && !sameScopeMap(msg.syncScope, this.authContext?.scopes)) {
|
|
3110
|
+
this.clientDeliveryWatermark = 0;
|
|
3111
|
+
}
|
|
3095
3112
|
const clientUsesWatermark = this.clientDeliveryWatermark !== null;
|
|
3096
3113
|
let serverMaxDelivery = 0;
|
|
3097
3114
|
if (clientUsesWatermark) {
|