mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-07 18:02:30 +00:00
Prepare time-bound Setup URI integration for Commonlib release
Add Time-bound and Compatible generation to the Obsidian dialogue, browser peer check, and setup tools, with boundary and compatibility coverage. Show the fixed window end before sharing a Time-bound URI. This review branch depends on unpublished @vrtmrz/livesync-commonlib 0.1.32-next.0. The root npm pin and Deno lockfile remain unchanged until that candidate is available; a fresh install of this commit is not yet expected to build.
This commit is contained in:
@@ -20,6 +20,14 @@ Deno.test("generates an Object Storage Setup URI with a selected S3 profile", as
|
||||
passphrase: "vault-secret",
|
||||
uri_passphrase: "setup-secret",
|
||||
});
|
||||
assert(
|
||||
generated.mode === "ephemeral",
|
||||
"the default Setup URI mode was not Ephemeral",
|
||||
);
|
||||
assert(
|
||||
generated.usableUntil !== null && generated.usableUntil > Date.now(),
|
||||
"the Ephemeral Setup URI did not report its usable end time",
|
||||
);
|
||||
const decoded = await decodeSettingsFromSetupURI(
|
||||
generated.setupURI,
|
||||
generated.setupPassphrase,
|
||||
@@ -121,3 +129,33 @@ Deno.test("generates a random-room P2P Setup URI without copying a device identi
|
||||
"the selected profile was not a P2P connection URI",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("generates a Persistent Setup URI on explicit request", async () => {
|
||||
const generated = await generateSetupURI({
|
||||
remote_type: "p2p",
|
||||
passphrase: "vault-secret",
|
||||
uri_passphrase: "setup-secret",
|
||||
uri_mode: "persistent",
|
||||
});
|
||||
assert(generated.mode === "persistent", "the explicit mode was not retained");
|
||||
assert(
|
||||
generated.usableUntil === null,
|
||||
"Persistent unexpectedly has a time condition",
|
||||
);
|
||||
const decoded = await decodeSettingsFromSetupURI(
|
||||
generated.setupURI,
|
||||
generated.setupPassphrase,
|
||||
);
|
||||
assert(decoded, "the Persistent Setup URI could not be opened");
|
||||
});
|
||||
|
||||
Deno.test("rejects an unknown Setup URI mode", async () => {
|
||||
let rejected = false;
|
||||
try {
|
||||
await generateSetupURI({ uri_mode: "later" });
|
||||
} catch (error) {
|
||||
rejected = error instanceof Error &&
|
||||
error.message === "uri_mode must be ephemeral or persistent";
|
||||
}
|
||||
assert(rejected, "the generator accepted an unknown Setup URI mode");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user