@microsoft/teamsfx 0.3.2-rc.0 → 0.3.3-alpha.13914d2e.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +2 -2
  2. package/dist/index.esm2017.js +1413 -0
  3. package/dist/index.esm2017.js.map +1 -0
  4. package/dist/{index.js → index.esm2017.mjs} +1467 -1506
  5. package/dist/index.esm2017.mjs.map +1 -0
  6. package/dist/index.esm5.js +1575 -0
  7. package/dist/index.esm5.js.map +1 -0
  8. package/dist/index.node.cjs.js +1653 -0
  9. package/dist/index.node.cjs.js.map +1 -0
  10. package/package.json +73 -90
  11. package/types/teamsfx.d.ts +0 -2
  12. package/dist/index.js.map +0 -1
  13. package/dist/teamsfx.js +0 -30
  14. package/dist/teamsfx.js.map +0 -1
  15. package/dist-esm/src/bot/teamsBotSsoPrompt.browser.js +0 -118
  16. package/dist-esm/src/bot/teamsBotSsoPrompt.browser.js.map +0 -1
  17. package/dist-esm/src/bot/teamsBotSsoPrompt.js +0 -349
  18. package/dist-esm/src/bot/teamsBotSsoPrompt.js.map +0 -1
  19. package/dist-esm/src/bot/teamsBotSsoPromptTokenResponse.js +0 -2
  20. package/dist-esm/src/bot/teamsBotSsoPromptTokenResponse.js.map +0 -1
  21. package/dist-esm/src/core/cache.browser.js +0 -22
  22. package/dist-esm/src/core/cache.browser.js.map +0 -1
  23. package/dist-esm/src/core/cache.js +0 -28
  24. package/dist-esm/src/core/cache.js.map +0 -1
  25. package/dist-esm/src/core/configurationProvider.js +0 -124
  26. package/dist-esm/src/core/configurationProvider.js.map +0 -1
  27. package/dist-esm/src/core/defaultTediousConnectionConfiguration.browser.js +0 -28
  28. package/dist-esm/src/core/defaultTediousConnectionConfiguration.browser.js.map +0 -1
  29. package/dist-esm/src/core/defaultTediousConnectionConfiguration.js +0 -182
  30. package/dist-esm/src/core/defaultTediousConnectionConfiguration.js.map +0 -1
  31. package/dist-esm/src/core/errors.js +0 -97
  32. package/dist-esm/src/core/errors.js.map +0 -1
  33. package/dist-esm/src/core/msGraphAuthProvider.js +0 -68
  34. package/dist-esm/src/core/msGraphAuthProvider.js.map +0 -1
  35. package/dist-esm/src/core/msGraphClientProvider.js +0 -65
  36. package/dist-esm/src/core/msGraphClientProvider.js.map +0 -1
  37. package/dist-esm/src/credential/m365TenantCredential.browser.js +0 -38
  38. package/dist-esm/src/credential/m365TenantCredential.browser.js.map +0 -1
  39. package/dist-esm/src/credential/m365TenantCredential.js +0 -126
  40. package/dist-esm/src/credential/m365TenantCredential.js.map +0 -1
  41. package/dist-esm/src/credential/onBehalfOfUserCredential.browser.js +0 -46
  42. package/dist-esm/src/credential/onBehalfOfUserCredential.browser.js.map +0 -1
  43. package/dist-esm/src/credential/onBehalfOfUserCredential.js +0 -178
  44. package/dist-esm/src/credential/onBehalfOfUserCredential.js.map +0 -1
  45. package/dist-esm/src/credential/teamsUserCredential.browser.js +0 -462
  46. package/dist-esm/src/credential/teamsUserCredential.browser.js.map +0 -1
  47. package/dist-esm/src/credential/teamsUserCredential.js +0 -56
  48. package/dist-esm/src/credential/teamsUserCredential.js.map +0 -1
  49. package/dist-esm/src/index.js +0 -14
  50. package/dist-esm/src/index.js.map +0 -1
  51. package/dist-esm/src/models/accessTokenResult.js +0 -4
  52. package/dist-esm/src/models/accessTokenResult.js.map +0 -1
  53. package/dist-esm/src/models/authCodeResult.js +0 -4
  54. package/dist-esm/src/models/authCodeResult.js.map +0 -1
  55. package/dist-esm/src/models/configuration.js +0 -20
  56. package/dist-esm/src/models/configuration.js.map +0 -1
  57. package/dist-esm/src/models/grantType.js +0 -11
  58. package/dist-esm/src/models/grantType.js.map +0 -1
  59. package/dist-esm/src/models/ssoTokenInfo.js +0 -4
  60. package/dist-esm/src/models/ssoTokenInfo.js.map +0 -1
  61. package/dist-esm/src/models/userinfo.js +0 -4
  62. package/dist-esm/src/models/userinfo.js.map +0 -1
  63. package/dist-esm/src/util/logger.js +0 -134
  64. package/dist-esm/src/util/logger.js.map +0 -1
  65. package/dist-esm/src/util/utils.js +0 -130
  66. package/dist-esm/src/util/utils.js.map +0 -1
  67. package/dist-esm/src/util/utils.node.js +0 -23
  68. package/dist-esm/src/util/utils.node.js.map +0 -1
