@microsoft/m365-spec-parser 0.2.4-alpha.e84e1682b.0 → 0.2.4-alpha.f33089c4c.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.
- package/dist/index.esm2017.js +42 -6
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +134 -58
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +42 -6
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +137 -59
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +2 -3
- package/dist/src/interfaces.d.ts +10 -0
- package/dist/src/manifestUpdater.d.ts +3 -3
- package/dist/src/specParser.d.ts +2 -0
- package/dist/src/utils.d.ts +4 -1
- package/package.json +4 -4
package/dist/index.esm5.js
CHANGED
|
@@ -83,6 +83,7 @@ var WarningType;
|
|
|
83
83
|
WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
|
|
84
84
|
WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
|
|
85
85
|
WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
|
|
86
|
+
WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
|
|
86
87
|
WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
|
|
87
88
|
WarningType["Unknown"] = "unknown";
|
|
88
89
|
})(WarningType || (WarningType = {}));
|
|
@@ -130,6 +131,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
|
|
|
130
131
|
ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
|
|
131
132
|
ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
|
|
132
133
|
ConstantString.OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
|
|
134
|
+
ConstantString.AuthTypeIsNotSupported = "Unsupported authorization type in API '%s'. No authorization will be used.";
|
|
133
135
|
ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
|
|
134
136
|
ConstantString.FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
|
|
135
137
|
ConstantString.GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
|
|
@@ -144,12 +146,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
|
|
|
144
146
|
ConstantString.TextBlockType = "TextBlock";
|
|
145
147
|
ConstantString.ImageType = "Image";
|
|
146
148
|
ConstantString.ContainerType = "Container";
|
|
147
|
-
ConstantString.RegistrationIdPostfix =
|
|
148
|
-
apiKey: "REGISTRATION_ID",
|
|
149
|
-
oauth2: "CONFIGURATION_ID",
|
|
150
|
-
http: "REGISTRATION_ID",
|
|
151
|
-
openIdConnect: "REGISTRATION_ID",
|
|
152
|
-
};
|
|
149
|
+
ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
|
|
153
150
|
ConstantString.ResponseCodeFor20X = [
|
|
154
151
|
"200",
|
|
155
152
|
"201",
|
|
@@ -161,6 +158,7 @@ ConstantString.ResponseCodeFor20X = [
|
|
|
161
158
|
"207",
|
|
162
159
|
"208",
|
|
163
160
|
"226",
|
|
161
|
+
"2XX",
|
|
164
162
|
"default",
|
|
165
163
|
];
|
|
166
164
|
ConstantString.AllOperationMethods = [
|
|
@@ -230,11 +228,32 @@ class Utils {
|
|
|
230
228
|
static isAPIKeyAuth(authScheme) {
|
|
231
229
|
return authScheme.type === "apiKey";
|
|
232
230
|
}
|
|
231
|
+
static isAPIKeyAuthButNotInCookie(authScheme) {
|
|
232
|
+
return authScheme.type === "apiKey" && authScheme.in !== "cookie";
|
|
233
|
+
}
|
|
233
234
|
static isOAuthWithAuthCodeFlow(authScheme) {
|
|
234
235
|
return !!(authScheme.type === "oauth2" &&
|
|
235
236
|
authScheme.flows &&
|
|
236
237
|
authScheme.flows.authorizationCode);
|
|
237
238
|
}
|
|
239
|
+
static isNotSupportedAuth(authSchemeArray) {
|
|
240
|
+
if (authSchemeArray.length === 0) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (authSchemeArray.length > 0 && authSchemeArray.every((auths) => auths.length > 1)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
for (const auths of authSchemeArray) {
|
|
247
|
+
if (auths.length === 1) {
|
|
248
|
+
if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
|
|
249
|
+
Utils.isBearerTokenAuth(auths[0].authScheme) ||
|
|
250
|
+
Utils.isAPIKeyAuthButNotInCookie(auths[0].authScheme)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
238
257
|
static getAuthArray(securities, spec) {
|
|
239
258
|
var _a;
|
|
240
259
|
const result = [];
|
|
@@ -259,6 +278,20 @@ class Utils {
|
|
|
259
278
|
result.sort((a, b) => a[0].name.localeCompare(b[0].name));
|
|
260
279
|
return result;
|
|
261
280
|
}
|
|
281
|
+
static getAuthMap(spec) {
|
|
282
|
+
const authMap = {};
|
|
283
|
+
for (const url in spec.paths) {
|
|
284
|
+
for (const method in spec.paths[url]) {
|
|
285
|
+
const operation = spec.paths[url][method];
|
|
286
|
+
const authArray = Utils.getAuthArray(operation.security, spec);
|
|
287
|
+
if (authArray && authArray.length > 0) {
|
|
288
|
+
const currentAuth = authArray[0][0];
|
|
289
|
+
authMap[operation.operationId] = currentAuth;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return authMap;
|
|
294
|
+
}
|
|
262
295
|
static getAuthInfo(spec) {
|
|
263
296
|
let authInfo = undefined;
|
|
264
297
|
for (const url in spec.paths) {
|
|
@@ -729,6 +762,9 @@ class Validator {
|
|
|
729
762
|
reason: [ErrorType.MultipleAuthNotSupported],
|
|
730
763
|
};
|
|
731
764
|
}
|
|
765
|
+
if (this.projectType === ProjectType.Copilot) {
|
|
766
|
+
return { isValid: true, reason: [] };
|
|
767
|
+
}
|
|
732
768
|
for (const auths of authSchemeArray) {
|
|
733
769
|
if (auths.length === 1) {
|
|
734
770
|
if ((this.options.allowAPIKeyAuth && Utils.isAPIKeyAuth(auths[0].authScheme)) ||
|