wo-smtpclient
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -108,4 +108,4 @@ module.exports = function(grunt) { | ||
credentials: { | ||
key: '-----BEGIN RSA PRIVATE KEY-----\r\nMIICWwIBAAKBgQDA9jfkw2yzUyfc15vECzGMZT2wfM4O5lyobFH/Z3rGNerxPIwm\r\nDyxlOCq5cE8/K8FNuaNm9NkbECSX9WR7yyUTG8kX7cG6Hhw1ICsE5RKWa/7uIJIa\r\nu517Q5N6A2zBM4YLCAewQZhdv4fYNCz3vsTuyGznD5pAR7bIfCHR6lblBQIDAQAB\r\nAoGAY0hMSfAjJcFLaV2mT6BSxiHxM7WDcDcmxaG2LutXSFTFpYm5sntsJEhZ8z/O\r\nBnrE4vD5Gigw7LPJoEYqhWdokx+neXzrpMcQGToNxn8aQO5WbYcAuIx5j893spwz\r\nG0cPfYVLsCb9epxWTmsxpN8P+W7MeyLX6YbIktJJn0LGBgECQQDgSZ7DSdzori5f\r\n8c/5Yse5lqZT8Gaot004AcVF371apfiQxbI9OQihkKB/zJkg9DHddFCIQV6Z++1o\r\nWKknFn01AkEA3D64eshD1MM8bLhC2k+Km6Lr7RPjtjNnIPOoE+8bVdkNgouffgsk\r\nFvliFij6dVQqbueBs5mnM0VxIgZea2NSkQJAAlBAFvuYD75cNBkmcAgYz01CgfMk\r\n2/CoFz/NbR8VsO2tVrDzWbZQ5Hm9bhQKMFDUgthETGOAOk5i8ISZmhGdUQJAXvfA\r\njlj6Pqzsyiht0zrHFrMargCMiM0DZAcMa4QHsm3EUI0p+ayOJEXmUI3c6WigX2/9\r\n0lan7Qi9bqF2ZzHNsQJAeyiq21084T9XNoqInoiBSCfWpqYqNK45qwBbktqJEz22\r\nshQluCz31kX0gGgE54hprJGkY/Ryq2g8Sk2XyREwcA==\r\n-----END RSA PRIVATE KEY-----\r\n', | ||
cert: '-----BEGIN CERTIFICATE-----\r\nMIICKTCCAZICCQDpQ20Tsi+iMDANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQG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+NidW17WTBroqx2LMwH\r\ngDU7d/mBsfgGnXMCZmtkq3VcE/LTmQz5+PHrhLHsomvzqPPMGL1PM5i7UOBRxvZb\r\nI0P4WM8ZBRISHJ4JaUBupvrhXaeZAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEApduD\r\nnAGm+VIMkCfLxWNegd41xS6Z89F/szTXjqnT14UnDc9CayOqxhsoWirukmEr7W9d\r\ngOTjGvG5X2k012VT1WTWinMHmyRJ4mM+caGTAJCE6Z314duhzOXrHhJUSHU5F9vs\r\nk9+qfs5ewmYBE3J6adnRCszn2VuoSRuof1MWRsU=\r\n-----END CERTIFICATE-----' | ||
} | ||
@@ -112,0 +112,0 @@ }; |
{ | ||
"name": "wo-smtpclient", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"homepage": "https://github.com/whiteout-io/smtpclient", | ||
@@ -38,5 +38,4 @@ "description": "SMTP Client allows you to connect to and stream data to a SMTP server in the browser.", | ||
"simplesmtp": "^0.3.27", | ||
"sinon": "^1.9.0", | ||
"amdefine": "^0.1.0" | ||
"sinon": "^1.9.0" | ||
} | ||
} |
@@ -25,3 +25,3 @@ // Copyright (c) 2013 Andris Reinman | ||
if (typeof define === 'function' && define.amd) { | ||
define(['tcp-socket', 'wo-stringencoding', 'axe-logger', './smtpclient-response-parser'], function(TCPSocket, encoding, axe, SmtpClientResponseParser) { | ||
define(['tcp-socket', 'stringencoding', 'axe', './smtpclient-response-parser'], function(TCPSocket, encoding, axe, SmtpClientResponseParser) { | ||
return factory(TCPSocket, encoding.TextEncoder, encoding.TextDecoder, axe, SmtpClientResponseParser, window.btoa); | ||
@@ -28,0 +28,0 @@ }); |
@@ -14,6 +14,7 @@ define(['chai', 'smtpclient'], function(chai, SmtpClient) { | ||
useSecureTransport: true, | ||
ca: '-----BEGIN CERTIFICATE-----\r\nMIICKTCCAZICCQDpQ20Tsi+iMDANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJB\r\nVTETMBEGA1UECBMKU29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cyBQdHkgTHRkMRIwEAYDVQQDEwkx\r\nMjcuMC4wLjEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL0SbQFFWO5ylGyo\r\nHxj8ZCLNGk/ARPPZoFcfKE1ABw0e1xs+mF3Hrlq0AxoOI+NidW17WTBroqx2LMwH\r\ngDU7d/mBsfgGnXMCZmtkq3VcE/LTmQz5+PHrhLHsomvzqPPMGL1PM5i7UOBRxvZb\r\nI0P4WM8ZBRISHJ4JaUBupvrhXaeZAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEApduD\r\nnAGm+VIMkCfLxWNegd41xS6Z89F/szTXjqnT14UnDc9CayOqxhsoWirukmEr7W9d\r\ngOTjGvG5X2k012VT1WTWinMHmyRJ4mM+caGTAJCE6Z314duhzOXrHhJUSHU5F9vs\r\nk9+qfs5ewmYBE3J6adnRCszn2VuoSRuof1MWRsU=\r\n-----END CERTIFICATE-----' | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.oncert = function() {}; | ||
smtp.connect(); | ||
@@ -20,0 +21,0 @@ smtp.onidle = function() { |
'use strict'; | ||
if (typeof define !== 'function') { | ||
var define = require('amdefine')(module); | ||
} | ||
var SmtpClient = require('../../src/smtpclient'), | ||
simplesmtp = require('simplesmtp'), | ||
chai = require('chai'), | ||
axe = require('axe-logger'), | ||
expect = chai.expect; | ||
define(function(require) { | ||
describe('smtpclient node integration tests', function() { | ||
var smtp, port = 10001, | ||
server; | ||
var SmtpClient = require('../../src/smtpclient'), | ||
simplesmtp = require('simplesmtp'), | ||
chai = require('chai'), | ||
axe = require('axe-logger'), | ||
expect = chai.expect; | ||
before(function(done) { | ||
axe.removeAppender(axe.defaultAppender); | ||
describe('smtpclient node integration tests', function() { | ||
var smtp, port = 10001, | ||
server; | ||
// start smtp test server | ||
var options = { | ||
debug: false, | ||
disableDNSValidation: true, | ||
port: port, | ||
enableAuthentication: true, | ||
secureConnection: false | ||
}; | ||
before(function(done) { | ||
axe.removeAppender(axe.defaultAppender); | ||
// start smtp test server | ||
var options = { | ||
debug: false, | ||
disableDNSValidation: true, | ||
port: port, | ||
enableAuthentication: true, | ||
secureConnection: false | ||
}; | ||
server = simplesmtp.createServer(options); | ||
server.on('startData', function( /*connection*/ ) {}); | ||
server.on('data', function( /*connection, chunk*/ ) {}); | ||
server.on('dataReady', function(connection, callback) { | ||
callback(null, 'foo'); | ||
}); | ||
server.on('authorizeUser', function(connection, username, password, callback) { | ||
callback(null, username === 'abc' && password === 'def'); | ||
}); | ||
server.listen(options.port, done); | ||
server = simplesmtp.createServer(options); | ||
server.on('startData', function( /*connection*/ ) {}); | ||
server.on('data', function( /*connection, chunk*/ ) {}); | ||
server.on('dataReady', function(connection, callback) { | ||
callback(null, 'foo'); | ||
}); | ||
after(function(done) { | ||
// close smtp test server | ||
server.end(done); | ||
server.on('authorizeUser', function(connection, username, password, callback) { | ||
callback(null, username === 'abc' && password === 'def'); | ||
}); | ||
server.listen(options.port, done); | ||
}); | ||
beforeEach(function(done) { | ||
smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false | ||
}); | ||
expect(smtp).to.exist; | ||
after(function(done) { | ||
// close smtp test server | ||
server.end(done); | ||
}); | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
done(); | ||
}; | ||
beforeEach(function(done) { | ||
smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false | ||
}); | ||
expect(smtp).to.exist; | ||
it('should fail with invalid MAIL FROM', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Bad sender address syntax'); | ||
smtp.onclose = done; | ||
}; | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
done(); | ||
}; | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'invalid', | ||
to: ['receiver@localhost'] | ||
}); | ||
it('should fail with invalid MAIL FROM', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Bad sender address syntax'); | ||
smtp.onclose = done; | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'invalid', | ||
to: ['receiver@localhost'] | ||
}); | ||
}); | ||
it('should fail with empty recipients', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Can\'t send mail - no recipients defined'); | ||
smtp.onclose = done; | ||
}; | ||
it('should fail with empty recipients', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Can\'t send mail - no recipients defined'); | ||
smtp.onclose = done; | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: [] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: [] | ||
}); | ||
}); | ||
it('should fail with invalid recipients', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Can\'t send mail - all recipients were rejected'); | ||
smtp.onclose = done; | ||
}; | ||
it('should fail with invalid recipients', function(done) { | ||
smtp.onerror = function(err) { | ||
expect(err.message).to.equal('Can\'t send mail - all recipients were rejected'); | ||
smtp.onclose = done; | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['invalid'] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['invalid'] | ||
}); | ||
}); | ||
it('should pass RCPT TO', function(done) { | ||
smtp.onready = function(failed) { | ||
expect(failed).to.deep.equal([]); | ||
smtp.onclose = done; | ||
smtp.close(); | ||
}; | ||
it('should pass RCPT TO', function(done) { | ||
smtp.onready = function(failed) { | ||
expect(failed).to.deep.equal([]); | ||
smtp.onclose = done; | ||
smtp.close(); | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['receiver@example.com'] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['receiver@example.com'] | ||
}); | ||
}); | ||
it('should pass RCPT TO with some failures', function(done) { | ||
smtp.onready = function(failed) { | ||
expect(failed).to.deep.equal(['invalid']); | ||
smtp.onclose = done; | ||
smtp.close(); | ||
}; | ||
it('should pass RCPT TO with some failures', function(done) { | ||
smtp.onready = function(failed) { | ||
expect(failed).to.deep.equal(['invalid']); | ||
smtp.onclose = done; | ||
smtp.close(); | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['invalid', 'receiver@example.com'] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@example.com', | ||
to: ['invalid', 'receiver@example.com'] | ||
}); | ||
}); | ||
it('should succeed with DATA', function(done) { | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
it('should succeed with DATA', function(done) { | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
}; | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
}); | ||
it('should not idle', function(done) { | ||
smtp.onidle = function() { | ||
// should not run | ||
expect(true).to.be.false; | ||
}; | ||
it('should not idle', function(done) { | ||
smtp.onidle = function() { | ||
// should not run | ||
expect(true).to.be.false; | ||
}; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
}); | ||
}); | ||
describe('smtpclient authentication tests', function() { | ||
var port = 10001, | ||
server; | ||
describe('smtpclient authentication tests', function() { | ||
var port = 10001, | ||
server; | ||
before(function(done) { | ||
// start smtp test server | ||
var options = { | ||
debug: false, | ||
disableDNSValidation: true, | ||
port: port, | ||
enableAuthentication: true, | ||
secureConnection: false, | ||
ignoreTLS: true, | ||
authMethods: ["PLAIN", "LOGIN", "XOAUTH2"] | ||
}; | ||
before(function(done) { | ||
// start smtp test server | ||
var options = { | ||
debug: false, | ||
disableDNSValidation: true, | ||
port: port, | ||
enableAuthentication: true, | ||
secureConnection: false, | ||
ignoreTLS: true, | ||
authMethods: ["PLAIN", "LOGIN", "XOAUTH2"] | ||
}; | ||
server = simplesmtp.createServer(options); | ||
server.on('startData', function( /*connection*/ ) {}); | ||
server.on('data', function( /*connection, chunk*/ ) {}); | ||
server.on('dataReady', function(connection, callback) { | ||
callback(null, 'foo'); | ||
}); | ||
server.on('authorizeUser', function(connection, username, password, callback) { | ||
callback(null, username === 'abc' && password === 'def'); | ||
}); | ||
server.listen(options.port, done); | ||
server = simplesmtp.createServer(options); | ||
server.on('startData', function( /*connection*/ ) {}); | ||
server.on('data', function( /*connection, chunk*/ ) {}); | ||
server.on('dataReady', function(connection, callback) { | ||
callback(null, 'foo'); | ||
}); | ||
server.on('authorizeUser', function(connection, username, password, callback) { | ||
callback(null, username === 'abc' && password === 'def'); | ||
}); | ||
server.listen(options.port, done); | ||
}); | ||
after(function(done) { | ||
// close smtp test server | ||
server.end(done); | ||
after(function(done) { | ||
// close smtp test server | ||
server.end(done); | ||
}); | ||
it('should authenticate with default method', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
pass: 'def' | ||
} | ||
}); | ||
expect(smtp).to.exist; | ||
it('should authenticate with default method', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
pass: 'def' | ||
} | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
}); | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
it('should authenticate with AUTH LOGIN', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
pass: 'def' | ||
}, | ||
authMethod: 'LOGIN' | ||
}); | ||
expect(smtp).to.exist; | ||
it('should authenticate with AUTH LOGIN', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
pass: 'def' | ||
}, | ||
authMethod: 'LOGIN' | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
}); | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
it('should fail with invalid credentials', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abcd', | ||
pass: 'defe' | ||
}, | ||
authMethod: 'LOGIN' | ||
}); | ||
expect(smtp).to.exist; | ||
it('should fail with invalid credentials', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abcd', | ||
pass: 'defe' | ||
}, | ||
authMethod: 'LOGIN' | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.connect(); | ||
smtp.onerror = function() { | ||
smtp.onclose = done; | ||
}; | ||
}); | ||
smtp.connect(); | ||
smtp.onerror = function() { | ||
smtp.onclose = done; | ||
}; | ||
it('should authenticate with AUTH XOAUTH2 and send a message', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
xoauth2: 'def' | ||
} | ||
}); | ||
expect(smtp).to.exist; | ||
it('should authenticate with AUTH XOAUTH2 and send a message', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
xoauth2: 'def' | ||
} | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.connect(); | ||
smtp.connect(); | ||
smtp.onidle = function() { | ||
smtp.onidle = function() { | ||
smtp.onidle = function() { | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
smtp.onclose = done; | ||
smtp.quit(); | ||
}; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.onready = function(failedRecipients) { | ||
expect(failedRecipients).to.be.empty; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.send('Subject: test\r\n\r\nMessage body'); | ||
smtp.end(); | ||
}; | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
}; | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
smtp.ondone = function(success) { | ||
expect(success).to.be.true; | ||
}; | ||
}); | ||
it('should fail with AUTH XOAUTH2', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
xoauth2: 'ghi' | ||
} | ||
smtp.useEnvelope({ | ||
from: 'sender@localhost', | ||
to: ['receiver@localhost'] | ||
}); | ||
expect(smtp).to.exist; | ||
}; | ||
}); | ||
smtp.connect(); | ||
smtp.onerror = function() { | ||
smtp.onclose = done; | ||
}; | ||
it('should fail with AUTH XOAUTH2', function(done) { | ||
var smtp = new SmtpClient('127.0.0.1', port, { | ||
useSecureTransport: false, | ||
auth: { | ||
user: 'abc', | ||
xoauth2: 'ghi' | ||
} | ||
}); | ||
expect(smtp).to.exist; | ||
smtp.connect(); | ||
smtp.onerror = function() { | ||
smtp.onclose = done; | ||
}; | ||
}); | ||
}); |
'use strict'; | ||
if (typeof define !== 'function') { | ||
var define = require('amdefine')(module); | ||
} | ||
define(function(require) { | ||
var chai = require('chai'); | ||
var sinon = require('sinon'); | ||
var SmtpResponseParser = require('../../src/smtpclient-response-parser'); | ||
(function(factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(['chai', 'sinon', '../../src/smtpclient-response-parser'], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(require('chai'), require('sinon'), require('../../src/smtpclient-response-parser')); | ||
} | ||
}(function(chai, sinon, SmtpResponseParser) { | ||
var expect = chai.expect; | ||
@@ -127,2 +124,2 @@ chai.Assertion.includeStack = true; | ||
}); | ||
}); | ||
})); |
'use strict'; | ||
if (typeof define !== 'function') { | ||
var define = require('amdefine')(module); | ||
} | ||
define(function(require) { | ||
var chai = require('chai'); | ||
var sinon = require('sinon'); | ||
var axe = require('axe-logger'); | ||
var SmtpClient = require('../../src/smtpclient'); | ||
(function(factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(['chai', 'sinon', 'axe', 'smtpclient'], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(require('chai'), require('sinon'), require('axe-logger'), require('../../src/smtpclient')); | ||
} | ||
}(function(chai, sinon, axe, SmtpClient) { | ||
var expect = chai.expect; | ||
@@ -25,3 +21,3 @@ chai.Assertion.includeStack = true; | ||
axe.removeAppender(axe.defaultAppender); | ||
host = '127.0.0.1', | ||
@@ -790,2 +786,2 @@ port = 10000, | ||
}); | ||
}); | ||
})); |
@@ -8,4 +8,3 @@ 'use strict'; | ||
'forge': 'forge.min', | ||
'wo-stringencoding': 'stringencoding.min', | ||
'axe-logger': 'axe' | ||
'stringencoding': 'stringencoding.min' | ||
}, | ||
@@ -12,0 +11,0 @@ shim: { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
13
105948
2206