Skip to content

Commit ea88e47

Browse files
Merge branch 'dev' into fix-case
2 parents 73e0b1e + 704d5e3 commit ea88e47

File tree

75 files changed

+5276
-2809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5276
-2809
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ For more information, see the `CONTRIBUTING` guide.
3535

3636
**Actual behavior:** [What actually happened]
3737

38-
## Additional context
38+
## Additional Context
3939

4040
Add any other context about the problem here..
41+
42+
## Usage Information
43+
44+
SDK Version - [SDK version you are using]
45+
46+
- [ ] Node (Check, if using Node version of SDK)
47+
48+
> Node Version - [The version of Node you are using]
49+
50+
- [ ] Browser (Check, if using Browser version of SDK)
51+
52+
> Browser Name - [The name of Browser that you are using for SDK]
53+
54+
> Version - [The version of the browser you are using]

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ src/**/*.d.ts
2020

2121
samples/node/secrets.json
2222
samples/browser/src/secrets.js
23-
samples/browser/src/graph-js-sdk-core.js
24-
samples/browser/src/graph-js-sdk-web.js
23+
samples/browser/src/graph-js-sdk.js
2524
samples/browser/src/graph-es-sdk.js
2625

2726
spec/**/*.js

.huskyrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"hooks": {
3-
"pre-commit": "lint-staged && npm run lint && npm run test"
3+
"pre-commit": "npm run pre-build && git add src/Version.ts && lint-staged && npm run lint && npm run test"
44
}
55
}

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,35 @@ To make the contribution process as seamless as possible, follow these steps.
106106

107107
You navigate to the repository on your computer by using File Explorer. The repository files are in `C:\Users\<yourusername>\<repo name>`.
108108

109+
To install dependencies that are necessary for development run,
110+
111+
```cmd
112+
npm install
113+
```
114+
109115
To edit files, open them in an editor of your choice and modify them. To create a new file, use the editor of your choice and save the new file in the appropriate location in your local copy of the repository. While working, save your work frequently.
110116

117+
*Note: Make sure to add unit tests to validate you changes.*
118+
119+
Once you have done with your changes, You have to build and test your changes
120+
To build the library run,
121+
122+
```cmd
123+
npm run build
124+
```
125+
126+
To run tests,
127+
128+
```cmd
129+
npm run test
130+
```
131+
132+
To run linting,
133+
134+
```cmd
135+
npm run lint
136+
```
137+
111138
The files in `C:\Users\<yourusername>\<repo name>` are a working copy of the new branch that you created in your local repository. Changing anything in this folder doesn't affect the local repository until you commit a change. To commit a change to the local repository, type the following commands in GitBash:
112139

113140
git add .

README.md

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,32 @@ The Microsoft Graph JavaScript client library is a lightweight wrapper around th
1616
npm install @microsoft/microsoft-graph-client
1717
```
1818

19-
import `@microsoft/microsoft-graph-client` into your module.
19+
import `@microsoft/microsoft-graph-client` into your module and also you will need polyfills for fetch like [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
2020

2121
```typescript
22+
import "isomorphic-fetch";
2223
import { Client } from "@microsoft/microsoft-graph-client";
2324
```
2425

2526
### Via Script Tag
2627

27-
Include `lib/graph-js-sdk-web.js` in your page.
28+
Include [graph-js-sdk.js](https://cdn.jsdelivr.net/npm/@microsoft/microsoft-graph-client/lib/graph-js-sdk.js) in your HTML page.
2829

2930
```HTML
30-
<script type="text/javascript" src="graph-js-sdk-web.js"></script>
31+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@microsoft/microsoft-graph-client/lib/graph-js-sdk.js"></script>
3132
```
3233

33-
Incase if your application ships with [es6-promise](https://www.npmjs.com/package/es6-promise) and [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) just use `lib/graph-js-sdk-core.js`
34+
In case your browser doesn't have support for [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) [[support](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility)] or [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) [[support](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility)], you need to use polyfills like [github/fetch](https://github.com/github/fetch) for fetch and [es6-promise](https://github.com/stefanpenner/es6-promise) for promise.
3435

3536
```HTML
36-
<script type="text/javascript" src="graph-js-sdk-core.js"></script>
37+
<!-- polyfilling promise -->
38+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"></script>
39+
40+
<!-- polyfilling fetch -->
41+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/whatwg-fetch/dist/fetch.umd.min.js"></script>
42+
43+
<!-- depending on your browser you might wanna include babel polyfill -->
44+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@babel/[email protected]/dist/polyfill.min.js"></script>
3745
```
3846

3947
## Getting started
@@ -47,11 +55,11 @@ Register your application to use Microsoft Graph API using one of the following
4755

4856
### 2. Authenticate for the Microsoft Graph service
4957

50-
The Microsoft Graph JavaScript Client Library has an adapter implementation ([MSALAuthenticationProvider](src/MSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
58+
The Microsoft Graph JavaScript Client Library has an adapter implementation ([ImplicitMSALAuthenticationProvider](src/ImplicitMSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
5159

52-
> **Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
60+
> **Important Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Learn how you can create a [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
5361
54-
#### Creating an instance of MSALAuthenticationProvider in browser environment
62+
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
5563

5664
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
5765

@@ -60,20 +68,24 @@ Refer devDependencies in [package.json](./package.json) for the compatible msal
6068
```
6169

