Files
Hornwitser 5dcaca4d0b Migrate to ECMAScript Modules
Migrate the usage of CommonJS specific code and imports to ESM.  Roughly
summarised this:
- Changes all require() calls to import statement or expressions.
- Changes usage of module.exports to export statements.
- Replaces require.resolve with import.meta.resolve.
- Replaces conditional imports with conditional subpath imports.
- Replaces module === require.main with import.meta.main.
- Adds the full filename with extention to all relative imports.
- Changes all usage of __dirname and __filename to their import.meta
  equivalents.
- Sets "type": "module" in package.json files.
- Removes usage of "use strict".
- Adds .ts an an alias of .js for the webpack build.

Due to differences in how require and import resolves files the plugin
entrypoints will have to include the filename and extension after this
migration in order to work.
2026-09-11 22:43:57 +02:00

52 lines
1.3 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages.js";
declare module "@clusterio/lib" {
export interface InstanceConfigFields {
"player_auth.load_plugin": boolean;
}
export interface ControllerConfigFields {
"player_auth.code_length": number;
"player_auth.code_timeout": number;
"player_auth.show_connect_address": boolean;
}
}
export const plugin: lib.PluginDeclaration = {
name: "player_auth",
title: "Player Auth",
description: "Provides authentication to the cluster via logging into a Factorio server.",
controllerEntrypoint: "dist/node/controller.js",
instanceEntrypoint: "dist/node/instance.js",
webEntrypoint: "./web",
controllerConfigFields: {
"player_auth.code_length": {
title: "Code Length",
description: "Length in characters of the generated codes.",
type: "number",
initialValue: 6,
},
"player_auth.code_timeout": {
title: "Code Timeout",
description: "Time in seconds for the generated codes to stay valid.",
type: "number",
initialValue: 120,
},
"player_auth.show_connect_address": {
title: "Show Connect Address",
description: "Show server connect addresses to unauthenticated users.",
type: "boolean",
initialValue: false,
},
},
features: [
"SavePatching",
],
messages: [
messages.FetchPlayerCodeRequest,
messages.SetVerifyCodeRequest,
],
};