Skip to content

Commit 98ff475

Browse files
committed
merging with 3.0.0
2 parents 5a8ed6a + c41881f commit 98ff475

File tree

110 files changed

+29255
-3502
lines changed

Some content is hidden

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

110 files changed

+29255
-3502
lines changed

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ npm-debug.log
1414
/lib/*
1515
!/lib/.npmignore
1616

17+
/authProviders/*
18+
1719
src/**/*.js
1820
src/**/*.js.map
1921
src/**/*.d.ts
2022

23+
samples/**/secrets.ts
24+
samples/**/secrets.js
2125
samples/node/secrets.json
2226
samples/browser/src/secrets.js
2327
samples/browser/src/graph-js-sdk.js
2428
samples/browser/src/graph-es-sdk.js
2529

26-
spec/**/*.js
27-
spec/**/*.d.ts
28-
spec/**/*.js.map
29-
spec/**/secrets.ts
30+
test/development/secrets.ts
31+
32+
.nyc_output/*

.prettierignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ src/**/*.js
66
src/**/*.js.map
77
src/**/*.d.ts
88

9-
spec/**/*.js
10-
spec/**/*.js.map
11-
spec/**/*.d.ts
9+
test/**/*.js
10+
test/**/*.js.map
11+
test/**/*.d.ts

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"request": "launch",
1919
"name": "Run Content tests",
2020
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
21-
"args": ["${workspaceRoot}/lib/spec/content/*.js"],
21+
"args": ["${workspaceRoot}/lib/test/common/**/*.js"],
2222
"cwd": "${workspaceRoot}",
2323
"preLaunchTask": "Run Compile",
2424
"outFiles": [],
@@ -29,7 +29,7 @@
2929
"request": "launch",
3030
"name": "Run Core tests",
3131
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
32-
"args": ["${workspaceRoot}/lib/spec/core/*.js"],
32+
"args": ["${workspaceRoot}/lib/test/common/core/*.js"],
3333
"cwd": "${workspaceRoot}",
3434
"preLaunchTask": "Run Compile",
3535
"outFiles": [],
@@ -40,7 +40,7 @@
4040
"request": "launch",
4141
"name": "Run Middleware tests",
4242
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
43-
"args": ["${workspaceRoot}/lib/spec/middleware/*.js"],
43+
"args": ["${workspaceRoot}/lib/test/common/middleware/*.js"],
4444
"cwd": "${workspaceRoot}",
4545
"preLaunchTask": "Run Compile",
4646
"outFiles": [],
@@ -51,7 +51,7 @@
5151
"request": "launch",
5252
"name": "Run Tasks tests",
5353
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
54-
"args": ["${workspaceRoot}/lib/spec/tasks/*.js"],
54+
"args": ["${workspaceRoot}/lib/test/common/tasks/*.js"],
5555
"cwd": "${workspaceRoot}",
5656
"preLaunchTask": "Run Compile",
5757
"outFiles": [],
@@ -62,7 +62,7 @@
6262
"request": "launch",
6363
"name": "Run Workload tests",
6464
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
65-
"args": ["${workspaceRoot}/spec/development/workload/*.js"],
65+
"args": ["${workspaceRoot}/test/common/development/workload/*.js"],
6666
"cwd": "${workspaceRoot}",
6767
"preLaunchTask": "Run Compile",
6868
"outFiles": [],

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ To edit files, open them in an editor of your choice and modify them. To create
116116

117117
_Note: Make sure to add unit tests to validate you changes._
118118

119-
Once you have done with your changes, You have to build and test your changes. To build the library run,
119+
Build and test your changes with the following commands after you have completed your work:
120120

121121
```cmd
122122
npm run build

README.md

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,64 +55,15 @@ Register your application to use Microsoft Graph API using one of the following
5555

5656
### 2. Authenticate for the Microsoft Graph service
5757

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)).
58+
The Microsoft Graph JavaScript Client Library has an adapter implementation for the following -
5959

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).
60+
- ([TokenCredentialAuthenticationProvider](src/authentication/TokenCredentialAuthenticationProvider.ts)) to support [Azure Identity TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md) (Azure Identity client library for JavaScript) which takes care of getting the `accessToken`. @azure/identity library does not ship with this library, user has to include it externally (For including @azure/identity, refer [this](https://www.npmjs.com/package/@azure/identity)).
6161

62-
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
62+
> Learn how to [create an instance of TokenCredentialAuthenticationProvider](./docs/TokenCredentialAuthenticationProvider.md).
6363
64-
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
64+
- ([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)).
6565

66-
```html
67-
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/<version>/js/msal.min.js"></script>
68-
```
69-
70-
```typescript
71-
// Configuration options for MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL.js-1.0.0-api-release#configuration-options
72-
const msalConfig = {
73-
auth: {
74-
clientId: "your_client_id", // Client Id of the registered application
75-
redirectUri: "your_redirect_uri",
76-
},
77-
};
78-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
79-
80-
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
81-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
82-
const msalApplication = new Msal.UserAgentApplication(msalConfig);
83-
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
84-
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, options);
85-
```
86-
87-
#### Creating an instance of ImplicitMSALAuthenticationProvider in node environment
88-
89-
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
90-
91-
```cmd
92-
npm install msal@<version>
93-
```
94-
95-
```typescript
96-
import { UserAgentApplication } from "msal";
97-
98-
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
99-
import { MSALAuthenticationProviderOptions } from "@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions";
100-
101-
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
102-
const msalConfig = {
103-
auth: {
104-
clientId: "your_client_id", // Client Id of the registered application
105-
redirectUri: "your_redirect_uri",
106-
},
107-
};
108-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
109-
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 MSALAuthenticationProviderOptions(graphScopes);
114-
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);
115-
```
66+
> Learn how to [create an instance of ImplicitMSALAuthenticationProvider](./docs/ImplicitMSALAuthenticationProvider.md).
11667
11768
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
11869

authProviderOptions/ReadMe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The authProviderOptions/ folders contains barrels for exporting Authentication Provider options such as MSAL and Azure Identity Token Credentials.
2+
3+
[tsconfig-sub-cjs.json](../tsconfig-sub-es.json) and [tsconfig-sub-cjs.json](../tsconfig-sub-es.json) contains the config for transpiling the files to authProviders/ output folder.
4+
5+
This approach is used because of the limitations of creating a submodule structure - References - https://github.com/microsoft/TypeScript/issues/8305 https://github.com/microsoft/TypeScript/issues/33079
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
export * from "../../lib/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider";
8+
export * from "../../lib/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
export * from "../../../lib/es/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider";
8+
export * from "../../../lib/es/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
8+
export * from "../../../lib/es/src/authentication/msal/ImplicitMSALAuthenticationProvider";
9+
export * from "../../../lib/es/src/authentication/msal/MSALAuthenticationProviderOptions";

authProviderOptions/msal/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
export * from "../../lib/src/authentication/msal/MSALAuthenticationProviderOptions";
8+
export * from "../../lib/src/authentication/msal/ImplicitMSALAuthenticationProvider";

0 commit comments

Comments
 (0)