Skip to content

Commit

Permalink
feat: add SetClientPassword
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Sep 14, 2024
1 parent a60ae17 commit 12d7737
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ export type {
RenameServerRequest,
RenameServerResponse,
ServerClaimedErrorResponse,
PasswordInUseErrorResponse,
ServerNotClaimedErrorResponse,
SetClientPasswordRequest,
SetClientPasswordResponse,
} from "./v1/index.js";
21 changes: 21 additions & 0 deletions src/v1/SetClientPassword.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ApiRequest } from "./common.js";
import { buildApiRequest } from "./common.js";

export type SetClientPasswordRequest = ApiRequest<
"SetClientPassword",
{
/**
* Client Password to set on the Dedicated Server, in plaintext.
*/
password: string;
}
>;

export type SetClientPasswordResponse = string;

export const buildSetClientPassword = buildApiRequest<
SetClientPasswordRequest,
SetClientPasswordResponse
>("v1", {
function: "SetClientPassword",
});
4 changes: 4 additions & 0 deletions src/v1/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ export interface ServerClaimedErrorResponse extends ErrorResponse {
export interface ServerNotClaimedErrorResponse extends ErrorResponse {
errorCode: "server_not_claimed";
}

export interface PasswordInUseErrorResponse extends ErrorResponse {
errorCode: "password_in_use";
}
14 changes: 14 additions & 0 deletions src/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { buildPasswordlessLogin } from "./PasswordlessLogin.js";
import { buildPasswordLogin } from "./PasswordLogin.js";
import { buildQueryServerState } from "./QueryServerState.js";
import { buildRenameServer } from "./RenameServer.js";
import { buildSetClientPassword } from "./SetClientPassword.js";
import { buildVerifyAuthenticationToken } from "./VerifyAuthenticationToken.js";

export function buildV1(options: InternalClientOptions) {
Expand Down Expand Up @@ -74,6 +75,18 @@ export function buildV1(options: InternalClientOptions) {
* Function does not return any data on success.
*/
RenameServer: buildRenameServer(options),
/**
* Updates the currently set Client Protection Password.
*
* This will invalidate all previously issued Client authentication tokens.
*
* Pass empty string to remove the password, and let anyone join the server as Client.
*
* Requires Admin privileges.
*
* Function does not return any data on success.
*/
SetClientPassword: buildSetClientPassword(options),
};
}

Expand All @@ -88,4 +101,5 @@ export type * from "./PasswordlessLogin.js";
export type * from "./PasswordLogin.js";
export type * from "./QueryServerState.js";
export type * from "./RenameServer.js";
export type * from "./SetClientPassword.js";
export type * from "./VerifyAuthenticationToken.js";

0 comments on commit 12d7737

Please sign in to comment.