diff --git a/authProviderOptions/ReadMe.md b/authProviderOptions/ReadMe.md deleted file mode 100644 index b42e8c781..000000000 --- a/authProviderOptions/ReadMe.md +++ /dev/null @@ -1,5 +0,0 @@ -The authProviderOptions/ folders contains barrels for exporting Authentication Provider options such as MSAL and Azure Identity Token Credentials. - -[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. - -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 diff --git a/authProviderOptions/authCodeMsalBrowser/index.ts b/authProviderOptions/authCodeMsalBrowser/index.ts deleted file mode 100644 index a38e75797..000000000 --- a/authProviderOptions/authCodeMsalBrowser/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -export * from "../../lib/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider"; -export * from "../../lib/src/authentication/msalOptions/MSALAuthenticationProviderOptions"; diff --git a/authProviderOptions/azureTokenCredentials/index.ts b/authProviderOptions/azureTokenCredentials/index.ts deleted file mode 100644 index 6b417efad..000000000 --- a/authProviderOptions/azureTokenCredentials/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -export * from "../../lib/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider"; -export * from "../../lib/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions"; diff --git a/authProviderOptions/es/authCodeMsalBrowser/index.ts b/authProviderOptions/es/authCodeMsalBrowser/index.ts deleted file mode 100644 index a9ad2f6bb..000000000 --- a/authProviderOptions/es/authCodeMsalBrowser/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -export * from "../../../lib/es/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider"; -export * from "../../../lib/es/src/authentication/msalOptions/MSALAuthenticationProviderOptions"; diff --git a/authProviderOptions/es/azureTokenCredentials/index.ts b/authProviderOptions/es/azureTokenCredentials/index.ts deleted file mode 100644 index a0b6cfc2e..000000000 --- a/authProviderOptions/es/azureTokenCredentials/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -export * from "../../../lib/es/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider"; -export * from "../../../lib/es/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions"; diff --git a/package-lock.json b/package-lock.json index 0208203c3..2c8fceb5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5", + "@microsoft/kiota-abstractions": "1.0.29", "tslib": "^2.2.0" }, "devDependencies": { @@ -19,6 +20,7 @@ "@babel/plugin-transform-runtime": "^7.12.10", "@babel/preset-env": "^7.12.11", "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@microsoft/kiota-authentication-azure": "1.0.7", "@microsoft/microsoft-graph-types": "^2.11.0", "@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-commonjs": "^21.0.1", @@ -2448,6 +2450,30 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@microsoft/kiota-abstractions": { + "version": "1.0.29", + "resolved": "https://npm.pkg.github.com/download/@microsoft/kiota-abstractions/1.0.29/ac14f09292b58a75a64d0671eb69c4083dce3c3e71c0b8d20fe67d136fe70765", + "integrity": "sha512-KVJ1P1f28JMn8+kGnnYSg6+42NQzZVi/sZ9o0rka4Pz2SZSY1dq4QYMaL5J+OP8j24oznFmnm7O5KsPcB3bkCg==", + "license": "MIT", + "dependencies": { + "tinyduration": "^3.2.2", + "tslib": "^2.3.1", + "uri-template-lite": "^22.1.0", + "uuid": "^8.3.2" + } + }, + "node_modules/@microsoft/kiota-authentication-azure": { + "version": "1.0.7", + "resolved": "https://npm.pkg.github.com/download/@microsoft/kiota-authentication-azure/1.0.7/3d08786561dcf1b008a2883e03f540fa40cf66cdde740a383524cb9fb44f7138", + "integrity": "sha512-GSHisBf3qKE1R2RStlFoIblvwnROHbyg7seyH8QP4qNFVP5EbiahnwRSCr8iQAbqzQRiUoOumLeEpmhjFoHYJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@azure/core-auth": "^1.3.2", + "@microsoft/kiota-abstractions": "^1.0.28", + "tslib": "^2.3.1" + } + }, "node_modules/@microsoft/microsoft-graph-types": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/@microsoft/microsoft-graph-types/-/microsoft-graph-types-2.16.0.tgz", @@ -2929,6 +2955,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "lru-cache": "^6.0.0" }, @@ -12373,6 +12400,11 @@ "node": ">=0.6.0" } }, + "node_modules/tinyduration": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/tinyduration/-/tinyduration-3.2.2.tgz", + "integrity": "sha512-eH6D0KIA4Xxje3ZRUnbsWfN28pAgTx3ZFQvgb0w9u8p9lxSX0eloxi4w165gv03GnvduR9m5JhToPxXvADHe+w==" + }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -12553,6 +12585,9 @@ }, "engines": { "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, "node_modules/tsutils/node_modules/tslib": { @@ -12891,6 +12926,11 @@ "punycode": "^2.1.0" } }, + "node_modules/uri-template-lite": { + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/uri-template-lite/-/uri-template-lite-22.1.0.tgz", + "integrity": "sha512-KJvWlYkFgeHxFt2Y0c6E/MM6X1mgw1PZ/PfhLKI/S/dPqnr6RXZ6AFE7uEE3T5RxZ8+8uHwONsmBZ/CUPfNaRg==" + }, "node_modules/urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -12955,7 +12995,6 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, "bin": { "uuid": "dist/bin/uuid" } @@ -15416,6 +15455,28 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@microsoft/kiota-abstractions": { + "version": "1.0.29", + "resolved": "https://npm.pkg.github.com/download/@microsoft/kiota-abstractions/1.0.29/ac14f09292b58a75a64d0671eb69c4083dce3c3e71c0b8d20fe67d136fe70765", + "integrity": "sha512-KVJ1P1f28JMn8+kGnnYSg6+42NQzZVi/sZ9o0rka4Pz2SZSY1dq4QYMaL5J+OP8j24oznFmnm7O5KsPcB3bkCg==", + "requires": { + "tinyduration": "^3.2.2", + "tslib": "^2.3.1", + "uri-template-lite": "^22.1.0", + "uuid": "^8.3.2" + } + }, + "@microsoft/kiota-authentication-azure": { + "version": "1.0.7", + "resolved": "https://npm.pkg.github.com/download/@microsoft/kiota-authentication-azure/1.0.7/3d08786561dcf1b008a2883e03f540fa40cf66cdde740a383524cb9fb44f7138", + "integrity": "sha512-GSHisBf3qKE1R2RStlFoIblvwnROHbyg7seyH8QP4qNFVP5EbiahnwRSCr8iQAbqzQRiUoOumLeEpmhjFoHYJw==", + "dev": true, + "requires": { + "@azure/core-auth": "^1.3.2", + "@microsoft/kiota-abstractions": "^1.0.28", + "tslib": "^2.3.1" + } + }, "@microsoft/microsoft-graph-types": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/@microsoft/microsoft-graph-types/-/microsoft-graph-types-2.16.0.tgz", @@ -23463,6 +23524,11 @@ "setimmediate": "^1.0.4" } }, + "tinyduration": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/tinyduration/-/tinyduration-3.2.2.tgz", + "integrity": "sha512-eH6D0KIA4Xxje3ZRUnbsWfN28pAgTx3ZFQvgb0w9u8p9lxSX0eloxi4w165gv03GnvduR9m5JhToPxXvADHe+w==" + }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -23863,6 +23929,11 @@ "punycode": "^2.1.0" } }, + "uri-template-lite": { + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/uri-template-lite/-/uri-template-lite-22.1.0.tgz", + "integrity": "sha512-KJvWlYkFgeHxFt2Y0c6E/MM6X1mgw1PZ/PfhLKI/S/dPqnr6RXZ6AFE7uEE3T5RxZ8+8uHwONsmBZ/CUPfNaRg==" + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -23922,8 +23993,7 @@ "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" }, "v8-compile-cache": { "version": "2.3.0", diff --git a/package.json b/package.json index 2c8c23a86..b0072324e 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,9 @@ "shims.d.ts" ], "scripts": { - "build": "npm run pre-build && npm run build:sub_cjs && npm run build:sub_es && rollup -c", + "build": "npm run pre-build && npm run build:cjs && npm run build:es && rollup -c", "build:cjs": "tsc --p tsconfig-cjs.json", "build:es": "tsc --p tsconfig-es.json", - "build:sub_cjs": "tsc -b tsconfig-sub-cjs.json", - "build:sub_es": "tsc -b tsconfig-sub-es.json", "format": "npm run format:css && npm run format:html && npm run format:js && npm run format:json && npm run format:md && npm run format:rc && npm run format:ts", "format:css": "prettier --write \"**/*.css\"", "format:html": "prettier --write \"**/*.html\"", @@ -49,10 +47,10 @@ "pre-build": "npm run setVersion", "setVersion": "gulp setVersion", "test": "npm run test:cjs && npm run test:esm", - "test:cjs": "npm run build:sub_cjs && mocha 'lib/test/common/**/*.js' --require isomorphic-fetch && mocha 'lib/test/node/**/*.js' --require isomorphic-fetch", + "test:cjs": "npm run build:cjs && mocha 'lib/test/common/**/*.js' --require isomorphic-fetch && mocha 'lib/test/node/**/*.js' --require isomorphic-fetch", "test:coverage": "TS_NODE_PROJECT='./tsconfig-cjs.json' nyc mocha --require isomorphic-fetch -r ts-node/register test/common/**/*.ts && mocha --require isomorphic-fetch -r ts-node/register test/common/**/*.ts", "test:development": "tsc --p test/tsconfig-test-development.json && mocha 'lib/test/development/**/*.js' --require isomorphic-fetch", - "test:esm": "npm run build:sub_es && mocha 'lib/es/test/common/**/*.js' --require esm --require isomorphic-fetch && mocha 'lib/es/test/node/**/*.js' --require esm --require isomorphic-fetch" + "test:esm": "npm run build:es && mocha 'lib/es/test/common/**/*.js' --require esm --require isomorphic-fetch && mocha 'lib/es/test/node/**/*.js' --require esm --require isomorphic-fetch" }, "nyc": { "all": true, @@ -68,6 +66,7 @@ }, "dependencies": { "@babel/runtime": "^7.12.5", + "@microsoft/kiota-abstractions": "1.0.29", "tslib": "^2.2.0" }, "devDependencies": { @@ -77,6 +76,7 @@ "@babel/plugin-transform-runtime": "^7.12.10", "@babel/preset-env": "^7.12.11", "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@microsoft/kiota-authentication-azure": "1.0.7", "@microsoft/microsoft-graph-types": "^2.11.0", "@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-commonjs": "^21.0.1", diff --git a/rollup.config.js b/rollup.config.js index 02e1686b5..ad49f3b57 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -43,60 +43,6 @@ const config = [ }), ], }, - { - input: ["authProviders/es/azureTokenCredentials/index.js"], - output: { - file: "lib/graph-client-tokenCredentialAuthProvider.js", - format: "iife", - name: "MicrosoftGraphTokenCredentialAuthProvider", - }, - plugins: [ - resolve({ - browser: true, - preferBuiltins: false, - }), - babel({ - babelHelpers: "runtime", - exclude: "node_modules/**", - }), - commonjs({ include: "node_modules/**" }), - terser({ - format: { - comments: false, - preamble: copyRight, - }, - }), - ], - }, - { - input: ["lib/es/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.js"], - external: ["@azure/msal-browser"], - output: { - file: "lib/graph-client-msalBrowserAuthProvider.js", - format: "iife", - name: "MSGraphAuthCodeMSALBrowserAuthProvider", - globals: { - "@azure/msal-browser": "msal", - }, - }, - plugins: [ - resolve({ - browser: true, - preferBuiltins: false, - }), - babel({ - babelHelpers: "runtime", - exclude: "node_modules/**", - }), - commonjs({ include: "node_modules/**" }), - terser({ - format: { - comments: false, - preamble: copyRight, - }, - }), - ], - }, ]; export default config; diff --git a/samples/javascript/clientInitialization/ClientWithOptions.js b/samples/javascript/clientInitialization/ClientWithOptions.js index bb477a945..0d554d69b 100644 --- a/samples/javascript/clientInitialization/ClientWithOptions.js +++ b/samples/javascript/clientInitialization/ClientWithOptions.js @@ -5,17 +5,14 @@ * ------------------------------------------------------------------------------------------- */ -const { Client } = require("@microsoft/microsoft-graph-client"); +const { Client, SimpleAuthenticationProvider } = require("@microsoft/microsoft-graph-client"); require("isomorphic-fetch"); - -const error = "error throw by the authentication handler"; - const client = Client.init({ defaultVersion: "v1.0", debugLogging: true, - authProvider: (done) => { - done(error, "ACCESS_TOKEN"); - }, + authProvider: new SimpleAuthenticationProvider(async () => { + return "ACCESS_TOKEN"; + }, ["scope1", "scope2"]), }); client diff --git a/samples/package-lock.json b/samples/package-lock.json index 317dcbf86..720ef7f4a 100644 --- a/samples/package-lock.json +++ b/samples/package-lock.json @@ -1,8 +1,1379 @@ { "name": "samples", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@azure/identity": "^1.3.0", + "@microsoft/microsoft-graph-client": "file:../", + "isomorphic-fetch": "^3.0.0", + "ts-node": "^9.1.1", + "typescript": "^4.2.4" + } + }, + "..": { + "name": "@microsoft/microsoft-graph-client", + "version": "3.0.0-Preview.3", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5", + "@microsoft/kiota-abstractions": "1.0.29", + "tslib": "^2.2.0" + }, + "devDependencies": { + "@azure/identity": "^2.0.1", + "@azure/msal-browser": "^2.15.0", + "@babel/core": "^7.12.10", + "@babel/plugin-transform-runtime": "^7.12.10", + "@babel/preset-env": "^7.12.11", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@microsoft/kiota-authentication-azure": "1.0.7", + "@microsoft/microsoft-graph-types": "^2.11.0", + "@rollup/plugin-babel": "^5.2.2", + "@rollup/plugin-commonjs": "^21.0.1", + "@rollup/plugin-node-resolve": "^13.1.3", + "@types/chai": "^4.2.14", + "@types/mocha": "^9.0.0", + "@types/node": "^17.0.13", + "@types/sinon": "^10.0.8", + "@typescript-eslint/eslint-plugin": "^4.1.0", + "@typescript-eslint/parser": "^4.1.0", + "chai": "^4.2.0", + "eslint": "^7.19.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-simple-import-sort": "^7.0.0", + "esm": "^3.2.25", + "form-data": "^4.0.0", + "gulp": "^4.0.2", + "husky": "^7.0.4", + "isomorphic-fetch": "^3.0.0", + "karma": "^6.3.2", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^3.1.0", + "karma-firefox-launcher": "^2.1.0", + "karma-mocha": "^2.0.1", + "karma-typescript": "^5.2.0", + "lint-staged": "^12.3.1", + "mocha": "^6.2.3", + "nyc": "^15.1.0", + "prettier": "^2.5.1", + "rollup": "^2.36.2", + "rollup-plugin-terser": "^7.0.2", + "sinon": "^13.0.1", + "source-map-support": "^0.5.19", + "stream-browserify": "^3.0.0", + "ts-node": "^10.4.0", + "typescript": "^4.2.4", + "uglify-es": "^3.3.9" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependenciesMeta": { + "@azure/identity": { + "optional": true + }, + "@azure/msal-browser": { + "optional": true + }, + "buffer": { + "optional": true + }, + "stream-browserify": { + "optional": true + } + } + }, + "node_modules/@azure/abort-controller": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz", + "integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@azure/core-asynciterator-polyfill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz", + "integrity": "sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg==" + }, + "node_modules/@azure/core-auth": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.3.0.tgz", + "integrity": "sha512-kSDSZBL6c0CYdhb+7KuutnKGf2geeT+bCJAgccB0DD7wmNJSsQPcF7TcuoZX83B7VK4tLz/u+8sOO/CnCsYp8A==", + "dependencies": { + "@azure/abort-controller": "^1.0.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@azure/core-http": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.2.6.tgz", + "integrity": "sha512-odtH7UMKtekc5YQ86xg9GlVHNXR6pq2JgJ5FBo7/jbOjNGdBqcrIVrZx2bevXVJz/uUTSx6vUf62gzTXTfqYSQ==", + "dependencies": { + "@azure/abort-controller": "^1.0.0", + "@azure/core-asynciterator-polyfill": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-tracing": "1.0.0-preview.11", + "@azure/logger": "^1.0.0", + "@types/node-fetch": "^2.5.0", + "@types/tunnel": "^0.0.1", + "form-data": "^3.0.0", + "node-fetch": "^2.6.0", + "process": "^0.11.10", + "tough-cookie": "^4.0.0", + "tslib": "^2.2.0", + "tunnel": "^0.0.6", + "uuid": "^8.3.0", + "xml2js": "^0.4.19" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@azure/core-tracing": { + "version": "1.0.0-preview.11", + "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.0.0-preview.11.tgz", + "integrity": "sha512-frF0pJc9HTmKncVokhBxCqipjbql02DThQ1ZJ9wLi7SDMLdPAFyDI5xZNzX5guLz+/DtPkY+SGK2li9FIXqshQ==", + "dependencies": { + "@opencensus/web-types": "0.0.7", + "@opentelemetry/api": "1.0.0-rc.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@azure/identity": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-1.3.0.tgz", + "integrity": "sha512-qYTaWA+5ir4+/iEry7n3l1TyeNhTHP8IRpjsbNv8ur8W/QjqZmCz1H2naebRp5tQmehXfo1pUrp2ew+qGhTh0g==", + "dependencies": { + "@azure/core-http": "^1.2.4", + "@azure/core-tracing": "1.0.0-preview.11", + "@azure/logger": "^1.0.0", + "@azure/msal-node": "1.0.0-beta.6", + "@types/stoppable": "^1.1.0", + "axios": "^0.21.1", + "events": "^3.0.0", + "jws": "^4.0.0", + "msal": "^1.0.2", + "open": "^7.0.0", + "qs": "^6.7.0", + "stoppable": "^1.1.0", + "tslib": "^2.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=8.0.0" + }, + "optionalDependencies": { + "keytar": "^7.3.0" + } + }, + "node_modules/@azure/logger": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.2.tgz", + "integrity": "sha512-YZNjNV0vL3nN2nedmcjQBcpCTo3oqceXmgiQtEm6fLpucjRZyQKAQruhCmCpRlB1iykqKJJ/Y8CDmT5rIE6IJw==", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-4.3.0.tgz", + "integrity": "sha512-jFqUWe83wVb6O8cNGGBFg2QlKvqM1ezUgJTEV7kIsAPX0RXhGFE4B1DLNt6hCnkTXDbw+KGW0zgxOEr4MJQwLw==", + "dependencies": { + "debug": "^4.1.1" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "1.0.0-beta.6", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-1.0.0-beta.6.tgz", + "integrity": "sha512-ZQI11Uz1j0HJohb9JZLRD8z0moVcPks1AFW4Q/Gcl67+QvH4aKEJti7fjCcipEEZYb/qzLSO8U6IZgPYytsiJQ==", + "dependencies": { + "@azure/msal-common": "^4.0.0", + "axios": "^0.21.1", + "jsonwebtoken": "^8.5.1", + "uuid": "^8.3.0" + } + }, + "node_modules/@microsoft/microsoft-graph-client": { + "resolved": "..", + "link": true + }, + "node_modules/@opencensus/web-types": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@opencensus/web-types/-/web-types-0.0.7.tgz", + "integrity": "sha512-xB+w7ZDAu3YBzqH44rCmG9/RlrOmFuDPt/bpf17eJr8eZSrLt7nc7LnWdxM9Mmoj/YKMHpxRg28txu3TcpiL+g==", + "engines": { + "node": ">=6.0" + } + }, + "node_modules/@opentelemetry/api": { + "version": "1.0.0-rc.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.0-rc.0.tgz", + "integrity": "sha512-iXKByCMfrlO5S6Oh97BuM56tM2cIBB0XsL/vWF/AtJrJEKx4MC/Xdu0xDsGXMGcNWpqF7ujMsjjnp0+UHBwnDQ==", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@types/node": { + "version": "15.12.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.5.tgz", + "integrity": "sha512-se3yX7UHv5Bscf8f1ERKvQOD6sTyycH3hdaoozvaLxgUiY5lIGEeH37AD0G0Qi9kPqihPn0HOfd2yaIEN9VwEg==" + }, + "node_modules/@types/node-fetch": { + "version": "2.5.10", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz", + "integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==", + "dependencies": { + "@types/node": "*", + "form-data": "^3.0.0" + } + }, + "node_modules/@types/stoppable": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/stoppable/-/stoppable-1.1.1.tgz", + "integrity": "sha512-b8N+fCADRIYYrGZOcmOR8ZNBOqhktWTB/bMUl5LvGtT201QKJZOOH5UsFyI3qtteM6ZAJbJqZoBcLqqxKIwjhw==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/tunnel": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@types/tunnel/-/tunnel-0.0.1.tgz", + "integrity": "sha512-AOqu6bQu5MSWwYvehMXLukFHnupHrpZ8nvgae5Ggie9UwzDR1CCwoXgSSWNZJuyOlCdfdsWMA5F2LlmvyoTv8A==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "optional": true + }, + "node_modules/are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "optional": true + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "optional": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "optional": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "optional": true, + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "node_modules/buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "optional": true + }, + "node_modules/code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "optional": true + }, + "node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "optional": true + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "optional": true, + "dependencies": { + "mimic-response": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "optional": true, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, + "node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "optional": true, + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "optional": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "optional": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/follow-redirects": { + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "optional": true + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true, + "dependencies": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "node_modules/get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=", + "optional": true + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "optional": true + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "optional": true + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "optional": true + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "optional": true, + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "optional": true + }, + "node_modules/isomorphic-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", + "dependencies": { + "node-fetch": "^2.6.1", + "whatwg-fetch": "^3.4.1" + } + }, + "node_modules/jsonwebtoken": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=4", + "npm": ">=1.4.28" + } + }, + "node_modules/jsonwebtoken/node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", + "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", + "dependencies": { + "jwa": "^2.0.0", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws/node_modules/jwa": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", + "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/keytar": { + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.7.0.tgz", + "integrity": "sha512-YEY9HWqThQc5q5xbXbRwsZTh2PJ36OSYRjSv3NN2xf5s5dpLTjEZnC2YikR29OaVybf9nQ0dJ/80i40RS97t/A==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "node-addon-api": "^3.0.0", + "prebuild-install": "^6.0.0" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/mime-db": { + "version": "1.48.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", + "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.31", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", + "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", + "dependencies": { + "mime-db": "1.48.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "optional": true + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "optional": true + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/msal": { + "version": "1.4.11", + "resolved": "https://registry.npmjs.org/msal/-/msal-1.4.11.tgz", + "integrity": "sha512-8vW5/+irlcQQk87r8Qp3/kQEc552hr7FQLJ6GF5LLkqnwJDDxrswz6RYPiQhmiampymIs0PbHVZrNf8m+6DmgQ==", + "dependencies": { + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/msal/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, + "node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", + "optional": true + }, + "node_modules/node-abi": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.30.0.tgz", + "integrity": "sha512-g6bZh3YCKQRdwuO/tSZZYJAw622SjsRfJ2X0Iy4sSOHZ34/sPPdVBn8fev2tj7njzLwuqPw9uMtGsGkO5kIQvg==", + "optional": true, + "dependencies": { + "semver": "^5.4.1" + } + }, + "node_modules/node-addon-api": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", + "optional": true + }, + "node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, + "dependencies": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "node_modules/number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", + "integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==" + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "optional": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/prebuild-install": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-6.1.3.tgz", + "integrity": "sha512-iqqSR84tNYQUQHRXalSKdIaM8Ov1QxOVuBNWI7+BzZWv6Ih9k75wOnH1rGQ9WWTaaLkTpxWKIciOF0KyfM74+Q==", + "optional": true, + "dependencies": { + "detect-libc": "^1.0.3", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^2.21.0", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^3.0.3", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "optional": true + }, + "node_modules/psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "optional": true, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.1.tgz", + "integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "optional": true, + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "optional": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "optional": true + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, + "node_modules/signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "optional": true + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "optional": true + }, + "node_modules/simple-get": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", + "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", + "optional": true, + "dependencies": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/stoppable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", + "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", + "engines": { + "node": ">=4", + "npm": ">=6" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "optional": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true + }, + "node_modules/string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, + "dependencies": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "optional": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "optional": true, + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "optional": true, + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tar-stream/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "optional": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/tough-cookie": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", + "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.1.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + }, + "node_modules/ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dependencies": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "optional": true, + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/typescript": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz", + "integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "optional": true + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + }, + "node_modules/whatwg-fetch": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", + "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "optional": true, + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "optional": true + }, + "node_modules/xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + } + }, "dependencies": { "@azure/abort-controller": { "version": "1.0.4", @@ -107,19 +1478,57 @@ "uuid": "^8.3.0" } }, - "@babel/runtime": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", - "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, "@microsoft/microsoft-graph-client": { "version": "file:..", "requires": { + "@azure/identity": "^2.0.1", + "@azure/msal-browser": "^2.15.0", + "@babel/core": "^7.12.10", + "@babel/plugin-transform-runtime": "^7.12.10", + "@babel/preset-env": "^7.12.11", "@babel/runtime": "^7.12.5", - "tslib": "^2.2.0" + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@microsoft/kiota-abstractions": "1.0.29", + "@microsoft/kiota-authentication-azure": "1.0.7", + "@microsoft/microsoft-graph-types": "^2.11.0", + "@rollup/plugin-babel": "^5.2.2", + "@rollup/plugin-commonjs": "^21.0.1", + "@rollup/plugin-node-resolve": "^13.1.3", + "@types/chai": "^4.2.14", + "@types/mocha": "^9.0.0", + "@types/node": "^17.0.13", + "@types/sinon": "^10.0.8", + "@typescript-eslint/eslint-plugin": "^4.1.0", + "@typescript-eslint/parser": "^4.1.0", + "chai": "^4.2.0", + "eslint": "^7.19.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-simple-import-sort": "^7.0.0", + "esm": "^3.2.25", + "form-data": "^4.0.0", + "gulp": "^4.0.2", + "husky": "^7.0.4", + "isomorphic-fetch": "^3.0.0", + "karma": "^6.3.2", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^3.1.0", + "karma-firefox-launcher": "^2.1.0", + "karma-mocha": "^2.0.1", + "karma-typescript": "^5.2.0", + "lint-staged": "^12.3.1", + "mocha": "^6.2.3", + "nyc": "^15.1.0", + "prettier": "^2.5.1", + "rollup": "^2.36.2", + "rollup-plugin-terser": "^7.0.2", + "sinon": "^13.0.1", + "source-map-support": "^0.5.19", + "stream-browserify": "^3.0.0", + "ts-node": "^10.4.0", + "tslib": "^2.2.0", + "typescript": "^4.2.4", + "uglify-es": "^3.3.9" } }, "@opencensus/web-types": { @@ -834,11 +2243,6 @@ } } }, - "regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", - "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -912,17 +2316,6 @@ "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==" }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -940,6 +2333,17 @@ } } }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", diff --git a/samples/typescript/clientInitialization/ClientWithOptions.ts b/samples/typescript/clientInitialization/ClientWithOptions.ts index 7377c0c30..bacc51d61 100644 --- a/samples/typescript/clientInitialization/ClientWithOptions.ts +++ b/samples/typescript/clientInitialization/ClientWithOptions.ts @@ -6,26 +6,16 @@ */ import { Client } from "@microsoft/microsoft-graph-client"; +import "isomorphic-fetch"; -const error = "error throw by the authentication handler"; +import { SimpleAuthenticationProvider } from "./authentication/SimpleAuthentication/SimpleAuthenticationProvider"; -export const client = Client.init({ - defaultVersion: "v1.0", - debugLogging: true, - authProvider: (done) => { - done(error, "ACCESS_TOKEN"); - }, +const token = ""; +const simpleAuthenticationProvider = new SimpleAuthenticationProvider({getAccessTokenCallback:async () => { return token;}}); +const client = Client.init({ + authProvider: simpleAuthenticationProvider }); -// Following is the example of how to make requests to the Microsoft Graph API using the client instance - -client - .api("/me") - .select("displayName") - .get() - .then((res) => { - console.log(res); - }) - .catch((err) => { - console.log(err); - }); +client.api('/me').get().then(res => { + console.log(res); +}); diff --git a/src/Client.ts b/src/Client.ts index ac8a76831..c6b5a3a02 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -9,13 +9,15 @@ * @module Client */ +import { BaseBearerTokenAuthenticationProvider } from "@microsoft/kiota-abstractions"; + +import { GraphClientError } from "."; import { GRAPH_API_VERSION, GRAPH_BASE_URL } from "./Constants"; -import { CustomAuthenticationProvider } from "./CustomAuthenticationProvider"; import { GraphRequest } from "./GraphRequest"; +import { appendGraphAndCustomHosts } from "./GraphRequestUtil"; import { HTTPClient } from "./HTTPClient"; import { HTTPClientFactory } from "./HTTPClientFactory"; import { ClientOptions } from "./IClientOptions"; -import { Options } from "./IOptions"; import { validatePolyFilling } from "./ValidatePolyFilling"; export class Client { @@ -35,6 +37,8 @@ export class Client { */ private httpClient: HTTPClient; + private authProvider: BaseBearerTokenAuthenticationProvider; + /** * @public * @static @@ -42,25 +46,8 @@ export class Client { * @param {Options} options - The options for client instance * @returns The Client instance */ - public static init(options: Options): Client { - const clientOptions: ClientOptions = {}; - for (const i in options) { - if (Object.prototype.hasOwnProperty.call(options, i)) { - clientOptions[i] = i === "authProvider" ? new CustomAuthenticationProvider(options[i]) : options[i]; - } - } - return Client.initWithMiddleware(clientOptions); - } - - /** - * @public - * @static - * To create a client instance with the Client Options - * @param {ClientOptions} clientOptions - The options object for initializing the client - * @returns The Client instance - */ - public static initWithMiddleware(clientOptions: ClientOptions): Client { - return new Client(clientOptions); + public static init(options: ClientOptions): Client { + return new Client(options); } /** @@ -77,20 +64,21 @@ export class Client { } } let httpClient: HTTPClient; - if (clientOptions.authProvider !== undefined && clientOptions.middleware !== undefined) { - const error = new Error(); - error.name = "AmbiguityInInitialization"; - error.message = "Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both"; + if (clientOptions.authProvider === undefined) { + const error = new GraphClientError(); + error.name = "Client Initialization Failed"; + error.message = "Unable to Create Client, Please provide an authentication provider"; throw error; - } else if (clientOptions.authProvider !== undefined) { - httpClient = HTTPClientFactory.createWithAuthenticationProvider(clientOptions.authProvider); - } else if (clientOptions.middleware !== undefined) { - httpClient = new HTTPClient(...[].concat(clientOptions.middleware)); + } + this.authProvider = clientOptions.authProvider; + const hostsValidator = this.authProvider.accessTokenProvider.getAllowedHostsValidator(); + const allowedHosts = clientOptions.customHosts ? new Set([...clientOptions.customHosts, ...hostsValidator.getAllowedHosts()]) : new Set(hostsValidator.getAllowedHosts()); + const hostSetWithGraphandCustomHosts = appendGraphAndCustomHosts(allowedHosts); + hostsValidator.setAllowedHosts(hostSetWithGraphandCustomHosts); + if (!clientOptions.middleware) { + httpClient = HTTPClientFactory.createWithDefaultMiddleware(this.authProvider); } else { - const error = new Error(); - error.name = "InvalidMiddlewareChain"; - error.message = "Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain"; - throw error; + httpClient = new HTTPClient(...[].concat(clientOptions.middleware)); } this.httpClient = httpClient; } diff --git a/src/CustomAuthenticationProvider.ts b/src/CustomAuthenticationProvider.ts deleted file mode 100644 index eac4ba6e3..000000000 --- a/src/CustomAuthenticationProvider.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module CustomAuthenticationProvider - */ - -import { GraphClientError } from "./GraphClientError"; -import { AuthenticationProvider } from "./IAuthenticationProvider"; -import { AuthProvider } from "./IAuthProvider"; - -/** - * @class - * Class representing CustomAuthenticationProvider - * @extends AuthenticationProvider - */ -export class CustomAuthenticationProvider implements AuthenticationProvider { - /** - * @private - * A member to hold authProvider callback - */ - private provider: AuthProvider; - - /** - * @public - * @constructor - * Creates an instance of CustomAuthenticationProvider - * @param {AuthProviderCallback} provider - An authProvider function - * @returns An instance of CustomAuthenticationProvider - */ - public constructor(provider: AuthProvider) { - this.provider = provider; - } - - /** - * @public - * @async - * To get the access token - * @returns The promise that resolves to an access token - */ - public async getAccessToken(): Promise { - return new Promise((resolve: (accessToken: string) => void, reject: (error: any) => void) => { - this.provider(async (error: any, accessToken: string | null) => { - if (accessToken) { - resolve(accessToken); - } else { - if (!error) { - const invalidTokenMessage = "Access token is undefined or empty.\ - Please provide a valid token.\ - For more help - https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CustomAuthenticationProvider.md"; - error = new GraphClientError(invalidTokenMessage); - } - const err = await GraphClientError.setGraphClientError(error); - reject(err); - } - }); - }); - } -} diff --git a/src/GraphRequest.ts b/src/GraphRequest.ts index e7f5999df..c9ba9bfaf 100644 --- a/src/GraphRequest.ts +++ b/src/GraphRequest.ts @@ -8,6 +8,8 @@ /** * @module GraphRequest */ +import {BaseBearerTokenAuthenticationProvider, RequestInformation } from "@microsoft/kiota-abstractions"; + import { GraphClientError } from "./GraphClientError"; import { GraphError } from "./GraphError"; import { GraphErrorHandler } from "./GraphErrorHandler"; @@ -367,7 +369,7 @@ export class GraphRequest { let rawResponse: Response; const middlewareControl = new MiddlewareControl(this._middlewareOptions); this.updateRequestOptions(options); - const customHosts = this.config?.customHosts; + const customHosts = this.config?.customHosts; try { const context: Context = await this.httpClient.sendRequest({ request, diff --git a/src/GraphRequestUtil.ts b/src/GraphRequestUtil.ts index 02cf6c156..6ed33d565 100644 --- a/src/GraphRequestUtil.ts +++ b/src/GraphRequestUtil.ts @@ -21,11 +21,11 @@ export const oDataQueryNames = ["$select", "$expand", "$orderby", "$filter", "$t * @returns The constructed URL string */ export const urlJoin = (urlSegments: string[]): string => { - const removePostSlash = (s) => s.replace(/\/+$/, ""); - const removePreSlash = (s) => s.replace(/^\/+/, ""); - const joiner = (pre, cur) => [removePostSlash(pre), removePreSlash(cur)].join("/"); - const parts = Array.prototype.slice.call(urlSegments); - return parts.reduce(joiner); + const removePostSlash = (s) => s.replace(/\/+$/, ""); + const removePreSlash = (s) => s.replace(/^\/+/, ""); + const joiner = (pre, cur) => [removePostSlash(pre), removePreSlash(cur)].join("/"); + const parts = Array.prototype.slice.call(urlSegments); + return parts.reduce(joiner); }; /** @@ -42,22 +42,22 @@ export const urlJoin = (urlSegments: string[]): string => { */ export const serializeContent = (content: any): any => { - const className: string = content && content.constructor && content.constructor.name; - if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") { - return content; - } - if (className === "ArrayBuffer") { - content = Buffer.from(content); - } else if (className === "Int8Array" || className === "Int16Array" || className === "Int32Array" || className === "Uint8Array" || className === "Uint16Array" || className === "Uint32Array" || className === "Uint8ClampedArray" || className === "Float32Array" || className === "Float64Array" || className === "DataView") { - content = Buffer.from(content.buffer); - } else { - try { - content = JSON.stringify(content); - } catch (error) { - throw new Error("Unable to stringify the content"); - } - } - return content; + const className: string = content && content.constructor && content.constructor.name; + if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") { + return content; + } + if (className === "ArrayBuffer") { + content = Buffer.from(content); + } else if (className === "Int8Array" || className === "Int16Array" || className === "Int32Array" || className === "Uint8Array" || className === "Uint16Array" || className === "Uint32Array" || className === "Uint8ClampedArray" || className === "Float32Array" || className === "Float64Array" || className === "DataView") { + content = Buffer.from(content.buffer); + } else { + try { + content = JSON.stringify(content); + } catch (error) { + throw new Error("Unable to stringify the content"); + } + } + return content; }; /** @@ -66,7 +66,7 @@ export const serializeContent = (content: any): any => { * @returns {boolean} - Returns true if the url is a Graph URL */ export const isGraphURL = (url: string): boolean => { - return isValidEndpoint(url); + return isValidEndpoint(url); }; /** @@ -76,8 +76,8 @@ export const isGraphURL = (url: string): boolean => { * @returns {boolean} - Returns true if the url is a for a custom host */ export const isCustomHost = (url: string, customHosts: Set): boolean => { - customHosts.forEach((host) => isCustomHostValid(host)); - return isValidEndpoint(url, customHosts); + customHosts.forEach((host) => isCustomHostValid(host)); + return isValidEndpoint(url, customHosts); }; /** @@ -87,29 +87,29 @@ export const isCustomHost = (url: string, customHosts: Set): boolean => * @returns {boolean} - Returns true is for one of the provided endpoints. */ const isValidEndpoint = (url: string, allowedHosts: Set = GRAPH_URLS): boolean => { - // Valid Graph URL pattern - https://graph.microsoft.com/{version}/{resource}?{query-parameters} - // Valid Graph URL example - https://graph.microsoft.com/v1.0/ - url = url.toLowerCase(); + // Valid Graph URL pattern - https://graph.microsoft.com/{version}/{resource}?{query-parameters} + // Valid Graph URL example - https://graph.microsoft.com/v1.0/ + url = url.toLowerCase(); - if (url.indexOf("https://") !== -1) { - url = url.replace("https://", ""); + if (url.indexOf("https://") !== -1) { + url = url.replace("https://", ""); - // Find where the host ends - const startofPortNoPos = url.indexOf(":"); - const endOfHostStrPos = url.indexOf("/"); - let hostName = ""; - if (endOfHostStrPos !== -1) { - if (startofPortNoPos !== -1 && startofPortNoPos < endOfHostStrPos) { - hostName = url.substring(0, startofPortNoPos); - return allowedHosts.has(hostName); - } - // Parse out the host - hostName = url.substring(0, endOfHostStrPos); - return allowedHosts.has(hostName); - } - } + // Find where the host ends + const startofPortNoPos = url.indexOf(":"); + const endOfHostStrPos = url.indexOf("/"); + let hostName = ""; + if (endOfHostStrPos !== -1) { + if (startofPortNoPos !== -1 && startofPortNoPos < endOfHostStrPos) { + hostName = url.substring(0, startofPortNoPos); + return allowedHosts.has(hostName); + } + // Parse out the host + hostName = url.substring(0, endOfHostStrPos); + return allowedHosts.has(hostName); + } + } - return false; + return false; }; /** @@ -117,7 +117,13 @@ const isValidEndpoint = (url: string, allowedHosts: Set = GRAPH_URLS): b * @param {string} host - The host to be verified */ const isCustomHostValid = (host: string) => { - if (host.indexOf("/") !== -1) { - throw new GraphClientError("Please add only hosts or hostnames to the CustomHosts config. If the url is `http://example.com:3000/`, host is `example:3000`"); - } + if (host.indexOf("/") !== -1) { + throw new GraphClientError("Please add only hosts or hostnames to the CustomHosts config. If the url is `http://example.com:3000/`, host is `example:3000`"); + } +}; + +export const appendGraphAndCustomHosts = (customHosts: Set): Set => { + if (!customHosts) return GRAPH_URLS; + + return new Set([...customHosts, ...GRAPH_URLS]); }; diff --git a/src/HTTPClientFactory.ts b/src/HTTPClientFactory.ts index 1b01b9fad..cdef7dfe6 100644 --- a/src/HTTPClientFactory.ts +++ b/src/HTTPClientFactory.ts @@ -8,9 +8,9 @@ /** * @module HTTPClientFactory */ +import { BaseBearerTokenAuthenticationProvider } from "@microsoft/kiota-abstractions"; import { HTTPClient } from "./HTTPClient"; -import { AuthenticationProvider } from "./IAuthenticationProvider"; import { AuthenticationHandler } from "./middleware/AuthenticationHandler"; import { HTTPMessageHandler } from "./middleware/HTTPMessageHandler"; import { Middleware } from "./middleware/IMiddleware"; @@ -47,8 +47,8 @@ export class HTTPClientFactory { * * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for * them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same. */ - public static createWithAuthenticationProvider(authProvider: AuthenticationProvider): HTTPClient { - const authenticationHandler = new AuthenticationHandler(authProvider); + public static createWithDefaultMiddleware(authenticationProvider: BaseBearerTokenAuthenticationProvider): HTTPClient { + const authenticationHandler = new AuthenticationHandler(authenticationProvider.accessTokenProvider); const retryHandler = new RetryHandler(new RetryHandlerOptions()); const telemetryHandler = new TelemetryHandler(); const httpMessageHandler = new HTTPMessageHandler(); @@ -56,6 +56,7 @@ export class HTTPClientFactory { authenticationHandler.setNext(retryHandler); if (isNodeEnvironment()) { const redirectHandler = new RedirectHandler(new RedirectHandlerOptions()); + retryHandler.setNext(redirectHandler); redirectHandler.setNext(telemetryHandler); } else { diff --git a/src/IAuthProvider.ts b/src/IAuthProvider.ts deleted file mode 100644 index 452a978d8..000000000 --- a/src/IAuthProvider.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { AuthProviderCallback } from "./IAuthProviderCallback"; - -/** - * @interface - * Signature that holds authProvider - * @callback - The anonymous callback function which takes a single param - */ -export type AuthProvider = (done: AuthProviderCallback) => void; diff --git a/src/IAuthProviderCallback.ts b/src/IAuthProviderCallback.ts deleted file mode 100644 index 9fc008493..000000000 --- a/src/IAuthProviderCallback.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @interface - * Signature that defines callback for an authentication provider - * @callback - The anonymous callback function which takes two params - */ -export type AuthProviderCallback = (error: any, accessToken: string | null) => void; diff --git a/src/IAuthenticationProvider.ts b/src/IAuthenticationProvider.ts deleted file mode 100644 index 4fbd817a8..000000000 --- a/src/IAuthenticationProvider.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { AuthenticationProviderOptions } from "./IAuthenticationProviderOptions"; - -/** - * @interface - * A signature representing Authentication provider - * @property {Function} getAccessToken - The function to get the access token from the authentication provider - */ -export interface AuthenticationProvider { - /** - * To get access token from the authentication provider - * @param {AuthenticationProviderOptions} [authenticationProviderOptions] - The authentication provider options instance - * @returns A promise that resolves to an access token - */ - getAccessToken: (authenticationProviderOptions?: AuthenticationProviderOptions) => Promise; -} diff --git a/src/IAuthenticationProviderOptions.ts b/src/IAuthenticationProviderOptions.ts deleted file mode 100644 index 21b3f304a..000000000 --- a/src/IAuthenticationProviderOptions.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @interface - * A signature represents the Authentication provider options - * @property {string[]} [scopes] - The array of scopes - */ -export interface AuthenticationProviderOptions { - scopes?: string[]; -} diff --git a/src/IClientOptions.ts b/src/IClientOptions.ts index ee9f62059..256db0013 100644 --- a/src/IClientOptions.ts +++ b/src/IClientOptions.ts @@ -5,7 +5,7 @@ * ------------------------------------------------------------------------------------------- */ -import { AuthenticationProvider } from "./IAuthenticationProvider"; +import { AuthenticationProvider, BaseBearerTokenAuthenticationProvider } from "@microsoft/kiota-abstractions"; import { FetchOptions } from "./IFetchOptions"; import { Middleware } from "./middleware/IMiddleware"; @@ -22,7 +22,7 @@ import { Middleware } from "./middleware/IMiddleware"; */ export interface ClientOptions { - authProvider?: AuthenticationProvider; + authProvider?: BaseBearerTokenAuthenticationProvider; baseUrl?: string; debugLogging?: boolean; defaultVersion?: string; diff --git a/src/IOptions.ts b/src/IOptions.ts deleted file mode 100644 index 967c14ac1..000000000 --- a/src/IOptions.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { AuthProvider } from "./IAuthProvider"; -import { FetchOptions } from "./IFetchOptions"; - -/** - * @interface - * Options for initializing the Graph Client - * @property {AuthProvider} authProvider - The function to get the authentication token - * @property {string} [baseUrl] - Base url that needs to be appended to every request - * @property {boolean} [debugLogging] - The boolean to enable/disable debug logging - * @property {string} [defaultVersion] - The default version that needs to be used while making graph api request - * @property {FetchOptions} [fetchOptions] - The options for fetch request - * @property {Set}[customHosts] - A set of custom host names. Should contain hostnames only. - */ -export interface Options { - authProvider: AuthProvider; - baseUrl?: string; - debugLogging?: boolean; - defaultVersion?: string; - fetchOptions?: FetchOptions; - /** - * Example - If URL is "https://test_host/v1.0", then set property "customHosts" as "customHosts: Set(["test_host"])" - */ - customHosts?: Set; -} diff --git a/src/authentication/SimpleAuthentication/SimpleAccessTokenProvider.ts b/src/authentication/SimpleAuthentication/SimpleAccessTokenProvider.ts new file mode 100644 index 000000000..5c65710c2 --- /dev/null +++ b/src/authentication/SimpleAuthentication/SimpleAccessTokenProvider.ts @@ -0,0 +1,59 @@ +/** + * ------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. + * See License in the project root for license information. + * ------------------------------------------------------------------------------------------- + */ + +/** + * @module SimpleAccessTokenProvider + */ + +import { AccessTokenProvider, AllowedHostsValidator, validateProtocol } from "@microsoft/kiota-abstractions"; + +import { GraphClientError } from "../../GraphClientError"; + +/** + * @class + * Simple Access Token Provider that returns an access token. + * @extends AuthenticationProvider + */ +export class SimpleAccessTokenProvider implements AccessTokenProvider { + /** + * @public + * @constructor + * Creates an instance of SimpleAccessTokenProvider + * @param {()=>Promise}getAccessTokenCallback - The callback function to get the access token + * @param {string[]} scopes - The scopes for the access token + * @param {allowedHosts} allowedhosts - A set of custom host names. Should contain hostnames only. + * @returns An instance of SimpleAccessTokenProvider + */ + public constructor(private getAccessTokenCallback: (scopes?: string[]) => Promise, private scopes: string[], private allowedhosts?: Set) { + this.allowedHostsValidator = new AllowedHostsValidator(allowedhosts); + } + validateProtocol(url); + private readonly allowedHostsValidator: AllowedHostsValidator; + public getAllowedHostsValidator = () => this.allowedHostsValidator; + + /** + * @public + * @async + * To get the access token + * @returns The promise that resolves to an access token + */ + public async getAuthorizationToken(url: string): Promise { + if (!url || !this.allowedHostsValidator.isUrlHostValid(url)) { + throw new GraphClientError("The request url is not present in the allowed hosts list or is not a valid host"); + } + let token = ""; + if (this.getAccessTokenCallback) { + token = await this.getAccessTokenCallback(this.scopes); + } + if (!token) { + throw new GraphClientError("Please provide a valid access token"); + } + + console.log(token); + return token; + } +} diff --git a/src/authentication/SimpleAuthentication/SimpleAuthenticationProvider.ts b/src/authentication/SimpleAuthentication/SimpleAuthenticationProvider.ts new file mode 100644 index 000000000..32fc8a241 --- /dev/null +++ b/src/authentication/SimpleAuthentication/SimpleAuthenticationProvider.ts @@ -0,0 +1,24 @@ +import { BaseBearerTokenAuthenticationProvider } from "@microsoft/kiota-abstractions"; + +import { SimpleAccessTokenProvider } from "./SimpleAccessTokenProvider"; + +/** + * @module SimpleAuthenticationProvider + */ +/** + * A class which accepts callbacks to returns the access token. + */ +export class SimpleAuthenticationProvider extends BaseBearerTokenAuthenticationProvider { + /** + * @public + * @constructor + * Creates an instance of SimpleAuthenticationProvider + * @param {()=>Promise}getAccessTokenCallback - The callback function to get the access token + * @param {string[]} scopes - The scopes for the access token + * @param {allowedHosts} allowedhosts - A set of custom host names. Should contain hostnames only. + * @returns An instance of SimpleAuthenticationProvider + */ + constructor(getAccessTokenCallback: (scopes?: string[]) => Promise, scopes: string[], allowedHosts?: Set) { + super(new SimpleAccessTokenProvider(getAccessTokenCallback, scopes, allowedHosts)); + } +} diff --git a/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions.ts b/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions.ts deleted file mode 100644 index 09b3b0995..000000000 --- a/src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -import { GetTokenOptions } from "@azure/identity"; - -import { AuthenticationProviderOptions } from "../../IAuthenticationProviderOptions"; - -/** - * @interface - * A signature represents the Authentication provider options for Token Credentials - * @property {getTokenoptions} [GetTokenOptions] - Defines options for TokenCredential.getToken. - */ -export interface TokenCredentialAuthenticationProviderOptions extends AuthenticationProviderOptions { - getTokenoptions?: GetTokenOptions; -} diff --git a/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider.ts b/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider.ts deleted file mode 100644 index 7d9d1faab..000000000 --- a/src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { TokenCredential } from "@azure/identity"; - -import { GraphClientError } from "../../GraphClientError"; -import { AuthenticationProvider } from "../../IAuthenticationProvider"; -import { TokenCredentialAuthenticationProviderOptions } from "./ITokenCredentialAuthenticationProviderOptions"; - -/** - * @module TokenCredentialAuthenticationProvider - */ - -/** - * @class - * Class representing TokenCredentialAuthenticationProvider - * This feature is introduced in Version 3.0.0 - * @extends AuthenticationProvider - * Reference - https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md - */ -export class TokenCredentialAuthenticationProvider implements AuthenticationProvider { - /** - * @private - * A member holding an instance of @azure/identity TokenCredential - */ - private tokenCredential: TokenCredential; - - /** - * @private - * A member holding an instance of TokenCredentialAuthenticationProviderOptions - */ - private authenticationProviderOptions: TokenCredentialAuthenticationProviderOptions; - - /** - * @public - * @constructor - * Creates an instance of TokenCredentialAuthenticationProvider - * @param {TokenCredential} tokenCredential - An instance of @azure/identity TokenCredential - * @param {TokenCredentialAuthenticationProviderOptions} authenticationProviderOptions - An instance of TokenCredentialAuthenticationProviderOptions - * @returns An instance of TokenCredentialAuthenticationProvider - */ - public constructor(tokenCredential: TokenCredential, authenticationProviderOptions: TokenCredentialAuthenticationProviderOptions) { - if (!tokenCredential) { - throw new GraphClientError("Please pass a token credential object to the TokenCredentialAuthenticationProvider class constructor"); - } - if (!authenticationProviderOptions) { - throw new GraphClientError("Please pass the TokenCredentialAuthenticationProviderOptions with scopes to the TokenCredentialAuthenticationProvider class constructor"); - } - this.authenticationProviderOptions = authenticationProviderOptions; - this.tokenCredential = tokenCredential; - } - - /** - * @public - * @async - * To get the access token - * @param {TokenCredentialAuthenticationProviderOptions} authenticationProviderOptions - The authentication provider options object - * @returns The promise that resolves to an access token - */ - public async getAccessToken(): Promise { - const scopes = this.authenticationProviderOptions.scopes; - const error = new GraphClientError(); - - if (!scopes || scopes.length === 0) { - error.name = "Empty Scopes"; - error.message = "Scopes cannot be empty, Please provide scopes"; - throw error; - } - const response = await this.tokenCredential.getToken(scopes, this.authenticationProviderOptions.getTokenoptions); - if (response) { - return response.token; - } - error.message = "Cannot retrieve accessToken from the Token Credential object"; - error.name = "Access token is undefined"; - throw error; - } -} diff --git a/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.ts b/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.ts deleted file mode 100644 index 0d80004a1..000000000 --- a/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module AuthCodeMSALBrowserAuthenticationProvider - */ - -import { AuthenticationResult, InteractionRequiredAuthError, InteractionType, PublicClientApplication } from "@azure/msal-browser"; - -import { GraphClientError } from "../../GraphClientError"; -import { AuthenticationProvider } from "../../IAuthenticationProvider"; -import { AuthCodeMSALBrowserAuthenticationProviderOptions } from "../msalOptions/MSALAuthenticationProviderOptions"; - -/** - * an AuthenticationProvider implementation supporting msal-browser library. - * This feature is introduced in Version 3.0.0 - * @class - * @extends AuthenticationProvider - */ -export class AuthCodeMSALBrowserAuthenticationProvider implements AuthenticationProvider { - /** - * @public - * @constructor - * Creates an instance of ImplicitMSALAuthenticationProvider - * @param {PublicClientApplication} msalApplication - An instance of MSAL PublicClientApplication - * @param {AuthCodeMSALBrowserAuthenticationProviderOptions} options - An instance of MSALAuthenticationProviderOptions - * @returns An instance of ImplicitMSALAuthenticationProvider - */ - public constructor(private publicClientApplication: PublicClientApplication, private options: AuthCodeMSALBrowserAuthenticationProviderOptions) { - if (!options || !publicClientApplication) { - throw new GraphClientError("Please pass valid PublicClientApplication instance and AuthCodeMSALBrowserAuthenticationProviderOptions instance to instantiate MSALBrowserAuthenticationProvider"); - } - } - - /** - * @public - * @async - * To get the access token for the request - * @returns The promise that resolves to an access token - */ - public async getAccessToken(): Promise { - const scopes = this.options && this.options.scopes; - const account = this.options && this.options.account; - const error = new GraphClientError(); - if (!scopes || scopes.length === 0) { - error.name = "Empty Scopes"; - error.message = "Scopes cannot be empty, Please provide scopes"; - throw error; - } - try { - const response: AuthenticationResult = await this.publicClientApplication.acquireTokenSilent({ - scopes, - account, - }); - if (!response || !response.accessToken) { - error.name = "Access token is undefined"; - error.message = "Received empty access token from PublicClientApplication"; - throw error; - } - return response.accessToken; - } catch (error) { - if (error instanceof InteractionRequiredAuthError) { - if (this.options.interactionType === InteractionType.Redirect) { - this.publicClientApplication.acquireTokenRedirect({ scopes }); - } else if (this.options.interactionType === InteractionType.Popup) { - const response: AuthenticationResult = await this.publicClientApplication.acquireTokenPopup({ scopes }); - return response.accessToken; - } - } else { - throw error; - } - } - } -} diff --git a/src/authentication/msalOptions/MSALAuthenticationProviderOptions.ts b/src/authentication/msalOptions/MSALAuthenticationProviderOptions.ts deleted file mode 100644 index 5e70cbd18..000000000 --- a/src/authentication/msalOptions/MSALAuthenticationProviderOptions.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module MSALAuthenticationProviderOptions - */ - -import { AccountInfo, InteractionType } from "@azure/msal-browser"; - -import { AuthenticationProviderOptions } from "../../IAuthenticationProviderOptions"; - -export interface AuthCodeMSALBrowserAuthenticationProviderOptions extends AuthenticationProviderOptions { - scopes: string[]; - account: AccountInfo; - interactionType: InteractionType; -} diff --git a/src/browser/index.ts b/src/browser/index.ts index 4a25774ae..7aed78501 100644 --- a/src/browser/index.ts +++ b/src/browser/index.ts @@ -4,20 +4,19 @@ * See License in the project root for license information. * ------------------------------------------------------------------------------------------- */ - // eslint-disable-next-line @typescript-eslint/triple-slash-reference /// +export { AuthenticationProvider, AccessTokenProvider } from "@microsoft/kiota-abstractions"; + export { BatchRequestStep, BatchRequestData, BatchRequestContent, RequestData, BatchRequestBody } from "../content/BatchRequestContent"; export { BatchResponseBody, BatchResponseContent } from "../content/BatchResponseContent"; -export { AuthenticationHandler } from "../middleware/AuthenticationHandler"; export { HTTPMessageHandler } from "../middleware/HTTPMessageHandler"; export { Middleware } from "../middleware/IMiddleware"; export { RetryHandler } from "../middleware/RetryHandler"; export { RedirectHandler } from "../middleware/RedirectHandler"; export { TelemetryHandler } from "../middleware/TelemetryHandler"; export { MiddlewareFactory } from "../middleware/MiddlewareFactory"; -export { AuthenticationHandlerOptions } from "../middleware/options/AuthenticationHandlerOptions"; export { MiddlewareOptions } from "../middleware/options/IMiddlewareOptions"; export { ShouldRetry, RetryHandlerOptions } from "../middleware/options/RetryHandlerOptions"; export { ShouldRedirect, RedirectHandlerOptions } from "../middleware/options/RedirectHandlerOptions"; @@ -37,17 +36,16 @@ export { Range } from "../tasks/FileUploadTask/Range"; export { PageIteratorCallback, PageIterator, PageCollection, GraphRequestOptions } from "../tasks/PageIterator"; export { Client } from "../Client"; -export { CustomAuthenticationProvider } from "../CustomAuthenticationProvider"; export { GraphError } from "../GraphError"; export { GraphClientError } from "../GraphClientError"; export { GraphRequest } from "../GraphRequest"; -export { AuthProvider } from "../IAuthProvider"; -export { AuthenticationProvider } from "../IAuthenticationProvider"; -export { AuthenticationProviderOptions } from "../IAuthenticationProviderOptions"; -export { AuthProviderCallback } from "../IAuthProviderCallback"; + export { ClientOptions } from "../IClientOptions"; export { Context } from "../IContext"; export { NodeFetchInit, FetchOptions } from "../IFetchOptions"; export { GraphRequestCallback } from "../IGraphRequestCallback"; -export { Options } from "../IOptions"; + export { ResponseType } from "../ResponseType"; + +export { SimpleAuthenticationProvider } from "../authentication/SimpleAuthentication/SimpleAuthenticationProvider"; +export { SimpleAccessTokenProvider } from "../authentication/SimpleAuthentication/SimpleAccessTokenProvider"; diff --git a/src/index.ts b/src/index.ts index d2505175b..a836d44c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,14 +11,12 @@ export { BatchRequestBody, RequestData, BatchRequestContent, BatchRequestData, BatchRequestStep } from "./content/BatchRequestContent"; export { BatchResponseBody, BatchResponseContent } from "./content/BatchResponseContent"; -export { AuthenticationHandler } from "./middleware/AuthenticationHandler"; export { HTTPMessageHandler } from "./middleware/HTTPMessageHandler"; export { Middleware } from "./middleware/IMiddleware"; export { RetryHandler } from "./middleware/RetryHandler"; export { RedirectHandler } from "./middleware/RedirectHandler"; export { TelemetryHandler } from "./middleware/TelemetryHandler"; export { MiddlewareFactory } from "./middleware/MiddlewareFactory"; -export { AuthenticationHandlerOptions } from "./middleware/options/AuthenticationHandlerOptions"; export { MiddlewareOptions } from "./middleware/options/IMiddlewareOptions"; export { RetryHandlerOptions, ShouldRetry } from "./middleware/options/RetryHandlerOptions"; export { RedirectHandlerOptions, ShouldRedirect } from "./middleware/options/RedirectHandlerOptions"; @@ -38,17 +36,16 @@ export { Range } from "./tasks/FileUploadTask/Range"; export { GraphRequestOptions, PageCollection, PageIterator, PageIteratorCallback } from "./tasks/PageIterator"; export { Client } from "./Client"; -export { CustomAuthenticationProvider } from "./CustomAuthenticationProvider"; export { GraphError } from "./GraphError"; export { GraphClientError } from "./GraphClientError"; export { GraphRequest, URLComponents } from "./GraphRequest"; -export { AuthProvider } from "./IAuthProvider"; -export { AuthenticationProvider } from "./IAuthenticationProvider"; -export { AuthenticationProviderOptions } from "./IAuthenticationProviderOptions"; -export { AuthProviderCallback } from "./IAuthProviderCallback"; + export { ClientOptions } from "./IClientOptions"; export { Context } from "./IContext"; export { FetchOptions, NodeFetchInit } from "./IFetchOptions"; export { GraphRequestCallback } from "./IGraphRequestCallback"; -export { Options } from "./IOptions"; + export { ResponseType } from "./ResponseType"; + +export { SimpleAccessTokenProvider } from "./authentication/SimpleAuthentication/SimpleAccessTokenProvider"; +export { SimpleAuthenticationProvider } from "./authentication/SimpleAuthentication/SimpleAuthenticationProvider"; diff --git a/src/middleware/AuthenticationHandler.ts b/src/middleware/AuthenticationHandler.ts index 3e25f7cdf..614543332 100644 --- a/src/middleware/AuthenticationHandler.ts +++ b/src/middleware/AuthenticationHandler.ts @@ -9,14 +9,12 @@ * @module AuthenticationHandler */ +import { AccessTokenProvider } from "@microsoft/kiota-abstractions"; + import { isCustomHost, isGraphURL } from "../GraphRequestUtil"; -import { AuthenticationProvider } from "../IAuthenticationProvider"; -import { AuthenticationProviderOptions } from "../IAuthenticationProviderOptions"; import { Context } from "../IContext"; import { Middleware } from "./IMiddleware"; -import { MiddlewareControl } from "./MiddlewareControl"; import { appendRequestHeader } from "./MiddlewareUtil"; -import { AuthenticationHandlerOptions } from "./options/AuthenticationHandlerOptions"; import { FeatureUsageFlag, TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions"; /** @@ -31,12 +29,6 @@ export class AuthenticationHandler implements Middleware { */ private static AUTHORIZATION_HEADER = "Authorization"; - /** - * @private - * A member to hold an AuthenticationProvider instance - */ - private authenticationProvider: AuthenticationProvider; - /** * @private * A member to hold next middleware in the middleware chain @@ -47,11 +39,9 @@ export class AuthenticationHandler implements Middleware { * @public * @constructor * Creates an instance of AuthenticationHandler - * @param {AuthenticationProvider} authenticationProvider - The authentication provider for the authentication handler + * @param {AccessTokenProvider} accessTokenProvider - The access token provider used to retrieve the access token and add it to the request header */ - public constructor(authenticationProvider: AuthenticationProvider) { - this.authenticationProvider = authenticationProvider; - } + public constructor(private accessTokenProvider: AccessTokenProvider) {} /** * @public @@ -63,20 +53,7 @@ export class AuthenticationHandler implements Middleware { public async execute(context: Context): Promise { const url = typeof context.request === "string" ? context.request : context.request.url; if (isGraphURL(url) || (context.customHosts && isCustomHost(url, context.customHosts))) { - let options: AuthenticationHandlerOptions; - if (context.middlewareControl instanceof MiddlewareControl) { - options = context.middlewareControl.getMiddlewareOptions(AuthenticationHandlerOptions) as AuthenticationHandlerOptions; - } - let authenticationProvider: AuthenticationProvider; - let authenticationProviderOptions: AuthenticationProviderOptions; - if (options) { - authenticationProvider = options.authenticationProvider; - authenticationProviderOptions = options.authenticationProviderOptions; - } - if (!authenticationProvider) { - authenticationProvider = this.authenticationProvider; - } - const token: string = await authenticationProvider.getAccessToken(authenticationProviderOptions); + const token: string = await this.accessTokenProvider.getAuthorizationToken(url); const bearerKey = `Bearer ${token}`; appendRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey); TelemetryHandlerOptions.updateFeatureUsageFlag(context, FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED); diff --git a/src/middleware/MiddlewareFactory.ts b/src/middleware/MiddlewareFactory.ts index 98bb6f083..2e052da78 100644 --- a/src/middleware/MiddlewareFactory.ts +++ b/src/middleware/MiddlewareFactory.ts @@ -9,8 +9,6 @@ * @module MiddlewareFactory */ -import { AuthenticationProvider } from "../IAuthenticationProvider"; -import { AuthenticationHandler } from "./AuthenticationHandler"; import { HTTPMessageHandler } from "./HTTPMessageHandler"; import { Middleware } from "./IMiddleware"; import { RedirectHandlerOptions } from "./options/RedirectHandlerOptions"; @@ -40,14 +38,12 @@ export class MiddlewareFactory { * @param {AuthenticationProvider} authProvider - The authentication provider instance * @returns an array of the middleware handlers of the default middleware chain */ - public static getDefaultMiddlewareChain(authProvider: AuthenticationProvider): Middleware[] { + public static getDefaultMiddlewareChain(): Middleware[] { const middleware: Middleware[] = []; - const authenticationHandler = new AuthenticationHandler(authProvider); const retryHandler = new RetryHandler(new RetryHandlerOptions()); const telemetryHandler = new TelemetryHandler(); const httpMessageHandler = new HTTPMessageHandler(); - middleware.push(authenticationHandler); middleware.push(retryHandler); if (isNodeEnvironment()) { const redirectHandler = new RedirectHandler(new RedirectHandlerOptions()); diff --git a/src/middleware/options/AuthenticationHandlerOptions.ts b/src/middleware/options/AuthenticationHandlerOptions.ts deleted file mode 100644 index 547b326ba..000000000 --- a/src/middleware/options/AuthenticationHandlerOptions.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module AuthenticationHandlerOptions - */ - -import { AuthenticationProvider } from "../../IAuthenticationProvider"; -import { AuthenticationProviderOptions } from "../../IAuthenticationProviderOptions"; -import { MiddlewareOptions } from "./IMiddlewareOptions"; - -/** - * @class - * @implements MiddlewareOptions - * Class representing AuthenticationHandlerOptions - */ -export class AuthenticationHandlerOptions implements MiddlewareOptions { - /** - * @public - * A member holding an instance of an authentication provider - */ - public authenticationProvider: AuthenticationProvider; - - /** - * @public - * A member holding an instance of authentication provider options - */ - public authenticationProviderOptions: AuthenticationProviderOptions; - - /** - * @public - * @constructor - * To create an instance of AuthenticationHandlerOptions - * @param {AuthenticationProvider} [authenticationProvider] - The authentication provider instance - * @param {AuthenticationProviderOptions} [authenticationProviderOptions] - The authentication provider options instance - * @returns An instance of AuthenticationHandlerOptions - */ - public constructor(authenticationProvider?: AuthenticationProvider, authenticationProviderOptions?: AuthenticationProviderOptions) { - this.authenticationProvider = authenticationProvider; - this.authenticationProviderOptions = authenticationProviderOptions; - } -} diff --git a/test/DummyAuthenticationProvider.ts b/test/DummyAuthenticationProvider.ts deleted file mode 100644 index a560e53bd..000000000 --- a/test/DummyAuthenticationProvider.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module DummyAuthenticationProvider - */ - -import { AuthenticationProvider } from "../src/IAuthenticationProvider"; - -/** - * @class - * @implements AuthenticationProvider - * Class representing DummyAuthenticationProvider - */ -export class DummyAuthenticationProvider implements AuthenticationProvider { - /** - * @public - * @async - * To get the access token - * @returns The promise that resolves to an access token - */ - public async getAccessToken(): Promise { - const token = "DUMMY_TOKEN"; - return Promise.resolve(token); - } -} diff --git a/test/common/authentication/AuthCodeMSALBrowserAuthenticationProvider.ts b/test/common/authentication/AuthCodeMSALBrowserAuthenticationProvider.ts deleted file mode 100644 index 8018c5f6a..000000000 --- a/test/common/authentication/AuthCodeMSALBrowserAuthenticationProvider.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -/*tslint:disable*/ -import { AccountInfo, AuthenticationResult, InteractionRequiredAuthError, InteractionType, PublicClientApplication } from "@azure/msal-browser"; -import { assert } from "chai"; -import * as sinon from "sinon"; - -import { AuthCodeMSALBrowserAuthenticationProvider } from "../../../src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider"; -import { AuthCodeMSALBrowserAuthenticationProviderOptions } from "../../../src/authentication/msalOptions/MSALAuthenticationProviderOptions"; -describe("AuthCodeMSALBrowserAuthenticationProvider.ts", () => { - const scopes = ["test_scopes"]; - it("AccessToken is returned correctly from getToken function", async () => { - const dummyApp = new PublicClientApplication({ - auth: { - clientId: "", - }, - }); - if (typeof dummyApp.acquireTokenSilent !== "function") { - throw new Error("Method definition for getToken is not found"); - } - const account: AccountInfo = { - homeAccountId: "", - localAccountId: "", - environment: "", - tenantId: "", - username: "", - }; - const options: AuthCodeMSALBrowserAuthenticationProviderOptions = { - interactionType: InteractionType.Popup, - scopes, - account, - }; - const accessToken: AuthenticationResult = { - accessToken: "dummy_valid_token", - account, - authority: "", - scopes, - uniqueId: "", - tenantId: "", - idToken: "", - idTokenClaims: null, - fromCache: false, - expiresOn: new Date(), - tokenType: "", - correlationId: "" - }; - - const moq = sinon.mock(dummyApp); - moq.expects("acquireTokenSilent").resolves(accessToken); - const msalBrowserAuthenticationProvider = new AuthCodeMSALBrowserAuthenticationProvider(dummyApp, options); - const access = await msalBrowserAuthenticationProvider.getAccessToken(); - assert.equal(access, accessToken.accessToken); - }); - - it("InteractionRequiredAuthError function is handled", async () => { - const dummyApp = new PublicClientApplication({ - auth: { - clientId: "", - }, - }); - if (typeof dummyApp.acquireTokenSilent !== "function") { - throw new Error("Method definition for getToken is not found"); - } - const account: AccountInfo = { - homeAccountId: "", - localAccountId: "", - environment: "", - tenantId: "", - username: "", - }; - const options: AuthCodeMSALBrowserAuthenticationProviderOptions = { - interactionType: InteractionType.Popup, - scopes, - account, - }; - const accessToken: AuthenticationResult = { - accessToken: "dummy_popUp_token", - account, - authority: "", - scopes, - uniqueId: "", - tenantId: "", - idToken: "", - idTokenClaims: null, - fromCache: false, - expiresOn: new Date(), - tokenType: "", - correlationId: "" - }; - - const moq = sinon.mock(dummyApp); - moq.expects("acquireTokenSilent").throws(new InteractionRequiredAuthError("TEST_ERROR")); - moq.expects("acquireTokenPopup").resolves(accessToken); - const msalBrowserAuthenticationProvider = new AuthCodeMSALBrowserAuthenticationProvider(dummyApp, options); - const access = await msalBrowserAuthenticationProvider.getAccessToken(); - assert.equal(access, accessToken.accessToken); - }); -}); diff --git a/test/common/core/Client.ts b/test/common/core/Client.ts index eae57d88f..230fc5b37 100644 --- a/test/common/core/Client.ts +++ b/test/common/core/Client.ts @@ -8,45 +8,28 @@ import "isomorphic-fetch"; import { assert } from "chai"; -import * as sinon from "sinon"; -import { CustomAuthenticationProvider, TelemetryHandler } from "../../../src"; +import { SimpleAuthenticationProvider, TelemetryHandler } from "../../../src"; import { Client } from "../../../src/Client"; import { GraphClientError } from "../../../src/GraphClientError"; -import { AuthProvider } from "../../../src/IAuthProvider"; import { ClientOptions } from "../../../src/IClientOptions"; -import { Options } from "../../../src/IOptions"; -import { AuthenticationHandler } from "../../../src/middleware/AuthenticationHandler"; import { ChaosHandler } from "../../../src/middleware/ChaosHandler"; import { ChaosHandlerOptions } from "../../../src/middleware/options/ChaosHandlerOptions"; import { ChaosStrategy } from "../../../src/middleware/options/ChaosStrategy"; -import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider"; import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler"; describe("Client.ts", () => { - describe("initWithMiddleware", () => { - const dummyAuthProvider = new DummyAuthenticationProvider(); + describe("init", () => { + const dummyAuthProvider = new SimpleAuthenticationProvider(async () => { + return "AccessToken"; + }, ["scope1", "scope2"]); const dummyHTTPHandler = new DummyHTTPMessageHandler(); - it("Should throw an error in case if both auth provider and custom middleware is passed", () => { - try { - const options: ClientOptions = { - authProvider: dummyAuthProvider, - middleware: dummyHTTPHandler, - }; - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const client: Client = Client.initWithMiddleware(options); - throw new Error("Test Failed - Something wrong with the ambiguity check"); - } catch (error) { - assert.equal(error.name, "AmbiguityInInitialization"); - } - }); - it("Should return client instance for an authentication provider", () => { const options: ClientOptions = { authProvider: dummyAuthProvider, }; - const client: Client = Client.initWithMiddleware(options); + const client: Client = Client.init(options); assert.isTrue(client instanceof Client); assert.isDefined(client["httpClient"]); }); @@ -54,52 +37,43 @@ describe("Client.ts", () => { it("Should return client instance for a custom middleware chain", () => { const options: ClientOptions = { middleware: dummyHTTPHandler, + authProvider: dummyAuthProvider, }; - const client: Client = Client.initWithMiddleware(options); + const client: Client = Client.init(options); assert.isTrue(client instanceof Client); assert.isDefined(client["httpClient"]); }); - it("Should throw error in case of neither auth provider nor custom middleware is passed", () => { + it("Should throw error in case of auth provider is not passed", () => { try { - const options: ClientOptions = {}; - Client.initWithMiddleware(options); + const options: ClientOptions = { authProvider: undefined }; + Client.init(options); throw new Error("Test Failed - Something wrong with the client initialization check"); } catch (error) { - assert.equal(error.name, "InvalidMiddlewareChain"); + assert.equal(error.name, "Client Initialization Failed"); } }); it("Init middleware using a middleware array", async () => { - const provider: AuthProvider = (done) => { - done(null, "dummy_token"); - }; - const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider)); const responseBody = "Test response body"; const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing middleware array", 200, 100, responseBody); - const middlewareArray = [authHandler, new ChaosHandler(options)]; - const client = Client.initWithMiddleware({ middleware: middlewareArray }); + const middlewareArray = [new ChaosHandler(options)]; + const client = Client.init({ middleware: middlewareArray, authProvider: dummyAuthProvider }); const response = await client.api("me").get(); assert.equal(response, responseBody); }); it("Init middleware using a chained middleware array", async () => { - const provider: AuthProvider = (done) => { - done(null, "dummy_token"); - }; - const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider)); - const responseBody = "Test response body"; const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing chained middleware array", 200, 100, responseBody); const chaosHandler = new ChaosHandler(options); const telemetryHandler = new TelemetryHandler(); - authHandler.setNext(telemetryHandler); telemetryHandler.setNext(chaosHandler); - const middlewareArray = [authHandler]; - const client = Client.initWithMiddleware({ middleware: middlewareArray }); + const middlewareArray = [telemetryHandler]; + const client = Client.init({ middleware: middlewareArray, authProvider: dummyAuthProvider }); const response = await client.api("me").get(); assert.equal(response, responseBody); @@ -110,14 +84,11 @@ describe("Client.ts", () => { const options = { defaultVersion: "v1.0", debugLogging: true, - authProvider: (done) => { - done(null, getTokenFunction()); - }, + authProvider: new SimpleAuthenticationProvider(async () => { + return undefined; + }, ["scope1", "scope2"]), }; - const getTokenFunction = (): string => { - return undefined; - }; const client = Client.init(options); // eslint-disable-next-line @typescript-eslint/no-unused-vars const res = await client.api("/test").get(); @@ -128,93 +99,92 @@ describe("Client.ts", () => { }); it("Should throw error in case the access token is empty", async () => { - const customError = { message: "Token is empty" }; try { const options = { defaultVersion: "v1.0", debugLogging: true, - authProvider: (done) => { - done(customError, getTokenFunction()); - }, - }; - const getTokenFunction = (): string => { - return ""; + authProvider: new SimpleAuthenticationProvider(async () => { + return ""; + }, ["scope1", "scope2"]), }; + const client = Client.init(options); // eslint-disable-next-line @typescript-eslint/no-unused-vars const res = await client.api("/test").get(); throw new Error("Test failed - Expected error was not thrown"); } catch (error) { assert.isTrue(error instanceof GraphClientError); - assert.equal(error.customError, customError); + assert.equal(error.message, "Please provide a valid access token"); } }); it("Init middleware with custom hosts", async () => { - const accessToken = "DUMMY_TOKEN"; - const provider: AuthProvider = (done) => { - done(null, "DUMMY_TOKEN"); - }; const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing chained middleware array", 200, 100, ""); const chaosHandler = new ChaosHandler(options); - const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider)); - const telemetry = new TelemetryHandler(); - const middleware = [authHandler, telemetry, chaosHandler]; + const middleware = [telemetry, chaosHandler]; const customHost = "test_custom"; const customHosts = new Set([customHost]); - const client = Client.initWithMiddleware({ middleware, customHosts }); - - const spy = sinon.spy(telemetry, "execute"); + const client = Client.init({ + middleware, + authProvider: new SimpleAuthenticationProvider( + async () => { + return ""; + }, + ["scope1", "scope2"], + customHosts, + ), + }); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const response = await client.api(`https://${customHost}/v1.0/me`).get(); - const context = spy.getCall(0).args[0]; + const allowedHosts = client["authProvider"].accessTokenProvider.getAllowedHostsValidator().getAllowedHosts(); - assert.equal(context.options.headers["Authorization"], `Bearer ${accessToken}`); + assert.isTrue(allowedHosts.includes(customHost)); }); it("Pass invalid custom hosts", async () => { try { // eslint-disable-next-line @typescript-eslint/no-unused-vars const accessToken = "DUMMY_TOKEN"; - const provider: AuthProvider = (done) => { - done(null, "DUMMY_TOKEN"); - }; const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing chained middleware array", 200, 100, ""); const chaosHandler = new ChaosHandler(options); - const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider)); - const telemetry = new TelemetryHandler(); - const middleware = [authHandler, telemetry, chaosHandler]; + const middleware = [telemetry, chaosHandler]; - const customHost = "https://test_custom"; + const customHost = "https://test_custom/v1.0/me"; const customHosts = new Set([customHost]); - const client = Client.initWithMiddleware({ middleware, customHosts }); - + const client = Client.init({ + middleware, + authProvider: new SimpleAuthenticationProvider( + async () => { + return accessToken; + }, + ["scope1", "scope2"], + customHosts, + ), + }); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const response = await client.api(`https://${customHost}/v1.0/me`).get(); + const response = await client.api(`https://test_custom/v1.0/me`).get(); throw new Error("Test fails - Error expected when custom host is not valid"); } catch (error) { assert.isDefined(error); assert.isDefined(error.message); - assert.equal(error.message, "Please add only hosts or hostnames to the CustomHosts config. If the url is `http://example.com:3000/`, host is `example:3000`"); + assert.equal(error.message, "The request url is not present in the allowed hosts list or is not a valid host"); } }); }); describe("init", () => { - it("Should return a client instance with default authentication provider and default middleware chain", () => { - const provider: AuthProvider = (done) => { - done(null, "dummy_token"); - }; - const options: Options = { - authProvider: provider, + it("Should return a client instance with default middleware chain", () => { + const options: ClientOptions = { + authProvider: new SimpleAuthenticationProvider(async () => { + return ""; + }, ["scope1", "scope2"]), }; const client: Client = Client.init(options); assert.isDefined(client["httpClient"]); diff --git a/test/common/core/HTTPClientFactory.ts b/test/common/core/HTTPClientFactory.ts index f51e7a5bb..ef4f6a173 100644 --- a/test/common/core/HTTPClientFactory.ts +++ b/test/common/core/HTTPClientFactory.ts @@ -7,17 +7,20 @@ import { assert } from "chai"; +import { SimpleAuthenticationProvider } from "../../../src/authentication/SimpleAuthentication/SimpleAuthenticationProvider"; import { HTTPClient } from "../../../src/HTTPClient"; import { HTTPClientFactory } from "../../../src/HTTPClientFactory"; -import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider"; import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler"; describe("HTTPClientFactory.ts", () => { + const authProvider = new SimpleAuthenticationProvider(async () => { + return "DUMMY_ACCESS_TOKEN"; + }, ["scope1", "scope2"]); + describe("createWithAuthenticationProvider", () => { - const dummyAuthProvider = new DummyAuthenticationProvider(); const dummyHTTPHandler = new DummyHTTPMessageHandler(); it("Should create an HTTPClient instance with default middleware chain", () => { - const client: HTTPClient = HTTPClientFactory.createWithAuthenticationProvider(dummyAuthProvider); + const client: HTTPClient = HTTPClientFactory.createWithDefaultMiddleware(authProvider); assert.isTrue(client instanceof HTTPClient); assert.isDefined(client["middleware"]); }); diff --git a/test/common/core/SimpleAuthenticationProvider.ts b/test/common/core/SimpleAuthenticationProvider.ts new file mode 100644 index 000000000..00c811c7a --- /dev/null +++ b/test/common/core/SimpleAuthenticationProvider.ts @@ -0,0 +1,72 @@ +/** + * ------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. + * See License in the project root for license information. + * ------------------------------------------------------------------------------------------- + */ + +import { RequestInformation } from "@microsoft/kiota-abstractions"; +import { assert } from "chai"; + +import { SimpleAuthenticationProvider } from "../../../src"; +import { GRAPH_BASE_URL } from "../../../src/Constants"; + +describe("SimpleAuthenticationProvider.ts", async () => { + describe("Auth Headers", () => { + // TODO : Check in case of redirection + it("Should delete Auth header when Request object is passed with non Graph URL", () => {}); + + it("Should contain Auth header when Request object is passed with custom URL", async () => { + const accessToken = "Bearer DUMMY_TOKEN"; + const requestInfo = new RequestInformation(); + + requestInfo.URL = "https://custom.host.com/test_url"; + requestInfo.headers = {}; + const customHost = "custom.host.com"; + const customHosts = new Set([customHost]); + const simpleAuthProvider = new SimpleAuthenticationProvider( + async () => { + return "DUMMY_TOKEN"; + }, + ["scope1", "scope2"], + customHosts, + ); + + await simpleAuthProvider.authenticateRequest(requestInfo); + assert.equal(requestInfo.headers["Authorization"], accessToken); + }); + + it("Should contain Auth header when Request object is passed with a valid Graph URL", async () => { + const accessToken = "Bearer DUMMY_TOKEN"; + const requestInfo = new RequestInformation(); + requestInfo.URL = GRAPH_BASE_URL; + requestInfo.headers = {}; + const simpleAuthProvider = new SimpleAuthenticationProvider(async () => { + return "DUMMY_TOKEN"; + }, ["scope1", "scope2"]); + + await simpleAuthProvider.authenticateRequest(requestInfo); + assert.equal(requestInfo.headers["Authorization"], accessToken); + }); + + it("Verify if scopes are passed as parameters", async () => { + const requestInfo = new RequestInformation(); + + requestInfo.URL = "https://custom.host.com/test_url"; + requestInfo.headers = {}; + const customHost = "custom.host.com"; + const customHosts = new Set([customHost]); + const scopes = ["scope1", "scope2"]; + const simpleAuthProvider = new SimpleAuthenticationProvider( + async (scopes: string[]) => { + return scopes[0] + scopes[1]; + }, + scopes, + customHosts, + ); + + await simpleAuthProvider.authenticateRequest(requestInfo); + assert.equal(requestInfo.headers["Authorization"], "Bearer " + scopes[0] + scopes[1]); + }); + }); +}); diff --git a/test/common/middleware/AuthenticationHandler.ts b/test/common/middleware/AuthenticationHandler.ts deleted file mode 100644 index 677fdc33c..000000000 --- a/test/common/middleware/AuthenticationHandler.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { assert } from "chai"; - -import { ChaosHandler, ChaosHandlerOptions, ChaosStrategy } from "../../../src"; -import { GRAPH_BASE_URL } from "../../../src/Constants"; -import { Context } from "../../../src/IContext"; -import { AuthenticationHandler } from "../../../src/middleware/AuthenticationHandler"; -import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider"; - -const dummyAuthProvider = new DummyAuthenticationProvider(); -const authHandler = new AuthenticationHandler(dummyAuthProvider); -const chaosHandler = new ChaosHandler(new ChaosHandlerOptions(ChaosStrategy.MANUAL, "TEST_MESSAGE", 200)); - -describe("AuthenticationHandler.ts", async () => { - describe("Constructor", () => { - it("Should return an AuthenticationHandler for given AuthenticationProvider", () => { - assert.isTrue(authHandler instanceof AuthenticationHandler); - assert.equal(authHandler["authenticationProvider"], dummyAuthProvider); - }); - }); - describe("Auth Headers", () => { - it("Should delete Auth header when Request object is passed with non Graph URL", async () => { - const request = new Request("test_url"); - const context: Context = { - request, - options: { - headers: { - Authorization: "TEST_VALUE", - }, - }, - }; - authHandler.setNext(chaosHandler); - await authHandler.execute(context); - assert.equal(context.options.headers["Authorization"], undefined); - }); - - it("Should contain Auth header when Request object is passed with custom URL", async () => { - const request = new Request("https://custom/"); - const context: Context = { - request, - customHosts: new Set(["custom"]), - options: { - headers: {}, - }, - }; - const accessToken = "Bearer DUMMY_TOKEN"; - - await authHandler.execute(context); - assert.equal((request as Request).headers.get("Authorization"), accessToken); - }); - - it("Should contain Auth header when Request object is passed with a valid Graph URL", async () => { - const request = new Request(GRAPH_BASE_URL); - const context: Context = { - request, - customHosts: new Set(["custom"]), - options: { - headers: {}, - }, - }; - const accessToken = "Bearer DUMMY_TOKEN"; - await authHandler.execute(context); - assert.equal((request as Request).headers.get("Authorization"), accessToken); - }); - }); -}); diff --git a/test/common/middleware/AuthenticationHandlerOptions.ts b/test/common/middleware/AuthenticationHandlerOptions.ts deleted file mode 100644 index 1a0554388..000000000 --- a/test/common/middleware/AuthenticationHandlerOptions.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -import { assert } from "chai"; - -import { AuthenticationHandlerOptions } from "../../../src/middleware/options/AuthenticationHandlerOptions"; -import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider"; - -describe("AuthenticationHandlerOptions.ts", () => { - const dummyAuthProvider = new DummyAuthenticationProvider(); - const authOptions = { scopes: ["test"] }; - it("Should create an instance with all the given options", () => { - const options = new AuthenticationHandlerOptions(dummyAuthProvider, authOptions); - assert.equal(options.authenticationProvider, dummyAuthProvider); - assert.equal(options.authenticationProviderOptions, authOptions); - }); - - it("Should be undefined value if no value is passed", () => { - const options = new AuthenticationHandlerOptions(undefined, authOptions); - assert.isUndefined(options.authenticationProvider); - assert.equal(options.authenticationProviderOptions, authOptions); - }); -}); diff --git a/test/common/middleware/MiddlewareFactory.ts b/test/common/middleware/MiddlewareFactory.ts index fed9cbddf..c96a6f3e4 100644 --- a/test/common/middleware/MiddlewareFactory.ts +++ b/test/common/middleware/MiddlewareFactory.ts @@ -7,21 +7,15 @@ import { assert } from "chai"; -import { AuthenticationHandler, CustomAuthenticationProvider, HTTPMessageHandler, RedirectHandler, RetryHandler, TelemetryHandler } from "../../../src"; -import { AuthProvider } from "../../../src/IAuthProvider"; +import { HTTPMessageHandler, RedirectHandler, RetryHandler, TelemetryHandler } from "../../../src"; import { MiddlewareFactory } from "../../../src/middleware/MiddlewareFactory"; describe("MiddlewareFactory", () => { it("Should return the default pipeline", () => { - const provider: AuthProvider = (done) => { - done(null, "dummy_token"); - }; - const defaultMiddleWareArray = MiddlewareFactory.getDefaultMiddlewareChain(new CustomAuthenticationProvider(provider)); - - assert.isTrue(defaultMiddleWareArray[0] instanceof AuthenticationHandler); - assert.isTrue(defaultMiddleWareArray[1] instanceof RetryHandler); - assert.isTrue(defaultMiddleWareArray[2] instanceof RedirectHandler); - assert.isTrue(defaultMiddleWareArray[3] instanceof TelemetryHandler); - assert.isTrue(defaultMiddleWareArray[4] instanceof HTTPMessageHandler); + const defaultMiddleWareArray = MiddlewareFactory.getDefaultMiddlewareChain(); + assert.isTrue(defaultMiddleWareArray[0] instanceof RetryHandler); + assert.isTrue(defaultMiddleWareArray[1] instanceof RedirectHandler); + assert.isTrue(defaultMiddleWareArray[2] instanceof TelemetryHandler); + assert.isTrue(defaultMiddleWareArray[3] instanceof HTTPMessageHandler); }); }); diff --git a/test/development/HardCodedAuthenticationProvider.ts b/test/development/HardCodedAuthenticationProvider.ts deleted file mode 100644 index aabf436fe..000000000 --- a/test/development/HardCodedAuthenticationProvider.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ - -/** - * @module HardCodedAuthenticationProvider - */ - -import { AuthenticationProvider } from "../../src/IAuthenticationProvider"; -import { AccessToken } from "./secrets"; - -/** - * @class - * @implements AuthenticationProvider - * Class representing HardCodedAuthenticationProvider - */ -export class HardCodedAuthenticationProvider implements AuthenticationProvider { - /** - * @public - * @async - * To get the access token - * @returns The promise that resolves to an access token - */ - public async getAccessToken(): Promise { - return Promise.resolve(AccessToken); - } -} diff --git a/test/development/test-helper.ts b/test/development/test-helper.ts index 55e034276..764e7f112 100644 --- a/test/development/test-helper.ts +++ b/test/development/test-helper.ts @@ -7,17 +7,17 @@ import "isomorphic-fetch"; -import { Client } from "../../src/index"; -import { HardCodedAuthenticationProvider } from "./HardCodedAuthenticationProvider"; +import { Client, SimpleAuthenticationProvider } from "../../src/index"; +import { AccessToken } from "./secrets"; export function getClient(): Client { - return Client.initWithMiddleware({ - authProvider: new HardCodedAuthenticationProvider(), + return Client.init({ + authProvider: new SimpleAuthenticationProvider(async () => { + return AccessToken; + }, ["scope1", "scope2"]), }); } export function randomString() { - return Math.random() - .toString(36) - .substring(7); + return Math.random().toString(36).substring(7); } diff --git a/test/development/workload/PageIterator.ts b/test/development/workload/PageIterator.ts index 8077997a9..6c486c1e7 100644 --- a/test/development/workload/PageIterator.ts +++ b/test/development/workload/PageIterator.ts @@ -116,7 +116,7 @@ describe("PageIterator", () => { const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, JSON.stringify(responseBody), new Headers({ "Content-Type": "application/json", "content-length": "100" }))]; const requestOptions = { middlewareOptions }; - const client = Client.initWithMiddleware(clientOptions); + const client = Client.init(clientOptions); const pageIterator = new PageIterator(client, getPageCollection(), callback, requestOptions); await pageIterator.iterate(); }); diff --git a/test/node/authentication/TokenCredentialAuthenticationProvider.ts b/test/node/authentication/TokenCredentialAuthenticationProvider.ts deleted file mode 100644 index 4a1183d15..000000000 --- a/test/node/authentication/TokenCredentialAuthenticationProvider.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * ------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. - * See License in the project root for license information. - * ------------------------------------------------------------------------------------------- - */ -/*tslint:disable*/ -import { AccessToken, ClientSecretCredential } from "@azure/identity"; -import { assert } from "chai"; -import * as sinon from "sinon"; - -import { TokenCredentialAuthenticationProviderOptions } from "../../../src/authentication/azureTokenCredentials/ITokenCredentialAuthenticationProviderOptions"; -import { TokenCredentialAuthenticationProvider } from "../../../src/authentication/azureTokenCredentials/TokenCredentialAuthenticationProvider"; -describe("TokenCredentialAuthenticationProvider.ts", () => { - const tenantId = "0000-1111-0000-1111"; - const clientId = "CLIENT_ID"; - const clientSecret = "CLIENT_SECRET"; - const scopes = ["test_scopes"]; - it("AccessToken is returned correctly from getToken function", async () => { - const client = new ClientSecretCredential(tenantId, clientId, clientSecret); - if (typeof client.getToken !== "function") { - throw new Error("Method definition for getToken is not found"); - } - - const authProviderOptions: TokenCredentialAuthenticationProviderOptions = { - getTokenoptions: null, - scopes, - }; - const accessToken: AccessToken = { token: "dummy_valid_token", expiresOnTimestamp: 1 }; - - const moq = sinon.mock(client); - moq.expects("getToken").resolves(accessToken); - const tokenCredentialAuthenticationProvider = new TokenCredentialAuthenticationProvider(client, authProviderOptions); - const access = await tokenCredentialAuthenticationProvider.getAccessToken(); - assert.equal(access, accessToken.token); - }); - - it("Error is thrown when accessToken cannot be retrieved from getToken function", async () => { - let expectedError; - try { - const client = new ClientSecretCredential(tenantId, clientId, clientSecret); - if (typeof client.getToken !== "function") { - throw new Error("Method definition for getToken is not found"); - } - const authProviderOptions: TokenCredentialAuthenticationProviderOptions = { - getTokenoptions: null, - scopes, - }; - const accessToken: AccessToken = undefined; - - const moq = sinon.mock(client); - moq.expects("getToken").resolves(accessToken); - const tokenCredentialAuthenticationProvider = new TokenCredentialAuthenticationProvider(client, authProviderOptions); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const access = await tokenCredentialAuthenticationProvider.getAccessToken(); - } catch (err) { - expectedError = err; - } - assert.equal(expectedError.name, "Access token is undefined"); - }); -}); diff --git a/test/test-helper.ts b/test/test-helper.ts index f5e63426d..d76ae3e98 100644 --- a/test/test-helper.ts +++ b/test/test-helper.ts @@ -5,17 +5,16 @@ * ------------------------------------------------------------------------------------------- */ -import { Client } from "../src/index"; -import { DummyAuthenticationProvider } from "./DummyAuthenticationProvider"; +import { Client, SimpleAuthenticationProvider } from "../src/index"; export function getClient(): Client { - return Client.initWithMiddleware({ - authProvider: new DummyAuthenticationProvider(), + return Client.init({ + authProvider: new SimpleAuthenticationProvider(async () => { + return "DUMMY_ACCESS_TOKEN"; + }, ["scope1", "scope2"]), }); } export function randomString() { - return Math.random() - .toString(36) - .substring(7); + return Math.random().toString(36).substring(7); } diff --git a/test/tsconfig-test-development.json b/test/tsconfig-test-development.json index 70c6c27ca..6c5c5b27c 100644 --- a/test/tsconfig-test-development.json +++ b/test/tsconfig-test-development.json @@ -2,7 +2,7 @@ "extends": "./../tsconfig-base.json", "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "esModuleInterop": true, "noEmitOnError": true, "lib": ["dom", "esnext"], diff --git a/tsconfig-base.json b/tsconfig-base.json index cb2aa81c1..29d91efc1 100644 --- a/tsconfig-base.json +++ b/tsconfig-base.json @@ -7,5 +7,6 @@ "removeComments": false, "sourceMap": true, "declaration": true, + "downlevelIteration": true, } -} \ No newline at end of file +} diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json index fe990a632..895482cca 100644 --- a/tsconfig-cjs.json +++ b/tsconfig-cjs.json @@ -2,10 +2,9 @@ "extends": "./tsconfig-base.json", "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "lib": ["dom", "esnext"], - "outDir": "lib", - "composite": true + "outDir": "lib" }, "exclude": ["node_modules", "lib", "samples", "test/development"], "include": ["./src/**/*.ts", "./test"] diff --git a/tsconfig-es.json b/tsconfig-es.json index ac57e1af6..321626ea3 100644 --- a/tsconfig-es.json +++ b/tsconfig-es.json @@ -4,8 +4,7 @@ "module": "es6", "target": "es6", "lib": ["dom", "esnext"], - "outDir": "lib/es", - "composite": true + "outDir": "lib/es" }, "exclude": ["node_modules", "lib", "samples", "test/development"], "include": ["./src/**/*.ts", "./test/**/*.ts"] diff --git a/tsconfig-sub-cjs.json b/tsconfig-sub-cjs.json deleted file mode 100644 index 8809ef20f..000000000 --- a/tsconfig-sub-cjs.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "./tsconfig-base.json", - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": ["dom", "esnext"], - "outDir": "authProviders" - }, - "exclude": ["node_modules", "lib", "samples", "test/", "src"], - "include": ["authProviderOptions/azureTokenCredentials/", "authProviderOptions/authCodeMsalBrowser"], - "references": [ - { - "path": "./tsconfig-cjs.json" - } - ] -} diff --git a/tsconfig-sub-es.json b/tsconfig-sub-es.json deleted file mode 100644 index a9d62e216..000000000 --- a/tsconfig-sub-es.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "./tsconfig-base.json", - "compilerOptions": { - "module": "es6", - "target": "es6", - "lib": ["dom", "esnext"], - "outDir": "authProviders/es" - }, - "exclude": ["node_modules", "lib", "samples", "test/**", "src"], - "include": ["authProviderOptions/es/**/*.ts"], - "references": [ - { - "path": "./tsconfig-es.json" - } - ] -}