@microsoft/teamsfx 0.3.0-alpha.def66483.0 → 0.3.0-rc.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.
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/models/configuration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsGlC;;;GAGG;AACH,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB;;;OAGG;IACH,6CAAG,CAAA;IAEH;;;OAGG;IACH,6CAAG,CAAA;AACL,CAAC,EAZW,YAAY,KAAZ,YAAY,QAYvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Configuration for current environment.\n * @beta\n */\nexport interface Configuration {\n /**\n * Authentication related configuration.\n *\n * @readonly\n */\n readonly authentication?: AuthenticationConfiguration;\n\n /**\n * Configuration for resources.\n *\n * @readonly\n */\n readonly resources?: ResourceConfiguration[];\n}\n\n/**\n * Authentication related configuration.\n * @beta\n */\nexport interface AuthenticationConfiguration {\n /**\n * Hostname of AAD authority. Default value comes from M365_AUTHORITY_HOST environment variable.\n *\n * @readonly\n */\n readonly authorityHost?: string;\n\n /**\n * AAD tenant id, default value comes from M365_TENANT_ID environment variable.\n *\n * @readonly\n */\n readonly tenantId?: string;\n\n /**\n * The client (application) ID of an App Registration in the tenant, default value comes from M365_CLIENT_ID environment variable\n *\n * @readonly\n */\n readonly clientId?: string;\n\n /**\n * Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal. Default value comes from M365_CLIENT_SECRET environment variable\n *\n * @readonly\n */\n readonly clientSecret?: string;\n\n /**\n * Endpoint of auth service provisioned by Teams Framework. Default value comes from SIMPLE_AUTH_ENDPOINT environment variable.\n *\n * @readonly\n */\n readonly simpleAuthEndpoint?: string;\n\n /**\n * Login page for Teams to redirect to. Default value comes from INITIATE_LOGIN_ENDPOINT environment variable.\n *\n * @readonly\n */\n readonly initiateLoginEndpoint?: string;\n\n /**\n * Application ID URI. Default value comes from M365_APPLICATION_ID_URI environment variable.\n */\n readonly applicationIdUri?: string;\n}\n\n/**\n * Configuration for resources.\n * @beta\n */\nexport interface ResourceConfiguration {\n /**\n * Resource type.\n *\n * @readonly\n */\n readonly type: ResourceType;\n\n /**\n * Resource name.\n *\n * @readonly\n */\n readonly name: string;\n\n /**\n * Config for the resource.\n *\n * @readonly\n */\n readonly properties: { [index: string]: any };\n}\n\n/**\n * Available resource type.\n * @beta\n */\nexport enum ResourceType {\n /**\n * SQL database.\n *\n */\n SQL,\n\n /**\n * Rest API.\n *\n */\n API,\n}\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/models/configuration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA6GlC;;;GAGG;AACH,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB;;;OAGG;IACH,6CAAG,CAAA;IAEH;;;OAGG;IACH,6CAAG,CAAA;AACL,CAAC,EAZW,YAAY,KAAZ,YAAY,QAYvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Configuration for current environment.\n * @beta\n */\nexport interface Configuration {\n /**\n * Authentication related configuration.\n *\n * @readonly\n */\n readonly authentication?: AuthenticationConfiguration;\n\n /**\n * Configuration for resources.\n *\n * @readonly\n */\n readonly resources?: ResourceConfiguration[];\n}\n\n/**\n * Authentication related configuration.\n * @beta\n */\nexport interface AuthenticationConfiguration {\n /**\n * Hostname of AAD authority. Default value comes from M365_AUTHORITY_HOST environment variable.\n *\n * @readonly\n */\n readonly authorityHost?: string;\n\n /**\n * AAD tenant id, default value comes from M365_TENANT_ID environment variable.\n *\n * @readonly\n */\n readonly tenantId?: string;\n\n /**\n * The client (application) ID of an App Registration in the tenant, default value comes from M365_CLIENT_ID environment variable\n *\n * @readonly\n */\n readonly clientId?: string;\n\n /**\n * Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal. Default value comes from M365_CLIENT_SECRET environment variable\n *\n * @readonly\n */\n readonly clientSecret?: string;\n\n /**\n * The content of a PEM-encoded public/private key certificate.\n *\n * @readonly\n */\n readonly certificateContent?: string;\n\n /**\n * Endpoint of auth service provisioned by Teams Framework. Default value comes from SIMPLE_AUTH_ENDPOINT environment variable.\n *\n * @readonly\n */\n readonly simpleAuthEndpoint?: string;\n\n /**\n * Login page for Teams to redirect to. Default value comes from INITIATE_LOGIN_ENDPOINT environment variable.\n *\n * @readonly\n */\n readonly initiateLoginEndpoint?: string;\n\n /**\n * Application ID URI. Default value comes from M365_APPLICATION_ID_URI environment variable.\n */\n readonly applicationIdUri?: string;\n}\n\n/**\n * Configuration for resources.\n * @beta\n */\nexport interface ResourceConfiguration {\n /**\n * Resource type.\n *\n * @readonly\n */\n readonly type: ResourceType;\n\n /**\n * Resource name.\n *\n * @readonly\n */\n readonly name: string;\n\n /**\n * Config for the resource.\n *\n * @readonly\n */\n readonly properties: { [index: string]: any };\n}\n\n/**\n * Available resource type.\n * @beta\n */\nexport enum ResourceType {\n /**\n * SQL database.\n *\n */\n SQL,\n\n /**\n * Rest API.\n *\n */\n API,\n}\n"]}
@@ -46,7 +46,7 @@ export function getLogLevel() {
46
46
  }
