@backstage-community/plugin-servicenow-backend 1.11.0 → 1.11.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage-community/plugin-servicenow-backend
2
2
 
3
+ ## 1.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 85f6e69: Bump axios to 1.16.0 to include different security fixes.
8
+
3
9
  ## 1.11.0
4
10
 
5
11
  ### Minor Changes
@@ -26,8 +26,8 @@ class ServiceNowSchemaChecker {
26
26
  if (response.status !== 200) {
27
27
  throw new Error(`ServiceNow API returned status ${response.status}`);
28
28
  }
29
- const contentType = response.headers["content-type"] ?? "";
30
- if (!contentType.includes("application/json")) {
29
+ const contentType = response.headers["content-type"];
30
+ if (!contentType || typeof contentType === "string" && !contentType.includes("application/json") || Array.isArray(contentType) && !contentType.some((ct) => ct.includes("application/json")) || !Array.isArray(contentType) && typeof contentType === "object" && !contentType.hasContentType("application/json")) {
31
31
  throw new Error(
32
32
  `Expected JSON response but got Content-Type: ${contentType}`
33
33
  );
@@ -1 +1 @@
1
- {"version":3,"file":"schema-checker.cjs.js","sources":["../../src/service-now-rest/schema-checker.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceNowConnection } from './connection';\n\ntype CachedSchema = {\n fields: Set<string>;\n fetchedAt: number;\n};\n\nconst INCIDENT_TABLE_NAME = 'incident';\nconst SCHEMA_TTL_MS = 5 * 60 * 1000; // 5 minutes cache timeout\n\nexport class ServiceNowSchemaChecker {\n private cache?: CachedSchema;\n\n constructor(private readonly conn: ServiceNowConnection) {}\n\n private async fetchIncidentSchema(): Promise<Set<string>> {\n try {\n const authHeaders = await this.conn.getAuthHeaders();\n const url = `api/now/table/sys_dictionary`;\n\n const response = await this.conn.getAxiosInstance().get(url, {\n headers: {\n ...authHeaders,\n Accept: 'application/json',\n },\n params: {\n sysparm_query: `name=${INCIDENT_TABLE_NAME}`,\n sysparm_fields: 'element',\n sysparm_limit: 500,\n },\n responseType: 'json',\n });\n\n if (response.status !== 200) {\n throw new Error(`ServiceNow API returned status ${response.status}`);\n }\n\n const contentType = response.headers['content-type'] ?? '';\n if (!contentType.includes('application/json')) {\n throw new Error(\n `Expected JSON response but got Content-Type: ${contentType}`,\n );\n }\n\n const data = response.data;\n if (!data || typeof data !== 'object') {\n throw new Error('ServiceNow API returned invalid JSON response');\n }\n\n if (data.error) {\n throw new Error(`ServiceNow API Error: ${data.error.message}`);\n }\n\n const result = data.result ?? [];\n return new Set(result.map((r: any) => r.element));\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Failed to fetch incident schema: ${e.message}`);\n }\n throw e;\n }\n }\n\n private async getIncidentFields(): Promise<Set<string>> {\n const now = Date.now();\n\n if (this.cache && now - this.cache.fetchedAt < SCHEMA_TTL_MS) {\n return this.cache.fields;\n }\n\n const fields = await this.fetchIncidentSchema();\n\n this.cache = {\n fields,\n fetchedAt: now,\n };\n\n return fields;\n }\n\n public async fieldExists(...fields: string[]): Promise<boolean> {\n if (fields.length === 0) {\n return true;\n }\n const incidentFields = await this.getIncidentFields();\n return fields.every(field => incidentFields.has(field));\n }\n}\n"],"names":[],"mappings":";;AAuBA,MAAM,mBAAA,GAAsB,UAAA;AAC5B,MAAM,aAAA,GAAgB,IAAI,EAAA,GAAK,GAAA;AAExB,MAAM,uBAAA,CAAwB;AAAA,EAGnC,YAA6B,IAAA,EAA4B;AAA5B,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAA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A,CAAE,CAAA;AAAA,MAC/D;AAEA,MAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,IAAU,EAAC;AAC/B,MAAA,OAAO,IAAI,IAAI,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA,KAAW,CAAA,CAAE,OAAO,CAAC,CAAA;AAAA,IAClD,SAAS,CAAA,EAAG;AACV,MAAA,IAAI,aAAa,KAAA,EAAO;AACtB,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,iCAAA,EAAoC,CAAA,CAAE,OAAO,CAAA,CAAE,CAAA;AAAA,MACjE;AACA,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAc,iBAAA,GAA0C;AACtD,IAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AAErB,IAAA,IAAI,KAAK,KAAA,IAAS,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,YAAY,aAAA,EAAe;AAC5D,MAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,IACpB;AAEA,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,mBAAA,EAAoB;AAE9C,IAAA,IAAA,CAAK,KAAA,GAAQ;AAAA,MACX,MAAA;AAAA,MACA,SAAA,EAAW;AAAA,KACb;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,MAAa,eAAe,MAAA,EAAoC;AAC9D,IAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,cAAA,GAAiB,MAAM,IAAA,CAAK,iBAAA,EAAkB;AACpD,IAAA,OAAO,OAAO,KAAA,CAAM,CAAA,KAAA,KAAS,cAAA,CAAe,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,EACxD;AACF;;;;"}
1
+ {"version":3,"file":"schema-checker.cjs.js","sources":["../../src/service-now-rest/schema-checker.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ServiceNowConnection } from './connection';\n\ntype CachedSchema = {\n fields: Set<string>;\n fetchedAt: number;\n};\n\nconst INCIDENT_TABLE_NAME = 'incident';\nconst SCHEMA_TTL_MS = 5 * 60 * 1000; // 5 minutes cache timeout\n\nexport class ServiceNowSchemaChecker {\n private cache?: CachedSchema;\n\n constructor(private readonly conn: ServiceNowConnection) {}\n\n private async fetchIncidentSchema(): Promise<Set<string>> {\n try {\n const authHeaders = await this.conn.getAuthHeaders();\n const url = `api/now/table/sys_dictionary`;\n\n const response = await this.conn.getAxiosInstance().get(url, {\n headers: {\n ...authHeaders,\n Accept: 'application/json',\n },\n params: {\n sysparm_query: `name=${INCIDENT_TABLE_NAME}`,\n sysparm_fields: 'element',\n sysparm_limit: 500,\n },\n responseType: 'json',\n });\n\n if (response.status !== 200) {\n throw new Error(`ServiceNow API returned status ${response.status}`);\n }\n\n const contentType = response.headers['content-type'];\n if (\n !contentType ||\n (typeof contentType === 'string' &&\n !contentType.includes('application/json')) ||\n (Array.isArray(contentType) &&\n !contentType.some(ct => ct.includes('application/json'))) ||\n (!Array.isArray(contentType) &&\n typeof contentType === 'object' &&\n !contentType.hasContentType('application/json'))\n ) {\n throw new Error(\n `Expected JSON response but got Content-Type: ${contentType}`,\n );\n }\n\n const data = response.data;\n if (!data || typeof data !== 'object') {\n throw new Error('ServiceNow API returned invalid JSON response');\n }\n\n if (data.error) {\n throw new Error(`ServiceNow API Error: ${data.error.message}`);\n }\n\n const result = data.result ?? [];\n return new Set(result.map((r: any) => r.element));\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Failed to fetch incident schema: ${e.message}`);\n }\n throw e;\n }\n }\n\n private async getIncidentFields(): Promise<Set<string>> {\n const now = Date.now();\n\n if (this.cache && now - this.cache.fetchedAt < SCHEMA_TTL_MS) {\n return this.cache.fields;\n }\n\n const fields = await this.fetchIncidentSchema();\n\n this.cache = {\n fields,\n fetchedAt: now,\n };\n\n return fields;\n }\n\n public async fieldExists(...fields: string[]): Promise<boolean> {\n if (fields.length === 0) {\n return true;\n }\n const incidentFields = await this.getIncidentFields();\n return fields.every(field => incidentFields.has(field));\n }\n}\n"],"names":[],"mappings":";;AAuBA,MAAM,mBAAA,GAAsB,UAAA;AAC5B,MAAM,aAAA,GAAgB,IAAI,EAAA,GAAK,GAAA;AAExB,MAAM,uBAAA,CAAwB;AAAA,EAGnC,YAA6B,IAAA,EAA4B;AAA5B,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAA6B;AAAA,EAFlD,KAAA;AAAA,EAIR,MAAc,mBAAA,GAA4C;AACxD,IAAA,IAAI;AACF,MAAA,MAAM,WAAA,GAAc,MAAM,IAAA,CAAK,IAAA,CAAK,cAAA,EAAe;AACnD,MAAA,MAAM,GAAA,GAAM,CAAA,4BAAA,CAAA;AAEZ,MAAA,MAAM,WAAW,MAAM,IAAA,CAAK,KAAK,gBAAA,EAAiB,CAAE,IAAI,GAAA,EAAK;AAAA,QAC3D,OAAA,EAAS;AAAA,UACP,GAAG,WAAA;AAAA,UACH,MAAA,EAAQ;AAAA,SACV;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,aAAA,EAAe,QAAQ,mBAAmB,CAAA,CAAA;AAAA,UAC1C,cAAA,EAAgB,SAAA;AAAA,UAChB,aAAA,EAAe;AAAA,SACjB;AAAA,QACA,YAAA,EAAc;AAAA,OACf,CAAA;AAED,MAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,+BAAA,EAAkC,QAAA,CAAS,MAAM,CAAA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;AAAA,EAEA,MAAc,iBAAA,GAA0C;AACtD,IAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AAErB,IAAA,IAAI,KAAK,KAAA,IAAS,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,YAAY,aAAA,EAAe;AAC5D,MAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,IACpB;AAEA,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,mBAAA,EAAoB;AAE9C,IAAA,IAAA,CAAK,KAAA,GAAQ;AAAA,MACX,MAAA;AAAA,MACA,SAAA,EAAW;AAAA,KACb;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,MAAa,eAAe,MAAA,EAAoC;AAC9D,IAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,cAAA,GAAiB,MAAM,IAAA,CAAK,iBAAA,EAAkB;AACpD,IAAA,OAAO,OAAO,KAAA,CAAM,CAAA,KAAA,KAAS,cAAA,CAAe,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,EACxD;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-servicenow-backend",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "@backstage/config": "^1.3.7",
43
43
  "@backstage/errors": "^1.3.0",
44
44
  "@backstage/plugin-catalog-node": "^2.2.0",
45
- "axios": "^1.9.0",
45
+ "axios": "^1.16.0",
46
46
  "express": "^4.17.1",
47
47
  "express-promise-router": "^4.1.0",
48
48
  "simple-oauth2": "^5.1.0"