@sinch/mcp
Version:
Sinch MCP server
49 lines • 2.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.reportSmsVerificationHandler = exports.registerReportSmsVerification = void 0;
const zod_1 = require("zod");
const verification_service_helper_1 = require("./utils/verification-service-helper");
const verification_tools_helper_1 = require("./utils/verification-tools-helper");
const utils_1 = require("../../utils");
const types_1 = require("../../types");
const TOOL_KEY = 'reportSmsVerification';
const TOOL_NAME = (0, verification_tools_helper_1.getToolName)(TOOL_KEY);
const registerReportSmsVerification = (server, tags) => {
if (!(0, utils_1.matchesAnyTag)(tags, verification_tools_helper_1.verificationToolsConfig[TOOL_KEY].tags))
return;
server.tool(TOOL_NAME, 'Report the received verification code to verify it, using the phone number of the user', {
phoneNumber: zod_1.z.string().describe('Phone number in E.164 format used to start the verification process'),
oneTimePassword: zod_1.z.string().describe('The code which was received by the user submitting the SMS verification.')
}, exports.reportSmsVerificationHandler);
};
exports.registerReportSmsVerification = registerReportSmsVerification;
const reportSmsVerificationHandler = async ({ phoneNumber, oneTimePassword }) => {
try {
const maybeService = (0, verification_service_helper_1.getVerificationService)(TOOL_NAME);
if ((0, utils_1.isPromptResponse)(maybeService)) {
return maybeService.promptResponse;
}
const verificationService = maybeService;
const response = await verificationService.verifications.reportSmsByIdentity({
endpoint: phoneNumber,
reportSmsVerificationByIdentityRequestBody: {
sms: {
code: oneTimePassword
}
}
});
return new types_1.PromptResponse(JSON.stringify({
success: true,
verification_id: response.id,
status: response.status
})).promptResponse;
}
catch (error) {
return new types_1.PromptResponse(JSON.stringify({
success: false,
error: error instanceof Error ? error.message : String(error)
})).promptResponse;
}
};
exports.reportSmsVerificationHandler = reportSmsVerificationHandler;
//# sourceMappingURL=report-sms-verification.js.map