Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smtp-server-as-promised

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtp-server-as-promised - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

76

CHANGELOG.md
# Changelog
## v5.2.1 2019-05-10
- Updated dependencies.
## v5.2.0 2019-01-28
* `onData` method's first argument is an `SMTPServerDataStream` interface.
- `onData` method's first argument is an `SMTPServerDataStream` interface.
## v5.1.2 2019-01-08
* Use null-writable as productional dependency.
- Use null-writable as productional dependency.
## v5.1.1 2019-01-08
* Uses smtp-server@3.5.0
- Uses smtp-server@3.5.0
## v5.1.0 2018-09-19
* `onData` method is resolved when `stream` is finished. It is rejected if the
- `onData` method is resolved when `stream` is finished. It is rejected if the
`stream` is already finished.

@@ -22,31 +26,31 @@

* Callback handler are replaced with protected methods that should be overriden
- Callback handler are replaced with protected methods that should be overriden
in own subclass.
* `onData` handler consumes the stream after error.
- `onData` handler consumes the stream after error.
## v4.1.0 2018-09-10
* New method `destroy`.
- New method `destroy`.
## v4.0.0 2018-09-09
* Rewritten in Typescript.
* Requires Node >= 6
* Changed syntax for import.
- Rewritten in Typescript.
- Requires Node >= 6
- Changed syntax for import.
## v3.3.2 2018-03-09
* Typescript: use @types/nodemailer@4.6.0.
- Typescript: use @types/nodemailer@4.6.0.
## v3.3.1 2018-02-13
* Typescript: back to `TlsOptions` type.
- Typescript: back to `TlsOptions` type.
## v3.3.0 2018-02-13
* Accept `0` as a port number.
- Accept `0` as a port number.
## v3.2.0 2018-02-13
* Typescript: `host`, `port` and `backlog` are part of
- Typescript: `host`, `port` and `backlog` are part of
`SMTPServerAsPromisedOptions`.

@@ -56,3 +60,3 @@

* Typescript: `updateSecureOption` with `TlsServerOptions` type as an
- Typescript: `updateSecureOption` with `TlsServerOptions` type as an
argument.

@@ -62,8 +66,8 @@

