Laravel package for OTP validation with built-in features like max retry and resend mechanism. Both OTP/Security Code over SMS or Email or AWS SNS of your choice with template user-defined.
71
stars
13
forks
source link
Set SMS type to Transactional via `MessageAttributes` when using AWS SNS #8
In theory there's a race condition where this library sets the global value to transactional, some other code somewhere sets the global value to promotional immediately after, resulting in an OTP message being sent as promotional.
This commit instead switches to specifying the message type using the AWS.SNS.SMS.SMSType attribute.
This avoids all of the issues above while still ensuring OTP messages are sent as transactional.
... instead of using a
SetSMSAttributes
request.While globally setting the default SMS type via
SetSMSAttributes
does work most of the time, it has some issues:SetSMSAttributes
is rate limited to one transaction per second. Rates for sending SMSes via SNS are generally multiple messages per second, so usingSetSMSAttributes
makes the library less suitable for supporting many users at the same time.This commit instead switches to specifying the message type using the
AWS.SNS.SMS.SMSType
attribute. This avoids all of the issues above while still ensuring OTP messages are sent as transactional.See https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk for details.