smtp-server-as-promised
Advanced tools
Comparing version 3.0.0 to 3.1.0
# Changelog | ||
## v3.1.0 2018-02-09 | ||
* Clean up listeners after `close`. | ||
* Typescript: support `import foo from 'foo'` syntax. | ||
## v3.0.0 2018-01-25 | ||
* Removed `usePromiseReadable` option. `onData` handler gives `Readable` | ||
stream always. | ||
* Removed `usePromiseReadable` option. `onData` handler gives `Readable` | ||
stream always. | ||
## v2.0.4 2017-10-24 | ||
* Typescript: typings from DefinitelyTyped. | ||
* Typescript: typings from DefinitelyTyped. | ||
## v2.0.3 2017-10-20 | ||
* Typescript: onData stream is Readable. | ||
* Typescript: use @types/nodemailer@4.1.0. | ||
* Typescript: onData stream is Readable. | ||
* Typescript: use @types/nodemailer@4.1.0. | ||
## v2.0.2 2017-10-09 | ||
* Do not publish typings for `nodemailer`. | ||
* Do not publish typings for `nodemailer`. | ||
## v2.0.1 2017-10-06 | ||
* Do not use UMD import internally. | ||
* Do not use UMD import internally. | ||
## v2.0.0 2017-10-06 | ||
* Use native `Promise` rather than `any-event`. | ||
* Use native `Promise` rather than `any-event`. | ||
## v1.1.1 2017-10-06 | ||
* Typescript: reference additional modules in our typings file. | ||
* Typescript: reference additional modules in our typings file. | ||
## v1.1.0 2017-10-06 | ||
* smtp-server@3.3.0: new `updateSecureContext` method. | ||
* Typescript: reexport symbols from `smtp-server` and `shared`. | ||
* smtp-server@3.3.0: new `updateSecureContext` method. | ||
* Typescript: reexport symbols from `smtp-server` and `shared`. | ||
## v1.0.1 2017-10-03 | ||
* Correct exports. | ||
* Correct exports. | ||
## v1.0.0 2017-10-03 | ||
* Exports also as a class and namespace and the default. | ||
* Typings for Typescript. | ||
* Based on promise-socket@1.x.x | ||
* Exports also as a class and namespace and the default. | ||
* Typings for Typescript. | ||
* Based on promise-socket@1.x.x | ||
## v0.1.2 2017-06-22 | ||
* Upgraded chai-as-promised@7.0.0, promise-readable@0.4.3, tap@10.5.1, | ||
tap-given@0.4.1 | ||
* Upgraded chai-as-promised@7.0.0, promise-readable@0.4.3, tap@10.5.1, | ||
tap-given@0.4.1 | ||
## v0.1.1 2017-04-10 | ||
* Node >= 5 is required | ||
* Node >= 5 is required | ||
## v0.1.0 2017-04-10 | ||
* Use the lastest `smtp-server` module on MIT license | ||
* `new Buffer()` is obsoleted. | ||
* Use the lastest `smtp-server` module on MIT license | ||
* `new Buffer()` is obsoleted. | ||
## v0.0.1 2017-03-16 | ||
* Initial release | ||
* Initial release |
/// <reference types="node" /> | ||
/// <reference types="nodemailer" /> | ||
/// <reference types="smtp-server" /> | ||
import * as net from 'net' | ||
import net from 'net' | ||
export { Logger, LoggerLevel } from 'nodemailer/lib/shared' | ||
import { Readable } from 'stream' | ||
import * as tls from 'tls' | ||
import tls from 'tls' | ||
@@ -10,0 +9,0 @@ import { SMTPServer, SMTPServerAddress, SMTPServerAuthentication, SMTPServerAuthenticationResponse, SMTPServerOptions, SMTPServerSession } from 'smtp-server' |
@@ -11,4 +11,6 @@ 'use strict' | ||
if (options.onConnect) { | ||
const promise = options.onConnect | ||
options.onConnect = (session, callback) => promise(session).then(callback).catch((err) => callback(err)) | ||
const handler = options.onConnect | ||
options.onConnect = (session, callback) => handler(session) | ||
.then(() => callback()) | ||
.catch((err) => callback(err)) | ||
} | ||
@@ -23,13 +25,17 @@ if (options.onAuth) { | ||
const handler = options.onMailFrom | ||
options.onMailFrom = (from, session, callback) => handler(from, session).then(callback).catch((err) => callback(err)) | ||
options.onMailFrom = (from, session, callback) => handler(from, session) | ||
.then(() => callback()) | ||
.catch((err) => callback(err)) | ||
} | ||
if (options.onRcptTo) { | ||
const handler = options.onRcptTo | ||
options.onRcptTo = (to, session, callback) => handler(to, session).then(callback).catch((err) => callback(err)) | ||
options.onRcptTo = (to, session, callback) => handler(to, session) | ||
.then(() => callback()) | ||
.catch((err) => callback(err)) | ||
} | ||
if (options.onData) { | ||
const handler = options.onData | ||
options.onData = (stream, session, callback) => { | ||
return handler(stream, session).then(callback).catch((err) => callback(err)) | ||
} | ||
options.onData = (stream, session, callback) => handler(stream, session) | ||
.then(() => callback()) | ||
.catch((err) => callback(err)) | ||
} | ||
@@ -54,14 +60,16 @@ if (options.onClose) { | ||
return new Promise((resolve, reject) => { | ||
const onceListening = () => { | ||
this.server.server.removeListener('error', onceError) | ||
resolve(this.server.server.address()) | ||
const netServer = this.server.server | ||
const listeningHandler = () => { | ||
netServer.removeListener('error', errorHandler) | ||
resolve(netServer.address()) | ||
} | ||
const onceError = (err) => { | ||
this.server.server.removeListener('listening', onceListening) | ||
const errorHandler = (err) => { | ||
netServer.removeListener('listening', listeningHandler) | ||
reject(err) | ||
} | ||
this.server.server.once('listening', onceListening) | ||
this.server.server.once('error', onceError) | ||
netServer.once('listening', listeningHandler) | ||
netServer.once('error', errorHandler) | ||
@@ -76,2 +84,6 @@ // node < 7 doesn't accept undefined as port number | ||
this.server.close(() => { | ||
const options = this.options | ||
if (options.onError) { | ||
this.server.removeListener('error', options.onError) | ||
} | ||
resolve() | ||
@@ -88,4 +100,3 @@ }) | ||
SMTPServerAsPromised.SMTPServerAsPromised = SMTPServerAsPromised | ||
SMTPServerAsPromised.default = SMTPServerAsPromised | ||
module.exports = SMTPServerAsPromised |
{ | ||
"name": "smtp-server-as-promised", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Promisify smtp-server module", | ||
@@ -26,20 +26,24 @@ "main": "lib/smtp-server-as-promised.js", | ||
"dependencies": { | ||
"smtp-server": "^3.3.0" | ||
"smtp-server": "^3.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.0.47", | ||
"@types/nodemailer": "^4.2.0", | ||
"@types/smtp-server": "^3.3.0", | ||
"@types/node": "^9.4.4", | ||
"@types/nodemailer": "^4.3.2", | ||
"@types/smtp-server": "^3.3.2", | ||
"chai": "^4.1.2", | ||
"chai-as-promised": "^7.1.1", | ||
"onchange": "^3.2.1", | ||
"promise-readable": "^2.1.0", | ||
"promise-socket": "^2.0.2", | ||
"null-writable": "^0.2.0", | ||
"onchange": "^3.3.0", | ||
"promise-readable": "^3.1.3", | ||
"promise-socket": "^3.0.0", | ||
"snazzy": "^7.0.0", | ||
"standard": "^10.0.3", | ||
"tap": "^10.7.2", | ||
"tap-given": "^0.6.0" | ||
"tap": "^11.1.0", | ||
"tap-given": "^0.6.0", | ||
"tslint": "^5.9.1", | ||
"tslint-config-standard": "^7.0.0", | ||
"typescript": "^2.7.1" | ||
}, | ||
"scripts": { | ||
"pretest": "standard --verbose | snazzy", | ||
"pretest": "standard --verbose | snazzy && tsc --noEmit --pretty && tslint -t stylish -p .", | ||
"test": "tap test/*.js", | ||
@@ -46,0 +50,0 @@ "test:coverage": "npm test -- --coverage", |
@@ -1,15 +0,16 @@ | ||
## smtp-server-as-promised | ||
# smtp-server-as-promised | ||
[![Build Status](https://secure.travis-ci.org/dex4er/js-smtp-server-as-promised.svg)](http://travis-ci.org/dex4er/js-smtp-server-as-promised) [![Coverage Status](https://coveralls.io/repos/github/dex4er/js-smtp-server-as-promised/badge.svg)](https://coveralls.io/github/dex4er/js-smtp-server-as-promised) [![npm](https://img.shields.io/npm/v/smtp-server-as-promised.svg)](https://www.npmjs.com/package/smtp-server-as-promised) | ||
This module provides promisified version of [`smtp-server`](https://www.npmjs.com/package/smtp-server) module. The | ||
API is the same as for `smtp-server`, except `listen` method which return | ||
This module provides promisified version of | ||
[`smtp-server`](https://www.npmjs.com/package/smtp-server) module. The API is | ||
the same as for `smtp-server`, except `listen` method which return | ||
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) | ||
object and callback options which are `Promise` objects. | ||
### Requirements | ||
## Requirements | ||
This module requires Node >= 5. For Node < 6 `--harmony` flag is required. | ||
### Installation | ||
## Installation | ||
@@ -20,3 +21,3 @@ ```shell | ||
### Usage | ||
## Usage | ||
@@ -26,3 +27,3 @@ `smtp-server-as-promised` can be used like standard `smtp-server` module: | ||
```js | ||
const { SMTPServerAsPromised } = require('smtp-server-as-promised') | ||
const SMTPServerAsPromised = require('smtp-server-as-promised') | ||
``` | ||
@@ -33,6 +34,6 @@ | ||
```ts | ||
import { SMTPServerAsPromised } from 'smtp-server-as-promised' | ||
import SMTPServerAsPromised from 'smtp-server-as-promised' | ||
``` | ||
#### constructor | ||
### constructor | ||
@@ -57,3 +58,3 @@ ```js | ||
##### onConnect | ||
### onConnect | ||
@@ -66,3 +67,3 @@ ```js | ||
##### onAuth | ||
### onAuth | ||
@@ -81,3 +82,3 @@ ```js | ||
##### onMailFrom | ||
### onMailFrom | ||
@@ -95,3 +96,3 @@ ```js | ||
##### onRcptTo | ||
### onRcptTo | ||
@@ -107,3 +108,3 @@ ```js | ||
##### onData | ||
### onData | ||
@@ -134,3 +135,3 @@ ```js | ||
```js | ||
const { NullWritable } = require('null-writable') | ||
const NullWritable = require('null-writable') | ||
@@ -147,3 +148,3 @@ async function onData (stream, session) { | ||
##### onError | ||
### onError | ||
@@ -156,3 +157,3 @@ ```js | ||
#### listen | ||
### listen | ||
@@ -175,3 +176,3 @@ ```js | ||
#### close | ||
### close | ||
@@ -194,3 +195,3 @@ ```js | ||
#### updateSecureContext | ||
### updateSecureContext | ||
@@ -209,3 +210,3 @@ ```js | ||
### License | ||
## License | ||
@@ -212,0 +213,0 @@ Copyright (c) 2016-2018 Piotr Roszatycki <piotr.roszatycki@gmail.com> |
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"module": "commonjs", | ||
"target": "ES2017", | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"strict": true, | ||
"strictNullChecks": true | ||
"target": "ES2017" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13957
133
202
16
Updatedsmtp-server@^3.4.1