@@ -1,124 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { isNode } from "@azure/core-http";
4
- import { ResourceType, } from "../models/configuration";
5
- import { internalLogger } from "../util/logger";
6
- import { formatString } from "../util/utils";
7
- import { ErrorWithCode, ErrorCode, ErrorMessage } from "./errors";
8
- /**
9
- * Global configuration instance
10
- *
11
- */
12
- export let config;
13
- /**
14
- * Initialize configuration from environment variables or configuration object and set the global instance
15
- *
16
- * @param {Configuration} configuration - Optional configuration that overrides the default configuration values. The override depth is 1.
17
- *
18
- * @throws {@link ErrorCode|InvalidParameter} when configuration is not passed in browser environment
19
- *
20
- * @beta
21
- */
22
- export function loadConfiguration(configuration) {
23
- internalLogger.info("load configuration");
24
- // browser environment
25
- if (!isNode) {
26
- if (!configuration) {
27
- const errorMsg = "You are running the code in browser. Configuration must be passed in.";
28
- internalLogger.error(errorMsg);
29
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
30
- }
31
- config = configuration;
32
- return;
33
- }
34
- // node environment
35
- let newAuthentication;
36
- let newResources = [];
37
- const defaultResourceName = "default";
38
- if (configuration === null || configuration === void 0 ? void 0 : configuration.authentication) {
39
- newAuthentication = configuration.authentication;
40
- }
41
- else {
42
- newAuthentication = {
43
- authorityHost: process.env.M365_AUTHORITY_HOST,
44
- tenantId: process.env.M365_TENANT_ID,
45
- clientId: process.env.M365_CLIENT_ID,
46
- clientSecret: process.env.M365_CLIENT_SECRET,
47
- simpleAuthEndpoint: process.env.SIMPLE_AUTH_ENDPOINT,
48
- initiateLoginEndpoint: process.env.INITIATE_LOGIN_ENDPOINT,
49
- applicationIdUri: process.env.M365_APPLICATION_ID_URI,
50
- };
51
- }
52
- if (configuration === null || configuration === void 0 ? void 0 : configuration.resources) {
53
- newResources = configuration.resources;
54
- }
55
- else {
56
- newResources = [
57
- {
58
- // SQL resource
59
- type: ResourceType.SQL,
60
- name: defaultResourceName,
61
- properties: {
62
- sqlServerEndpoint: process.env.SQL_ENDPOINT,
63
- sqlUsername: process.env.SQL_USER_NAME,
64
- sqlPassword: process.env.SQL_PASSWORD,
65
- sqlDatabaseName: process.env.SQL_DATABASE_NAME,
66
- sqlIdentityId: process.env.IDENTITY_ID,
67
- },
68
- },
69
- {
70
- // API resource
71
- type: ResourceType.API,
72
- name: defaultResourceName,
73
- properties: {
74
- endpoint: process.env.API_ENDPOINT,
75
- },
76
- },
77
- ];
78
- }
79
- config = {
80
- authentication: newAuthentication,
81
- resources: newResources,
82
- };
83
- }
84
- /**
85
- * Get configuration for a specific resource.
86
- * @param {ResourceType} resourceType - The type of resource
87
- * @param {string} resourceName - The name of resource, default value is "default".
88
- *
89
- * @returns Resource configuration for target resource from global configuration instance.
90
- *
91
- * @throws {@link ErrorCode|InvalidConfiguration} when resource configuration with the specific type and name is not found
92
- *
93
- * @beta
94
- */
95
- export function getResourceConfiguration(resourceType, resourceName = "default") {
96
- var _a;
97
- internalLogger.info(`Get resource configuration of ${ResourceType[resourceType]} from ${resourceName}`);
98
- const result = (_a = config.resources) === null || _a === void 0 ? void 0 : _a.find((item) => item.type === resourceType && item.name === resourceName);
99
- if (result) {
100
- return result.properties;
101
- }
102
- const errorMsg = formatString(ErrorMessage.MissingResourceConfiguration, ResourceType[resourceType], resourceName);
103
- internalLogger.error(errorMsg);
104
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);
105
- }
106
- /**
107
- * Get configuration for authentication.
108
- *
109
- * @returns Authentication configuration from global configuration instance, the value may be undefined if no authentication config exists in current environment.
110
- *
111
- * @throws {@link ErrorCode|InvalidConfiguration} when global configuration does not exist
112
- *
113
- * @beta
114
- */
115
- export function getAuthenticationConfiguration() {
116
- internalLogger.info("Get authentication configuration");
117
- if (config) {
118
- return config.authentication;
119
- }
120
- const errorMsg = "Please call loadConfiguration() first before calling getAuthenticationConfiguration().";
121
- internalLogger.error(errorMsg);
122
- throw new ErrorWithCode(formatString(ErrorMessage.ConfigurationNotExists, errorMsg), ErrorCode.InvalidConfiguration);
123
- }
124
- //# sourceMappingURL=configurationProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configurationProvider.js","sourceRoot":"","sources":["../../../src/core/configurationProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAIL,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,IAAI,MAAqB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAA6B;IAC7D,cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAE1C,sBAAsB;IACtB,IAAI,CAAC,MAAM,EAAE;QACX,IAAI,CAAC,aAAa,EAAE;YAClB,MAAM,QAAQ,GAAG,uEAAuE,CAAC;YACzF,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC/B,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;SAC/D;QACD,MAAM,GAAG,aAAa,CAAC;QACvB,OAAO;KACR;IAED,mBAAmB;IACnB,IAAI,iBAA8C,CAAC;IACnD,IAAI,YAAY,GAA4B,EAAE,CAAC;IAC/C,MAAM,mBAAmB,GAAG,SAAS,CAAC;IAEtC,IAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,cA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;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CACtC,YAA0B,EAC1B,YAAY,GAAG,SAAS;;IAExB,cAAc,CAAC,IAAI,CACjB,iCAAiC,YAAY,CAAC,YAAY,CAAC,SAAS,YAAY,EAAE,CACnF,CAAC;IACF,MAAM,MAAM,GAAsC,MAAA,MAAM,CAAC,SAAS,0CAAE,IAAI,CACtE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,CACnE,CAAC;IACF,IAAI,MAAM,EAAE;QACV,OAAO,MAAM,CAAC,UAAU,CAAC;KAC1B;IAED,MAAM,QAAQ,GAAG,YAAY,CAC3B,YAAY,CAAC,4BAA4B,EACzC,YAAY,CAAC,YAAY,CAAC,EAC1B,YAAY,CACb,CAAC;IACF,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B;IAC5C,cAAc,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACxD,IAAI,MAAM,EAAE;QACV,OAAO,MAAM,CAAC,cAAc,CAAC;KAC9B;IACD,MAAM,QAAQ,GACZ,wFAAwF,CAAC;IAC3F,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,IAAI,aAAa,CACrB,YAAY,CAAC,YAAY,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAC3D,SAAS,CAAC,oBAAoB,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNode } from \"@azure/core-http\";\nimport {\n AuthenticationConfiguration,\n Configuration,\n ResourceConfiguration,\n ResourceType,\n} from \"../models/configuration\";\nimport { internalLogger } from \"../util/logger\";\nimport { formatString } from \"../util/utils\";\nimport { ErrorWithCode, ErrorCode, ErrorMessage } from \"./errors\";\n\n/**\n * Global configuration instance\n *\n */\nexport let config: Configuration;\n\n/**\n * Initialize configuration from environment variables or configuration object and set the global instance\n *\n * @param {Configuration} configuration - Optional configuration that overrides the default configuration values. The override depth is 1.\n *\n * @throws {@link ErrorCode|InvalidParameter} when configuration is not passed in browser environment\n *\n * @beta\n */\nexport function loadConfiguration(configuration?: Configuration): void {\n internalLogger.info(\"load configuration\");\n\n // browser environment\n if (!isNode) {\n if (!configuration) {\n const errorMsg = \"You are running the code in browser. Configuration must be passed in.\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);\n }\n config = configuration;\n return;\n }\n\n // node environment\n let newAuthentication: AuthenticationConfiguration;\n let newResources: ResourceConfiguration[] = [];\n const defaultResourceName = \"default\";\n\n if (configuration?.authentication) {\n newAuthentication = configuration.authentication;\n } else {\n newAuthentication = {\n authorityHost: process.env.M365_AUTHORITY_HOST,\n tenantId: process.env.M365_TENANT_ID,\n clientId: process.env.M365_CLIENT_ID,\n clientSecret: process.env.M365_CLIENT_SECRET,\n simpleAuthEndpoint: process.env.SIMPLE_AUTH_ENDPOINT,\n initiateLoginEndpoint: process.env.INITIATE_LOGIN_ENDPOINT,\n applicationIdUri: process.env.M365_APPLICATION_ID_URI,\n };\n }\n\n if (configuration?.resources) {\n newResources = configuration.resources;\n } else {\n newResources = [\n {\n // SQL resource\n type: ResourceType.SQL,\n name: defaultResourceName,\n properties: {\n sqlServerEndpoint: process.env.SQL_ENDPOINT,\n sqlUsername: process.env.SQL_USER_NAME,\n sqlPassword: process.env.SQL_PASSWORD,\n sqlDatabaseName: process.env.SQL_DATABASE_NAME,\n sqlIdentityId: process.env.IDENTITY_ID,\n },\n },\n {\n // API resource\n type: ResourceType.API,\n name: defaultResourceName,\n properties: {\n endpoint: process.env.API_ENDPOINT,\n },\n },\n ];\n }\n\n config = {\n authentication: newAuthentication,\n resources: newResources,\n };\n}\n\n/**\n * Get configuration for a specific resource.\n * @param {ResourceType} resourceType - The type of resource\n * @param {string} resourceName - The name of resource, default value is \"default\".\n *\n * @returns Resource configuration for target resource from global configuration instance.\n *\n * @throws {@link ErrorCode|InvalidConfiguration} when resource configuration with the specific type and name is not found\n *\n * @beta\n */\nexport function getResourceConfiguration(\n resourceType: ResourceType,\n resourceName = \"default\"\n): { [index: string]: any } {\n internalLogger.info(\n `Get resource configuration of ${ResourceType[resourceType]} from ${resourceName}`\n );\n const result: ResourceConfiguration | undefined = config.resources?.find(\n (item) => item.type === resourceType && item.name === resourceName\n );\n if (result) {\n return result.properties;\n }\n\n const errorMsg = formatString(\n ErrorMessage.MissingResourceConfiguration,\n ResourceType[resourceType],\n resourceName\n );\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);\n}\n\n/**\n * Get configuration for authentication.\n *\n * @returns Authentication configuration from global configuration instance, the value may be undefined if no authentication config exists in current environment.\n *\n * @throws {@link ErrorCode|InvalidConfiguration} when global configuration does not exist\n *\n * @beta\n */\nexport function getAuthenticationConfiguration(): AuthenticationConfiguration | undefined {\n internalLogger.info(\"Get authentication configuration\");\n if (config) {\n return config.authentication;\n }\n const errorMsg =\n \"Please call loadConfiguration() first before calling getAuthenticationConfiguration().\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(\n formatString(ErrorMessage.ConfigurationNotExists, errorMsg),\n ErrorCode.InvalidConfiguration\n );\n}\n"]}
@@ -1,28 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT license.
4
- import { ErrorWithCode, ErrorCode, ErrorMessage } from "./errors";
5
- import { formatString } from "../util/utils";
6
- /**
7
- * Generate connection configuration consumed by tedious.
8
- * @remarks
9
- * Only works in in server side.
10
- * @beta
11
- */
12
- export class DefaultTediousConnectionConfiguration {
13
- constructor() {
14
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultTediousConnectionConfiguration"), ErrorCode.RuntimeNotSupported);
15
- }
16
- /**
17
- * Generate connection configuration consumed by tedious.
18
- * @remarks
19
- * Only works in in server side.
20
- * @beta
21
- */
22
- getConfig() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultTediousConnectionConfiguration"), ErrorCode.RuntimeNotSupported);
25
- });
26
- }
27
- }
28
- //# sourceMappingURL=defaultTediousConnectionConfiguration.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultTediousConnectionConfiguration.browser.js","sourceRoot":"","sources":["../../../src/core/defaultTediousConnectionConfiguration.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,OAAO,qCAAqC;IAChD;QACE,MAAM,IAAI,aAAa,CACrB,YAAY,CACV,YAAY,CAAC,0BAA0B,EACvC,uCAAuC,CACxC,EACD,SAAS,CAAC,mBAAmB,CAC9B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACU,SAAS;;YACpB,MAAM,IAAI,aAAa,CACrB,YAAY,CACV,YAAY,CAAC,0BAA0B,EACvC,uCAAuC,CACxC,EACD,SAAS,CAAC,mBAAmB,CAC9B,CAAC;QACJ,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ErrorWithCode, ErrorCode, ErrorMessage } from \"./errors\";\nimport { ConnectionConfig } from \"tedious\";\nimport { formatString } from \"../util/utils\";\n\n/**\n * Generate connection configuration consumed by tedious.\n * @remarks\n * Only works in in server side.\n * @beta\n */\nexport class DefaultTediousConnectionConfiguration {\n constructor() {\n throw new ErrorWithCode(\n formatString(\n ErrorMessage.BrowserRuntimeNotSupported,\n \"DefaultTediousConnectionConfiguration\"\n ),\n ErrorCode.RuntimeNotSupported\n );\n }\n\n /**\n * Generate connection configuration consumed by tedious.\n * @remarks\n * Only works in in server side.\n * @beta\n */\n public async getConfig(): Promise<ConnectionConfig> {\n throw new ErrorWithCode(\n formatString(\n ErrorMessage.BrowserRuntimeNotSupported,\n \"DefaultTediousConnectionConfiguration\"\n ),\n ErrorCode.RuntimeNotSupported\n );\n }\n}\n"]}
@@ -1,182 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { __awaiter } from "tslib";
4
- import { getResourceConfiguration } from "./configurationProvider";
5
- import { ResourceType } from "../models/configuration";
6
- import { ManagedIdentityCredential } from "@azure/identity";
7
- import { ErrorWithCode, ErrorCode } from "./errors";
8
- import { internalLogger } from "../util/logger";
9
- /**
10
- * SQL connection configuration instance.
11
- * @remarks
12
- * Only works in in server side.
13
- *
14
- * @beta
15
- *
16
- */
17
- export class DefaultTediousConnectionConfiguration {
18
- constructor() {
19
- /**
20
- * MSSQL default scope
21
- * https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi
22
- */
23
- this.defaultSQLScope = "https://database.windows.net/";
24
- }
25
- /**
26
- * Generate connection configuration consumed by tedious.
27
- *
28
- * @returns Connection configuration of tedious for the SQL.
29
- *
30
- * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
31
- * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
32
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
33
- *
34
- * @beta
35
- */
36
- getConfig() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- internalLogger.info("Get SQL configuration");
39
- const configuration = getResourceConfiguration(ResourceType.SQL);
40
- if (!configuration) {
41
- const errMsg = "SQL resource configuration not exist";
42
- internalLogger.error(errMsg);
43
- throw new ErrorWithCode(errMsg, ErrorCode.InvalidConfiguration);
44
- }
45
- try {
46
- this.isSQLConfigurationValid(configuration);
47
- }
48
- catch (err) {
49
- throw err;
50
- }
51
- if (!this.isMsiAuthentication()) {
52
- const configWithUPS = this.generateDefaultConfig(configuration);
53
- internalLogger.verbose("SQL configuration with username and password generated");
54
- return configWithUPS;
55
- }
56
- try {
57
- const configWithToken = yield this.generateTokenConfig(configuration);
58
- internalLogger.verbose("SQL configuration with MSI token generated");
59
- return configWithToken;
60
- }
61
- catch (error) {
62
- throw error;
63
- }
64
- });
65
- }
66
- /**
67
- * Check SQL use MSI identity or username and password.
68
- *
69
- * @returns false - login with SQL MSI identity, true - login with username and password.
70
- * @internal
71
- */
72
- isMsiAuthentication() {
73
- internalLogger.verbose("Check connection config using MSI access token or username and password");
74
- const configuration = getResourceConfiguration(ResourceType.SQL);
75
- if ((configuration === null || configuration === void 0 ? void 0 : configuration.sqlUsername) != null && (configuration === null || configuration === void 0 ? void 0 : configuration.sqlPassword) != null) {
76
- internalLogger.verbose("Login with username and password");
77
- return false;
78
- }
79
- internalLogger.verbose("Login with MSI identity");
80
- return true;
81
- }
82
- /**
83
- * check configuration is an available configurations.
84
- * @param { SqlConfiguration } sqlConfig
85
- *
86
- * @returns true - SQL configuration has a valid SQL endpoints, SQL username with password or identity ID.
87
- * false - configuration is not valid.
88
- * @internal
89
- */
90
- isSQLConfigurationValid(sqlConfig) {
91
- internalLogger.verbose("Check SQL configuration if valid");
92
- if (!sqlConfig.sqlServerEndpoint) {
93
- internalLogger.error("SQL configuration is not valid without SQL server endpoint exist");
94
- throw new ErrorWithCode("SQL configuration error without SQL server endpoint exist", ErrorCode.InvalidConfiguration);
95
- }
96
- if (!(sqlConfig.sqlUsername && sqlConfig.sqlPassword) && !sqlConfig.sqlIdentityId) {
97
- const errMsg = `SQL configuration is not valid without ${sqlConfig.sqlIdentityId ? "" : "identity id "} ${sqlConfig.sqlUsername ? "" : "SQL username "} ${sqlConfig.sqlPassword ? "" : "SQL password"} exist`;
98
- internalLogger.error(errMsg);
99
- throw new ErrorWithCode(errMsg, ErrorCode.InvalidConfiguration);
100
- }
101
- internalLogger.verbose("SQL configuration is valid");
102
- }
103
- /**
104
- * Generate tedious connection configuration with default authentication type.
105
- *
106
- * @param { SqlConfiguration } SQL configuration with username and password.
107
- *
108
- * @returns Tedious connection configuration with username and password.
109
- * @internal
110
- */
111
- generateDefaultConfig(sqlConfig) {
112
- internalLogger.verbose(`SQL server ${sqlConfig.sqlServerEndpoint}, user name ${sqlConfig.sqlUsername}, database name ${sqlConfig.sqlDatabaseName}`);
113
- const config = {
114
- server: sqlConfig.sqlServerEndpoint,
115
- authentication: {
116
- type: TediousAuthenticationType.default,
117
- options: {
118
- userName: sqlConfig.sqlUsername,
119
- password: sqlConfig.sqlPassword,
120
- },
121
- },
122
- options: {
123
- database: sqlConfig.sqlDatabaseName,
124
- encrypt: true,
125
- },
126
- };
127
- return config;
128
- }
129
- /**
130
- * Generate tedious connection configuration with azure-active-directory-access-token authentication type.
131
- *
132
- * @param { SqlConfiguration } SQL configuration with AAD access token.
133
- *
134
- * @returns Tedious connection configuration with access token.
135
- * @internal
136
- */
137
- generateTokenConfig(sqlConfig) {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- internalLogger.verbose("Generate tedious config with MSI token");
140
- let token;
141
- try {
142
- const credential = new ManagedIdentityCredential(sqlConfig.sqlIdentityId);
143
- token = yield credential.getToken(this.defaultSQLScope);
144
- }
145
- catch (error) {
146
- const errMsg = "Get user MSI token failed";
147
- internalLogger.error(errMsg);
148
- throw new ErrorWithCode(errMsg, ErrorCode.InternalError);
149
- }
150
- if (token) {
151
- const config = {
152
- server: sqlConfig.sqlServerEndpoint,
153
- authentication: {
154
- type: TediousAuthenticationType.MSI,
155
- options: {
156
- token: token.token,
157
- },
158
- },
159
- options: {
160
- database: sqlConfig.sqlDatabaseName,
161
- encrypt: true,
162
- },
163
- };
164
- internalLogger.verbose(`Generate token configuration success, server endpoint is ${sqlConfig.sqlServerEndpoint}, database name is ${sqlConfig.sqlDatabaseName}`);
165
- return config;
166
- }
167
- internalLogger.error(`Generate token configuration, server endpoint is ${sqlConfig.sqlServerEndpoint}, MSI token is not valid`);
168
- throw new ErrorWithCode("MSI token is not valid", ErrorCode.InternalError);
169
- });
170
- }
171
- }
172
- /**
173
- * tedious connection config authentication type.
174
- * https://tediousjs.github.io/tedious/api-connection.html
175
- * @internal
176
- */
177
- var TediousAuthenticationType;
178
- (function (TediousAuthenticationType) {
179
- TediousAuthenticationType["default"] = "default";
180
- TediousAuthenticationType["MSI"] = "azure-active-directory-access-token";
181
- })(TediousAuthenticationType || (TediousAuthenticationType = {}));
182
- //# sourceMappingURL=defaultTediousConnectionConfiguration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultTediousConnectionConfiguration.js","sourceRoot":"","sources":["../../../src/core/defaultTediousConnectionConfiguration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAe,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,OAAO,qCAAqC;IAAlD;QACE;;;WAGG;QACc,oBAAe,GAAW,+BAA+B,CAAC;IAsK7E,CAAC;IApKC;;;;;;;;;;OAUG;IACU,SAAS;;YACpB,cAAc,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YAC7C,MAAM,aAAa,GAAqB,wBAAwB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAEnF,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,MAAM,GAAG,sCAAsC,CAAC;gBACtD,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;g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AAyB,KAAzB,yBAAyB,QAG7B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getResourceConfiguration } from \"./configurationProvider\";\nimport { ResourceType } from \"../models/configuration\";\nimport { AccessToken, ManagedIdentityCredential } from \"@azure/identity\";\nimport { ErrorWithCode, ErrorCode } from \"./errors\";\nimport { ConnectionConfig } from \"tedious\";\nimport { internalLogger } from \"../util/logger\";\n\n/**\n * SQL connection configuration instance.\n * @remarks\n * Only works in in server side.\n *\n * @beta\n *\n */\nexport class DefaultTediousConnectionConfiguration {\n /**\n * MSSQL default scope\n * https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi\n */\n private readonly defaultSQLScope: string = \"https://database.windows.net/\";\n\n /**\n * Generate connection configuration consumed by tedious.\n *\n * @returns Connection configuration of tedious for the SQL.\n *\n * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.\n * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.\n * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.\n *\n * @beta\n */\n public async getConfig(): Promise<ConnectionConfig> {\n internalLogger.info(\"Get SQL configuration\");\n const configuration = <SqlConfiguration>getResourceConfiguration(ResourceType.SQL);\n\n if (!configuration) {\n const errMsg = \"SQL resource configuration not exist\";\n internalLogger.error(errMsg);\n throw new ErrorWithCode(errMsg, ErrorCode.InvalidConfiguration);\n }\n\n try {\n this.isSQLConfigurationValid(configuration);\n } catch (err) {\n throw err;\n }\n\n if (!this.isMsiAuthentication()) {\n const configWithUPS = this.generateDefaultConfig(configuration);\n internalLogger.verbose(\"SQL configuration with username and password generated\");\n return configWithUPS;\n }\n\n try {\n const configWithToken = await this.generateTokenConfig(configuration);\n internalLogger.verbose(\"SQL configuration with MSI token generated\");\n return configWithToken;\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * Check SQL use MSI identity or username and password.\n *\n * @returns false - login with SQL MSI identity, true - login with username and password.\n * @internal\n */\n private isMsiAuthentication(): boolean {\n internalLogger.verbose(\n \"Check connection config using MSI access token or username and password\"\n );\n const configuration = <SqlConfiguration>getResourceConfiguration(ResourceType.SQL);\n if (configuration?.sqlUsername != null && configuration?.sqlPassword != null) {\n internalLogger.verbose(\"Login with username and password\");\n return false;\n }\n internalLogger.verbose(\"Login with MSI identity\");\n return true;\n }\n\n /**\n * check configuration is an available configurations.\n * @param { SqlConfiguration } sqlConfig\n *\n * @returns true - SQL configuration has a valid SQL endpoints, SQL username with password or identity ID.\n * false - configuration is not valid.\n * @internal\n */\n private isSQLConfigurationValid(sqlConfig: SqlConfiguration) {\n internalLogger.verbose(\"Check SQL configuration if valid\");\n if (!sqlConfig.sqlServerEndpoint) {\n internalLogger.error(\"SQL configuration is not valid without SQL server endpoint exist\");\n throw new ErrorWithCode(\n \"SQL configuration error without SQL server endpoint exist\",\n ErrorCode.InvalidConfiguration\n );\n }\n if (!(sqlConfig.sqlUsername && sqlConfig.sqlPassword) && !sqlConfig.sqlIdentityId) {\n const errMsg = `SQL configuration is not valid without ${\n sqlConfig.sqlIdentityId ? \"\" : \"identity id \"\n } ${sqlConfig.sqlUsername ? \"\" : \"SQL username \"} ${\n sqlConfig.sqlPassword ? \"\" : \"SQL password\"\n } exist`;\n internalLogger.error(errMsg);\n throw new ErrorWithCode(errMsg, ErrorCode.InvalidConfiguration);\n }\n internalLogger.verbose(\"SQL configuration is valid\");\n }\n\n /**\n * Generate tedious connection configuration with default authentication type.\n *\n * @param { SqlConfiguration } SQL configuration with username and password.\n *\n * @returns Tedious connection configuration with username and password.\n * @internal\n */\n private generateDefaultConfig(sqlConfig: SqlConfiguration): ConnectionConfig {\n internalLogger.verbose(\n `SQL server ${sqlConfig.sqlServerEndpoint}, user name ${sqlConfig.sqlUsername}, database name ${sqlConfig.sqlDatabaseName}`\n );\n\n const config = {\n server: sqlConfig.sqlServerEndpoint,\n authentication: {\n type: TediousAuthenticationType.default,\n options: {\n userName: sqlConfig.sqlUsername,\n password: sqlConfig.sqlPassword,\n },\n },\n options: {\n database: sqlConfig.sqlDatabaseName,\n encrypt: true,\n },\n };\n return config;\n }\n\n /**\n * Generate tedious connection configuration with azure-active-directory-access-token authentication type.\n *\n * @param { SqlConfiguration } SQL configuration with AAD access token.\n *\n * @returns Tedious connection configuration with access token.\n * @internal\n */\n private async generateTokenConfig(sqlConfig: SqlConfiguration): Promise<ConnectionConfig> {\n internalLogger.verbose(\"Generate tedious config with MSI token\");\n\n let token: AccessToken | null;\n try {\n const credential = new ManagedIdentityCredential(sqlConfig.sqlIdentityId);\n token = await credential.getToken(this.defaultSQLScope);\n } catch (error) {\n const errMsg = \"Get user MSI token failed\";\n internalLogger.error(errMsg);\n throw new ErrorWithCode(errMsg, ErrorCode.InternalError);\n }\n if (token) {\n const config = {\n server: sqlConfig.sqlServerEndpoint,\n authentication: {\n type: TediousAuthenticationType.MSI,\n options: {\n token: token.token,\n },\n },\n options: {\n database: sqlConfig.sqlDatabaseName,\n encrypt: true,\n },\n };\n internalLogger.verbose(\n `Generate token configuration success, server endpoint is ${sqlConfig.sqlServerEndpoint}, database name is ${sqlConfig.sqlDatabaseName}`\n );\n return config;\n }\n internalLogger.error(\n `Generate token configuration, server endpoint is ${sqlConfig.sqlServerEndpoint}, MSI token is not valid`\n );\n throw new ErrorWithCode(\"MSI token is not valid\", ErrorCode.InternalError);\n }\n}\n\n/**\n * tedious connection config authentication type.\n * https://tediousjs.github.io/tedious/api-connection.html\n * @internal\n */\nenum TediousAuthenticationType {\n default = \"default\",\n MSI = \"azure-active-directory-access-token\",\n}\n\n/**\n * Configuration for SQL resource.\n * @internal\n */\ninterface SqlConfiguration {\n /**\n * SQL server endpoint.\n *\n * @readonly\n */\n readonly sqlServerEndpoint: string;\n\n /**\n * SQL server username.\n *\n * @readonly\n */\n readonly sqlUsername: string;\n\n /**\n * SQL server password.\n *\n * @readonly\n */\n readonly sqlPassword: string;\n\n /**\n * SQL server database name.\n *\n * @readonly\n */\n readonly sqlDatabaseName: string;\n\n /**\n * Managed identity id.\n *\n * @readonly\n */\n readonly sqlIdentityId: string;\n}\n"]}
@@ -1,97 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * Error code to trace the error types.
5
- * @beta
6
- */
7
- export var ErrorCode;
8
- (function (ErrorCode) {
9
- /**
10
- * Invalid parameter error.
11
- */
12
- ErrorCode["InvalidParameter"] = "InvalidParameter";
13
- /**
14
- * Invalid configuration error.
15
- */
16
- ErrorCode["InvalidConfiguration"] = "InvalidConfiguration";
17
- /**
18
- * Invalid certificate error.
19
- */
20
- ErrorCode["InvalidCertificate"] = "InvalidCertificate";
21
- /**
22
- * Internal error.
23
- */
24
- ErrorCode["InternalError"] = "InternalError";
25
- /**
26
- * Channel is not supported error.
27
- */
28
- ErrorCode["ChannelNotSupported"] = "ChannelNotSupported";
29
- /**
30
- * Runtime is not supported error.
31
- */
32
- ErrorCode["RuntimeNotSupported"] = "RuntimeNotSupported";
33
- /**
34
- * User failed to finish the AAD consent flow failed.
35
- */
36
- ErrorCode["ConsentFailed"] = "ConsentFailed";
37
- /**
38
- * The user or administrator has not consented to use the application error.
39
- */
40
- ErrorCode["UiRequiredError"] = "UiRequiredError";
41
- /**
42
- * Token is not within its valid time range error.
43
- */
44
- ErrorCode["TokenExpiredError"] = "TokenExpiredError";
45
- /**
46
- * Call service (AAD or simple authentication server) failed.
47
- */
48
- ErrorCode["ServiceError"] = "ServiceError";
49
- /**
50
- * Operation failed.
51
- */
52
- ErrorCode["FailedOperation"] = "FailedOperation";
53
- })(ErrorCode || (ErrorCode = {}));
54
- /**
55
- * @internal
56
- */
57
- export class ErrorMessage {
58
- }
59
- // InvalidConfiguration Error
60
- ErrorMessage.InvalidConfiguration = "{0} in configuration is invalid: {1}.";
61
- ErrorMessage.ConfigurationNotExists = "Configuration does not exist. {0}";
62
- ErrorMessage.ResourceConfigurationNotExists = "{0} resource configuration does not exist.";
63
- ErrorMessage.MissingResourceConfiguration = "Missing resource configuration with type: {0}, name: {1}.";
64
- ErrorMessage.AuthenticationConfigurationNotExists = "Authentication configuration does not exist.";
65
- // RuntimeNotSupported Error
66
- ErrorMessage.BrowserRuntimeNotSupported = "{0} is not supported in browser.";
67
- ErrorMessage.NodejsRuntimeNotSupported = "{0} is not supported in Node.";
68
- // Internal Error
69
- ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token on behalf of user: {0}";
70
- // ChannelNotSupported Error
71
- ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
72
- /**
73
- * Error class with code and message thrown by the SDK.
74
- *
75
- * @beta
76
- */
77
- export class ErrorWithCode extends Error {
78
- /**
79
- * Constructor of ErrorWithCode.
80
- *
81
- * @param {string} message - error message.
82
- * @param {ErrorCode} code - error code.
83
- *
84
- * @beta
85
- */
86
- constructor(message, code) {
87
- if (!code) {
88
- super(message);
89
- return;
90
- }
91
- super(message);
92
- Object.setPrototypeOf(this, ErrorWithCode.prototype);
93
- this.name = `${new.target.name}.${code}`;
94
- this.code = code;
95
- }
96
- }
97
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAN,IAAY,SAuDX;AAvDD,WAAY,SAAS;IACnB;;OAEG;IACH,kDAAqC,CAAA;IAErC;;OAEG;IACH,0DAA6C,CAAA;IAE7C;;OAEG;IACH,sDAAyC,CAAA;IAEzC;;OAEG;IACH,4CAA+B,CAAA;IAE/B;;OAEG;IACH,wDAA2C,CAAA;IAE3C;;OAEG;IACH,wDAA2C,CAAA;IAE3C;;OAEG;IACH,4CAA+B,CAAA;IAE/B;;OAEG;IACH,gDAAmC,CAAA;IAEnC;;OAEG;IACH,oDAAuC,CAAA;IAEvC;;OAEG;IACH,0CAA6B,CAAA;IAE7B;;OAEG;IACH,gDAAmC,CAAA;AACrC,CAAC,EAvDW,SAAS,KAAT,SAAS,QAuDpB;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;;AACvB,6BAA6B;AACb,iCAAoB,GAAG,uCAAuC,CAAC;AAC/D,mCAAsB,GAAG,mCAAmC,CAAC;AAC7D,2CAA8B,GAAG,4CAA4C,CAAC;AAC9E,yCAA4B,GAC1C,2DAA2D,CAAC;AAC9C,iDAAoC,GAClD,8CAA8C,CAAC;AAEjD,4BAA4B;AACZ,uCAA0B,GAAG,kCAAkC,CAAC;AAChE,sCAAyB,GAAG,+BAA+B,CAAC;AAE5E,iBAAiB;AACD,6CAAgC,GAC9C,uDAAuD,CAAC;AAE1D,4BAA4B;AACZ,wCAA2B,GAAG,2CAA2C,CAAC;AAG5F;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAQtC;;;;;;;OAOG;IACH,YAAY,OAAgB,EAAE,IAAgB;QAC5C,IAAI,CAAC,IAAI,EAAE;YACT,KAAK,CAAC,OAAO,CAAC,CAAC;YACf,OAAO;SACR;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Error code to trace the error types.\n * @beta\n */\nexport enum ErrorCode {\n /**\n * Invalid parameter error.\n */\n InvalidParameter = \"InvalidParameter\",\n\n /**\n * Invalid configuration error.\n */\n InvalidConfiguration = \"InvalidConfiguration\",\n\n /**\n * Invalid certificate error.\n */\n InvalidCertificate = \"InvalidCertificate\",\n\n /**\n * Internal error.\n */\n InternalError = \"InternalError\",\n\n /**\n * Channel is not supported error.\n */\n ChannelNotSupported = \"ChannelNotSupported\",\n\n /**\n * Runtime is not supported error.\n */\n RuntimeNotSupported = \"RuntimeNotSupported\",\n\n /**\n * User failed to finish the AAD consent flow failed.\n */\n ConsentFailed = \"ConsentFailed\",\n\n /**\n * The user or administrator has not consented to use the application error.\n */\n UiRequiredError = \"UiRequiredError\",\n\n /**\n * Token is not within its valid time range error.\n */\n TokenExpiredError = \"TokenExpiredError\",\n\n /**\n * Call service (AAD or simple authentication server) failed.\n */\n ServiceError = \"ServiceError\",\n\n /**\n * Operation failed.\n */\n FailedOperation = \"FailedOperation\",\n}\n\n/**\n * @internal\n */\nexport class ErrorMessage {\n // InvalidConfiguration Error\n static readonly InvalidConfiguration = \"{0} in configuration is invalid: {1}.\";\n static readonly ConfigurationNotExists = \"Configuration does not exist. {0}\";\n static readonly ResourceConfigurationNotExists = \"{0} resource configuration does not exist.\";\n static readonly MissingResourceConfiguration =\n \"Missing resource configuration with type: {0}, name: {1}.\";\n static readonly AuthenticationConfigurationNotExists =\n \"Authentication configuration does not exist.\";\n\n // RuntimeNotSupported Error\n static readonly BrowserRuntimeNotSupported = \"{0} is not supported in browser.\";\n static readonly NodejsRuntimeNotSupported = \"{0} is not supported in Node.\";\n\n // Internal Error\n static readonly FailToAcquireTokenOnBehalfOfUser =\n \"Failed to acquire access token on behalf of user: {0}\";\n\n // ChannelNotSupported Error\n static readonly OnlyMSTeamsChannelSupported = \"{0} is only supported in MS Teams Channel\";\n}\n\n/**\n * Error class with code and message thrown by the SDK.\n *\n * @beta\n */\nexport class ErrorWithCode extends Error {\n /**\n * Error code\n *\n * @readonly\n */\n code: string | undefined;\n\n /**\n * Constructor of ErrorWithCode.\n *\n * @param {string} message - error message.\n * @param {ErrorCode} code - error code.\n *\n * @beta\n */\n constructor(message?: string, code?: ErrorCode) {\n if (!code) {\n super(message);\n return;\n }\n\n super(message);\n Object.setPrototypeOf(this, ErrorWithCode.prototype);\n this.name = `${new.target.name}.${code}`;\n this.code = code;\n }\n}\n"]}
@@ -1,68 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { __awaiter } from "tslib";
4
- import { ErrorWithCode, ErrorCode } from "./errors";
5
- import { internalLogger } from "../util/logger";
6
- import { validateScopesType } from "../util/utils";
7
- const defaultScope = "https://graph.microsoft.com/.default";
8
- /**
9
- * Microsoft Graph auth provider for Teams Framework
10
- *
11
- * @beta
12
- */
13
- export class MsGraphAuthProvider {
14
- /**
15
- * Constructor of MsGraphAuthProvider.
16
- *
17
- * @param {TokenCredential} credential - Credential used to invoke Microsoft Graph APIs.
18
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
19
- *
20
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
21
- *
22
- * @returns An instance of MsGraphAuthProvider.
23
- *
24
- * @beta
25
- */
26
- constructor(credential, scopes) {
27
- this.credential = credential;
28
- let scopesStr = defaultScope;
29
- if (scopes) {
30
- validateScopesType(scopes);
31
- scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
32
- if (scopesStr === "") {
33
- scopesStr = defaultScope;
34
- }
35
- }
36
- internalLogger.info(`Create Microsoft Graph Authentication Provider with scopes: '${scopesStr}'`);
37
- this.scopes = scopesStr;
38
- }
39
- /**
40
- * Get access token for Microsoft Graph API requests.
41
- *
42
- * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
43
- * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
44
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
45
- * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
46
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
47
- *
48
- * @returns Access token from the credential.
49
- *
50
- */
51
- getAccessToken() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
54
- const accessToken = yield this.credential.getToken(this.scopes);
55
- return new Promise((resolve, reject) => {
56
- if (accessToken) {
57
- resolve(accessToken.token);
58
- }
59
- else {
60
- const errorMsg = "Graph access token is undefined or empty";
61
- internalLogger.error(errorMsg);
62
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
63
- }
64
- });
65
- });
66
- }
67
- }
68
- //# sourceMappingURL=msGraphAuthProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msGraphAuthProvider.js","sourceRoot":"","sources":["../../../src/core/msGraphAuthProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAIlC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAI9B;;;;;;;;;;;OAWG;IACH,YAAY,UAA2B,EAAE,MAA0B;QACjE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,SAAS,GAAG,YAAY,CAAC;QAC7B,IAAI,MAAM,EAAE;YACV,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC3B,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnE,IAAI,SAAS,KAAK,EAAE,EAAE;gBACpB,SAAS,GAAG,YAAY,CAAC;aAC1B;SACF;QAED,cAAc,CAAC,IAAI,CACjB,gEAAgE,SAAS,GAAG,CAC7E,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;;OAWG;IACU,cAAc;;YACzB,cAAc,CAAC,IAAI,CAAC,wCAAwC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEhE,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC7C,IAAI,WAAW,EAAE;oBACf,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;iBAC5B;qBAAM;oBACL,MAAM,QAAQ,GAAG,0CAA0C,CAAC;oBAC5D,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAC/B,MAAM,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;iBAC9D;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AuthenticationProvider } from \"@microsoft/microsoft-graph-client\";\nimport { TokenCredential } from \"@azure/identity\";\nimport { ErrorWithCode, ErrorCode } from \"./errors\";\nimport { internalLogger } from \"../util/logger\";\nimport { validateScopesType } from \"../util/utils\";\n\nconst defaultScope = \"https://graph.microsoft.com/.default\";\n\n/**\n * Microsoft Graph auth provider for Teams Framework\n *\n * @beta\n */\nexport class MsGraphAuthProvider implements AuthenticationProvider {\n private credential: TokenCredential;\n private scopes: string | string[];\n\n /**\n * Constructor of MsGraphAuthProvider.\n *\n * @param {TokenCredential} credential - Credential used to invoke Microsoft Graph APIs.\n * @param {string | string[]} scopes - The list of scopes for which the token will have access.\n *\n * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.\n *\n * @returns An instance of MsGraphAuthProvider.\n *\n * @beta\n */\n constructor(credential: TokenCredential, scopes?: string | string[]) {\n this.credential = credential;\n\n let scopesStr = defaultScope;\n if (scopes) {\n validateScopesType(scopes);\n scopesStr = typeof scopes === \"string\" ? scopes : scopes.join(\" \");\n if (scopesStr === \"\") {\n scopesStr = defaultScope;\n }\n }\n\n internalLogger.info(\n `Create Microsoft Graph Authentication Provider with scopes: '${scopesStr}'`\n );\n\n this.scopes = scopesStr;\n }\n\n /**\n * Get access token for Microsoft Graph API requests.\n *\n * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.\n * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.\n * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.\n * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.\n * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.\n *\n * @returns Access token from the credential.\n *\n */\n public async getAccessToken(): Promise<string> {\n internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);\n const accessToken = await this.credential.getToken(this.scopes);\n\n return new Promise<string>((resolve, reject) => {\n if (accessToken) {\n resolve(accessToken.token);\n } else {\n const errorMsg = \"Graph access token is undefined or empty\";\n internalLogger.error(errorMsg);\n reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));\n }\n });\n }\n}\n"]}
@@ -1,65 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { Client } from "@microsoft/microsoft-graph-client";
4
- import { MsGraphAuthProvider } from "./msGraphAuthProvider";
5
- import { internalLogger } from "../util/logger";
6
- /**
7
- * Get Microsoft graph client.
8
- *
9
- * @example
10
- * Get Microsoft graph client by TokenCredential
11
- * ```typescript
12
- * // Sso token example (Azure Function)
13
- * const ssoToken = "YOUR_TOKEN_STRING";
14
- * const options = {"AAD_APP_ID", "AAD_APP_SECRET"};
15
- * const credential = new OnBehalfOfAADUserCredential(ssoToken, options);
16
- * const graphClient = await createMicrosoftGraphClient(credential);
17
- * const profile = await graphClient.api("/me").get();
18
- *
19
- * // TeamsBotSsoPrompt example (Bot Application)
20
- * const requiredScopes = ["User.Read"];
21
- * const config: Configuration = {
22
- * loginUrl: loginUrl,
23
- * clientId: clientId,
24
- * clientSecret: clientSecret,
25
- * tenantId: tenantId
26
- * };
27
- * const prompt = new TeamsBotSsoPrompt(dialogId, {
28
- * config: config
29
- * scopes: '["User.Read"],
30
- * });
31
- * this.addDialog(prompt);
32
- *
33
- * const oboCredential = new OnBehalfOfAADUserCredential(
34
- * getUserId(dialogContext),
35
- * {
36
- * clientId: "AAD_APP_ID",
37
- * clientSecret: "AAD_APP_SECRET"
38
- * });
39
- * try {
40
- * const graphClient = await createMicrosoftGraphClient(credential);
41
- * const profile = await graphClient.api("/me").get();
42
- * } catch (e) {
43
- * dialogContext.beginDialog(dialogId);
44
- * return Dialog.endOfTurn();
45
- * }
46
- * ```
47
- *
48
- * @param {TokenCredential} credential - token credential instance.
49
- * @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.
50
- *
51
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
52
- *
53
- * @returns Graph client with specified scopes.
54
- *
55
- * @beta
56
- */
57
- export function createMicrosoftGraphClient(credential, scopes) {
58
- internalLogger.info("Create Microsoft Graph Client");
59
- const authProvider = new MsGraphAuthProvider(credential, scopes);
60
- const graphClient = Client.initWithMiddleware({
61
- authProvider,
62
- });
63
- return graphClient;
64
- }
65
- //# sourceMappingURL=msGraphClientProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msGraphClientProvider.js","sourceRoot":"","sources":["../../../src/core/msGraphClientProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAA2B,EAC3B,MAA0B;IAE1B,cAAc,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,CAAC;QAC5C,YAAY;KACb,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TokenCredential } from \"@azure/identity\";\nimport { Client } from \"@microsoft/microsoft-graph-client\";\nimport { MsGraphAuthProvider } from \"./msGraphAuthProvider\";\nimport { internalLogger } from \"../util/logger\";\n\n/**\n * Get Microsoft graph client.\n *\n * @example\n * Get Microsoft graph client by TokenCredential\n * ```typescript\n * // Sso token example (Azure Function)\n * const ssoToken = \"YOUR_TOKEN_STRING\";\n * const options = {\"AAD_APP_ID\", \"AAD_APP_SECRET\"};\n * const credential = new OnBehalfOfAADUserCredential(ssoToken, options);\n * const graphClient = await createMicrosoftGraphClient(credential);\n * const profile = await graphClient.api(\"/me\").get();\n *\n * // TeamsBotSsoPrompt example (Bot Application)\n * const requiredScopes = [\"User.Read\"];\n * const config: Configuration = {\n * loginUrl: loginUrl,\n * clientId: clientId,\n * clientSecret: clientSecret,\n * tenantId: tenantId\n * };\n * const prompt = new TeamsBotSsoPrompt(dialogId, {\n * config: config\n * scopes: '[\"User.Read\"],\n * });\n * this.addDialog(prompt);\n *\n * const oboCredential = new OnBehalfOfAADUserCredential(\n * getUserId(dialogContext),\n * {\n * clientId: \"AAD_APP_ID\",\n * clientSecret: \"AAD_APP_SECRET\"\n * });\n * try {\n * const graphClient = await createMicrosoftGraphClient(credential);\n * const profile = await graphClient.api(\"/me\").get();\n * } catch (e) {\n * dialogContext.beginDialog(dialogId);\n * return Dialog.endOfTurn();\n * }\n * ```\n *\n * @param {TokenCredential} credential - token credential instance.\n * @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.\n *\n * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.\n *\n * @returns Graph client with specified scopes.\n *\n * @beta\n */\nexport function createMicrosoftGraphClient(\n credential: TokenCredential,\n scopes?: string | string[]\n): Client {\n internalLogger.info(\"Create Microsoft Graph Client\");\n const authProvider = new MsGraphAuthProvider(credential, scopes);\n const graphClient = Client.initWithMiddleware({\n authProvider,\n });\n\n return graphClient;\n}\n"]}