New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-outlook

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-outlook - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

115

calendar-api.js

@@ -94,2 +94,115 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.

/**
* Syncs events of a calendar.
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param [parameters.skipToken] {string} The value to pass in the `skipToken` query parameter in the API call.
* @param [parameters.deltaToken] {string} The value to pass in the `deltaToken` query parameter in the API call.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.calendarId] {string} The calendar id. If absent, the API calls the `/User/calendarview` endpoint. Valid values of this parameter are:
*
* - The `Id` property of a `Calendar` entity
* - `Primary`, the primary calendar is used. It is used by default if no Id is specified
*
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the 2.0 version of the api
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* // You have to specify a time window
* var startDateTime = "2017-01-01";
* var endDateTime = "2017-12-31";
*
* var apiOptions = {
* token: token,
* calendarId: 'calendar_id', // If none specified, the Primary calendar will be used
* user: userinfo,
* startDateTime: startDateTime,
* endDateTime: endDateTime
* };
*
* outlook.calendar.syncEvents(apiOptions, function(error, events) {
* if (error) {
* console.log('syncEvents returned an error:', error);
* } else {
* // Do something with the events.value array
* // Then get the @odata.deltaLink
* var delta = messages['@odata.deltaLink'];
*
* // Handle deltaLink value appropriately:
* // In general, if the deltaLink has a $skiptoken, that means there are more
* // "pages" in the sync results, you should call syncEvents again, passing
* // the $skiptoken value in the apiOptions.skipToken. If on the other hand,
* // the deltaLink has a $deltatoken, that means the sync is complete, and you should
* // store the $deltatoken value for future syncs.
* //
* // The one exception to this rule is on the intial sync (when you call with no skip or delta tokens).
* // In this case you always get a $deltatoken back, even if there are more results. In this case, you should
* // immediately call syncMessages again, passing the $deltatoken value in apiOptions.deltaToken.
* }
* }
*/
syncEvents: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var calendarSpec = parameters.calendarId === undefined ? '' : "/calendars/" + parameters.calendarId;
var requestUrl = base.apiEndpoint() + userSpec + '/calendarview?startdatetime=' + parameters.startDatetime + '&enddatetime=' + parameters.endDatetime;
var query = parameters.odataParams || {};
if (parameters.skipToken) {
query['$skiptoken'] = parameters.skipToken;
}
if (parameters.deltaToken) {
query['$deltatoken'] = parameters.deltaToken;
}
var headers = {
Prefer: [
'odata.track-changes',
'odata.maxpagesize' + (parameters.pageSize === undefined ? '50' : parameters.pageSize.toString())
]
};
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user,
query: query,
headers: headers
}
base.makeApiCall(apiOptions, (error, response) => {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
}
else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
}
else {
if(typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Used to get a specific event.

@@ -445,2 +558,2 @@ *

WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/

6

index.js

@@ -8,5 +8,5 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.

exchangefile = fs.readFileSync(path.join(currentDirectory, './exchange-lib/exchange.js'), 'utf8');
var exchangefile = fs.readFileSync(path.join(currentDirectory, './exchange-lib/exchange.js'), 'utf8');
eval(exchangefile);
utilityfile = fs.readFileSync(path.join(currentDirectory, './exchange-lib/utility.js'), 'utf8');
var utilityfile = fs.readFileSync(path.join(currentDirectory, './exchange-lib/utility.js'), 'utf8');
eval(utilityfile);

@@ -41,2 +41,2 @@

WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/

@@ -98,3 +98,3 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.

},
/**

@@ -181,2 +181,71 @@ * Used to get a specific message.

/**
* Get all attachments from a message
*
* @param parameters {object} An object containing all of the relevant parameters. Possible values:
* @param parameters.token {string} The access token.
* @param parameters.messageId {string} The Id of the message.
* @param [parameters.useMe] {boolean} If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case).
* @param [parameters.user.email] {string} The SMTP address of the user. If absent, the `/Me` segment is used in the API URL.
* @param [parameters.user.timezone] {string} The timezone of the user.
* @param [parameters.odataParams] {object} An object containing key/value pairs representing OData query parameters. See [Use OData query parameters]{@link https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters} for details.
* @param [callback] {function} A callback function that is called when the function completes. It should have the signature `function (error, result)`.
*
* @example var outlook = require('node-outlook');
*
* // Set the API endpoint to use the v2.0 endpoint
* outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
*
* // This is the oAuth token
* var token = 'eyJ0eXAiOiJKV1Q...';
*
* // The Id property of the message to retrieve. This could be
* // from a previous call to getMessages
* var msgId = 'AAMkADVhYTYwNzk...';
*
* // Pass the user's email address
* var userInfo = {
* email: 'sarad@contoso.com'
* };
*
* outlook.mail.getMessageAttachments({token: token, messageId: msgId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('getMessageAttachments returned an error: ' + error);
* }
* else if (result) {
* console.log(JSON.stringify(result, null, 2));
* }
* });
*/
getMessageAttachments: function(parameters, callback) {
var userSpec = utilities.getUserSegment(parameters);
var requestUrl = base.apiEndpoint() + userSpec + '/messages/' + parameters.messageId + '/attachments';
var apiOptions = {
url: requestUrl,
token: parameters.token,
user: parameters.user
};
if (parameters.odataParams !== undefined) {
apiOptions['query'] = parameters.odataParams;
}
base.makeApiCall(apiOptions, function(error, response) {
if (error) {
if (typeof callback === 'function') {
callback(error, response);
}
} else if (response.statusCode !== 200) {
if (typeof callback === 'function') {
callback('REST request returned ' + response.statusCode + '; body: ' + JSON.stringify(response.body), response);
}
} else {
if (typeof callback === 'function') {
callback(null, response.body);
}
}
});
},
/**
* Create a new message

@@ -610,12 +679,36 @@ *

* };
*
* var syncMsgParams = {
* '$select': 'Subject,ReceivedDateTime,From,BodyPreview,IsRead',
* '$orderby': 'ReceivedDateTime desc'
* };
*
* var apiOptions = {
* token: token,
* folderId: 'Inbox',
* odataParams: syncMsgParams,
* user: userinfo,
* pageSize: 20
* };
*
* outlook.mail.syncMessages(apiOptions, function(error, messages) {
* if (error) {
* console.log('syncMessages returned an error:', error);
* } else {
* // Do something with the messages.value array
* // Then get the @odata.deltaLink
* var delta = messages['@odata.deltaLink'];
*
* outlook.mail.sendDraftMessage({token: token, messageId: msgId, user: userInfo},
* function(error, result){
* if (error) {
* console.log('sendDraftMessage returned an error: ' + error);
* }
* else if (result) {
* console.log('SUCCESS');
* }
* });
* // Handle deltaLink value appropriately:
* // In general, if the deltaLink has a $skiptoken, that means there are more
* // "pages" in the sync results, you should call syncMessages again, passing
* // the $skiptoken value in the apiOptions.skipToken. If on the other hand,
* // the deltaLink has a $deltatoken, that means the sync is complete, and you should
* // store the $deltatoken value for future syncs.
* //
* // The one exception to this rule is on the intial sync (when you call with no skip or delta tokens).
* // In this case you always get a $deltatoken back, even if there are more results. In this case, you should
* // immediately call syncMessages again, passing the $deltatoken value in apiOptions.deltaToken.
* }
* }
*/

@@ -708,2 +801,2 @@

WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
{
"name": "node-outlook",
"version": "1.1.6",
"version": "1.1.7",
"description": "A package for calling the Outlook APIs from Node.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,2 +15,3 @@ ## Modules

<a name="module_base"></a>
## base

@@ -31,2 +32,3 @@

<a name="module_base.makeApiCall"></a>
### base.makeApiCall(parameters, [callback])

@@ -51,2 +53,3 @@ Used to do the actual send of a REST request to the REST endpoint.

<a name="module_base.getUser"></a>
### base.getUser(parameters, [callback])

@@ -71,2 +74,3 @@ Used to get information about a user.

<a name="module_base.setTraceFunc"></a>
### base.setTraceFunc(traceFunc)

@@ -82,2 +86,3 @@ Used to provide a tracing function.

<a name="module_base.setFiddlerEnabled"></a>
### base.setFiddlerEnabled(enabled)

@@ -93,2 +98,3 @@ Used to enable network sniffing with Fiddler.

<a name="module_base.apiEndpoint"></a>
### base.apiEndpoint() ⇒ <code>string</code>

@@ -99,2 +105,3 @@ Gets the API endpoint URL.

<a name="module_base.setApiEndpoint"></a>
### base.setApiEndpoint(newEndPoint)

@@ -110,2 +117,3 @@ Sets the API endpoint URL. If not called, the default of `https://outlook.office.com/api/v1.0` is used.

<a name="module_base.anchorMailbox"></a>
### base.anchorMailbox() ⇒ <code>string</code>

@@ -116,2 +124,3 @@ Gets the default anchor mailbox address.

<a name="module_base.setAnchorMailbox"></a>
### base.setAnchorMailbox(newAnchor)

@@ -127,2 +136,3 @@ Sets the default anchor mailbox address.

<a name="module_base.preferredTimeZone"></a>
### base.preferredTimeZone() ⇒ <code>string</code>

@@ -133,2 +143,3 @@ Gets the default preferred time zone.

<a name="module_base.setPreferredTimeZone"></a>
### base.setPreferredTimeZone(preferredTimeZone)

@@ -144,2 +155,3 @@ Sets the default preferred time zone.

<a name="module_mail"></a>
## mail

@@ -150,2 +162,3 @@

* [.getMessage(parameters, [callback])](#module_mail.getMessage)
* [.getMessageAttachments(parameters, [callback])](#module_mail.getMessageAttachments)
* [.createMessage(parameters, [callback])](#module_mail.createMessage)

@@ -159,2 +172,3 @@ * [.updateMessage(parameters, [callback])](#module_mail.updateMessage)

<a name="module_mail.getMessages"></a>
### mail.getMessages(parameters, [callback])

@@ -181,2 +195,3 @@ Used to get messages from a folder.

<a name="module_mail.getMessage"></a>
### mail.getMessage(parameters, [callback])

@@ -202,3 +217,26 @@ Used to get a specific message.

```
<a name="module_mail.getMessageAttachments"></a>
### mail.getMessageAttachments(parameters, [callback])
Get all attachments from a message
**Kind**: static method of <code>[mail](#module_mail)</code>
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>object</code> | An object containing all of the relevant parameters. Possible values: |
| parameters.token | <code>string</code> | The access token. |
| parameters.messageId | <code>string</code> | The Id of the message. |
| [parameters.useMe] | <code>boolean</code> | If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case). |
| [parameters.user.email] | <code>string</code> | The SMTP address of the user. If absent, the `/Me` segment is used in the API URL. |
| [parameters.user.timezone] | <code>string</code> | The timezone of the user. |
| [parameters.odataParams] | <code>object</code> | An object containing key/value pairs representing OData query parameters. See [Use OData query parameters](https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparameters) for details. |
| [callback] | <code>function</code> | A callback function that is called when the function completes. It should have the signature `function (error, result)`. |
**Example**
```js
var outlook = require('node-outlook'); // Set the API endpoint to use the v2.0 endpoint outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0'); // This is the oAuth token var token = 'eyJ0eXAiOiJKV1Q...'; // The Id property of the message to retrieve. This could be // from a previous call to getMessages var msgId = 'AAMkADVhYTYwNzk...'; // Pass the user's email address var userInfo = { email: 'sarad@contoso.com' }; outlook.mail.getMessageAttachments({token: token, messageId: msgId, user: userInfo}, function(error, result){ if (error) { console.log('getMessageAttachments returned an error: ' + error); } else if (result) { console.log(JSON.stringify(result, null, 2)); } });
```
<a name="module_mail.createMessage"></a>
### mail.createMessage(parameters, [callback])

@@ -225,2 +263,3 @@ Create a new message

<a name="module_mail.updateMessage"></a>
### mail.updateMessage(parameters, [callback])

@@ -248,2 +287,3 @@ Update a specific message.

<a name="module_mail.deleteMessage"></a>
### mail.deleteMessage(parameters, [callback])

@@ -269,2 +309,3 @@ Delete a specific message.

<a name="module_mail.sendNewMessage"></a>
### mail.sendNewMessage(parameters, [callback])

@@ -291,2 +332,3 @@ Sends a new message

<a name="module_mail.sendDraftMessage"></a>
### mail.sendDraftMessage(parameters, [callback])

@@ -312,2 +354,3 @@ Sends a draft message.

<a name="module_mail.syncMessages"></a>
### mail.syncMessages(parameters, [callback])

@@ -334,5 +377,6 @@ Syncs messages in a folder.

```js
var outlook = require('node-outlook'); // Set the API endpoint to use the beta endpoint outlook.base.setApiEndpoint('https://outlook.office.com/api/beta'); // This is the oAuth token var token = 'eyJ0eXAiOiJKV1Q...'; // Pass the user's email address var userInfo = { email: 'sarad@contoso.com' }; outlook.mail.sendDraftMessage({token: token, messageId: msgId, user: userInfo}, function(error, result){ if (error) { console.log('sendDraftMessage returned an error: ' + error); } else if (result) { console.log('SUCCESS'); } });
var outlook = require('node-outlook'); // Set the API endpoint to use the beta endpoint outlook.base.setApiEndpoint('https://outlook.office.com/api/beta'); // This is the oAuth token var token = 'eyJ0eXAiOiJKV1Q...'; // Pass the user's email address var userInfo = { email: 'sarad@contoso.com' }; var syncMsgParams = { '$select': 'Subject,ReceivedDateTime,From,BodyPreview,IsRead', '$orderby': 'ReceivedDateTime desc' }; var apiOptions = { token: token, folderId: 'Inbox', odataParams: syncMsgParams, user: userinfo, pageSize: 20 }; outlook.mail.syncMessages(apiOptions, function(error, messages) { if (error) { console.log('syncMessages returned an error:', error); } else { // Do something with the messages.value array // Then get the @odata.deltaLink var delta = messages['@odata.deltaLink']; // Handle deltaLink value appropriately: // In general, if the deltaLink has a $skiptoken, that means there are more // "pages" in the sync results, you should call syncMessages again, passing // the $skiptoken value in the apiOptions.skipToken. If on the other hand, // the deltaLink has a $deltatoken, that means the sync is complete, and you should // store the $deltatoken value for future syncs. // // The one exception to this rule is on the intial sync (when you call with no skip or delta tokens). // In this case you always get a $deltatoken back, even if there are more results. In this case, you should // immediately call syncMessages again, passing the $deltatoken value in apiOptions.deltaToken. } }
```
<a name="module_calendar"></a>
## calendar

@@ -342,2 +386,3 @@

* [.getEvents(parameters, [callback])](#module_calendar.getEvents)
* [.syncEvents(parameters, [callback])](#module_calendar.syncEvents)
* [.getEvent(parameters, [callback])](#module_calendar.getEvent)

@@ -349,2 +394,3 @@ * [.createEvent(parameters, [callback])](#module_calendar.createEvent)

<a name="module_calendar.getEvents"></a>
### calendar.getEvents(parameters, [callback])

@@ -370,3 +416,27 @@ Used to get events from a calendar.

```
<a name="module_calendar.syncEvents"></a>
### calendar.syncEvents(parameters, [callback])
Syncs events of a calendar.
**Kind**: static method of <code>[calendar](#module_calendar)</code>
| Param | Type | Description |
| --- | --- | --- |
| parameters | <code>object</code> | An object containing all of the relevant parameters. Possible values: |
| parameters.token | <code>string</code> | The access token. |
| [parameters.skipToken] | <code>string</code> | The value to pass in the `skipToken` query parameter in the API call. |
| [parameters.deltaToken] | <code>string</code> | The value to pass in the `deltaToken` query parameter in the API call. |
| [parameters.useMe] | <code>boolean</code> | If true, use the `/Me` segment instead of the `/Users/<email>` segment. This parameter defaults to false and is ignored if the `parameters.user.email` parameter isn't provided (the `/Me` segment is always used in this case). |
| [parameters.user.email] | <code>string</code> | The SMTP address of the user. If absent, the `/Me` segment is used in the API URL. |
| [parameters.user.timezone] | <code>string</code> | The timezone of the user. |
| [parameters.calendarId] | <code>string</code> | The calendar id. If absent, the API calls the `/User/calendarview` endpoint. Valid values of this parameter are: - The `Id` property of a `Calendar` entity - `Primary`, the primary calendar is used. It is used by default if no Id is specified |
| [callback] | <code>function</code> | A callback function that is called when the function completes. It should have the signature `function (error, result)`. |
**Example**
```js
var outlook = require('node-outlook'); // Set the API endpoint to use the 2.0 version of the api outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0'); // This is the oAuth token var token = 'eyJ0eXAiOiJKV1Q...'; // Pass the user's email address var userInfo = { email: 'sarad@contoso.com' }; // You have to specify a time window var startDateTime = "2017-01-01"; var endDateTime = "2017-12-31"; var apiOptions = { token: token, calendarId: 'calendar_id', // If none specified, the Primary calendar will be used user: userinfo, startDateTime: startDateTime, endDateTime: endDateTime }; outlook.calendar.syncEvents(apiOptions, function(error, events) { if (error) { console.log('syncEvents returned an error:', error); } else { // Do something with the events.value array // Then get the @odata.deltaLink var delta = messages['@odata.deltaLink']; // Handle deltaLink value appropriately: // In general, if the deltaLink has a $skiptoken, that means there are more // "pages" in the sync results, you should call syncEvents again, passing // the $skiptoken value in the apiOptions.skipToken. If on the other hand, // the deltaLink has a $deltatoken, that means the sync is complete, and you should // store the $deltatoken value for future syncs. // // The one exception to this rule is on the intial sync (when you call with no skip or delta tokens). // In this case you always get a $deltatoken back, even if there are more results. In this case, you should // immediately call syncMessages again, passing the $deltatoken value in apiOptions.deltaToken. } }
```
<a name="module_calendar.getEvent"></a>
### calendar.getEvent(parameters, [callback])

@@ -393,2 +463,3 @@ Used to get a specific event.

<a name="module_calendar.createEvent"></a>
### calendar.createEvent(parameters, [callback])

@@ -415,2 +486,3 @@ Create a new event

<a name="module_calendar.updateEvent"></a>
### calendar.updateEvent(parameters, [callback])

@@ -438,2 +510,3 @@ Update a specific event.

<a name="module_calendar.deleteEvent"></a>
### calendar.deleteEvent(parameters, [callback])

@@ -459,2 +532,3 @@ Delete a specific event.

<a name="module_contacts"></a>
## contacts

@@ -470,2 +544,3 @@

<a name="module_contacts.getContacts"></a>
### contacts.getContacts(parameters, [callback])

@@ -492,2 +567,3 @@ Used to get contacts from a contact folder.

<a name="module_contacts.getContact"></a>
### contacts.getContact(parameters, [callback])

@@ -514,2 +590,3 @@ Used to get a specific contact.

<a name="module_contacts.createContact"></a>
### contacts.createContact(parameters, [callback])

@@ -536,2 +613,3 @@ Create a new contact

<a name="module_contacts.updateContact"></a>
### contacts.updateContact(parameters, [callback])

@@ -559,2 +637,3 @@ Update a specific contact.

<a name="module_contacts.deleteContact"></a>
### contacts.deleteContact(parameters, [callback])

@@ -561,0 +640,0 @@ Delete a specific contact.

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