import { Client, AuthenticationType } from '@vonage/server-client'; import { SMSParams } from './types/SMSParams.mjs'; import { SMSMessages } from './types/SMSMessages.mjs'; import { AlgorithmTypes } from '@vonage/auth'; import './enums/MessageClassEnum.mjs'; import './enums/TypeEnum.mjs'; import './types/ErrorMessage.mjs'; import './types/Message.mjs'; import './types/Responses/SMSMessageResponse.mjs'; import './enums/SMSStatus.mjs'; import './types/Responses/SMSResponse.mjs'; import './types/Responses/SMSErrorMessageResponse.mjs'; /** * Client for sending legacy SMS messages using the Vonage API. * * @example * Create a standalone SMS client * * ```ts * import { AlgorithmTypes } from '@vonage/auth'; * import { SMS } from '@vonage/sms'; * * const smsClient = new SMS({ * apiKey: VONAGE_API_KEY, * apiSecret: VONAGE_API_SECRET * secret: { * secret: VONAGE_SIGNATURE_SECRET * algorithm: AlgorithmTypes.sha512hmac * }, * }); * ``` * * @example * Create an SMS client from the Vonage client * * ```ts * import { AlgorithmTypes } from '@vonage/auth'; * import { Vonage } from '@vonage/server-client'; * * const vonage = new Vonage({ * apiKey: VONAGE_API_KEY, * apiSecret: VONAGE_API_SECRET * secret: { * secret: VONAGE_SIGNATURE_SECRET * algorithm: AlgorithmTypes.sha512hmac * }, * }); * * const smsClient = vonage.sms; * ``` */ declare class SMS extends Client { /** * @see {@link Client.authType} */ protected authType?: AuthenticationType; /** * Sends an SMS message using the legacy Vonage SMS API. * * @param {SMSParams} [params] - The parameters for the SMS message. * @return {Promise} A Promise that resolves to the response containing details about the sent SMS messages. * @throws {MessageSendAllFailure} If all SMS messages fail to send. * @throws {MessageSendPartialFailure} If some SMS messages fail to send. * @example * * ```ts * const response = await smsClient.send({ * to: TO_NUMBER, * from: FROM_NUMBER, * text: 'Hello from Vonage SMS API', * }); * console.log(`Number of messages sent: ${response.messageCount}`);); * ``` */ send(params?: SMSParams): Promise; /** * Verifies the signature of a request using the specified algorithm and signature secret. * * @remarks * This will not parse the request parameters from the request object, so you will need to do that yourself. * * @param {string} signature - The signature to be verified. * @param {Record} params - The request parameters used to generate the signature. * @param {string} signatureSecret - The secret key used for generating the signature. * @param {AlgorithmTypes} algorithm - The algorithm used for generating the signature. * @return {boolean} `true` if the signature is valid, `false` otherwise. * @throws {Error} If the provided signature algorithm is not supported. * * @example * ```ts * const params = Object.assign(request.query, request.body); * const { sig } = params; * * sms.verifySignature( * sig, * {}, // request parameters * VONAGE_API_SIGNATURE_SECRET, * AlgorithmTypes.md5hash, * ) === params.sig) { * console.log("Valid signature"); * } else { * console.log("Invalid signature"); * } * ``` */ verifySignature(signature: string, params: Record, signatureSecret: string, algorithm: AlgorithmTypes): boolean; } export { SMS };