@sinch/mcp
Version:
Sinch MCP server
37 lines • 2.05 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 utils_1 = require("../../utils");
const types_1 = require("../../types");
const registerReportSmsVerification = (server, tags) => {
if (!(0, utils_1.hasMatchingTag)(['all', 'verification'], tags)) {
return;
}
server.tool('report-sms-verification', '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 }) => {
const maybeClient = (0, verification_service_helper_1.getVerificationService)();
if ((0, utils_1.isPromptResponse)(maybeClient)) {
return maybeClient.promptResponse;
}
const verificationService = maybeClient.verification;
const response = await verificationService.verifications.reportSmsByIdentity({
endpoint: phoneNumber,
reportSmsVerificationByIdentityRequestBody: {
sms: {
code: oneTimePassword
}
}
});
return response.status === 'SUCCESSFUL' ?
new types_1.PromptResponse(`Verification successful for number ${phoneNumber}. The verification ID is ${response.id}`).promptResponse
: new types_1.PromptResponse(`Failed to verify the phone number ${phoneNumber}. The verification ID is ${response.id}`).promptResponse;
};
exports.reportSmsVerificationHandler = reportSmsVerificationHandler;
//# sourceMappingURL=report-sms-verification.js.map