"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const xrpc_server_1 = require("@atproto/xrpc-server");
const scrypt_1 = require("../../../../account-manager/helpers/scrypt");
function default_1(server, ctx) {
    server.com.atproto.admin.updateAccountPassword({
        auth: ctx.authVerifier.adminToken,
        handler: async ({ input, req }) => {
            if (ctx.entrywayAgent) {
                await ctx.entrywayAgent.com.atproto.admin.updateAccountPassword(input.body, ctx.entrywayPassthruHeaders(req));
                return;
            }
            const { did, password } = input.body;
            if (password.length > scrypt_1.NEW_PASSWORD_MAX_LENGTH) {
                throw new xrpc_server_1.InvalidRequestError('Invalid password length.');
            }
            await ctx.accountManager.updateAccountPassword({ did, password });
        },
    });
}
//# sourceMappingURL=updateAccountPassword.js.map