Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@microsoft/microsoft-graph-types
Advanced tools
@microsoft/microsoft-graph-types is an npm package that provides TypeScript type definitions for the Microsoft Graph API. This package helps developers to interact with Microsoft Graph API in a type-safe manner, ensuring that the data structures and API calls are correctly used.
User Management
This feature allows you to define and manage user objects in a type-safe manner. The code sample demonstrates how to create a user object with specific properties.
const user: MicrosoftGraph.User = {
id: 'user-id',
displayName: 'John Doe',
mail: 'john.doe@example.com'
};
Calendar Events
This feature allows you to define and manage calendar events. The code sample demonstrates how to create an event object with specific properties such as subject, start time, and end time.
const event: MicrosoftGraph.Event = {
subject: 'Meeting',
start: {
dateTime: '2023-10-01T10:00:00',
timeZone: 'Pacific Standard Time'
},
end: {
dateTime: '2023-10-01T11:00:00',
timeZone: 'Pacific Standard Time'
}
};
Mail Management
This feature allows you to define and manage email messages. The code sample demonstrates how to create a message object with specific properties such as subject, body, and recipients.
const message: MicrosoftGraph.Message = {
subject: 'Hello World',
body: {
contentType: 'Text',
content: 'This is a test email.'
},
toRecipients: [
{
emailAddress: {
address: 'recipient@example.com'
}
}
]
};
The @microsoft/microsoft-graph-client package provides a client library for making requests to the Microsoft Graph API. Unlike @microsoft/microsoft-graph-types, which focuses on type definitions, this package provides methods for making API calls and handling responses.
The @pnp/graph package is part of the PnPjs library and provides a fluent API for working with Microsoft Graph. It offers a more streamlined and fluent interface compared to @microsoft/microsoft-graph-types, which focuses on type definitions.
The Microsoft Graph TypeScript definitions enable editors to provide intellisense on Microsoft Graph objects including users, messages, and groups.
NOTE: The Microsoft Graph TypeScript Types Beta npm package and GitHub repo is now available. Imports from the
microsoftgraph/msgraph-typescript-typings#beta
branch will no longer be supported.
We recommend including the .d.ts file by downloading this package through npm.
# Install types and save in package.json as a development dependency
npm install @microsoft/microsoft-graph-types --save-dev
The following examples assume that you have a valid access token. The following example uses isomorphic-fetch and Microsoft Graph JavaScript client library -
import { User } from "@microsoft/microsoft-graph-types-beta";
import { Client } from "@microsoft/microsoft-graph-client";
import 'isomorphic-fetch';
const client = Client.initWithMiddleware({
defaultVersion: 'beta',
...
});
const response = await client.api("/me").get();
const user = response as User;
// Create the message object
// Note that all the properties must follow the interface definitions.
// For example, this will not compile if you try to type "xml" instead of "html" for contentType.
let mail:MicrosoftGraphBeta.Message = {
subject: "Microsoft Graph TypeScript Sample",
toRecipients: [{
emailAddress: {
address: "microsoftgraph@example.com"
}
}],
body: {
content: "<h1>Microsoft Graph TypeScript Sample</h1>Try modifying the sample",
contentType: "html"
}
}
"devDependencies": {
// import published v1.0 types with a version from NPM
"@microsoft/microsoft-graph-types": "^0.4.0",
// import beta types with a version from NPM
"@microsoft/microsoft-graph-types-beta": "^0.1.0-preview"
}
}
import * as MicrosoftGraph from "@microsoft/microsoft-graph-types"
import * as MicrosoftGraphBeta from "@microsoft/microsoft-graph-types-beta"
const v1User: MicrosoftGraph.User = {
givenName: "V1 User"
}
const betaUser: MicrosoftGraphBeta.User = {
givenName: "Beta User"
}
Any TypeScript project can consume these types when using at least TypeScript 2.0. We've tested including the types as a dependency in the following editors.
We'd love to get your feedback about the TypeScript definitions project. You can send your questions and suggestions to us in the Issues section of this repository.
Please see the contributing guidelines.
If you find a security issue with our libraries or services please report it to secure@microsoft.com with as much detail as possible. Your submission may be eligible for a bounty through the Microsoft Bounty program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting this page and subscribing to Security Advisory Alerts.
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License");
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
FAQs
Types for Microsoft Graph objects
The npm package @microsoft/microsoft-graph-types receives a total of 183,497 weekly downloads. As such, @microsoft/microsoft-graph-types popularity was classified as popular.
We found that @microsoft/microsoft-graph-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.