Code Monkey home page Code Monkey logo

node-asclient's Introduction

asclient

Exchange ActiveSync Client for node.js with support for NTLM/NTLMv2/Basic authentication. In the current version, the client only supports device provisioning and folder synchronization. Support for write operations will follow.

npm install asclient

API

asclient(opts)

Factory that creates a new client instance.

  • Arguments
    • opts
      • username Required. Username for NTLM Authentication
      • password Required. Password for NTLM Authentication
      • endpoint Required. The URL to the ActiveSync server, e.g. https://mymailprovider.com/Microsoft-Server-ActiveSync
      • policyKey Active Sync Policy key (if the device is already provisioned). Default: '0'
      • folderSyncKey Last used sync key for the FolderSync command. Default: '0'
      • folders Array containing folder objects (if you want to continue synchronization from a previous state)
      • device
        • id Required. Device ID (ASCII, up to 32 characters. The first four characters should be alphabetical and represent the company that creates the client software)
        • type Required. Device Type, e.g. iPhone
        • model
        • imei
        • name
        • operatingSystem
        • language
        • userAgent
  • Returns
    • asclient A new client instance with the provided properties

asclient.prototype.testConnectivity()

Tests the connectivity to the server by sending an OPTIONS request

  • Returns
    • Promise

asclient.prototype.provision()

Provision the device and obtain a policyKey that is required for all further requests.

  • Returns
    • Promise

asclient.prototype.folderSync()

Fetch the folder list from the server. The result will be added to asclient.opts.folders

  • Returns
    • Promise

asclient.prototype.enableCalendarSync()

Flags all calendar folders in the list as to be synced. Run folderSync before!

  • Returns
    • Promise that will always resolve

asclient.prototype.enableEmailSync()

Flags all email folders in the list as to be synced. Run folderSync before!

  • Returns
    • Promise that will always resolve

asclient.prototype.sync()

Synchronizes all folders that have been flagged. The content will be added to asclient.contents

  • Returns
    • Promise

Example

const asclient = require('asclient');

const options = {
	username: 'user',
	password: 'password',
	endpoint: 'https://mymailprovider.com/Microsoft-Server-ActiveSync',
	device: {
		id: 'test0123456789',
		type: 'test-device'
	}
};

const myMailClient = asclient(options);

myMailClient.provision().
then(myMailClient.folderSync.bind(myMailClient)).
then(myMailClient.enableEmailSync.bind(myMailClient)).
then(myMailClient.sync.bind(myMailClient)).
then(function() {
	console.log('All went well');
	console.log(myMailClient.contents);
	console.log(myMailClient.policies);
}, function(err) {
	//handle error
});

node-asclient's People

Contributors

clncln1 avatar davenonymous avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.