@cyvest/cyvest-js 7.0.0 → 7.2.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.cjs CHANGED
@@ -1027,6 +1027,28 @@ var cyvest_schema_default = {
1027
1027
  "title": "Tag",
1028
1028
  "type": "object"
1029
1029
  },
1030
+ "Taxonomy": {
1031
+ "additionalProperties": false,
1032
+ "description": "A named value with a display verdict. No weight, confidence or scoring effect.",
1033
+ "properties": {
1034
+ "name": {
1035
+ "title": "Name",
1036
+ "type": "string"
1037
+ },
1038
+ "value": {
1039
+ "title": "Value",
1040
+ "type": "string"
1041
+ },
1042
+ "verdict": {
1043
+ "$ref": "#/$defs/Verdict",
1044
+ "default": "INFO",
1045
+ "description": "Descriptive only; never affects scoring"
1046
+ }
1047
+ },
1048
+ "required": ["name", "value"],
1049
+ "title": "Taxonomy",
1050
+ "type": "object"
1051
+ },
1030
1052
  "ThreatIntel": {
1031
1053
  "additionalProperties": false,
1032
1054
  "description": "A verdict from a threat-intelligence source.\n\nIdentity is ``(source, subject_key)``, so a source re-asserting the same observable updates\nin place instead of piling up duplicates. Pass ``external_id`` to keep history on purpose.",
@@ -1126,7 +1148,7 @@ var cyvest_schema_default = {
1126
1148
  },
1127
1149
  "taxonomies": {
1128
1150
  "default": [],
1129
- "items": { "type": "string" },
1151
+ "items": { "$ref": "#/$defs/Taxonomy" },
1130
1152
  "title": "Taxonomies",
1131
1153
  "type": "array"
1132
1154
  },
@@ -1165,7 +1187,7 @@ var cyvest_schema_default = {
1165
1187
  description: "A complete serialized investigation.",
1166
1188
  properties: {
1167
1189
  "schema_version": {
1168
- "default": "7.0.0",
1190
+ "default": "7.1.0",
1169
1191
  "pattern": "^7\\.\\d+\\.\\d+$",
1170
1192
  "title": "Schema Version",
1171
1193
  "type": "string"
@@ -1211,7 +1233,7 @@ var cyvest_schema_default = {
1211
1233
  * window is the SDK's job alone; reading and judging the version first also keeps the error
1212
1234
  * message explicit instead of an opaque ajv shape error.
1213
1235
  */
1214
- const SCHEMA_VERSION = "7.0.0";
1236
+ const SCHEMA_VERSION = "7.1.0";
1215
1237
  const SEMVER = /^\d+\.\d+\.\d+$/;
1216
1238
  const ajv = new ajv_dist_2020_js.default({ allErrors: true });
1217
1239
  (0, ajv_formats.default)(ajv);
@@ -1243,16 +1265,40 @@ function assertReadableVersion(version) {
1243
1265
  if (docMajor > libMajor || docMajor === libMajor && docMinor > libMinor) throw new Error(`Document schema ${version} is newer than this SDK (${SCHEMA_VERSION}); upgrade @cyvest/cyvest-js.`);
1244
1266
  if (docMajor < libMajor) throw new Error(`Document schema ${version} predates this SDK (${SCHEMA_VERSION}); run 'cyvest migrate'.`);
1245
1267
  }
1268
+ function isRecord(value) {
1269
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1270
+ }
1271
+ /** Normalize 7.0 free-text taxonomies once at the input boundary, without mutating the caller. */
1272
+ function normalizeTaxonomies(json) {
1273
+ if (!isRecord(json) || !isRecord(json.facts) || !isRecord(json.facts.signals)) return json;
1274
+ const signals = Object.fromEntries(Object.entries(json.facts.signals).map(([key, signal]) => [key, isRecord(signal) && Array.isArray(signal.taxonomies) ? {
1275
+ ...signal,
1276
+ taxonomies: signal.taxonomies.map((entry) => typeof entry === "string" ? {
1277
+ name: entry,
1278
+ value: "",
1279
+ verdict: "INFO"
1280
+ } : entry)
1281
+ } : signal]));
1282
+ return {
1283
+ ...json,
1284
+ facts: {
1285
+ ...json.facts,
1286
+ signals
1287
+ }
1288
+ };
1289
+ }
1246
1290
  function parseCyvest(json) {
1247
1291
  assertReadableVersion(detectSchemaVersion(json));
1292
+ const normalized = normalizeTaxonomies(json);
1248
1293
  const validate = getValidator();
1249
- if (!validate(json)) throw new Error(`Invalid Cyvest payload: ${ajv.errorsText(validate.errors || [])}`);
1250
- return json;
1294
+ if (!validate(normalized)) throw new Error(`Invalid Cyvest payload: ${ajv.errorsText(validate.errors || [])}`);
1295
+ return normalized;
1251
1296
  }
1297
+ /** A type guard cannot normalize its argument: legacy strings need parseCyvest first. */
1252
1298
  function isCyvest(json) {
1253
1299
  try {
1254
- parseCyvest(json);
1255
- return true;
1300
+ assertReadableVersion(detectSchemaVersion(json));
1301
+ return !!getValidator()(json);
1256
1302
  } catch {
1257
1303
  return false;
1258
1304
  }
package/dist/index.d.cts CHANGED
@@ -45,7 +45,7 @@ export type ExternalId2 = string | null;
45
45
  export type EvidenceKeys2 = string[];
46
46
  export type ObservedAt1 = string | null;
47
47
  export type Labels = Label[];
48
- export type Taxonomies = string[];
48
+ export type Taxonomies = Taxonomy[];
49
49
  export type OccurredAt3 = string | null;
50
50
  export type ExternalId3 = string | null;
51
51
  export type EvidenceKeys3 = string[];
@@ -293,6 +293,14 @@ export interface Label {
293
293
  export interface Payload {
294
294
  [k: string]: unknown;
295
295
  }
296
+ /**
297
+ * A named value with a display verdict. No weight, confidence or scoring effect.
298
+ */
299
+ export interface Taxonomy {
300
+ name: string;
301
+ value: string;
302
+ verdict?: Verdict;
303
+ }
296
304
  export interface Evidences {
297
305
  [k: string]: Evidence;
298
306
  }
@@ -526,7 +534,7 @@ type FindingResult$1 = FindingResult;
526
534
  type InvestigationResult$1 = InvestigationResult;
527
535
  //#endregion
528
536
  //#region src/helpers.d.ts
529
- export declare const SCHEMA_VERSION = "7.0.0";
537
+ export declare const SCHEMA_VERSION = "7.1.0";
530
538
  /**
531
539
  * Read the declared schema version, falling back to `"5"` for anything unversioned.
532
540
  *
@@ -538,6 +546,7 @@ export declare function detectSchemaVersion(json: unknown): string;
538
546
  /** Upward compatibility only: read older documents, never newer ones. */
539
547
  export declare function assertReadableVersion(version: string): void;
540
548
  export declare function parseCyvest(json: unknown): Investigation;
549
+ /** A type guard cannot normalize its argument: legacy strings need parseCyvest first. */
541
550
  export declare function isCyvest(json: unknown): json is Investigation;
542
551
  //#endregion
543
552
  //#region src/keys.d.ts
package/dist/index.d.ts CHANGED
@@ -45,7 +45,7 @@ export type ExternalId2 = string | null;
45
45
  export type EvidenceKeys2 = string[];
46
46
  export type ObservedAt1 = string | null;
47
47
  export type Labels = Label[];
48
- export type Taxonomies = string[];
48
+ export type Taxonomies = Taxonomy[];
49
49
  export type OccurredAt3 = string | null;
50
50
  export type ExternalId3 = string | null;
51
51
  export type EvidenceKeys3 = string[];
@@ -293,6 +293,14 @@ export interface Label {
293
293
  export interface Payload {
294
294
  [k: string]: unknown;
295
295
  }
296
+ /**
297
+ * A named value with a display verdict. No weight, confidence or scoring effect.
298
+ */
299
+ export interface Taxonomy {
300
+ name: string;
301
+ value: string;
302
+ verdict?: Verdict;
303
+ }
296
304
  export interface Evidences {
297
305
  [k: string]: Evidence;
298
306
  }
@@ -526,7 +534,7 @@ type FindingResult$1 = FindingResult;
526
534
  type InvestigationResult$1 = InvestigationResult;
527
535
  //#endregion
528
536
  //#region src/helpers.d.ts
529
- export declare const SCHEMA_VERSION = "7.0.0";
537
+ export declare const SCHEMA_VERSION = "7.1.0";
530
538
  /**
531
539
  * Read the declared schema version, falling back to `"5"` for anything unversioned.
532
540
  *
@@ -538,6 +546,7 @@ export declare function detectSchemaVersion(json: unknown): string;
538
546
  /** Upward compatibility only: read older documents, never newer ones. */
539
547
  export declare function assertReadableVersion(version: string): void;
540
548
  export declare function parseCyvest(json: unknown): Investigation;
549
+ /** A type guard cannot normalize its argument: legacy strings need parseCyvest first. */
541
550
  export declare function isCyvest(json: unknown): json is Investigation;
542
551
  //#endregion
543
552
  //#region src/keys.d.ts
package/dist/index.js CHANGED
@@ -1002,6 +1002,28 @@ var cyvest_schema_default = {
1002
1002
  "title": "Tag",
1003
1003
  "type": "object"
1004
1004
  },
1005
+ "Taxonomy": {
1006
+ "additionalProperties": false,
1007
+ "description": "A named value with a display verdict. No weight, confidence or scoring effect.",
1008
+ "properties": {
1009
+ "name": {
1010
+ "title": "Name",
1011
+ "type": "string"
1012
+ },
1013
+ "value": {
1014
+ "title": "Value",
1015
+ "type": "string"
1016
+ },
1017
+ "verdict": {
1018
+ "$ref": "#/$defs/Verdict",
1019
+ "default": "INFO",
1020
+ "description": "Descriptive only; never affects scoring"
1021
+ }
1022
+ },
1023
+ "required": ["name", "value"],
1024
+ "title": "Taxonomy",
1025
+ "type": "object"
1026
+ },
1005
1027
  "ThreatIntel": {
1006
1028
  "additionalProperties": false,
1007
1029
  "description": "A verdict from a threat-intelligence source.\n\nIdentity is ``(source, subject_key)``, so a source re-asserting the same observable updates\nin place instead of piling up duplicates. Pass ``external_id`` to keep history on purpose.",
@@ -1101,7 +1123,7 @@ var cyvest_schema_default = {
1101
1123
  },
1102
1124
  "taxonomies": {
1103
1125
  "default": [],
1104
- "items": { "type": "string" },
1126
+ "items": { "$ref": "#/$defs/Taxonomy" },
1105
1127
  "title": "Taxonomies",
1106
1128
  "type": "array"
1107
1129
  },
@@ -1140,7 +1162,7 @@ var cyvest_schema_default = {
1140
1162
  description: "A complete serialized investigation.",
1141
1163
  properties: {
1142
1164
  "schema_version": {
1143
- "default": "7.0.0",
1165
+ "default": "7.1.0",
1144
1166
  "pattern": "^7\\.\\d+\\.\\d+$",
1145
1167
  "title": "Schema Version",
1146
1168
  "type": "string"
@@ -1186,7 +1208,7 @@ var cyvest_schema_default = {
1186
1208
  * window is the SDK's job alone; reading and judging the version first also keeps the error
1187
1209
  * message explicit instead of an opaque ajv shape error.
1188
1210
  */
1189
- const SCHEMA_VERSION = "7.0.0";
1211
+ const SCHEMA_VERSION = "7.1.0";
1190
1212
  const SEMVER = /^\d+\.\d+\.\d+$/;
1191
1213
  const ajv = new Ajv2020({ allErrors: true });
1192
1214
  addFormats(ajv);
@@ -1218,16 +1240,40 @@ function assertReadableVersion(version) {
1218
1240
  if (docMajor > libMajor || docMajor === libMajor && docMinor > libMinor) throw new Error(`Document schema ${version} is newer than this SDK (${SCHEMA_VERSION}); upgrade @cyvest/cyvest-js.`);
1219
1241
  if (docMajor < libMajor) throw new Error(`Document schema ${version} predates this SDK (${SCHEMA_VERSION}); run 'cyvest migrate'.`);
1220
1242
  }
1243
+ function isRecord(value) {
1244
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1245
+ }
1246
+ /** Normalize 7.0 free-text taxonomies once at the input boundary, without mutating the caller. */
1247
+ function normalizeTaxonomies(json) {
1248
+ if (!isRecord(json) || !isRecord(json.facts) || !isRecord(json.facts.signals)) return json;
1249
+ const signals = Object.fromEntries(Object.entries(json.facts.signals).map(([key, signal]) => [key, isRecord(signal) && Array.isArray(signal.taxonomies) ? {
1250
+ ...signal,
1251
+ taxonomies: signal.taxonomies.map((entry) => typeof entry === "string" ? {
1252
+ name: entry,
1253
+ value: "",
1254
+ verdict: "INFO"
1255
+ } : entry)
1256
+ } : signal]));
1257
+ return {
1258
+ ...json,
1259
+ facts: {
1260
+ ...json.facts,
1261
+ signals
1262
+ }
1263
+ };
1264
+ }
1221
1265
  function parseCyvest(json) {
1222
1266
  assertReadableVersion(detectSchemaVersion(json));
1267
+ const normalized = normalizeTaxonomies(json);
1223
1268
  const validate = getValidator();
1224
- if (!validate(json)) throw new Error(`Invalid Cyvest payload: ${ajv.errorsText(validate.errors || [])}`);
1225
- return json;
1269
+ if (!validate(normalized)) throw new Error(`Invalid Cyvest payload: ${ajv.errorsText(validate.errors || [])}`);
1270
+ return normalized;
1226
1271
  }
1272
+ /** A type guard cannot normalize its argument: legacy strings need parseCyvest first. */
1227
1273
  function isCyvest(json) {
1228
1274
  try {
1229
- parseCyvest(json);
1230
- return true;
1275
+ assertReadableVersion(detectSchemaVersion(json));
1276
+ return !!getValidator()(json);
1231
1277
  } catch {
1232
1278
  return false;
1233
1279
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyvest/cyvest-js",
3
- "version": "7.0.0",
3
+ "version": "7.2.0",
4
4
  "description": "Typed reader for Cyvest investigation documents: schema validation, fact accessors, and graph helpers.",
5
5
  "keywords": [
6
6
  "cybersecurity",