* Clean up listeners after `close`.
* Typescript: support `import foo from 'foo'` syntax.
- 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`
- Removed `usePromiseReadable` option. `onData` handler gives `Readable`
stream always.

@@ -73,43 +77,43 @@

* 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,
- Upgraded chai-as-promised@7.0.0, promise-readable@0.4.3, tap@10.5.1,
tap-given@0.4.1

@@ -119,11 +123,11 @@

* 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

@@ -32,3 +32,3 @@ "use strict";

}
stream_finished_1.default(stream, (err) => {
stream_finished_1.default(stream, err => {
if (err)

@@ -101,2 +101,4 @@ reject(err);

/** This method can be overriden in subclass */
// prettier-ignore
// @ts-ignore
onAuth(auth, session) {

@@ -106,2 +108,3 @@ return Promise.reject(new Error('onAuth method not overriden in subclass'));

/** This method can be overriden in subclass */
// @ts-ignore
onClose(session) {

@@ -111,2 +114,3 @@ return Promise.resolve();

/** This method can be overriden in subclass */
// @ts-ignore
onConnect(session) {

@@ -116,2 +120,3 @@ return Promise.resolve();

/** This method can be overriden in subclass */
// @ts-ignore
onData(stream, session) {

@@ -122,2 +127,3 @@ stream.pipe(new null_writable_1.default());

/** This method can be overriden in subclass */
// @ts-ignore
onMailFrom(address, session) {

@@ -127,2 +133,3 @@ return Promise.resolve();

/** This method can be overriden in subclass */
// @ts-ignore
onRcptTo(address, session) {

@@ -132,2 +139,3 @@ return Promise.resolve();

/** This method can be overriden in subclass */
// @ts-ignore
onError(error) {

@@ -134,0 +142,0 @@ return Promise.resolve();

{
"name": "smtp-server-as-promised",
"version": "5.2.0",
"version": "5.2.1",
"description": "Promisify smtp-server module",

@@ -27,5 +27,5 @@ "main": "lib/smtp-server-as-promised.js",

"is-stream-ended": "^0.1.4",
"null-writable": "^1.0.0",
"null-writable": "^1.0.1",
"smtp-server": "^3.5.0",
"stream.finished": "^1.1.1",
"stream.finished": "^1.2.0",
"tslib": "^1.9.3"

@@ -35,36 +35,34 @@ },

"@types/chai": "^4.1.7",
"@types/chai-as-promised": "^7.1.0",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.18",
"@types/nodemailer": "^4.6.5",
"@types/semver": "^5.5.0",
"@types/smtp-server": "^3.5.0",
"@types/mocha": "^5.2.6",
"@types/node": "^12.0.0",
"@types/nodemailer": "^4.6.8",
"@types/semver": "^6.0.0",
"@types/smtp-server": "^3.5.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.2",
"eslint": "^5.12.1",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"markdownlint-cli": "^0.13.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"promise-readable": "^3.1.5",
"promise-socket": "^3.1.1",
"rimraf": "^2.6.3",
"semver": "^5.6.0",
"ts-node": "^8.0.2",
"tslint": "^5.12.1",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.2.4"
"coveralls": "^3.0.3",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.1.1",
"markdownlint-cli": "^0.15.0",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"prettier": "^1.17.0",
"promise-readable": "^4.2.0",
"promise-socket": "^4.0.0",
"semver": "^6.0.0",
"shx": "^0.3.2",
"ts-node": "^8.1.0",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.4.5"
},
"scripts": {
"build": "npm run compile",
"clean": "rimraf lib",
"compile": "tsc --pretty",
"clean": "shx rm -rf lib",
"postpublish": "git tag v$npm_package_version -a -m \"Release v$npm_package_version\" && git push --tags",
"prepublishOnly": "npm run build",
"pretest": "npm run build && tsc --pretty -p examples && tsc --pretty -p test && eslint . && tslint -t stylish -p . && tslint -t stylish -p examples && tslint -t stylish -p test && markdownlint \"*.md\"",
"prepack": "npm run build",
"pretest": "npm run build && tsc --pretty -p examples && tsc --pretty -p test && eslint . && tslint -t stylish -p . && tslint -t stylish -p examples && tslint -t stylish -p test && prettier --ignore-path .gitignore --list-different '**/*.js' '**/*.json' '**/*.md' '**/*.ts' '**/*.yml' && markdownlint \"*.md\"",
"test": "npm run test:spec",

@@ -71,0 +69,0 @@ "test:spec": "npm run ts-mocha -- \"test/*.ts\"",

# smtp-server-as-promised
<!-- markdownlint-disable MD013 -->
[![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)
<!-- markdownlint-enable MD013 -->

@@ -35,6 +37,10 @@

"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"paths": {
"smtp-server-as-promised": ["node_modules/smtp-server-as-promised/src/smtp-server-as-promised"]
}
}
},
"strict": true
},
"include": ["*.ts", "node_modules/smtp-server-as-promised/src/*.ts"]
}

@@ -48,3 +54,3 @@ ```

```js
const { SMTPServerAsPromised } = require('smtp-server-as-promised')
const {SMTPServerAsPromised} = require('smtp-server-as-promised')

@@ -74,3 +80,3 @@ class MySMTPServer extends SMTPServerAsPromised {}

const server = new MySMTPServer({
disabledCommands: ['AUTH']
disabledCommands: ['AUTH'],
})

@@ -90,3 +96,3 @@ ```

