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

browserbox

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserbox - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

3

Gruntfile.js

@@ -65,3 +65,4 @@ module.exports = function(grunt) {

'mimefuncs/src/mimefuncs.js',
'axe-logger/axe.js'
'axe-logger/axe.js',
'es6-promise/dist/es6-promise.js'
],

@@ -68,0 +69,0 @@ dest: 'test/lib/'

{
"name": "browserbox",
"version": "0.7.0",
"version": "0.8.0",
"homepage": "https://github.com/whiteout-io/browserbox",

@@ -25,3 +25,4 @@ "description": "IMAP client for browsers.",

"axe-logger": "~0.0.2",
"tcp-socket": "~0.5.0"
"tcp-socket": "~0.5.0",
"es6-promise": "^2.0.1"
},

@@ -44,4 +45,5 @@ "devDependencies": {

"wo-stringencoding": "~0.1.1",
"grunt-mocha-test": "^0.10.2"
"grunt-mocha-test": "^0.10.2",
"es6-promise": "^2.0.1"
}
}

@@ -21,2 +21,9 @@ # browserbox

## Promises
This module uses the Promises API, so make sure your platform either supports `Promise` constructor natively, or use the [es6-promise](https://www.npmjs.com/package/es6-promise) polyfill.
var ES6Promise = require('es6-promises');
ES6Promise.polyfill();
## Installation

@@ -26,3 +33,3 @@

npm install https://github.com/whiteout-io/browserbox/tarball/<TAG_NAME>
npm install browserbox

@@ -139,2 +146,4 @@ ## Usage

If callback is not specified, the method returns a Promise.
Mailbox object is with the following structure

@@ -244,2 +253,4 @@

If callback is not specified, the method returns a Promise.
Namespace object is with the following structure

@@ -301,2 +312,4 @@

If callback is not specified, the method returns a Promise.
## Select mailbox

@@ -327,2 +340,4 @@

If callback is not specified, the method returns a Promise.
Example

@@ -380,2 +395,4 @@

If callback is not specified, the method returns a Promise.
> **A note about sequence ranges** – using `*` as a range selector might be a really bad idea. If the mailbox contains thousands of messages and you are running a `1:*` query, it might choke your application. Additionally, remember that `*` stands for the sequence number of _the last message_ in the mailbox. This means that if you have 10 messages in a mailbox and you run a query for a range of `5000:*` you still get a match as the query is treated as `10:5000` by the server

@@ -520,2 +537,4 @@

If callback is not specified, the method returns a Promise.
Queries are composed as objects where keys are search terms and values are term arguments.

@@ -573,2 +592,4 @@ Only strings, numbers and Date values are used as arguments.

If callback is not specified, the method returns a Promise.
### Reading flags

@@ -610,2 +631,4 @@

If callback is not specified, the method returns a Promise.
If possible (`byUid:true` is set and UIDPLUS extension is supported by the server) uses `UID EXPUNGE`

@@ -646,2 +669,4 @@ otherwise falls back to EXPUNGE to delete the messages – which means that this method might be

If callback is not specified, the method returns a Promise.
### Example

@@ -672,2 +697,4 @@

If callback is not specified, the method returns a Promise.
If possible (MOVE extension is supported by the server) uses `MOVE` or `UID MOVE`

@@ -752,3 +779,3 @@ otherwise falls back to COPY + EXPUNGE.

}, {
// add precheck(ctx, next) to the query options
// add precheck(ctx, next) to the query options
precheck: function(ctx, next) {

@@ -767,3 +794,3 @@ // make sure inbox is selected before the search command is run

A `precheck` callback receives two arguments:
A `precheck` callback receives two arguments:
* **ctx** is a context parameter, i.e. a pointer to the current position in the command queue

@@ -770,0 +797,0 @@ * **next** callback to be invoked when the precheck is done

@@ -5,9 +5,14 @@ 'use strict';

if (typeof define === 'function' && define.amd) {
define(['chai', '../../src/browserbox', 'hoodiecrow', 'axe'], factory);
define(['chai', '../../src/browserbox', 'hoodiecrow', 'axe', 'es6-promise'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('chai'), require('../../src/browserbox'), require('hoodiecrow'), require('axe-logger'));
module.exports = factory(require('chai'), require('../../src/browserbox'), require('hoodiecrow'), require('axe-logger'), require('es6-promise'));
}
}(function(chai, BrowserBox, hoodiecrow, axe) {
}(function(chai, BrowserBox, hoodiecrow, axe, ES6Promise) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
if (typeof Promise === 'undefined') {
// load ES6 Promises polyfill
ES6Promise.polyfill();
}
var expect = chai.expect;

@@ -245,2 +250,12 @@ chai.Assertion.includeStack = true;

});
it('should succeed with promise', function(done) {
imap.listMailboxes().then(function(mailboxes) {
expect(mailboxes).to.not.be.empty;
done();
}).catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -259,2 +274,15 @@

});
it('should succeed with promise', function(done) {
imap.selectMailbox("inbox").then(function() {
imap.listMessages("1:*", ["uid", "flags", "envelope", "bodystructure", "body.peek[]"], function(err, messages) {
expect(err).to.not.exist;
expect(messages).to.not.be.empty;
done();
});
}).catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -287,2 +315,30 @@

});
it('should succeed with promise', function(done) {
var msgCount;
imap.selectMailbox("inbox").
then(function() {
return imap.listMessages("1:*", ["uid", "flags", "envelope", "bodystructure"]);
}).
then(function(messages) {
expect(messages).to.not.be.empty;
msgCount = messages.length;
return imap.upload('inbox', 'MIME-Version: 1.0\r\nDate: Wed, 9 Jul 2014 15:07:47 +0200\r\nDelivered-To: test@test.com\r\nMessage-ID: <CAHftYYQo=5fqbtnv-DazXhL2j5AxVP1nWarjkztn-N9SV91Z2w@mail.gmail.com>\r\nSubject: test\r\nFrom: Test Test <test@test.com>\r\nTo: Test Test <test@test.com>\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\ntest', {
flags: ['\\Seen', '\\Answered', '\\$MyFlag']
});
}).
then(function(success) {
expect(success).to.be.true;
return imap.listMessages("1:*", ["uid", "flags", "envelope", "bodystructure"]);
}).
then(function(messages) {
expect(messages.length).to.equal(msgCount + 1);
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -304,2 +360,18 @@

it('should return a sequence number with promise', function(done) {
imap.selectMailbox('inbox').then(function() {
imap.search({
header: ['subject', 'hello 3']
}, function(err, result) {
expect(err).to.not.exist;
expect(result).to.deep.equal([3]);
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});
it('should return an uid', function(done) {

@@ -320,2 +392,21 @@ imap.selectMailbox('inbox', function(err) {

it('should return an uid with promise', function(done) {
imap.selectMailbox('inbox').
then(function() {
return imap.search({
header: ['subject', 'hello 3']
}, {
byUid: true
});
}).
then(function(result) {
expect(result).to.deep.equal([555]);
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
it('should work with complex queries', function(done) {

@@ -352,2 +443,20 @@ imap.selectMailbox('inbox', function(err) {

it('should set flags for a message with promise', function(done) {
imap.selectMailbox('inbox').
then(function() {
return imap.setFlags('1', ['\\Seen', '$MyFlag']);
}).
then(function(result) {
expect(result).to.deep.equal([{
'#': 1,
'flags': ['\\Seen', '$MyFlag']
}]);
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
it('should add flags to a message', function(done) {

@@ -423,2 +532,25 @@ imap.selectMailbox('inbox', function(err) {

});
it('should delete a message with promise', function(done) {
var initialInfo;
imap.selectMailbox('inbox').
then(function(info) {
initialInfo = info;
return imap.deleteMessages(557, {
byUid: true
});
}).
then(function(result) {
expect(result).to.be.true;
return imap.selectMailbox('inbox');
}).
then(function(resultInfo) {
expect(initialInfo.exists !== resultInfo.exists).to.be.true;
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -442,2 +574,19 @@

});
it('should copy a message with promise', function(done) {
imap.selectMailbox('inbox').then(function() {
return imap.copyMessages(555, '[Gmail]/Trash', {
byUid: true
});
}).then(function() {
return imap.selectMailbox('[Gmail]/Trash');
}).then(function(info) {
expect(info.exists).to.equal(1);
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -467,2 +616,26 @@

});
it('should move a message with promise', function(done) {
var initialInfo;
imap.selectMailbox('inbox').
then(function(info) {
initialInfo = info;
return imap.moveMessages(555, '[Gmail]/Spam', {
byUid: true
});
}).then(function(result) {
expect(result).to.be.true;
return imap.selectMailbox('[Gmail]/Spam');
}).then(function(info) {
expect(info.exists).to.equal(1);
return imap.selectMailbox('inbox');
}).then(function(resultInfo) {
expect(initialInfo.exists !== resultInfo.exists).to.be.true;
done();
}).
catch(function(err) {
expect(err).to.not.exist;
done();
});
});
});

@@ -581,3 +754,3 @@

* start out in [Gmail]/Drafts
* execution path #1:

@@ -584,0 +757,0 @@ * setFlags precheck() should error and never be executed

@@ -34,2 +34,8 @@ 'use strict';

if (typeof Promise === 'undefined') {
// load ES6 Promises polyfill
ES6Promise.polyfill();
}
mocha.setup('bdd');

@@ -36,0 +42,0 @@ require(['test/unit/browserbox-test', 'test/unit/browserbox-imap-test'], function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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