{"id":48127,"library":"har-guard","title":"har-guard","description":"Zero-dependency TypeScript library for validating HAR 1.2 (HTTP Archive) files, designed as a modern replacement for the deprecated har-validator package. Current version 0.1.0, released as an independent migration helper supporting Node >=18. Key differentiators: fully typed with TypeScript, no external dependencies, offers both synchronous (validateHar, assertHar, isHar) and Promise-based (har, request, response, entry) APIs, and provides structured validation results with detailed issues instead of simple boolean flags. Suitable for projects migrating away from har-validator or building new HAR validation pipelines.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/iexitdev/har-guard","tags":["javascript","har","har-validator","http-archive","validation","typescript","migration","replacement","deprecated"],"install":[{"cmd":"npm install har-guard","lang":"bash","label":"npm"},{"cmd":"yarn add har-guard","lang":"bash","label":"yarn"},{"cmd":"pnpm add har-guard","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will not work. Use ESM imports.","wrong":"const validateHar = require('har-guard').validateHar","symbol":"validateHar","correct":"import { validateHar } from 'har-guard'"},{"note":"assertHar is a named export, not the default export.","wrong":"import assertHar from 'har-guard' (default import does not exist)","symbol":"assertHar","correct":"import { assertHar } from 'har-guard'"},{"note":"Type guard returning boolean; no wrong pattern common yet.","symbol":"isHar","correct":"import { isHar } from 'har-guard'"}],"quickstart":{"code":"import { assertHar, validateHar } from 'har-guard';\n\nconst sampleHar = {\n  log: {\n    version: '1.2',\n    creator: { name: 'test', version: '0.1' },\n    entries: []\n  }\n};\n\nconst result = validateHar(sampleHar);\nconsole.log(result.valid); // true or false\nconsole.log(result.issues); // array of issues if invalid\n\n// Throws HarValidationError on invalid\ntry {\n  assertHar(sampleHar);\n  console.log('HAR is valid');\n} catch (e) {\n  console.error(e.message);\n}\n\n// Type guard example\nif (isHar(sampleHar)) {\n  console.log('Sample is a valid HAR object');\n}","lang":"typescript","description":"Demonstrates synchronous validation, assertion, and type guard with a sample HAR 1.2 object."},"warnings":[{"fix":"Ensure your project uses ESM (type: module in package.json) and use import syntax.","message":"har-guard is ESM-only and cannot be used with CommonJS require().","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Access result.valid to check validity, not the result directly.","message":"The validateHar function returns an object with valid and issues properties, not a boolean like har-validator's validate().","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Migrate from har-validator to har-guard as recommended by the original project.","message":"har-validator is deprecated; har-guard is an independent replacement.","severity":"deprecated","affected_versions":"any"},{"fix":"Use .catch() or try/catch with async/await to handle errors.","message":"The Promise-based functions (har(), request(), etc.) reject with HarValidationError, not a boolean or result object.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.0':30 '1.2':12 '18':39 'api':63 'archiv':14,99 'asserthar':53 'away':81 'base':58 'boolean':75 'build':87 'current':28 'depend':6,48 'deprec':23,104 'design':16 'detail':70 'differenti':41 'entri':62 'extern':47 'file':15 'flag':76 'fulli':42 'guard':3 'har':2,11,25,59,84,89,93,95 'har-guard':1 'har-valid':24,83,94 'helper':36 'http':13,98 'http-archiv':97 'independ':34 'instead':72 'ishar':54 'issu':71 'javascript':92 'key':40 'librari':8 'migrat':35,80,102 'modern':19 'new':88 'node':38 'offer':49 'packag':27 'pipelin':91 'project':79 'promis':57 'promise-bas':56 'provid':65 'releas':31 'replac':20,103 'request':60 'respons':61 'result':68 'simpl':74 'structur':66 'suitabl':77 'support':37 'synchron':51 'type':43 'typescript':7,45,101 'valid':10,26,67,85,90,96,100 'validatehar':52 'version':29 'zero':5 'zero-depend':4","created_at":"2026-06-07T16:55:03.460936+00:00","updated_at":"2026-06-07T16:55:03.460936+00:00","problems":[{"fix":"Switch your project to ESM (add type: module to package.json) and use import statements.","cause":"Trying to load har-guard with CommonJS require() while it is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use import { validateHar } from 'har-guard' correctly.","cause":"Incorrectly destructuring from a default import instead of named imports.","error":"TypeError: harGuard_1.validateHar is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/iexitdev/har-guard#readme","github":"https://github.com/iexitdev/har-guard","docs":null,"changelog":null,"pypi":null,"npm":"har-guard","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}