6270
```typescript
63-
const clientId = "your_client_id"; // Client Id of the registered application
64-
const callback = (errorDesc, token, error, tokenType) => {};
65-
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
66-
const options = {
67-
redirectUri: "Your redirect URI",
71+
72+
// Configuration options for MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL.js-1.0.0-api-release#configuration-options
73+
const msalConfig = {
74+
auth: {
75+
clientId: "your_client_id", // Client Id of the registered application
76+
redirectUri: "your_redirect_uri",
77+
},
6878
};
6979
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
7080

71-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
72-
const userAgentApplication = new Msal.UserAgentApplication(clientId, undefined, callback, options);
73-
const authProvider = new MicrosoftGraph.MSALAuthenticationProvider(userAgentApplication, graphScopes);
81+
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
82+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
83+
const msalApplication = new Msal.UserAgentApplication(msalConfig);
84+
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
85+
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, options);
7486
```
7587

76-
#### Creating an instance of MSALAuthenticationProvider in node environment
88+
#### Creating an instance of ImplicitMSALAuthenticationProvider in node environment
7789

7890
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
7991

@@ -84,19 +96,22 @@ npm install msal@<version>
8496
```typescript
8597
import { UserAgentApplication } from "msal";
8698

87-
import { MSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProvider";
99+
import { ImplicitMSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
88100

89-
const clientId = "your_client_id"; // Client Id of the registered application
90-
const callback = (errorDesc, token, error, tokenType) => {};
91101
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
92-
const options = {
93-
redirectUri: "Your redirect URI",
102+
const msalConfig = {
103+
auth: {
104+
clientId: "your_client_id", // Client Id of the registered application
105+
redirectUri: "your_redirect_uri",
106+
},
94107
};
95108
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
96109

97-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
98-
const userAgentApplication = new UserAgentApplication(clientId, undefined, callback, options);
99-
const authProvider = new MSALAuthenticationProvider(userAgentApplication, scopes);
110+
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
111+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
112+
const msalApplication = new UserAgentApplication(msalConfig);
113+
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
114+
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);
100115
```
101116

102117
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
@@ -193,8 +208,8 @@ Please see the [contributing guidelines](CONTRIBUTING.md).
193208

194209
- [Microsoft Graph website](https://graph.microsoft.io)
195210
- [Microsoft Graph TypeScript types](https://github.com/microsoftgraph/msgraph-typescript-typings/)
196-
- [Angular.js sample using the JavaScript client library](https://github.com/microsoftgraph/angular-connect-sample)
197-
- [Node.js sample using the JavaScript client library](https://github.com/microsoftgraph/nodejs-connect-sample)
211+
- [Build Angular single-page apps with Microsoft Graph](https://github.com/microsoftgraph/msgraph-training-angularspa)
212+
- [Build Node.js Express apps with Microsoft Graph](https://github.com/microsoftgraph/msgraph-training-nodeexpressapp)
198213
- [Office Dev Center](http://dev.office.com/)
199214

200215
## Third Party Notices

babel.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = function(api) {
2+
api.cache(true);
3+
const presets = [
4+
[
5+
"@babel/preset-env",
6+
{
7+
targets: {
8+
ie: 11,
9+
},
10+
},
11+
],
12+
];
13+
14+
const plugins = [
15+
[
16+
"@babel/plugin-transform-runtime",
17+
{
18+
absoluteRuntime: false,
19+
corejs: false,
20+
helpers: true,
21+
regenerator: true,
22+
useESModules: false,
23+
},
24+
],
25+
];
26+
return {
27+
presets,
28+
plugins,
29+
};
30+
};

browser-wrapper.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

browserify-with-dependencies.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

browserify.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/CallingPattern.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,45 @@ All calls to Microsoft Graph are chained together starting with **.api()**, then
44

55
## Path supports the following formats
66

7-
* `me`
8-
* `/me`
9-
* `https://graph.microsoft.com/v1.0/me`
10-
* `https://graph.microsoft.com/beta/me`
11-
* `me/events?$filter=startswith(subject, "Adventure")`
7+
- `me`
8+
- `/me`
9+
- `https://graph.microsoft.com/v1.0/me`
10+
- `https://graph.microsoft.com/beta/me`
11+
- `me/events?$filter=startswith(subject, "Adventure")`
1212

1313
## Promise based calling
1414

1515
Getting user details with `async`/`await`,
1616

1717
```typescript
1818
try {
19-
let res = await client.api("/me").get();
20-
console.log(res);
19+
let res = await client.api("/me").get();
20+
console.log(res);
2121
} catch (error) {
22-
throw error;
22+
throw error;
2323
}
2424
```
2525

2626
Getting user details with `then`/`catch`,
2727

2828
```typescript
2929
client
30-
.api('/me')
31-
.get()
32-
.then((res) => {
33-
console.log(res);
34-
}).catch((err) => {
35-
console.log(err);
36-
});
30+
.api("/me")
31+
.get()
32+
.then((res) => {
33+
console.log(res);
34+
})
35+
.catch((err) => {
36+
console.log(err);
37+
});
3738
```
3839

3940
## Callback based calling
4041

4142
Getting user details by passing `callback`,
4243

4344
```typescript
44-
client
45-
.api('/me')
46-
.get((err, res) => {
47-
console.log(res);
48-
});
49-
```
45+
client.api("/me").get((err, res) => {
46+
console.log(res);
47+
});
48+
```

0 commit comments

Comments
 (0)