class MySMTPServer extends SMTPServerAsPromised {
async onConnect (session) {
async onConnect(session) {
console.log(`[${session.id}] onConnect`)

@@ -107,5 +113,5 @@ }

class MySMTPServer extends SMTPServerAsPromised {
async onAuth (auth, session) {
async onAuth(auth, session) {
if (auth.method === 'PLAIN' && auth.username === 'username' && auth.password === 'password') {
return { user: auth.username }
return {user: auth.username}
} else {

@@ -130,3 +136,3 @@ throw new Error('Invalid username or password')

class MySMTPServer extends SMTPServerAsPromised {
async onMailFrom (from, session) {
async onMailFrom(from, session) {
console.log(`[${session.id}] onMailFrom ${from.address}`)

@@ -150,3 +156,3 @@ if (from.address.split('@')[1] === 'spammer.com') {

class MySMTPServer extends SMTPServerAsPromised {
async onRcptTo (to, session) {
async onRcptTo(to, session) {
console.log(`[${session.id}] onRcptTo ${to.address}`)

@@ -170,5 +176,5 @@ if (from.address.split('@')[1] === 'spammer.com') {

class MySMTPServer extends SMTPServerAsPromised {
async onData (stream, session) {
async onData(stream, session) {
console.log(`[${session.id}] onData started`)
if (stream.sizeExceeded) throw new Error('Message too big');
if (stream.sizeExceeded) throw new Error('Message too big')
stream.pipe(process.stdout)

@@ -199,3 +205,3 @@ }

class MySMTPServer extends SMTPServerAsPromised {
async onError (error) {
async onError(error) {
console.log('Server error:', error)

@@ -219,4 +225,4 @@ }

```js
async function main () {
const address = await server.listen({ port: 2525 })
async function main() {
const address = await server.listen({port: 2525})
console.log(`Listening on [${address.address}]:${address.port}`)

@@ -237,3 +243,3 @@ }

```js
async function main () {
async function main() {
// ...

@@ -256,3 +262,3 @@ await server.close()

```js
server.updateSecureContext({ key: tlsKeyPem })
server.updateSecureContext({key: tlsKeyPem})
```

@@ -259,0 +265,0 @@

@@ -6,3 +6,3 @@ /// <reference types="node" />

import net from 'net'
export { Logger, LoggerLevel } from 'nodemailer/lib/shared'
export {Logger, LoggerLevel} from 'nodemailer/lib/shared'
import NullWritable from 'null-writable'

@@ -12,3 +12,11 @@ import finished from 'stream.finished'

import { SMTPServer, SMTPServerAddress, SMTPServerAuthentication, SMTPServerAuthenticationResponse, SMTPServerDataStream, SMTPServerOptions, SMTPServerSession } from 'smtp-server'
import {
SMTPServer,
SMTPServerAddress,
SMTPServerAuthentication,
SMTPServerAuthenticationResponse,
SMTPServerDataStream,
SMTPServerOptions,
SMTPServerSession,
} from 'smtp-server'

@@ -39,22 +47,42 @@ export * from 'smtp-server'

constructor (options: SMTPServerAsPromisedOptions = {}) {
constructor(options: SMTPServerAsPromisedOptions = {}) {
const newOptions: SMTPServerOptions = {}
newOptions.onConnect = (session: SMTPServerSession, callback: (err?: Error) => void) => this.onConnect(session)
.then(() => callback())
.catch((err: Error) => callback(err))
newOptions.onConnect = (session: SMTPServerSession, callback: (err?: Error) => void) =>
this.onConnect(session)
.then(() => callback())
.catch((err: Error) => callback(err))
newOptions.onAuth = (auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null, response?: SMTPServerAuthenticationResponse) => void) => this.onAuth(auth, session)
newOptions.onAuth = (
auth: SMTPServerAuthentication,
session: SMTPServerSession,
callback: (err: Error | null, response?: SMTPServerAuthenticationResponse) => void,
) =>
this.onAuth(auth, session)
.then((response: SMTPServerAuthenticationResponse) => callback(null, response))
.catch((err: Error) => callback(err))
newOptions.onMailFrom = (address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void) => this.onMailFrom(address, session)
newOptions.onMailFrom = (
address: SMTPServerAddress,
session: SMTPServerSession,
callback: (err?: Error | null) => void,
) =>
this.onMailFrom(address, session)
.then(() => callback())
.catch((err: Error) => callback(err))
newOptions.onRcptTo = (address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void) => this.onRcptTo(address, session)
newOptions.onRcptTo = (
address: SMTPServerAddress,
session: SMTPServerSession,
callback: (err?: Error | null) => void,
) =>
this.onRcptTo(address, session)
.then(() => callback())
.catch((err: Error) => callback(err))
newOptions.onData = (stream: SMTPServerDataStream, session: SMTPServerSession, callback: (err?: Error | null) => void) => {
newOptions.onData = (
stream: SMTPServerDataStream,
session: SMTPServerSession,
callback: (err?: Error | null) => void,
) => {
const promiseStream = new Promise((resolve, reject) => {

@@ -64,3 +92,3 @@ if (isStreamEnded(stream)) {

}
finished(stream, (err) => {
finished(stream, err => {
if (err) reject(err)

@@ -86,3 +114,3 @@ else resolve()

this.server = new SMTPServer({ ...options as SMTPServerOptions, ...newOptions })
this.server = new SMTPServer({...(options as SMTPServerOptions), ...newOptions})

@@ -92,3 +120,3 @@ this.server.on('error', (err: Error) => this.onError(err))

listen (options: net.ListenOptions = {}): Promise<SMTPServerAsPromisedServerAddress> {
listen(options: net.ListenOptions = {}): Promise<SMTPServerAsPromisedServerAddress> {
return new Promise((resolve, reject) => {

@@ -115,3 +143,3 @@ const netServer = this.server.server

close (): Promise<void> {
close(): Promise<void> {
return new Promise((resolve, reject) => {

@@ -133,7 +161,7 @@ this.server.close((err?: Error | null) => {

updateSecureContext (options: tls.TlsOptions): void {
updateSecureContext(options: tls.TlsOptions): void {
this.server.updateSecureContext(options)
}
destroy (): Promise<void> {
destroy(): Promise<void> {
if (!this.closed) {

@@ -147,3 +175,5 @@ return this.close()

/** This method can be overriden in subclass */
protected onAuth (auth: SMTPServerAuthentication, session: SMTPServerSession): Promise<SMTPServerAuthenticationResponse> {
// prettier-ignore
// @ts-ignore
protected onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession): Promise<SMTPServerAuthenticationResponse> {
return Promise.reject(new Error('onAuth method not overriden in subclass'))

@@ -153,3 +183,4 @@ }

/** This method can be overriden in subclass */
protected onClose (session: SMTPServerSession): Promise<void> {
// @ts-ignore
protected onClose(session: SMTPServerSession): Promise<void> {
return Promise.resolve()

@@ -159,3 +190,4 @@ }

/** This method can be overriden in subclass */
protected onConnect (session: SMTPServerSession): Promise<void> {
// @ts-ignore
protected onConnect(session: SMTPServerSession): Promise<void> {
return Promise.resolve()

@@ -165,3 +197,4 @@ }

/** This method can be overriden in subclass */
protected onData (stream: SMTPServerDataStream, session: SMTPServerSession): Promise<void> {
// @ts-ignore
protected onData(stream: SMTPServerDataStream, session: SMTPServerSession): Promise<void> {
stream.pipe(new NullWritable())

@@ -172,3 +205,4 @@ return Promise.resolve()

/** This method can be overriden in subclass */
protected onMailFrom (address: SMTPServerAddress, session: SMTPServerSession): Promise<void> {
// @ts-ignore
protected onMailFrom(address: SMTPServerAddress, session: SMTPServerSession): Promise<void> {
return Promise.resolve()

@@ -178,3 +212,4 @@ }

/** This method can be overriden in subclass */
protected onRcptTo (address: SMTPServerAddress, session: SMTPServerSession): Promise<void> {
// @ts-ignore
protected onRcptTo(address: SMTPServerAddress, session: SMTPServerSession): Promise<void> {
return Promise.resolve()

@@ -184,3 +219,4 @@ }

/** This method can be overriden in subclass */
protected onError (error: Error): Promise<void> {
// @ts-ignore
protected onError(error: Error): Promise<void> {
return Promise.resolve()

@@ -187,0 +223,0 @@ }

@@ -6,20 +6,14 @@ {

"importHelpers": true,
"lib": [
"es6"
],
"lib": ["es6"],
"module": "commonjs",
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"target": "es6",
"strict": true,
"typeRoots": [
"node_modules/@types"
]
"typeRoots": ["node_modules/@types"]
},
"exclude": [
"./examples/**/*",
"./lib/**/*",
"./test/**/*"
]
"exclude": ["./examples/**/*", "./lib/**/*", "./test/**/*"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc