ConstThe plugin keeps a token the user pasted, or tells them it is empty or
too long. Values are 1–1024 bytes counted in UTF-8, so the check uses
Buffer.byteLength; secrets.set would refuse other values with
invalid. The store itself can still refuse (unsupported without a
system store, unavailable when it cannot be reached, failed when the
user denies access): only
those codes get the "could not be saved" message, anything else (an
invalid name) is a bug and is thrown on.
import { SECRET_LIMITS } from "@vestra-player/sdk/testing";
if (!token || Buffer.byteLength(token) > SECRET_LIMITS.valueBytes) {
await plugin.osd.show("Paste a token of at most 1024 bytes.");
} else {
try {
await plugin.secrets.set("api-token", token);
} catch (error) {
const { code } = error as PluginError;
if (!["unsupported", "unavailable", "failed"].includes(code)) throw error;
// No keychain or access denied: ask again next time.
await plugin.osd.show("The token could not be saved.");
}
}
The player's limits on Secrets. A name or value outside them fails with code
invalid; a new name beyondnamesfails withlimit. The player's tests check that these agree with the player.