The Express Server library uses the SDK's Notifier module for sending Email and SMS for OTP verifications. The library includes default templates (handlebar files) but can be overridden by your own templates.
The Email template may be found in src/templates/otp/email.handlebars.
The exposed data are as follows:
Parameter | Description |
---|---|
vars.brand | Filled with the data from config -> OTP Settings. |
data.code | The generated OTP code that will be delivered to the user. |
The SMS template may be found in src/templates/otp/sms.handlebars.
The exposed data are as follows:
Parameter | Description |
---|---|
vars.brand | Filled with the data from config -> OTP Settings. |
data.code | The generated OTP code that will be delivered to the user. |
In order to replace templates with your own customized templates, use the following code snippet (taken from Notifications docs) to declare the templates first:
import { Notifications } from "@ssofy/node-sdk";
...
const templates = [
<Notifications.Template>{
name: 'otp',
path: 'PATH_TO_SMS_HANDLEBARS_TEMPLATE_FILE',
engine: Notifications.HandlebarsEngine,
channel: Notifications.Channel.SMS
},
<Notifications.Template>{
name: 'otp',
path: 'PATH_TO_EMAIL_HANDLEBARS_TEMPLATE_FILE',
engine: Notifications.HandlebarsEngine,
channel: Notifications.Channel.EMAIL
},
];
And then, pass the templates
object to the notifiers:
const serverConfig: ServerConfig = {
...
otp: {
storage: new Storage.MemoryStorage(),
vars: {
brand: 'SSOfy',
},
notifiers: [
new Notifications.ConsoleNotifier(Notifications.Channel.SMS, 'Test', templates),
new Notifications.ConsoleNotifier(Notifications.Channel.EMAIL, 'Test', templates),
],
},
...
};