jkdsjkd
This commit is contained in:
@@ -13,6 +13,10 @@ const NOTIFICATION_WINDOW_MS = 15 * 60 * 1000;
|
|||||||
// somebody to open the sign-up link again every 48 hours. It carries the id of the link so that
|
// somebody to open the sign-up link again every 48 hours. It carries the id of the link so that
|
||||||
// revoking the link works right away — see services/passport.js.
|
// revoking the link works right away — see services/passport.js.
|
||||||
const OBSIDIAN_TOKEN_TTL = '365d';
|
const OBSIDIAN_TOKEN_TTL = '365d';
|
||||||
|
// A service describes itself with a handful of short values (its Foundry system, its Discord
|
||||||
|
// user id...), and those are shown to the user who answers the link, so both are capped.
|
||||||
|
const MAX_META_ENTRIES = 10;
|
||||||
|
const MAX_META_VALUE_LENGTH = 200;
|
||||||
|
|
||||||
// Every service that connects to a campaign does it the same way: it asks the
|
// Every service that connects to a campaign does it the same way: it asks the
|
||||||
// backend for a sign-up link, shows it to the person sitting in front of it,
|
// backend for a sign-up link, shows it to the person sitting in front of it,
|
||||||
|
|||||||
30
tests/service-link-target.test.js
Normal file
30
tests/service-link-target.test.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// A service asking for its sign-up link describes itself in `target`; the backend
|
||||||
|
// keeps only the short, plain values it can show the user who answers the link.
|
||||||
|
// Run with `npm test` from the repository root, or `node --test tests/`.
|
||||||
|
|
||||||
|
const { test } = require("node:test");
|
||||||
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
|
const serviceLinks = require("../backend/src/services/service-links");
|
||||||
|
|
||||||
|
test("a link request keeps the service metadata short and plain", () => {
|
||||||
|
const target = serviceLinks.readTarget({
|
||||||
|
target: {
|
||||||
|
id: "world-1",
|
||||||
|
name: "Test World",
|
||||||
|
user: "Test GM",
|
||||||
|
meta: {
|
||||||
|
system: "dnd5e",
|
||||||
|
url: "https://vtt.test/some/path",
|
||||||
|
nested: { ignored: true },
|
||||||
|
long: "x".repeat(500),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(target.targetId, "world-1");
|
||||||
|
assert.equal(target.targetMeta.system, "dnd5e");
|
||||||
|
assert.equal(target.targetMeta.url, "https://vtt.test", "only the origin of the world URL is kept");
|
||||||
|
assert.equal(target.targetMeta.nested, undefined, "objects are not copied into the metadata");
|
||||||
|
assert.equal(target.targetMeta.long.length, 200, "long values are cut to the metadata limit");
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user