Add email templates for copay
This commit is contained in:
parent
8797480a3b
commit
074dc52e78
@ -65,6 +65,7 @@
|
||||
"glob": "*",
|
||||
"leveldown": "~0.10.0",
|
||||
"levelup": "~0.19.0",
|
||||
"lodash": "^2.4.1",
|
||||
"microtime": "^0.6.0",
|
||||
"mkdirp": "^0.5.0",
|
||||
"moment": "~2.5.0",
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
module.exports = {
|
||||
confirmEmailHost: 'https://insight.bitpay.com',
|
||||
email: {
|
||||
service: 'Gmail',
|
||||
auth: {
|
||||
user: 'john@gmail.com',
|
||||
pass: 'mypassword'
|
||||
user: '',
|
||||
pass: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
193
plugins/emailTemplates/copay.html
Normal file
193
plugins/emailTemplates/copay.html
Normal file
@ -0,0 +1,193 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title><%= title%></title>
|
||||
<style type="text/css">
|
||||
/* Based on The MailChimp Reset INLINE: Yes. */
|
||||
/* Client-specific Styles */
|
||||
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
|
||||
body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
|
||||
/* Prevent Webkit and Windows Mobile platforms from changing default font sizes.*/
|
||||
.ExternalClass {width:100%;} /* Force Hotmail to display emails at full width */
|
||||
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;}
|
||||
/* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */
|
||||
#backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}
|
||||
/* End reset */
|
||||
|
||||
/* Some sensible defaults for images
|
||||
Bring inline: Yes. */
|
||||
img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;}
|
||||
a img {border:none;}
|
||||
.image_fix {display:block;}
|
||||
|
||||
/* Yahoo paragraph fix
|
||||
Bring inline: Yes. */
|
||||
p {margin: 1em 0;}
|
||||
|
||||
/* Hotmail header color reset
|
||||
Bring inline: Yes. */
|
||||
h1, h2, h3, h4, h5, h6 {color: black !important;}
|
||||
|
||||
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {color: blue !important;}
|
||||
|
||||
h1 a:active, h2 a:active, h3 a:active, h4 a:active, h5 a:active, h6 a:active {
|
||||
color: red !important; /* Preferably not the same color as the normal header link color. There is limited support for psuedo classes in email clients, this was added just for good measure. */
|
||||
}
|
||||
|
||||
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited {
|
||||
color: purple !important; /* Preferably not the same color as the normal header link color. There is limited support for psuedo classes in email clients, this was added just for good measure. */
|
||||
}
|
||||
|
||||
/* Outlook 07, 10 Padding issue fix
|
||||
Bring inline: No.*/
|
||||
table td {border-collapse: collapse;}
|
||||
|
||||
/* Remove spacing around Outlook 07, 10 tables
|
||||
Bring inline: Yes */
|
||||
table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }
|
||||
|
||||
/* Styling your links has become much simpler with the new Yahoo. In fact, it falls in line with the main credo of styling in email and make sure to bring your styles inline. Your link colors will be uniform across clients when brought inline.
|
||||
Bring inline: Yes. */
|
||||
a {color: orange;}
|
||||
|
||||
|
||||
/***************************************************
|
||||
****************************************************
|
||||
MOBILE TARGETING
|
||||
****************************************************
|
||||
***************************************************/
|
||||
@media only screen and (max-device-width: 480px) {
|
||||
/* Part one of controlling phone number linking for mobile. */
|
||||
a[href^="tel"], a[href^="sms"] {
|
||||
text-decoration: none;
|
||||
color: blue; /* or whatever your want */
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
|
||||
text-decoration: default;
|
||||
color: orange !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* More Specific Targeting */
|
||||
|
||||
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
|
||||
/* You guessed it, ipad (tablets, smaller screens, etc) */
|
||||
/* repeating for the ipad */
|
||||
a[href^="tel"], a[href^="sms"] {
|
||||
text-decoration: none;
|
||||
color: blue; /* or whatever your want */
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
|
||||
text-decoration: default;
|
||||
color: orange !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
|
||||
/* Put your iPhone 4g styles in here */
|
||||
}
|
||||
|
||||
/* Android targeting */
|
||||
@media only screen and (-webkit-device-pixel-ratio:.75){
|
||||
/* Put CSS for low density (ldpi) Android layouts in here */
|
||||
}
|
||||
@media only screen and (-webkit-device-pixel-ratio:1){
|
||||
/* Put CSS for medium density (mdpi) Android layouts in here */
|
||||
}
|
||||
@media only screen and (-webkit-device-pixel-ratio:1.5){
|
||||
/* Put CSS for high density (hdpi) Android layouts in here */
|
||||
}
|
||||
/* end Android targeting */
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Targeting Windows Mobile -->
|
||||
<!--[if IEMobile 7]>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
<![endif]-->
|
||||
|
||||
<!-- ***********************************************
|
||||
****************************************************
|
||||
END MOBILE TARGETING
|
||||
****************************************************
|
||||
************************************************ -->
|
||||
|
||||
<!--[if gte mso 9]>
|
||||
<style>
|
||||
/* Target Outlook 2007 and 2010 */
|
||||
</style>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<!-- Wrapper/Container Table: Use a wrapper table to control the width and the background color consistently of your email. Use this approach instead of setting attributes on the body tag. -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" id="backgroundTable">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<!-- Tables are the most common way to format your email consistently. Set your table widths inside cells and in most cases reset cellpadding, cellspacing, and border to zero. Use nested tables as a way to space effectively in your message. -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" align="center">
|
||||
<tr>
|
||||
<td width="200" valign="top"></td>
|
||||
<td width="200" valign="top"></td>
|
||||
<td width="200" valign="top"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- End example table -->
|
||||
|
||||
<p>Hi, <%= email %></p>
|
||||
|
||||
<p>You are now using Insight to store an encrypted Copay backup. This is a free
|
||||
service that we are providing that you can turn off from Copay's preferences.</p>
|
||||
|
||||
<p>In order to prevent abuse, we need you to confirm that this email is valid and
|
||||
that you requested this backup. Please follow this link if you agree on
|
||||
backing up your Copay profile within our servers:</p>
|
||||
|
||||
<p>
|
||||
<!-- Yahoo Link color fix updated: Simply bring your link styling inline. -->
|
||||
<a href="<%= confirm_url %>" target ="_blank" title="Confirm your email" style="color: orange; text-decoration: none;">Confirm your email (click here).</a>
|
||||
</p>
|
||||
<p style="font-size: small">If the above link doesn't work, head to: <%= confirm_url %></p>
|
||||
|
||||
<p>We would also like you to know that:</p>
|
||||
<ul>
|
||||
|
||||
<li>We only store information encrypted by your Copay app. We can't retrieve your private keys, help you remember the password, or collect any information about your wallet. </li>
|
||||
|
||||
<li>In case that one of our servers is compromised, intruders may be able to brute-force their way into your private keys unless you use a strong password.</li>
|
||||
|
||||
<li> Our code is open source and can be audited here:
|
||||
<ul>
|
||||
<li> https://github.com/bitpay/insight </li>
|
||||
<li> https://github.com/bitpay/copay </li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Thanks!</p>
|
||||
|
||||
<p> The Copay Team </p>
|
||||
|
||||
<!-- Gmail/Hotmail image display fix -->
|
||||
<img class="image_fix" src="https://eordano.com/Copay.png" alt="Copay" title="Copay" width="480" height="220" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- End of wrapper table -->
|
||||
</body>
|
||||
</html>
|
||||
27
plugins/emailTemplates/copay.plain
Normal file
27
plugins/emailTemplates/copay.plain
Normal file
@ -0,0 +1,27 @@
|
||||
Hi, <%= email %>
|
||||
|
||||
You are now using Insight to store an encrypted Copay backup. This is a free
|
||||
service that we are providing that you can turn off from Copay's preferences.
|
||||
|
||||
In order to prevent abuse, we need you to confirm that this email is valid and
|
||||
that you requested this backup. Please follow this link if you agree on
|
||||
backing up your Copay profile within our servers:
|
||||
|
||||
<%= confirm_url %>
|
||||
|
||||
We would also like you to take note of these:
|
||||
|
||||
* We only store information encrypted by your Copay app. We can't retrieve
|
||||
your private keys, help you remember the password, or collect any information
|
||||
about your wallet.
|
||||
|
||||
* In case of a service compromise, intruders may be able to brute-force their
|
||||
way into your private keys. Please use a strong password to avoid this.
|
||||
|
||||
* Our code is open source and can be audited here:
|
||||
https://github.com/bitpay/insight
|
||||
https://github.com/bitpay/copay
|
||||
|
||||
Thanks!
|
||||
|
||||
The Copay Team
|
||||
@ -39,13 +39,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var logger = require('../lib/logger').logger,
|
||||
levelup = require('levelup'),
|
||||
async = require('async'),
|
||||
crypto = require('crypto'),
|
||||
querystring = require('querystring'),
|
||||
nodemailer = require('nodemailer'),
|
||||
globalConfig = require('../config/config');
|
||||
var logger = require('../lib/logger').logger;
|
||||
var levelup = require('levelup');
|
||||
var async = require('async');
|
||||
var crypto = require('crypto');
|
||||
var querystring = require('querystring');
|
||||
var nodemailer = require('nodemailer');
|
||||
var globalConfig = require('../config/config');
|
||||
var _ = require('lodash');
|
||||
var fs = require('fs');
|
||||
|
||||
var emailPlugin = {};
|
||||
|
||||
@ -104,6 +106,14 @@ emailPlugin.init = function (expressApp, config) {
|
||||
|
||||
emailPlugin.email = config.emailTransport || nodemailer.createTransport(config.email);
|
||||
|
||||
emailPlugin.textTemplate = config.textTemplate || 'copay.plain';
|
||||
emailPlugin.htmlTemplate = config.htmlTemplate || 'copay.html';
|
||||
emailPlugin.confirmUrl = (
|
||||
(config.confirmEmailHost || 'https://insight.bitpay.com')
|
||||
+ globalConfig.apiPrefix
|
||||
+ '/email/validate'
|
||||
);
|
||||
|
||||
expressApp.post(globalConfig.apiPrefix + '/email/register', emailPlugin.post);
|
||||
expressApp.get(globalConfig.apiPrefix + '/email/retrieve/:email', emailPlugin.get);
|
||||
expressApp.post(globalConfig.apiPrefix + '/email/validate', emailPlugin.validate);
|
||||
@ -133,27 +143,63 @@ emailPlugin.returnError = function (error, response) {
|
||||
*/
|
||||
emailPlugin.sendVerificationEmail = function (email, secret) {
|
||||
|
||||
var emailBody = 'Activation code is ' + secret; // TODO: Use a template!
|
||||
var emailBodyHTML = '<h1>Activation code is ' + secret + '</h1>'; // TODO: Use a template!
|
||||
|
||||
var mailOptions = {
|
||||
from: 'Insight Services <insight@bitpay.com>',
|
||||
to: email,
|
||||
subject: 'Your Insight account has been created',
|
||||
text: emailBody,
|
||||
html: emailBodyHTML
|
||||
};
|
||||
|
||||
// send mail with defined transport object
|
||||
emailPlugin.email.sendMail(mailOptions, function (err, info) {
|
||||
if (err) {
|
||||
logger.error('An error occurred when trying to send email to ' + email, err);
|
||||
} else {
|
||||
logger.debug('Message sent: ' + info.response);
|
||||
async.series([
|
||||
function(callback) {
|
||||
emailPlugin.makeEmailBody({
|
||||
email: email,
|
||||
confirm_url: emailPlugin.makeConfirmUrl(secret)
|
||||
}, callback);
|
||||
},
|
||||
function(callback) {
|
||||
emailPlugin.makeEmailHTMLBody({
|
||||
email: email,
|
||||
confirm_url: emailPlugin.makeConfirmUrl(secret),
|
||||
title: 'Your wallet backup needs confirmation'
|
||||
}, callback);
|
||||
}
|
||||
], function(err, results) {
|
||||
var emailBody = results[0];
|
||||
var emailBodyHTML = results[1];
|
||||
var mailOptions = {
|
||||
from: 'Insight Services <insight@bitpay.com>',
|
||||
to: email,
|
||||
subject: '[Copay] Your wallet backup needs confirmation',
|
||||
text: emailBody,
|
||||
html: emailBodyHTML
|
||||
};
|
||||
|
||||
// send mail with defined transport object
|
||||
emailPlugin.email.sendMail(mailOptions, function (err, info) {
|
||||
if (err) {
|
||||
logger.error('An error occurred when trying to send email to ' + email, err);
|
||||
} else {
|
||||
logger.error('Message sent: ' + info.response);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
emailPlugin.makeConfirmUrl = function(secret) {
|
||||
return emailPlugin.confirmUrl + '?secret='+secret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a function that reads an underscore template and uses the `opts` param
|
||||
* to build an email body
|
||||
*/
|
||||
var applyTemplate = function(templateFilename) {
|
||||
return function(opts, callback) {
|
||||
fs.readFile(__dirname + '/emailTemplates/' + emailPlugin[templateFilename],
|
||||
function(err, template) {
|
||||
return callback(err, _.template(template, opts));
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
emailPlugin.makeEmailBody = applyTemplate('textTemplate');
|
||||
emailPlugin.makeEmailHTMLBody = applyTemplate('htmlTemplate');
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {Function(err, boolean)} callback
|
||||
@ -402,7 +448,6 @@ emailPlugin.validate = function (request, response) {
|
||||
}
|
||||
|
||||
emailPlugin.db.get(VALIDATION_NAMESPACE + email, function (err, value) {
|
||||
logger.info('Recibido: ' + value);
|
||||
if (err) {
|
||||
if (err.notFound) {
|
||||
return emailPlugin.returnError(emailPlugin.errors.NOT_FOUND, response);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user