Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ A JavaScript/TypeScript library for parsing, validating, and generating [XARF v4
## Installation

```bash
npm install xarf
npm install @xarf/xarf
```

## Quick Start

### Parsing a Report

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

// Missing first_seen and source_port produce validation errors.
const { report, errors, warnings } = parse({
Expand Down Expand Up @@ -64,7 +64,7 @@ if (errors.length === 0) {
### Creating a Report

```typescript
import { createReport, createEvidence } from 'xarf';
import { createReport, createEvidence } from '@xarf/xarf';

// Returns { content_type, payload (base64), hash, size, description }
const evidence = createEvidence('message/rfc822', rawEmailContent, {
Expand Down Expand Up @@ -104,7 +104,7 @@ console.log(JSON.stringify(report, null, 2));
Parse and validate a XARF report from JSON. Supports both v4 and v3 (legacy) formats — v3 reports are automatically converted to v4 with deprecation warnings.

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

const { report, errors, warnings, info } = parse(jsonData, options?);
```
Expand All @@ -127,7 +127,7 @@ const { report, errors, warnings, info } = parse(jsonData, options?);
Create a validated XARF report with auto-generated metadata. Automatically fills `xarf_version`, `report_id` (UUID), and `timestamp` (ISO 8601) if not provided.

```typescript
import { createReport } from 'xarf';
import { createReport } from '@xarf/xarf';

const { report, errors, warnings } = createReport(input, options?);
```
Expand All @@ -150,7 +150,7 @@ const { report, errors, warnings } = createReport(input, options?);
Create an evidence object with automatic base64 encoding, hashing, and size calculation.

```typescript
import { createEvidence } from 'xarf';
import { createEvidence } from '@xarf/xarf';

const evidence = createEvidence(contentType, payload, options?);
```
Expand All @@ -169,7 +169,7 @@ const evidence = createEvidence(contentType, payload, options?);
Access schema-derived validation rules and metadata programmatically.

```typescript
import { schemaRegistry } from 'xarf';
import { schemaRegistry } from '@xarf/xarf';

// Get all valid categories
schemaRegistry.getCategories();
Expand Down Expand Up @@ -211,7 +211,7 @@ if (info) {
The library automatically detects XARF v3 reports (by the `Version` field) and converts them to v4 during parsing. Converted reports include `legacy_version: '3'` and deprecation warnings.

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

const { report, warnings } = parse(v3Report);

Expand All @@ -224,7 +224,7 @@ console.log(report.legacy_version); // '3'
You can also use the low-level utilities directly:

```typescript
import { isXARFv3, convertV3toV4, getV3DeprecationWarning } from 'xarf';
import { isXARFv3, convertV3toV4, getV3DeprecationWarning } from '@xarf/xarf';

if (isXARFv3(jsonData)) {
const warnings: string[] = [];
Expand Down
10 changes: 5 additions & 5 deletions docs/MIGRATION_V3_TO_V4.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ XARF v4 introduces a category-based architecture that improves upon the v3 forma
The library automatically detects and converts v3 reports to v4 format:

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

// v3 report is automatically detected and converted
const { report, warnings } = parse(v3JsonData);
Expand Down Expand Up @@ -104,7 +104,7 @@ const { report, warnings } = parse(v3JsonData);
When parsing v3 reports, you'll receive deprecation warnings:

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

const { report, warnings } = parse(v3Report);
// warnings includes:
Expand All @@ -121,7 +121,7 @@ const { report, warnings } = parse(v3Report);
Use the library's automatic conversion:

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

function processReport(jsonData: string | Record<string, unknown>) {
const { report } = parse(jsonData);
Expand All @@ -140,7 +140,7 @@ function processReport(jsonData: string | Record<string, unknown>) {
Track v3 report usage to plan deprecation:

```typescript
import { parse } from 'xarf';
import { parse } from '@xarf/xarf';

function trackLegacyUsage(jsonData: string | Record<string, unknown>) {
const { report } = parse(jsonData);
Expand All @@ -157,7 +157,7 @@ function trackLegacyUsage(jsonData: string | Record<string, unknown>) {
Update your report generators to produce v4 format:

```typescript
import { createReport } from 'xarf';
import { createReport } from '@xarf/xarf';

const { report } = createReport({
category: 'messaging',
Expand Down
14 changes: 4 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
"jest": "^29.7.0",
"lint-staged": "^16.2.7",
"prettier": "^3.7.4",
"tar": "^7.5.2",
"ts-jest": "^29.4.6",
"ts-prune": "^0.10.3",
"typescript": "^5.3.3"
},
"files": [
"scripts",
"dist",
"README.md",
"LICENSE"
Expand All @@ -91,6 +91,7 @@
},
"dependencies": {
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1"
"ajv-formats": "^3.0.1",
"tar": "^7.5.2"
}
}
Loading