From cc18b42d4ffaf80b72262d0efee2d157ab9f7a1c Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 6 Jun 2024 13:13:59 -0700 Subject: [PATCH] Remove outdated TS Sample (#7149) --- .../TypescriptTestApp2.0/.babelrc | 13 - .../TypescriptTestApp2.0/.beachballrc | 3 - .../TypescriptTestApp2.0/.gitignore | 4 - .../TypescriptTestApp2.0/.npmrc | 1 - .../TypescriptTestApp2.0/CHANGELOG.json | 65 ---- .../TypescriptTestApp2.0/package.json | 47 --- .../TypescriptTestApp2.0/server.js | 38 --- .../TypescriptTestApp2.0/src/AuthModule.ts | 290 ------------------ .../TypescriptTestApp2.0/src/Constants.ts | 5 - .../TypescriptTestApp2.0/src/FetchManager.ts | 29 -- .../src/GraphReponseTypes.ts | 25 -- .../TypescriptTestApp2.0/src/UIManager.ts | 108 ------- .../TypescriptTestApp2.0/src/index.ts | 65 ---- .../TypescriptTestApp2.0/src/views/index.html | 73 ----- .../TypescriptTestApp2.0/tsconfig.json | 11 - .../TypescriptTestApp2.0/utils/copyViews.js | 3 - .../TypescriptTestApp2.0/webpack.config.js | 14 - 17 files changed, 794 deletions(-) delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/.babelrc delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/.beachballrc delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/.gitignore delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/.npmrc delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/CHANGELOG.json delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/package.json delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/server.js delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/AuthModule.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/Constants.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/FetchManager.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/GraphReponseTypes.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/UIManager.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/index.ts delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/src/views/index.html delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/tsconfig.json delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/utils/copyViews.js delete mode 100644 samples/msal-browser-samples/TypescriptTestApp2.0/webpack.config.js diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/.babelrc b/samples/msal-browser-samples/TypescriptTestApp2.0/.babelrc deleted file mode 100644 index 036f6362e3..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/.babelrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "browsers": ["last 2 versions", "safari >= 7"] - } - } - ] - ], - "plugins": ["@babel/plugin-transform-runtime"] -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/.beachballrc b/samples/msal-browser-samples/TypescriptTestApp2.0/.beachballrc deleted file mode 100644 index eaa7c78ebe..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/.beachballrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "shouldPublish": false -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/.gitignore b/samples/msal-browser-samples/TypescriptTestApp2.0/.gitignore deleted file mode 100644 index 991b6670c6..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Build folders -dist/ -build-babel/ -build-tsc/ diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/.npmrc b/samples/msal-browser-samples/TypescriptTestApp2.0/.npmrc deleted file mode 100644 index 43c97e719a..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/CHANGELOG.json b/samples/msal-browser-samples/TypescriptTestApp2.0/CHANGELOG.json deleted file mode 100644 index 70954967d1..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/CHANGELOG.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "typescript-test-app-2.0", - "entries": [ - { - "date": "Wed, 30 Sep 2020 17:58:33 GMT", - "tag": "typescript-test-app-2.0_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "add beachball config", - "author": "prkanher@microsoft.com", - "commit": "50d9a9533b07a4a5bf7833bd6a5d0d35798c4903", - "package": "typescript-test-app-2.0" - } - ] - } - }, - { - "date": "Thu, 17 Sep 2020 23:16:22 GMT", - "tag": "typescript-test-app-2.0_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "add beachball config", - "author": "prkanher@microsoft.com", - "commit": "50d9a9533b07a4a5bf7833bd6a5d0d35798c4903", - "package": "typescript-test-app-2.0" - } - ] - } - }, - { - "date": "Tue, 25 Aug 2020 00:40:45 GMT", - "tag": "typescript-test-app-2.0_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "add beachball config", - "author": "prkanher@microsoft.com", - "commit": "50d9a9533b07a4a5bf7833bd6a5d0d35798c4903", - "package": "typescript-test-app-2.0" - } - ] - } - }, - { - "date": "Thu, 13 Aug 2020 02:20:48 GMT", - "tag": "typescript-test-app-2.0_v1.0.0", - "version": "1.0.0", - "comments": { - "none": [ - { - "comment": "add beachball config", - "author": "prkanher@microsoft.com", - "commit": "50d9a9533b07a4a5bf7833bd6a5d0d35798c4903", - "package": "typescript-test-app-2.0" - } - ] - } - } - ] -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/package.json b/samples/msal-browser-samples/TypescriptTestApp2.0/package.json deleted file mode 100644 index d04f075733..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "typescript-test-app-2.0", - "version": "1.0.0", - "description": "Sample app written in typescript that shows how to use the @azure/msal-browser package", - "main": "server.js", - "private": true, - "scripts": { - "clean": "npm run clean:build && rimraf dist", - "clean:build": "rimraf build-tsc build-babel", - "copy-views": "node utils/copyViews", - "build:babel": "babel build-tsc --out-dir build-babel --source-maps", - "build:webpack": "webpack", - "build": "tsc && npm run build:babel && npm run build:webpack && npm run clean:build", - "prestart": "npm run clean && npm run build && npm run copy-views", - "start": "node ." - }, - "keywords": [ - "msal", - "@azure/msal-browser", - "typescript", - "oauth2", - "msal-browser" - ], - "license": "MIT", - "dependencies": { - "@azure/msal-browser": "^3.1.0", - "@babel/runtime": "^7.10.4", - "express": "^4.19.2", - "fs": "0.0.1-security", - "morgan": "^1.10.0", - "path": "^0.12.7", - "yargs": "^15.4.0" - }, - "devDependencies": { - "@babel/cli": "^7.10.4", - "@babel/core": "^7.10.4", - "@babel/plugin-transform-runtime": "^7.10.4", - "@babel/preset-env": "^7.10.4", - "@types/shelljs": "^0.8.8", - "rimraf": "^3.0.2", - "shelljs": "^0.8.4", - "ts-loader": "^8.0.0", - "typescript": "^3.9.6", - "webpack": "^4.43.0", - "webpack-cli": "^3.3.12" - } -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/server.js b/samples/msal-browser-samples/TypescriptTestApp2.0/server.js deleted file mode 100644 index 7fc27349b0..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/server.js +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. -* See LICENSE in the source repository root for complete license information. -*/ -const express = require('express'); -const morgan = require('morgan'); -const path = require('path'); -const argv = require('yargs') - .usage('Usage: $0 -p [PORT]') - .alias('p', 'port') - .describe('port', '(Optional) Port Number - default is 30662') - .strict() - .argv; - -const DEFAULT_PORT = 30662; - -//initialize express. -const app = express(); - -// Initialize variables. -let port = DEFAULT_PORT; // -p {PORT} || 30662; -if (argv.p) { - port = argv.p; -} - -// Configure morgan module to log all requests. -app.use(morgan('dev')); - -app.use(express.static('dist')); - -// Set up a route for index.html. -app.get('*', function (req, res) { - res.sendFile(path.join(__dirname + '/dist/views/index.html')); -}); - -// Start the server. -app.listen(port); -console.log(`Listening on port ${port}...`); diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/AuthModule.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/AuthModule.ts deleted file mode 100644 index 5505a49772..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/AuthModule.ts +++ /dev/null @@ -1,290 +0,0 @@ -import { PublicClientApplication, SilentRequest, AuthenticationResult, Configuration, LogLevel, AccountInfo, InteractionRequiredAuthError, RedirectRequest, PopupRequest, EndSessionRequest, SsoSilentRequest } from "@azure/msal-browser"; -import { UIManager } from "./UIManager"; - -/** - * Configuration class for @azure/msal-browser: - * https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/modules/_src_config_configuration_.html - */ -const MSAL_CONFIG: Configuration = { - auth: { - clientId: "2eb9245f-612b-46cc-994a-f5e35ef37da0" - }, - cache: { - cacheLocation: "sessionStorage", // This configures where your cache will be stored - storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge - }, - system: { - loggerOptions: { - loggerCallback: (level, message, containsPii) => { - if (containsPii) { - return; - } - switch (level) { - case LogLevel.Error: - console.error(message); - return; - case LogLevel.Info: - console.info(message); - return; - case LogLevel.Verbose: - console.debug(message); - return; - case LogLevel.Warning: - console.warn(message); - return; - } - } - } - } -}; - -/** - * AuthModule for application - handles authentication in app. - */ -export class AuthModule { - - private myMSALObj: PublicClientApplication; // https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/classes/_src_app_publicclientapplication_.publicclientapplication.html - private account: AccountInfo | null; // https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-common/modules/_src_account_accountinfo_.html - private loginRedirectRequest: RedirectRequest; // https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/modules/_src_request_redirectrequest_.html - private loginRequest: PopupRequest; // https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/modules/_src_request_popuprequest_.html - private profileRedirectRequest: RedirectRequest; - private profileRequest: PopupRequest; - private mailRedirectRequest: RedirectRequest; - private mailRequest: PopupRequest; - private silentProfileRequest: SilentRequest; // https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/modules/_src_request_silentrequest_.html - private silentMailRequest: SilentRequest; - private silentLoginRequest: SsoSilentRequest; - - constructor() { - this.myMSALObj = new PublicClientApplication(MSAL_CONFIG); - this.account = null; - - this.loginRequest = { - scopes: [] - }; - - this.loginRedirectRequest = { - ...this.loginRequest, - redirectStartPage: window.location.href - }; - - this.profileRequest = { - scopes: ["User.Read"] - }; - - this.profileRedirectRequest = { - ...this.profileRequest, - redirectStartPage: window.location.href - }; - - // Add here scopes for access token to be used at MS Graph API endpoints. - this.mailRequest = { - scopes: ["Mail.Read"] - }; - - this.mailRedirectRequest = { - ...this.mailRequest, - redirectStartPage: window.location.href - }; - - this.silentProfileRequest = { - scopes: ["openid", "profile", "User.Read"], - forceRefresh: false - }; - - this.silentMailRequest = { - scopes: ["openid", "profile", "Mail.Read"], - forceRefresh: false - }; - - this.silentLoginRequest = { - loginHint: "IDLAB@msidlab0.ccsctp.net" - } - } - - /** - * Calls getAllAccounts and determines the correct account to sign into, currently defaults to first account found in cache. - * TODO: Add account chooser code - * - * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/docs/Accounts.md - */ - private getAccount(): AccountInfo | null { - // need to call getAccount here? - const currentAccounts = this.myMSALObj.getAllAccounts(); - if (currentAccounts === null) { - console.log("No accounts detected"); - return null; - } - - if (currentAccounts.length > 1) { - // Add choose account code here - console.log("Multiple accounts detected, need to add choose account code."); - return currentAccounts[0]; - } else if (currentAccounts.length === 1) { - return currentAccounts[0]; - } - - return null; - } - - /** - * Checks whether we are in the middle of a redirect and handles state accordingly. Only required for redirect flows. - * - * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#redirect-apis - */ - loadAuthModule(): void { - this.myMSALObj.handleRedirectPromise().then((resp: AuthenticationResult | null) => { - this.handleResponse(resp); - }).catch(console.error); - } - - /** - * Handles the response from a popup or redirect. If response is null, will check if we have any accounts and attempt to sign in. - * @param response - */ - handleResponse(response: AuthenticationResult | null) { - if (response !== null) { - this.account = response.account; - } else { - this.account = this.getAccount(); - } - - if (this.account) { - UIManager.showWelcomeMessage(this.account); - } - } - - /** - * Calls ssoSilent to attempt silent flow. If it fails due to interaction required error, it will prompt the user to login using popup. - * @param request - */ - attemptSsoSilent() { - this.myMSALObj.ssoSilent(this.silentLoginRequest).then(() => { - this.account = this.getAccount(); - if (this.account) { - UIManager.showWelcomeMessage(this.account); - } else { - console.log("No account!"); - } - }).catch(error => { - console.error("Silent Error: " + error); - if (error instanceof InteractionRequiredAuthError) { - this.login("loginPopup"); - } - }) - } - - /** - * Calls loginPopup or loginRedirect based on given signInType. - * @param signInType - */ - login(signInType: string): void { - if (signInType === "loginPopup") { - this.myMSALObj.loginPopup(this.loginRequest).then((resp: AuthenticationResult) => { - this.handleResponse(resp); - }).catch(console.error); - } else if (signInType === "loginRedirect") { - this.myMSALObj.loginRedirect(this.loginRedirectRequest); - } - } - - /** - * Logs out of current account. - */ - logout(): void { - let account: AccountInfo | undefined; - if (this.account) { - account = this.account - } - const logOutRequest: EndSessionRequest = { - account - }; - - this.myMSALObj.logoutRedirect(logOutRequest); - } - - /** - * Gets the token to read user profile data from MS Graph silently, or falls back to interactive redirect. - */ - async getProfileTokenRedirect(): Promise { - if (this.account) { - this.silentProfileRequest.account = this.account; - } - return this.getTokenRedirect(this.silentProfileRequest, this.profileRedirectRequest); - } - - /** - * Gets the token to read user profile data from MS Graph silently, or falls back to interactive popup. - */ - async getProfileTokenPopup(): Promise { - if (this.account) { - this.silentProfileRequest.account = this.account; - } - return this.getTokenPopup(this.silentProfileRequest, this.profileRequest); - } - - /** - * Gets the token to read mail data from MS Graph silently, or falls back to interactive redirect. - */ - async getMailTokenRedirect(): Promise { - if (this.account) { - this.silentMailRequest.account = this.account; - } - return this.getTokenRedirect(this.silentMailRequest, this.mailRedirectRequest); - } - - /** - * Gets the token to read mail data from MS Graph silently, or falls back to interactive popup. - */ - async getMailTokenPopup(): Promise { - if (this.account) { - this.silentMailRequest.account = this.account; - } - return this.getTokenPopup(this.silentMailRequest, this.mailRequest); - } - - /** - * Gets a token silently, or falls back to interactive popup. - */ - private async getTokenPopup(silentRequest: SilentRequest, interactiveRequest: PopupRequest): Promise { - try { - const response: AuthenticationResult = await this.myMSALObj.acquireTokenSilent(silentRequest); - return response.accessToken; - } catch (e) { - console.log("silent token acquisition fails."); - if (e instanceof InteractionRequiredAuthError) { - console.log("acquiring token using redirect"); - return this.myMSALObj.acquireTokenPopup(interactiveRequest).then((resp) => { - return resp.accessToken; - }).catch((err) => { - console.error(err); - return null; - }); - } else { - console.error(e); - } - } - - return null; - } - - /** - * Gets a token silently, or falls back to interactive redirect. - */ - private async getTokenRedirect(silentRequest: SilentRequest, interactiveRequest: RedirectRequest): Promise { - try { - const response = await this.myMSALObj.acquireTokenSilent(silentRequest); - return response.accessToken; - } catch (e) { - console.log("silent token acquisition fails."); - if (e instanceof InteractionRequiredAuthError) { - console.log("acquiring token using redirect"); - this.myMSALObj.acquireTokenRedirect(interactiveRequest).catch(console.error); - } else { - console.error(e); - } - } - - return null; - } -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/Constants.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/Constants.ts deleted file mode 100644 index 75603dc7b1..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/Constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Add here the endpoints for MS Graph API services you would like to use. -export const GRAPH_CONFIG = { - GRAPH_ME_ENDPT: "https://graph.microsoft.com/v1.0/me", - GRAPH_MAIL_ENDPT: "https://graph.microsoft.com/v1.0/me/messages" -}; diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/FetchManager.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/FetchManager.ts deleted file mode 100644 index 01a78d0a64..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/FetchManager.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { UserInfo, MailInfo } from "./GraphReponseTypes"; - -/** - * Class that handles Bearer requests for data using Fetch. - */ -export class FetchManager { - - /** - * Makes an Authorization "Bearer" request with the given accessToken to the given endpoint. - * @param endpoint - * @param accessToken - */ - async callEndpointWithToken(endpoint: string, accessToken: string): Promise { - const headers = new Headers(); - const bearer = `Bearer ${accessToken}`; - - headers.append("Authorization", bearer); - - const options = { - method: "GET", - headers: headers - }; - - console.log('request made at: ' + new Date().toString()); - - const response = await fetch(endpoint, options); - return (await response.json()) as UserInfo | MailInfo; - } -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/GraphReponseTypes.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/GraphReponseTypes.ts deleted file mode 100644 index 21e6efbd16..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/GraphReponseTypes.ts +++ /dev/null @@ -1,25 +0,0 @@ - -/** - * Graph data about the user. - */ -export type UserInfo = { - businessPhones?: Array, - displayName?: string, - givenName?: string, - id?: string, - jobTitle?: string, - mail?: string, - mobilePhone?: string, - officeLocation?: string, - preferredLanguage?: string, - surname?: string, - userPrincipalName?: string -}; - - -/** - * Mail data from MS Graph - */ -export type MailInfo = { - value?: Array -}; diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/UIManager.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/UIManager.ts deleted file mode 100644 index 75b7ebf826..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/UIManager.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { AccountInfo } from "@azure/msal-browser"; -import { UserInfo, MailInfo } from "./GraphReponseTypes"; -import { GRAPH_CONFIG } from "./Constants"; - -/** - * Class that handles UI updates for the app. - */ -export class UIManager { - // Select DOM elements to work with - static welcomeDiv = document.getElementById("WelcomeMessage"); - static signInButton = document.getElementById("SignIn"); - static cardDiv = document.getElementById("card-div"); - static mailButton = document.getElementById("readMail"); - static profileButton = document.getElementById("seeProfile"); - static profileDiv = document.getElementById("profile-div"); - static tabList = document.getElementById("list-tab"); - static tabContent = document.getElementById("nav-tabContent"); - - static showWelcomeMessage(account: AccountInfo) { - // Reconfiguring DOM elements - if (UIManager.cardDiv) { - UIManager.cardDiv.style.display = 'initial'; - } - - if (UIManager.welcomeDiv) { - UIManager.welcomeDiv.innerHTML = `Welcome ${account.username}`; - } - - if (UIManager.signInButton) { - (UIManager.signInButton.nextElementSibling as HTMLElement).style.display = 'none'; - UIManager.signInButton.setAttribute("onclick", "App.signOut();"); - UIManager.signInButton.setAttribute('class', "btn btn-success") - UIManager.signInButton.innerHTML = "Sign Out"; - } - } - - static clearTabs() { - if (UIManager.tabList) { - UIManager.tabList.innerHTML = ''; - } - - if (UIManager.tabContent) { - UIManager.tabContent.innerHTML = ''; - } - } - - static updateUI(data: UserInfo | MailInfo, endpoint: string) { - console.log(`Graph API responded at: ${new Date().toString()}`); - if (endpoint === GRAPH_CONFIG.GRAPH_ME_ENDPT) { - UIManager.setProfile(data as UserInfo); - } else if (endpoint === GRAPH_CONFIG.GRAPH_MAIL_ENDPT) { - UIManager.setMail(data as MailInfo); - } - } - - static setProfile(data: UserInfo) { - const userInfo = data as UserInfo; - const profile = document.createElement("pre"); - profile.innerHTML = JSON.stringify(userInfo, null, 4); - UIManager.clearTabs(); - - if (UIManager.tabContent) { - UIManager.tabContent.appendChild(profile); - } - } - - static setMail(data: MailInfo) { - const mailInfo = data as MailInfo; - if (!mailInfo.value || mailInfo.value.length < 1) { - alert("Your mailbox is empty!") - } else { - UIManager.clearTabs(); - mailInfo.value.slice(0, 10).forEach((d: any, i) => { - UIManager.createAndAppendListItem(d, i); - UIManager.createAndAppendContentItem(d, i); - }); - } - } - - static createAndAppendListItem(d: any, i: Number) { - const listItem = document.createElement("a"); - listItem.setAttribute("class", "list-group-item list-group-item-action") - listItem.setAttribute("id", "list" + i + "list") - listItem.setAttribute("data-toggle", "list") - listItem.setAttribute("href", "#list" + i) - listItem.setAttribute("role", "tab") - listItem.setAttribute("aria-controls", `${i}`) - listItem.innerHTML = d.subject; - - if (UIManager.tabList) { - UIManager.tabList.appendChild(listItem) - } - } - - static createAndAppendContentItem(d: any, i: Number) { - const contentItem = document.createElement("div"); - contentItem.setAttribute("class", "tab-pane fade") - contentItem.setAttribute("id", "list" + i) - contentItem.setAttribute("role", "tabpanel") - contentItem.setAttribute("aria-labelledby", "list" + i + "list") - if (d.from) { - contentItem.innerHTML = " from: " + d.from.emailAddress.address + "

" + d.bodyPreview + "..."; - if (UIManager.tabContent) { - UIManager.tabContent.appendChild(contentItem); - } - } - } -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/index.ts b/samples/msal-browser-samples/TypescriptTestApp2.0/src/index.ts deleted file mode 100644 index a7c6cf7893..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { AuthModule } from "./AuthModule"; -import { FetchManager } from "./FetchManager"; -import { UIManager } from "./UIManager"; -import { GRAPH_CONFIG } from "./Constants"; - -// Browser check variables -// If you support IE, our recommendation is that you sign-in using Redirect APIs -// If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check -const ua = window.navigator.userAgent; -const msie = ua.indexOf("MSIE "); -const msie11 = ua.indexOf("Trident/"); -const isIE = msie > 0 || msie11 > 0; - -const authModule: AuthModule = new AuthModule(); -const networkModule: FetchManager = new FetchManager(); - -// Load auth module when browser window loads. Only required for redirect flows. -window.addEventListener("load", async () => { - authModule.loadAuthModule(); -}); - -/** - * Called when user clicks "Sign in with Redirect" or "Sign in with Popup" - * @param method - */ -export function signIn(method: string): void { - const signInType = isIE ? "loginRedirect" : method; - authModule.login(signInType); -} - -/** - * Called when user clicks "Sign Out" - */ -export function signOut(): void { - authModule.logout(); -} - -/** - * Called when user clicks "See Profile" - */ -export async function seeProfile(): Promise { - const token = isIE ? await authModule.getProfileTokenRedirect() : await authModule.getProfileTokenPopup(); - if (token && token.length > 0) { - const graphResponse = await networkModule.callEndpointWithToken(GRAPH_CONFIG.GRAPH_ME_ENDPT, token); - UIManager.updateUI(graphResponse, GRAPH_CONFIG.GRAPH_ME_ENDPT); - } -} - -/** - * Called when user clicks "Read Mail" - */ -export async function readMail(): Promise { - const token = isIE ? await authModule.getMailTokenRedirect() : await authModule.getMailTokenPopup(); - if (token && token.length > 0) { - const graphResponse = await networkModule.callEndpointWithToken(GRAPH_CONFIG.GRAPH_MAIL_ENDPT, token); - UIManager.updateUI(graphResponse, GRAPH_CONFIG.GRAPH_MAIL_ENDPT); - } -} - -/** - * Called when user clicks "Attempt SsoSilent" - */ -export function attemptSsoSilent(): void { - authModule.attemptSsoSilent(); -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/src/views/index.html b/samples/msal-browser-samples/TypescriptTestApp2.0/src/views/index.html deleted file mode 100644 index 955a0acc8e..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/src/views/index.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - Quickstart | MSAL.JS Vanilla JavaScript SPA - - - - - - - -
-
Vanilla JavaScript SPA calling MS Graph API with MSAL.JS
-
-
- -
-
-
-
-
-
-
- -
-
-
-
- - - - - - - - - - diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/tsconfig.json b/samples/msal-browser-samples/TypescriptTestApp2.0/tsconfig.json deleted file mode 100644 index 9aeabe7f62..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "CommonJS", - "noImplicitAny": true, - "moduleResolution": "node", - "rootDir": "./src", - "outDir": "./build-tsc", - "strict": true - } -} diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/utils/copyViews.js b/samples/msal-browser-samples/TypescriptTestApp2.0/utils/copyViews.js deleted file mode 100644 index 250940131d..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/utils/copyViews.js +++ /dev/null @@ -1,3 +0,0 @@ -const shell = require("shelljs"); - -shell.cp("-R", "src/views", "dist/"); diff --git a/samples/msal-browser-samples/TypescriptTestApp2.0/webpack.config.js b/samples/msal-browser-samples/TypescriptTestApp2.0/webpack.config.js deleted file mode 100644 index 0cb9249b03..0000000000 --- a/samples/msal-browser-samples/TypescriptTestApp2.0/webpack.config.js +++ /dev/null @@ -1,14 +0,0 @@ -const path = require('path'); - -module.exports = { - entry: './build-babel/index.js', - resolve: { - extensions: [ '.js' ], - }, - output: { - filename: 'bundle.js', - path: path.resolve(__dirname, 'dist'), - library: "App" - }, - devtool: "source-map" -};