@microsoft/m365-spec-parser 0.2.4-alpha.ad0d7aa1a.0 → 0.2.4-alpha.af47bc3a8.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.
@@ -146,12 +146,7 @@ ConstantString.AdaptiveCardType = "AdaptiveCard";
146
146
  ConstantString.TextBlockType = "TextBlock";
147
147
  ConstantString.ImageType = "Image";
148
148
  ConstantString.ContainerType = "Container";
149
- ConstantString.RegistrationIdPostfix = {
150
- apiKey: "REGISTRATION_ID",
151
- oauth2: "CONFIGURATION_ID",
152
- http: "REGISTRATION_ID",
153
- openIdConnect: "REGISTRATION_ID",
154
- };
149
+ ConstantString.RegistrationIdPostfix = "REGISTRATION_ID";
155
150
  ConstantString.ResponseCodeFor20X = [
156
151
  "200",
157
152
  "201",
@@ -163,6 +158,7 @@ ConstantString.ResponseCodeFor20X = [
163
158
  "207",
164
159
  "208",
165
160
  "226",
161
+ "2XX",
166
162
  "default",
167
163
  ];
168
164
  ConstantString.AllOperationMethods = [
@@ -232,6 +228,9 @@ class Utils {
232
228
  static isAPIKeyAuth(authScheme) {
233
229
  return authScheme.type === "apiKey";
234
230
  }
231
+ static isAPIKeyAuthButNotInCookie(authScheme) {
232
+ return authScheme.type === "apiKey" && authScheme.in !== "cookie";
233
+ }
235
234
  static isOAuthWithAuthCodeFlow(authScheme) {
236
235
  return !!(authScheme.type === "oauth2" &&
237
236
  authScheme.flows &&
@@ -247,7 +246,8 @@ class Utils {
247
246
  for (const auths of authSchemeArray) {
248
247
  if (auths.length === 1) {
249
248
  if (Utils.isOAuthWithAuthCodeFlow(auths[0].authScheme) ||
250
- Utils.isBearerTokenAuth(auths[0].authScheme)) {
249
+ Utils.isBearerTokenAuth(auths[0].authScheme) ||
250
+ Utils.isAPIKeyAuthButNotInCookie(auths[0].authScheme)) {
251
251
  return false;
252
252
  }
253
253
  }
@@ -278,6 +278,20 @@ class Utils {
278
278
  result.sort((a, b) => a[0].name.localeCompare(b[0].name));
279
279
  return result;
280
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
+ }
281
295
  static getAuthInfo(spec) {
282
296
  let authInfo = undefined;
283
297
  for (const url in spec.paths) {