A package can list permissions in its manifest: short names for what it uses. For now the list is information for the people who install your package, and Asterobot doesn't limit anything based on it.
Note
Coming soon. Asterobot will enforce the permissions a package declares. Until then, any package can use every function of every built-in module, whatever it lists.
Declare them
- Open your package's page and find the Manifest card.
- Under Permissions, type a name in the box that reads
e.g. gamedata, then click Add or press Enter. The name appears as a badge. - Add the other permissions the same way. The button on a badge removes it.
- Click Save manifest.
In the file, the list is the permissions key:
{
"permissions": [
"gamedata"
]
}
The rules:
- Each permission is a string. Asterobot doesn't define permission names yet, so it accepts any text and shows it as you wrote it.
- The card leaves out empty names and names already in the list. In a file, an empty entry or a name listed twice stops the package from starting, with
empty package permissionorduplicate package permission "<permission>". - The list comes along when the package is copied, exported or imported.
Where they show
On the package's page, the Manifest card shows each permission as a badge, or "No permissions declared." when there's none. For a package installed from the marketplace, the card is read-only, so the people who install yours read your list there.
A script reads the list with packages.info(), from asterobot:runtime, for its own package and for each of its dependencies. This one writes its own list to the bot's console when it starts, assuming the package is named my-bot:
import { session, botInfo } from "asterobot:bot";
import { send } from "asterobot:protocol";
import { packages } from "asterobot:runtime";
export default async function behavior(launch) {
const self = packages.info("my-bot");
botInfo(`${self.name} ${self.version} declares: ${self.permissions.join(", ") || "no permission"}`);
// A new game connection starts with this message. MITM bots never launch
// with "initial": the Dofus client has already identified their session.
if (launch.reason === "initial") {
await send("IdentificationRequest", {
ticketKey: session.gameToken,
languageCode: session.language,
});
}
}
permissions is always an array, empty when the package lists nothing. asterobot:runtime describes the other properties, and the errors packages.info() throws for a name the script doesn't load.
What to list
Since nothing checks the list today, it's worth exactly as much as it's honest. Name what your package really does, with words people understand, such as gamedata for a package that reads game data, the example the card itself gives. The names Asterobot will check aren't defined yet: expect to update your list, in a new version of your package, once they are.
Whatever the list says, people deciding whether to run your package should know what any package can do with their bot. Trusting a package explains it from their side.
Next, The editor.
Aucun avis à afficher.