47
47
  class InternalLogger {
48
48
  constructor() {
49
- this.level = LogLevel.Info;
49
+ this.level = undefined;
50
50
  this.defaultLogger = {
51
51
  verbose: console.debug,
52
52
  info: console.info,
@@ -73,7 +73,7 @@ class InternalLogger {
73
73
  const timestamp = new Date().toUTCString();
74
74
  const logHeader = `[${timestamp}] : @microsoft/teamsfx : ${LogLevel[logLevel]} - `;
75
75
  const logMessage = `${logHeader}${message}`;
76
- if (this.level <= logLevel) {
76
+ if (this.level !== undefined && this.level <= logLevel) {
77
77
  if (this.customLogger) {
78
78
  logFunction(this.customLogger)(logMessage);
79
79
  }
@@ -93,10 +93,20 @@ class InternalLogger {
93
93
  */
94
94
  export const internalLogger = new InternalLogger();
95
95
  /**
96
- * Set custom logger. Use the output function if it's set. Priority is higher than setLogFunction.
96
+ * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
97
97
  *
98
98
  * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
99
99
  *
100
+ * @example
101
+ * ```typescript
102
+ * setLogger({
103
+ * verbose: console.debug,
104
+ * info: console.info,
105
+ * warn: console.warn,
106
+ * error: console.error,
107
+ * });
108
+ * ```
109
+ *
100
110
  * @beta
101
111
  */
102
112
  export function setLogger(logger) {
@@ -107,6 +117,15 @@ export function setLogger(logger) {
107
117
  *
108
118
  * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
109
119
  *
120
+ * @example
121
+ * ```typescript
122
+ * setLogFunction((level: LogLevel, message: string) => {
123
+ * if (level === LogLevel.Error) {
124
+ * console.log(message);
125
+ * }
126
+ * });
127
+ * ```
128
+ *
110
129
  * @beta
111
130
  */
112
131
  export function setLogFunction(logFunction) {
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAgClC;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAiBX;AAjBD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAO,CAAA;IACP;;OAEG;IACH,uCAAI,CAAA;IACJ;;OAEG;IACH,uCAAI,CAAA;IACJ;;OAEG;IACH,yCAAK,CAAA;AACP,CAAC,EAjBW,QAAQ,KAAR,QAAQ,QAiBnB;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,cAAc,CAAC,KAAK,GAAG,KAAK,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,cAAc,CAAC,KAAK,CAAC;AAC9B,CAAC;AAED,MAAM,cAAc;IAApB;QACS,UAAK,GAAa,QAAQ,CAAC,IA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AAQ,EAAE;YAC1B,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC;aAC5C;iBAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBACjC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;aAC9C;iBAAM;gBACL,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC;aAC7C;SACF;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmB,IAAI,cAAc,EAAE,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,MAAe;IACvC,cAAc,CAAC,YAAY,GAAG,MAAM,CAAC;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,WAAyB;IACtD,cAAc,CAAC,iBAAiB,GAAG,WAAW,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Interface for customized logger.\n * @beta\n */\nexport interface Logger {\n /**\n * Writes to error level logging or lower.\n */\n error(message: string): void;\n /**\n * Writes to warning level logging or lower.\n */\n warn(message: string): void;\n /**\n * Writes to info level logging or lower.\n */\n info(message: string): void;\n /**\n * Writes to verbose level logging.\n */\n verbose(message: string): void;\n}\n\n/**\n * Log function for customized logging.\n *\n * @beta\n */\nexport type LogFunction = (level: LogLevel, message: string) => void;\n\n/**\n * Log level.\n *\n * @beta\n */\nexport enum LogLevel {\n /**\n * Show verbose, information, warning and error message.\n */\n Verbose,\n /**\n * Show information, warning and error message.\n */\n Info,\n /**\n * Show warning and error message.\n */\n Warn,\n /**\n * Show error message.\n */\n Error,\n}\n\n/**\n * Update log level helper.\n *\n * @param { LogLevel } level - log level in configuration\n *\n * @beta\n */\nexport function setLogLevel(level: LogLevel): void {\n internalLogger.level = level;\n}\n\n/**\n * Get log level.\n *\n * @returns Log level\n *\n * @beta\n */\nexport function getLogLevel(): LogLevel {\n return internalLogger.level;\n}\n\nclass InternalLogger {\n public level: LogLevel = LogLevel.Info;\n\n public customLogger: Logger | undefined;\n public customLogFunction: LogFunction | undefined;\n private defaultLogger: Logger = {\n verbose: console.debug,\n info: console.info,\n warn: console.warn,\n error: console.error,\n };\n\n public error(message: string): void {\n this.log(LogLevel.Error, (x: Logger) => x.error, message);\n }\n\n public warn(message: string): void {\n this.log(LogLevel.Warn, (x: Logger) => x.warn, message);\n }\n\n public info(message: string): void {\n this.log(LogLevel.Info, (x: Logger) => x.info, message);\n }\n\n public verbose(message: string): void {\n this.log(LogLevel.Verbose, (x: Logger) => x.verbose, message);\n }\n\n private log(\n logLevel: LogLevel,\n logFunction: (x: Logger) => (message: string) => void,\n message: string\n ): void {\n if (message.trim() === \"\") {\n return;\n }\n const timestamp = new Date().toUTCString();\n const logHeader = `[${timestamp}] : @microsoft/teamsfx : ${LogLevel[logLevel]} - `;\n const logMessage = `${logHeader}${message}`;\n if (this.level <= logLevel) {\n if (this.customLogger) {\n logFunction(this.customLogger)(logMessage);\n } else if (this.customLogFunction) {\n this.customLogFunction(logLevel, logMessage);\n } else {\n logFunction(this.defaultLogger)(logMessage);\n }\n }\n }\n}\n\n/**\n * Logger instance used internally\n *\n * @internal\n */\nexport const internalLogger: InternalLogger = new InternalLogger();\n\n/**\n * Set custom logger. Use the output function if it's set. Priority is higher than setLogFunction.\n *\n * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.\n *\n * @beta\n */\nexport function setLogger(logger?: Logger): void {\n internalLogger.customLogger = logger;\n}\n\n/**\n * Set custom log function. Use the function if it's set. Priority is lower than setLogger.\n *\n * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.\n *\n * @beta\n */\nexport function setLogFunction(logFunction?: LogFunction): void {\n internalLogger.customLogFunction = logFunction;\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","s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Content":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Interface for customized logger.\n * @beta\n */\nexport interface Logger {\n /**\n * Writes to error level logging or lower.\n */\n error(message: string): void;\n /**\n * Writes to warning level logging or lower.\n */\n warn(message: string): void;\n /**\n * Writes to info level logging or lower.\n */\n info(message: string): void;\n /**\n * Writes to verbose level logging.\n */\n verbose(message: string): void;\n}\n\n/**\n * Log function for customized logging.\n *\n * @beta\n */\nexport type LogFunction = (level: LogLevel, message: string) => void;\n\n/**\n * Log level.\n *\n * @beta\n */\nexport enum LogLevel {\n /**\n * Show verbose, information, warning and error message.\n */\n Verbose,\n /**\n * Show information, warning and error message.\n */\n Info,\n /**\n * Show warning and error message.\n */\n Warn,\n /**\n * Show error message.\n */\n Error,\n}\n\n/**\n * Update log level helper.\n *\n * @param { LogLevel } level - log level in configuration\n *\n * @beta\n */\nexport function setLogLevel(level: LogLevel): void {\n internalLogger.level = level;\n}\n\n/**\n * Get log level.\n *\n * @returns Log level\n *\n * @beta\n */\nexport function getLogLevel(): LogLevel | undefined {\n return internalLogger.level;\n}\n\nclass InternalLogger {\n public level?: LogLevel = undefined;\n\n public customLogger: Logger | undefined;\n public customLogFunction: LogFunction | undefined;\n private defaultLogger: Logger = {\n verbose: console.debug,\n info: console.info,\n warn: console.warn,\n error: console.error,\n };\n\n public error(message: string): void {\n this.log(LogLevel.Error, (x: Logger) => x.error, message);\n }\n\n public warn(message: string): void {\n this.log(LogLevel.Warn, (x: Logger) => x.warn, message);\n }\n\n public info(message: string): void {\n this.log(LogLevel.Info, (x: Logger) => x.info, message);\n }\n\n public verbose(message: string): void {\n this.log(LogLevel.Verbose, (x: Logger) => x.verbose, message);\n }\n\n private log(\n logLevel: LogLevel,\n logFunction: (x: Logger) => (message: string) => void,\n message: string\n ): void {\n if (message.trim() === \"\") {\n return;\n }\n const timestamp = new Date().toUTCString();\n const logHeader = `[${timestamp}] : @microsoft/teamsfx : ${LogLevel[logLevel]} - `;\n const logMessage = `${logHeader}${message}`;\n if (this.level !== undefined && this.level <= logLevel) {\n if (this.customLogger) {\n logFunction(this.customLogger)(logMessage);\n } else if (this.customLogFunction) {\n this.customLogFunction(logLevel, logMessage);\n } else {\n logFunction(this.defaultLogger)(logMessage);\n }\n }\n }\n}\n\n/**\n * Logger instance used internally\n *\n * @internal\n */\nexport const internalLogger: InternalLogger = new InternalLogger();\n\n/**\n * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.\n *\n * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.\n *\n * @example\n * ```typescript\n * setLogger({\n * verbose: console.debug,\n * info: console.info,\n * warn: console.warn,\n * error: console.error,\n * });\n * ```\n *\n * @beta\n */\nexport function setLogger(logger?: Logger): void {\n internalLogger.customLogger = logger;\n}\n\n/**\n * Set custom log function. Use the function if it's set. Priority is lower than setLogger.\n *\n * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.\n *\n * @example\n * ```typescript\n * setLogFunction((level: LogLevel, message: string) => {\n * if (level === LogLevel.Error) {\n * console.log(message);\n * }\n * });\n * ```\n *\n * @beta\n */\nexport function setLogFunction(logFunction?: LogFunction): void {\n internalLogger.customLogFunction = logFunction;\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  import { ErrorWithCode, ErrorCode } from "../core/errors";
4
4
  import jwt_decode from "jwt-decode";
5
5
  import { internalLogger } from "./logger";
6
+ import { createHash } from "crypto";
6
7
  /**
7
8
  * Parse jwt token payload
8
9
  *
@@ -89,4 +90,41 @@ export function validateScopesType(value) {
89
90
  internalLogger.error(errorMsg);
90
91
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
91
92
  }
93
+ /**
94
+ * @internal
95
+ */
96
+ export function getScopesArray(scopes) {
97
+ const scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
98
+ return scopesArray.filter((x) => x !== null && x !== "");
99
+ }
100
+ /**
101
+ * @internal
102
+ */
103
+ export function getAuthority(authorityHost, tenantId) {
104
+ const normalizedAuthorityHost = authorityHost.replace(/\/+$/g, "");
105
+ return normalizedAuthorityHost + "/" + tenantId;
106
+ }
107
+ /**
108
+ * @internal
109
+ */
110
+ export function parseCertificate(certificateContent) {
111
+ if (!certificateContent) {
112
+ return undefined;
113
+ }
114
+ const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/;
115
+ const match = certificatePattern.exec(certificateContent);
116
+ if (!match) {
117
+ const errorMsg = "The certificate content does not contain a PEM-encoded certificate.";
118
+ internalLogger.error(errorMsg);
119
+ throw new ErrorWithCode(errorMsg, ErrorCode.InvalidCertificate);
120
+ }
121
+ const thumbprint = createHash("sha1")
122
+ .update(Buffer.from(match[3], "base64"))
123
+ .digest("hex")
124
+ .toUpperCase();
125
+ return {
126
+ thumbprint: thumbprint,
127
+ privateKey: certificateContent,
128
+ };
129
+ }
92
130
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI;QACF,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAqB,CAAC;QACvD,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC9B,MAAM,IAAI,aAAa,CACrB,qDAAqD,EACrD,SAAS,CAAC,aAAa,CACxB,CAAC;SACH;QAED,OAAO,QAAQ,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,QAAQ,GAAG,i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AC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,SAAS;IACT,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QACxD,OAAO;KACR;IAED,cAAc;IACd,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAC9C,OAAO;KACR;IAED,eAAe;IACf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE;QAC/F,OAAO;KACR;IAED,MAAM,QAAQ,GAAG,oEAAoE,CAAC;IACtF,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;AAChE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ErrorWithCode, ErrorCode } from \"../core/errors\";\nimport { SSOTokenInfoBase, SSOTokenV1Info, SSOTokenV2Info } from \"../models/ssoTokenInfo\";\nimport { UserInfo } from \"../models/userinfo\";\nimport jwt_decode from \"jwt-decode\";\nimport { internalLogger } from \"./logger\";\n\n/**\n * Parse jwt token payload\n *\n * @param token\n *\n * @returns Payload object\n *\n * @internal\n */\nexport function parseJwt(token: string): SSOTokenInfoBase {\n try {\n const tokenObj = jwt_decode(token) as SSOTokenInfoBase;\n if (!tokenObj || !tokenObj.exp) {\n throw new ErrorWithCode(\n \"Decoded token is null or exp claim does not exists.\",\n ErrorCode.InternalError\n );\n }\n\n return tokenObj;\n } catch (err) {\n const errorMsg = \"Parse jwt token failed in node env with error: \" + err.message;\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);\n }\n}\n\n/**\n * @internal\n */\nexport function getUserInfoFromSsoToken(ssoToken: string): UserInfo {\n if (!ssoToken) {\n const errorMsg = \"SSO token is undefined.\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);\n }\n const tokenObject = parseJwt(ssoToken) as SSOTokenV1Info | SSOTokenV2Info;\n\n const userInfo: UserInfo = {\n displayName: tokenObject.name,\n objectId: tokenObject.oid,\n preferredUserName: \"\",\n };\n\n if (tokenObject.ver === \"2.0\") {\n userInfo.preferredUserName = (tokenObject as SSOTokenV2Info).preferred_username;\n } else if (tokenObject.ver === \"1.0\") {\n userInfo.preferredUserName = (tokenObject as SSOTokenV1Info).upn;\n }\n return userInfo;\n}\n\n/**\n * Format string template with replacements\n *\n * ```typescript\n * const template = \"{0} and {1} are fruit. {0} is my favorite one.\"\n * const formattedStr = formatString(template, \"apple\", \"pear\"); // formattedStr: \"apple and pear are fruit. apple is my favorite one.\"\n * ```\n *\n * @param str string template\n * @param replacements replacement string array\n * @returns Formatted string\n *\n * @internal\n */\nexport function formatString(str: string, ...replacements: string[]): string {\n const args = replacements;\n return str.replace(/{(\\d+)}/g, function (match, number) {\n return typeof args[number] != \"undefined\" ? args[number] : match;\n });\n}\n\n/**\n * @internal\n */\nexport function validateScopesType(value: any): void {\n // string\n if (typeof value === \"string\" || value instanceof String) {\n return;\n }\n\n // empty array\n if (Array.isArray(value) && value.length === 0) {\n return;\n }\n\n // string array\n if (Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === \"string\")) {\n return;\n }\n\n const errorMsg = \"The type of scopes is not valid, it must be string or string array\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/util/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE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ode, ErrorCode } from \"../core/errors\";\nimport { SSOTokenInfoBase, SSOTokenV1Info, SSOTokenV2Info } from \"../models/ssoTokenInfo\";\nimport { UserInfo } from \"../models/userinfo\";\nimport jwt_decode from \"jwt-decode\";\nimport { internalLogger } from \"./logger\";\nimport { createHash } from \"crypto\";\n\n/**\n * Parse jwt token payload\n *\n * @param token\n *\n * @returns Payload object\n *\n * @internal\n */\nexport function parseJwt(token: string): SSOTokenInfoBase {\n try {\n const tokenObj = jwt_decode(token) as SSOTokenInfoBase;\n if (!tokenObj || !tokenObj.exp) {\n throw new ErrorWithCode(\n \"Decoded token is null or exp claim does not exists.\",\n ErrorCode.InternalError\n );\n }\n\n return tokenObj;\n } catch (err: any) {\n const errorMsg = \"Parse jwt token failed in node env with error: \" + err.message;\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);\n }\n}\n\n/**\n * @internal\n */\nexport function getUserInfoFromSsoToken(ssoToken: string): UserInfo {\n if (!ssoToken) {\n const errorMsg = \"SSO token is undefined.\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);\n }\n const tokenObject = parseJwt(ssoToken) as SSOTokenV1Info | SSOTokenV2Info;\n\n const userInfo: UserInfo = {\n displayName: tokenObject.name,\n objectId: tokenObject.oid,\n preferredUserName: \"\",\n };\n\n if (tokenObject.ver === \"2.0\") {\n userInfo.preferredUserName = (tokenObject as SSOTokenV2Info).preferred_username;\n } else if (tokenObject.ver === \"1.0\") {\n userInfo.preferredUserName = (tokenObject as SSOTokenV1Info).upn;\n }\n return userInfo;\n}\n\n/**\n * Format string template with replacements\n *\n * ```typescript\n * const template = \"{0} and {1} are fruit. {0} is my favorite one.\"\n * const formattedStr = formatString(template, \"apple\", \"pear\"); // formattedStr: \"apple and pear are fruit. apple is my favorite one.\"\n * ```\n *\n * @param str string template\n * @param replacements replacement string array\n * @returns Formatted string\n *\n * @internal\n */\nexport function formatString(str: string, ...replacements: string[]): string {\n const args = replacements;\n return str.replace(/{(\\d+)}/g, function (match, number) {\n return typeof args[number] != \"undefined\" ? args[number] : match;\n });\n}\n\n/**\n * @internal\n */\nexport function validateScopesType(value: any): void {\n // string\n if (typeof value === \"string\" || value instanceof String) {\n return;\n }\n\n // empty array\n if (Array.isArray(value) && value.length === 0) {\n return;\n }\n\n // string array\n if (Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === \"string\")) {\n return;\n }\n\n const errorMsg = \"The type of scopes is not valid, it must be string or string array\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);\n}\n\n/**\n * @internal\n */\nexport function getScopesArray(scopes: string | string[]): string[] {\n const scopesArray: string[] = typeof scopes === \"string\" ? scopes.split(\" \") : scopes;\n return scopesArray.filter((x) => x !== null && x !== \"\");\n}\n\n/**\n * @internal\n */\nexport function getAuthority(authorityHost: string, tenantId: string): string {\n const normalizedAuthorityHost = authorityHost.replace(/\\/+$/g, \"\");\n return normalizedAuthorityHost + \"/\" + tenantId;\n}\n\n/**\n * @internal\n */\nexport function parseCertificate(\n certificateContent: string | undefined\n): ClientCertificate | undefined {\n if (!certificateContent) {\n return undefined;\n }\n\n const certificatePattern =\n /(-+BEGIN CERTIFICATE-+)(\\n\\r?|\\r\\n?)([A-Za-z0-9+/\\n\\r]+=*)(\\n\\r?|\\r\\n?)(-+END CERTIFICATE-+)/;\n const match = certificatePattern.exec(certificateContent);\n if (!match) {\n const errorMsg = \"The certificate content does not contain a PEM-encoded certificate.\";\n internalLogger.error(errorMsg);\n throw new ErrorWithCode(errorMsg, ErrorCode.InvalidCertificate);\n }\n const thumbprint = createHash(\"sha1\")\n .update(Buffer.from(match[3], \"base64\"))\n .digest(\"hex\")\n .toUpperCase();\n\n return {\n thumbprint: thumbprint,\n privateKey: certificateContent,\n };\n}\n\n/**\n * @internal\n */\nexport interface ClientCertificate {\n thumbprint: string;\n privateKey: string;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { ConfidentialClientApplication } from "@azure/msal-node";
2
+ import { getAuthority, parseCertificate } from "./utils";
3
+ /**
4
+ * @internal
5
+ */
6
+ export function createConfidentialClientApplication(authentication) {
7
+ const authority = getAuthority(authentication.authorityHost, authentication.tenantId);
8
+ const clientCertificate = parseCertificate(authentication.certificateContent);
9
+ const auth = {
10
+ clientId: authentication.clientId,
11
+ authority: authority,
12
+ };
13
+ if (clientCertificate) {
14
+ auth.clientCertificate = clientCertificate;
15
+ }
16
+ else {
17
+ auth.clientSecret = authentication.clientSecret;
18
+ }
19
+ return new ConfidentialClientApplication({
20
+ auth,
21
+ });
22
+ }
23
+ //# sourceMappingURL=utils.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.node.js","sourceRoot":"","sources":["../../../src/util/utils.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAmB,MAAM,kBAAkB,CAAC;AAElF,OAAO,EAAqB,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,mCAAmC,CACjD,cAA2C;IAE3C,MAAM,SAAS,GAAG,YAAY,CAAC,cAAc,CAAC,aAAc,EAAE,cAAc,CAAC,QAAS,CAAC,CAAC;IACxF,MAAM,iBAAiB,GAAkC,gBAAgB,CACvE,cAAc,CAAC,kBAAkB,CAClC,CAAC;IAEF,MAAM,IAAI,GAAoB;QAC5B,QAAQ,EAAE,cAAc,CAAC,QAAS;QAClC,SAAS,EAAE,SAAS;KACrB,CAAC;IAEF,IAAI,iBAAiB,EAAE;QACrB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;KAC5C;SAAM;QACL,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC;KACjD;IAED,OAAO,IAAI,6BAA6B,CAAC;QACvC,IAAI;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { ConfidentialClientApplication, NodeAuthOptions } from \"@azure/msal-node\";\nimport { AuthenticationConfiguration } from \"../models/configuration\";\nimport { ClientCertificate, getAuthority, parseCertificate } from \"./utils\";\n\n/**\n * @internal\n */\nexport function createConfidentialClientApplication(\n authentication: AuthenticationConfiguration\n): ConfidentialClientApplication {\n const authority = getAuthority(authentication.authorityHost!, authentication.tenantId!);\n const clientCertificate: ClientCertificate | undefined = parseCertificate(\n authentication.certificateContent\n );\n\n const auth: NodeAuthOptions = {\n clientId: authentication.clientId!,\n authority: authority,\n };\n\n if (clientCertificate) {\n auth.clientCertificate = clientCertificate;\n } else {\n auth.clientSecret = authentication.clientSecret;\n }\n\n return new ConfidentialClientApplication({\n auth,\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "0.3.0-alpha.def66483.0",
3
+ "version": "0.3.0-rc.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist-esm/src/index.js",
@@ -17,27 +17,29 @@
17
17
  "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
18
18
  "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
19
19
  "build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
20
- "build": "tsc -p . && npm run build:node && api-extractor run --local",
20
+ "build": "tsc -p . && npm run build:node && api-extractor run --local && npm run build:api-markdown",
21
21
  "prepare": "npm run build",
22
- "build:api-markdown": "tsc -p . && api-extractor run --local && api-documenter markdown -i temp -o ../../docs/sdk",
22
+ "build:api-markdown": "api-documenter generate -i temp -o ../../docs/sdk",
23
23
  "check-format": "prettier --list-different --config ./.prettierrc.json --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples/**/*.ts\" \"*.{js,json}\"",
24
24
  "clean": "rimraf dist dist-* temp types *.tgz *.log",
25
25
  "format": "prettier --write --config ./.prettierrc.json --ignore-path ./.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples/**/*.ts\" \"*.{js,json}\"",
26
- "integration-test:browser-case": "karma start --single-run --glob=./dist-test/index.integration.browser.js",
27
- "integration-test:browser": "node test/integration/scripts/DownloadSimpleAuth.js && concurrently --kill-others --success first \"node test/integration/scripts/StartSimpleAuth.js\" \"npm run integration-test:browser-case\"",
28
- "integration-test:node": "mocha -r test/mocha.env.ts -r ts-node/register \"./test/integration/node/*.spec.ts\" --timeout 100000 --exit --reporter ./tools/mocha-multi-reporter.js",
29
- "test:integration": "npm run integration-test:node && npm run integration-test:browser",
26
+ "e2e-test:browser-case": "karma start --single-run --glob=./dist-test/index.e2e.browser.js",
27
+ "e2e-test:browser": "node test/e2e/scripts/DownloadSimpleAuth.js && concurrently --kill-others --success first \"node test/e2e/scripts/StartSimpleAuth.js\" \"npm run e2e-test:browser-case\"",
28
+ "e2e-test:node": "mocha -r test/mocha.env.ts -r ts-node/register \"./test/e2e/node/*.spec.ts\" --timeout 100000 --exit --reporter ./tools/mocha-multi-reporter.js",
29
+ "test:e2e": "npm run e2e-test:node && npm run e2e-test:browser",
30
30
  "lint:staged": "lint-staged",
31
31
  "lint": "eslint \"**/*.ts\"",
32
32
  "prebuild": "npm run clean",
33
- "test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
34
- "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
35
- "test": "npm run test:unit && npm run test:integration",
33
+ "test:browser": "npm run build:test && npm run unit-test:browser && npm run e2e-test:browser",
34
+ "test:node": "npm run build:test && npm run unit-test:node && npm run e2e-test:node",
35
+ "test": "npm run test:unit && npm run test:e2e",
36
36
  "unit-test:browser": "karma start --single-run --glob=./dist-test/index.unit.browser.js",
37
- "unit-test:node": "mocha dist-test/index.node.js --reporter ./tools/mocha-multi-reporter.js",
37
+ "unit-test:node": "nyc mocha --no-timeouts -r test/mocha.env.ts --require ts-node/register \"test/unit/node/**/*.spec.ts\" \"test/unit/*.spec.ts\"",
38
38
  "test:unit": "npm run build:test && npm run unit-test:node && npm run unit-test:browser",
39
- "e2e-test": "mocha --no-timeouts -r test/mocha.env.ts -r ts-node/register test/e2e/**/*.spec.ts --exit",
40
- "precommit": "lint-staged"
39
+ "ui-test": "mocha --no-timeouts -r test/mocha.env.ts -r ts-node/register test/ui/**/*.spec.ts --exit",
40
+ "precommit": "lint-staged",
41
+ "version": "../../.github/scripts/pkg-version.sh templates",
42
+ "postversion": "../../.github/scripts/pkg-postversion.sh templates"
41
43
  },
42
44
  "files": [
43
45
  "dist/",
@@ -66,8 +68,9 @@
66
68
  "@microsoft/microsoft-graph-client": "^2.2.1",
67
69
  "@microsoft/teams-js": "^1.9.0",
68
70
  "axios": "^0.21.1",
69
- "botbuilder-core": ">=4.9.3 <5.0.0",
70
- "botbuilder-dialogs": ">=4.9.3 < 5.0.0",
71
+ "botbuilder": ">=4.9.4 <5.0.0",
72
+ "botbuilder-core": ">=4.9.4 <5.0.0",
73
+ "botbuilder-dialogs": ">=4.9.4 <5.0.0",
71
74
  "jwt-decode": "^3.1.2",
72
75
  "memory-cache": "^0.2.0",
73
76
  "tedious": "^9.2.1",
@@ -79,6 +82,7 @@
79
82
  "@azure/ms-rest-nodeauth": "^3.0.6",
80
83
  "@commitlint/cli": "^12.0.1",
81
84
  "@commitlint/config-conventional": "^12.0.1",
85
+ "@istanbuljs/nyc-config-typescript": "^1.0.1",
82
86
  "@microsoft/api-documenter": "^7.12.4",
83
87
  "@microsoft/api-extractor": "7.7.11",
84
88
  "@rollup/plugin-commonjs": "^13.0.2",
@@ -107,6 +111,7 @@
107
111
  "cross-env": "^7.0.2",
108
112
  "dotenv": "^8.2.0",
109
113
  "eslint": "^7.15.0",
114
+ "eslint-plugin-prettier": "^4.0.0",
110
115
  "fs-extra": "^9.1.0",
111
116
  "got": "^11.8.2",
112
117
  "isomorphic-fetch": "^3.0.0",
@@ -127,27 +132,27 @@
127
132
  "mocked-env": "^1.3.2",
128
133
  "nyc": "^15.1.0",
129
134
  "playwright-chromium": "^1.11.1",
135
+ "prettier": "^2.4.1",
130
136
  "puppeteer": "^9.1.1",
131
137
  "rimraf": "^3.0.0",
132
138
  "rollup": "^2.41.0",
133
139
  "rollup-plugin-sourcemaps": "^0.4.2",
134
140
  "rollup-plugin-terser": "^5.1.1",
141
+ "semver": "^7.3.5",
135
142
  "sinon": "^9.2.4",
143
+ "source-map-support": "^0.5.19",
136
144
  "ts-node": "^9.1.1",
137
145
  "typescript": "^4.1.2",
138
146
  "url-join": "^4.0.1",
139
147
  "util": "^0.12.1"
140
148
  },
141
- "gitHead": "def66483a50973522f9c45ba61e5366d51f5d050",
149
+ "gitHead": "8dabf9f0c48b989af24e4460dfc4d03b7a8763f3",
142
150
  "publishConfig": {
143
151
  "access": "public"
144
152
  },
145
153
  "lint-staged": {
146
154
  "*.{js,jsx,css,ts,tsx}": [
147
155
  "npx eslint --cache --fix --quiet"
148
- ],
149
- "*": [
150
- "npx prettier --config .prettierrc.js --ignore-unknown --write --ignore-path .prettierignore "
151
156
  ]
152
157
  }
153
158
  }