@tenonhq/dovetail-servicenow-app 0.0.2 → 0.0.3

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/app/README.md CHANGED
@@ -17,4 +17,6 @@ package is `private`.
17
17
  Bundled now: Dovetail 2.0.20261119, 25 records, exported from the publishing instance on
18
18
  2026-11-20 (UTC) with the platform's own Export to XML. The created-by and updated-by
19
19
  names in the export were replaced with `tenonhq` before bundling; nothing else differs from the
20
- export.
20
+ export. After every new export, run `dovetail-servicenow-app neutralize`: it makes that
21
+ replacement and updates the manifest's sha256. `verify` and `pack-check` fail while any
22
+ created-by or updated-by field holds another name, so a login cannot be published.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The audit names in an exported update set. Every record carries the login of whoever
3
+ * created and last changed it (sys_created_by / sys_updated_by), on the update rows and
4
+ * again inside each row's escaped payload. This package is public, so those logins are
5
+ * replaced with one neutral name before the XML is bundled.
6
+ *
7
+ * Text-only: pure functions over the XML string. ES6 only, no optional chaining.
8
+ */
9
+ /** The name every created-by and updated-by field holds in the bundled XML. */
10
+ export declare var NEUTRAL_AUDIT_NAME: string;
11
+ /**
12
+ * Accounts every instance has. They name no person, so they stay as exported (the
13
+ * platform's own export writes "admin" on every update row).
14
+ */
15
+ export declare var PLATFORM_ACCOUNTS: ReadonlyArray<string>;
16
+ /** How many created-by and updated-by fields hold something other than the neutral name. */
17
+ export declare function countAuditLogins(params: {
18
+ xml: string;
19
+ }): number;
20
+ /** Replace every created-by and updated-by login with the neutral name. */
21
+ export declare function neutralizeAuditNames(params: {
22
+ xml: string;
23
+ }): {
24
+ xml: string;
25
+ replaced: number;
26
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * The audit names in an exported update set. Every record carries the login of whoever
4
+ * created and last changed it (sys_created_by / sys_updated_by), on the update rows and
5
+ * again inside each row's escaped payload. This package is public, so those logins are
6
+ * replaced with one neutral name before the XML is bundled.
7
+ *
8
+ * Text-only: pure functions over the XML string. ES6 only, no optional chaining.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.PLATFORM_ACCOUNTS = exports.NEUTRAL_AUDIT_NAME = void 0;
12
+ exports.countAuditLogins = countAuditLogins;
13
+ exports.neutralizeAuditNames = neutralizeAuditNames;
14
+ /** The name every created-by and updated-by field holds in the bundled XML. */
15
+ exports.NEUTRAL_AUDIT_NAME = "tenonhq";
16
+ /**
17
+ * Accounts every instance has. They name no person, so they stay as exported (the
18
+ * platform's own export writes "admin" on every update row).
19
+ */
20
+ exports.PLATFORM_ACCOUNTS = [
21
+ "admin",
22
+ "system",
23
+ "guest",
24
+ ];
25
+ // An angle bracket as it appears at any escape depth: raw, &lt;, &amp;lt; and so on.
26
+ var LT = "(?:<|&(?:amp;)*lt;)";
27
+ var GT = "(?:>|&(?:amp;)*gt;)";
28
+ /** A fresh matcher each call: a shared global regex would carry lastIndex between calls. */
29
+ function auditFieldRe() {
30
+ return new RegExp("(" +
31
+ LT +
32
+ "(sys_created_by|sys_updated_by)" +
33
+ GT +
34
+ ")([\\s\\S]*?)(" +
35
+ LT +
36
+ "/\\2" +
37
+ GT +
38
+ ")", "g");
39
+ }
40
+ function isLogin(value) {
41
+ var trimmed = value.trim();
42
+ return (trimmed.length > 0 &&
43
+ trimmed !== exports.NEUTRAL_AUDIT_NAME &&
44
+ exports.PLATFORM_ACCOUNTS.indexOf(trimmed) === -1);
45
+ }
46
+ /** How many created-by and updated-by fields hold something other than the neutral name. */
47
+ function countAuditLogins(params) {
48
+ var count = 0;
49
+ var re = auditFieldRe();
50
+ var match = re.exec(params.xml);
51
+ while (match !== null) {
52
+ if (isLogin(match[3]))
53
+ count += 1;
54
+ match = re.exec(params.xml);
55
+ }
56
+ return count;
57
+ }
58
+ /** Replace every created-by and updated-by login with the neutral name. */
59
+ function neutralizeAuditNames(params) {
60
+ var replaced = 0;
61
+ var xml = params.xml.replace(auditFieldRe(), function (all, open, _field, value, close) {
62
+ if (!isLogin(value))
63
+ return all;
64
+ replaced += 1;
65
+ return open + exports.NEUTRAL_AUDIT_NAME + close;
66
+ });
67
+ return { xml: xml, replaced: replaced };
68
+ }
package/dist/bundle.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Locate and verify the bundled app: `app/manifest.json` plus the update-set XML it
3
- * names, including that no secret-typed field in the XML still holds a value. Local
3
+ * names, including that no secret-typed field in the XML still holds a value and no
4
+ * created-by or updated-by field still holds a user login. Local
4
5
  * only — reads files, makes no network call.
5
6
  *
6
7
  * ES6 only, no optional chaining.
package/dist/bundle.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Locate and verify the bundled app: `app/manifest.json` plus the update-set XML it
4
- * names, including that no secret-typed field in the XML still holds a value. Local
4
+ * names, including that no secret-typed field in the XML still holds a value and no
5
+ * created-by or updated-by field still holds a user login. Local
5
6
  * only — reads files, makes no network call.
6
7
  *
7
8
  * ES6 only, no optional chaining.
@@ -49,6 +50,7 @@ const crypto = __importStar(require("crypto"));
49
50
  const fs = __importStar(require("fs"));
50
51
  const path = __importStar(require("path"));
51
52
  const dovetail_servicenow_1 = require("@tenonhq/dovetail-servicenow");
53
+ const auditNames_1 = require("./auditNames");
52
54
  const manifest_1 = require("./manifest");
53
55
  /** The bundled app's scope string. The Dovetail app is global-scoped, so it is always addressed by sys_id. */
54
56
  exports.DOVETAIL_APP_SCOPE = "global";
@@ -167,6 +169,15 @@ function verifyBundle(params) {
167
169
  }
168
170
  checkParsedXml({ xml: xml, manifest: manifest, problems: result.problems });
169
171
  checkSecrets({ xml: xml, problems: result.problems });
172
+ // The count only: a login must not reach a log or a CI page either.
173
+ var logins = (0, auditNames_1.countAuditLogins)({ xml: xml });
174
+ if (logins > 0) {
175
+ result.problems.push("the XML holds " +
176
+ logins +
177
+ " created-by or updated-by name(s) that are not " +
178
+ auditNames_1.NEUTRAL_AUDIT_NAME +
179
+ "; run dovetail-servicenow-app neutralize");
180
+ }
170
181
  result.ok = result.problems.length === 0;
171
182
  return result;
172
183
  }
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export { DOVETAIL_APP_SYS_ID, MANIFEST_FILE, parseManifest, isDateStampVersion,
9
9
  export type { AppManifest, ParseManifestResult } from "./manifest";
10
10
  export { verifyBundle, defaultAppDir, countUpdateXml, hasUnloadRoot, MAX_XML_BYTES, DOVETAIL_APP_SCOPE, BUNDLE_LOCATION, } from "./bundle";
11
11
  export type { BundleCheck } from "./bundle";
12
+ export { NEUTRAL_AUDIT_NAME, PLATFORM_ACCOUNTS, countAuditLogins, neutralizeAuditNames, } from "./auditNames";
13
+ export { neutralizeBundle, DEFAULT_XML_FILE } from "./neutralize";
12
14
  export { manualInstallSteps, headlessInstall, postInstallChecks, } from "./install";
13
15
  export type { InstallDeps, InstallOptions, InstallIo } from "./install";
14
16
  export { run, parseArgs, COMMANDS, packCheck, defaultInstallDeps } from "./run";
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * with helpers to locate and verify it.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.defaultInstallDeps = exports.packCheck = exports.COMMANDS = exports.parseArgs = exports.run = exports.postInstallChecks = exports.headlessInstall = exports.manualInstallSteps = exports.BUNDLE_LOCATION = exports.DOVETAIL_APP_SCOPE = exports.MAX_XML_BYTES = exports.hasUnloadRoot = exports.countUpdateXml = exports.defaultAppDir = exports.verifyBundle = exports.compareVersions = exports.isDateStampVersion = exports.parseManifest = exports.MANIFEST_FILE = exports.DOVETAIL_APP_SYS_ID = void 0;
10
+ exports.defaultInstallDeps = exports.packCheck = exports.COMMANDS = exports.parseArgs = exports.run = exports.postInstallChecks = exports.headlessInstall = exports.manualInstallSteps = exports.DEFAULT_XML_FILE = exports.neutralizeBundle = exports.neutralizeAuditNames = exports.countAuditLogins = exports.PLATFORM_ACCOUNTS = exports.NEUTRAL_AUDIT_NAME = exports.BUNDLE_LOCATION = exports.DOVETAIL_APP_SCOPE = exports.MAX_XML_BYTES = exports.hasUnloadRoot = exports.countUpdateXml = exports.defaultAppDir = exports.verifyBundle = exports.compareVersions = exports.isDateStampVersion = exports.parseManifest = exports.MANIFEST_FILE = exports.DOVETAIL_APP_SYS_ID = void 0;
11
11
  var manifest_1 = require("./manifest");
12
12
  Object.defineProperty(exports, "DOVETAIL_APP_SYS_ID", { enumerable: true, get: function () { return manifest_1.DOVETAIL_APP_SYS_ID; } });
13
13
  Object.defineProperty(exports, "MANIFEST_FILE", { enumerable: true, get: function () { return manifest_1.MANIFEST_FILE; } });
@@ -22,6 +22,14 @@ Object.defineProperty(exports, "hasUnloadRoot", { enumerable: true, get: functio
22
22
  Object.defineProperty(exports, "MAX_XML_BYTES", { enumerable: true, get: function () { return bundle_1.MAX_XML_BYTES; } });
23
23
  Object.defineProperty(exports, "DOVETAIL_APP_SCOPE", { enumerable: true, get: function () { return bundle_1.DOVETAIL_APP_SCOPE; } });
24
24
  Object.defineProperty(exports, "BUNDLE_LOCATION", { enumerable: true, get: function () { return bundle_1.BUNDLE_LOCATION; } });
25
+ var auditNames_1 = require("./auditNames");
26
+ Object.defineProperty(exports, "NEUTRAL_AUDIT_NAME", { enumerable: true, get: function () { return auditNames_1.NEUTRAL_AUDIT_NAME; } });
27
+ Object.defineProperty(exports, "PLATFORM_ACCOUNTS", { enumerable: true, get: function () { return auditNames_1.PLATFORM_ACCOUNTS; } });
28
+ Object.defineProperty(exports, "countAuditLogins", { enumerable: true, get: function () { return auditNames_1.countAuditLogins; } });
29
+ Object.defineProperty(exports, "neutralizeAuditNames", { enumerable: true, get: function () { return auditNames_1.neutralizeAuditNames; } });
30
+ var neutralize_1 = require("./neutralize");
31
+ Object.defineProperty(exports, "neutralizeBundle", { enumerable: true, get: function () { return neutralize_1.neutralizeBundle; } });
32
+ Object.defineProperty(exports, "DEFAULT_XML_FILE", { enumerable: true, get: function () { return neutralize_1.DEFAULT_XML_FILE; } });
25
33
  var install_1 = require("./install");
26
34
  Object.defineProperty(exports, "manualInstallSteps", { enumerable: true, get: function () { return install_1.manualInstallSteps; } });
27
35
  Object.defineProperty(exports, "headlessInstall", { enumerable: true, get: function () { return install_1.headlessInstall; } });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The neutralize command: replace the created-by and updated-by logins in the bundled
3
+ * XML with the neutral name, and bring the manifest's sha256 back in line. Local files
4
+ * only. Runs before the manifest exists too (straight after an export).
5
+ *
6
+ * ES6 only, no optional chaining.
7
+ */
8
+ /** The XML's file name when no manifest names one yet. */
9
+ export declare var DEFAULT_XML_FILE: string;
10
+ interface NeutralizeIo {
11
+ out: (line: string) => void;
12
+ err: (line: string) => void;
13
+ }
14
+ export declare function neutralizeBundle(params: {
15
+ appDir?: string;
16
+ io: NeutralizeIo;
17
+ }): number;
18
+ export {};
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /**
3
+ * The neutralize command: replace the created-by and updated-by logins in the bundled
4
+ * XML with the neutral name, and bring the manifest's sha256 back in line. Local files
5
+ * only. Runs before the manifest exists too (straight after an export).
6
+ *
7
+ * ES6 only, no optional chaining.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.DEFAULT_XML_FILE = void 0;
44
+ exports.neutralizeBundle = neutralizeBundle;
45
+ const crypto = __importStar(require("crypto"));
46
+ const fs = __importStar(require("fs"));
47
+ const path = __importStar(require("path"));
48
+ const auditNames_1 = require("./auditNames");
49
+ const bundle_1 = require("./bundle");
50
+ const manifest_1 = require("./manifest");
51
+ /** The XML's file name when no manifest names one yet. */
52
+ exports.DEFAULT_XML_FILE = "dovetail-app.xml";
53
+ var XML_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*\.xml$/;
54
+ function isRecord(value) {
55
+ return typeof value === "object" && value !== null && !Array.isArray(value);
56
+ }
57
+ function fail(io, message) {
58
+ io.err("dovetail-servicenow-app: neutralize: " + message);
59
+ return 2;
60
+ }
61
+ function neutralizeBundle(params) {
62
+ var io = params.io;
63
+ var appDir = path.resolve(params.appDir || (0, bundle_1.defaultAppDir)());
64
+ var manifestPath = path.join(appDir, manifest_1.MANIFEST_FILE);
65
+ var manifest = null;
66
+ var xmlFile = exports.DEFAULT_XML_FILE;
67
+ if (fs.existsSync(manifestPath)) {
68
+ var raw;
69
+ try {
70
+ raw = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
71
+ }
72
+ catch (err) {
73
+ return fail(io, "cannot read " + manifest_1.MANIFEST_FILE);
74
+ }
75
+ if (!isRecord(raw))
76
+ return fail(io, manifest_1.MANIFEST_FILE + " is not an object");
77
+ manifest = raw;
78
+ if (typeof raw.xmlFile === "string")
79
+ xmlFile = raw.xmlFile;
80
+ }
81
+ // A bare file name inside the app directory, nothing else.
82
+ if (!XML_FILE_RE.test(xmlFile)) {
83
+ return fail(io, "the manifest's xmlFile is not a plain .xml file name");
84
+ }
85
+ var xmlPath = path.join(appDir, xmlFile);
86
+ var stat;
87
+ try {
88
+ stat = fs.statSync(xmlPath);
89
+ }
90
+ catch (err) {
91
+ return fail(io, xmlFile + " is missing from " + appDir);
92
+ }
93
+ if (!stat.isFile() || stat.size === 0 || stat.size > bundle_1.MAX_XML_BYTES) {
94
+ return fail(io, xmlFile + " is empty, not a file, or too large");
95
+ }
96
+ var result = (0, auditNames_1.neutralizeAuditNames)({ xml: fs.readFileSync(xmlPath, "utf8") });
97
+ if (result.replaced > 0)
98
+ fs.writeFileSync(xmlPath, result.xml, "utf8");
99
+ io.out("neutralize: replaced " +
100
+ result.replaced +
101
+ " created-by or updated-by name(s) with " +
102
+ auditNames_1.NEUTRAL_AUDIT_NAME +
103
+ " in " +
104
+ xmlFile);
105
+ if (manifest) {
106
+ var digest = crypto
107
+ .createHash("sha256")
108
+ .update(fs.readFileSync(xmlPath))
109
+ .digest("hex");
110
+ if (manifest.sha256 !== digest) {
111
+ manifest.sha256 = digest;
112
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf8");
113
+ io.out("neutralize: " + manifest_1.MANIFEST_FILE + " sha256 updated");
114
+ }
115
+ }
116
+ return 0;
117
+ }
package/dist/run.js CHANGED
@@ -56,6 +56,7 @@ const path = __importStar(require("path"));
56
56
  const dovetail_servicenow_1 = require("@tenonhq/dovetail-servicenow");
57
57
  const bundle_1 = require("./bundle");
58
58
  const install_1 = require("./install");
59
+ const neutralize_1 = require("./neutralize");
59
60
  exports.COMMANDS = [
60
61
  "info",
61
62
  "path",
@@ -63,6 +64,7 @@ exports.COMMANDS = [
63
64
  "copy",
64
65
  "install",
65
66
  "pack-check",
67
+ "neutralize",
66
68
  "help",
67
69
  ];
68
70
  var USAGE = [
@@ -86,6 +88,8 @@ var USAGE = [
86
88
  " --remote-set <sys_id> a set already on the instance (e.g. uploaded by hand)",
87
89
  " --engine auto|cicd|dovetail|platform --force (import over an equal or newer version)",
88
90
  " pack-check Fail when this package would publish without a verified app (runs on prepack)",
91
+ " neutralize Replace the created-by and updated-by logins in the XML with a neutral name and",
92
+ " update the manifest sha256. Local files only; verify and pack-check fail without it",
89
93
  " help Show this text",
90
94
  "",
91
95
  "Only install --env contacts an instance. Exit 4 = waiting on a manual step.",
@@ -418,6 +422,9 @@ async function run(params) {
418
422
  });
419
423
  return 0;
420
424
  }
425
+ if (args.command === "neutralize") {
426
+ return (0, neutralize_1.neutralizeBundle)({ appDir: args.dir || undefined, io: io });
427
+ }
421
428
  var check = (0, bundle_1.verifyBundle)({ appDir: args.dir || undefined });
422
429
  if (args.command === "pack-check") {
423
430
  return packCheck({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/dovetail-servicenow-app",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  "author": "Tenon",
19
19
  "license": "GPL-3.0",
20
20
  "dependencies": {
21
- "@tenonhq/dovetail-servicenow": "~0.0.62"
21
+ "@tenonhq/dovetail-servicenow": "~0.0.64"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/jest": "^29.5.5",