@aioschema/cli 0.5.5

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.
Files changed (4) hide show
  1. package/LICENSE.md +42 -0
  2. package/README.md +64 -0
  3. package/cli.js +165 -0
  4. package/package.json +39 -0
package/LICENSE.md ADDED
@@ -0,0 +1,42 @@
1
+ # License
2
+
3
+ ---
4
+
5
+ ## AIOSchema Specification
6
+
7
+ The AIOSchema v0.5.5 Specification is published under the **Creative Commons Attribution 4.0 International (CC-BY 4.0)** license.
8
+
9
+ You are free to implement the specification in any language, for any purpose, including commercial use, provided you include attribution to AIOSchema.
10
+
11
+ Full text: https://creativecommons.org/licenses/by/4.0/
12
+ Specification: https://aioschema.org
13
+
14
+ ---
15
+
16
+ ## Reference Implementations
17
+
18
+ The Python, TypeScript, Node.js, Go, and Rust reference implementations of AIOSchema are open source, licensed under the **Apache License 2.0**.
19
+
20
+ ```
21
+ Copyright 2026 Ovidiu Ancuta / AIOSchema Contributors
22
+
23
+ Licensed under the Apache License, Version 2.0 (the "License");
24
+ you may not use this file except in compliance with the License.
25
+ You may obtain a copy of the License at
26
+
27
+ https://www.apache.org/licenses/LICENSE-2.0
28
+
29
+ Unless required by applicable law or agreed to in writing, software
30
+ distributed under the License is distributed on an "AS IS" BASIS,
31
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ See the License for the specific language governing permissions and
33
+ limitations under the License.
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Attribution
39
+
40
+ AIOSchema is authored and maintained by Ovidiu Ancuta.
41
+ Website: https://aioschema.org
42
+ Hub: https://aioschemahub.com
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @aioschema/cli
2
+
3
+ **AIOSchema v0.5.5 — Command-line tool for generating and verifying provenance manifests.**
4
+
5
+ - Spec: [aioschema.org](https://aioschema.org)
6
+ - Hub: [aioschemahub.com](https://aioschemahub.com)
7
+
8
+ ---
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install -g @aioschema/cli
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Usage
19
+
20
+ ```bash
21
+ # Generate a manifest for any file
22
+ aioschema generate myfile.pdf
23
+
24
+ # Generate with SHA-384
25
+ aioschema generate myfile.pdf --algorithm sha384
26
+
27
+ # Generate with your creator ID
28
+ aioschema generate myfile.pdf --creator-id ed25519-fp-ebc64203390ddefc442ade9038e1ae18
29
+
30
+ # Verify a file against its manifest
31
+ aioschema verify myfile.pdf myfile.pdf.aios.json
32
+
33
+ # Help
34
+ aioschema --help
35
+
36
+ # Version
37
+ aioschema --version
38
+ ```
39
+
40
+ ---
41
+
42
+ ## What it produces
43
+
44
+ Running `aioschema generate` writes a `.aios.json` manifest alongside your file:
45
+
46
+ ```
47
+ myfile.pdf
48
+ myfile.pdf.aios.json ← manifest
49
+ ```
50
+
51
+ The manifest cryptographically describes your file — what it is, when it existed, and who created it. Verifiable forever by any conforming AIOSchema implementation.
52
+
53
+ ---
54
+
55
+ ## Library
56
+
57
+ For programmatic use, see [@aioschema/js](../implementations/js/README.md).
58
+
59
+ ---
60
+
61
+ ## License
62
+
63
+ Apache 2.0. See [LICENSE.md](./LICENSE.md).
64
+ Specification: CC-BY 4.0 — [aioschema.org](https://aioschema.org)
package/cli.js ADDED
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * AIOSchema v0.5.5 — CLI
5
+ * ======================
6
+ * Usage:
7
+ * aioschema generate <file> [--algorithm sha256|sha384] [--creator-id <id>]
8
+ * aioschema verify <file> <manifest.aios.json>
9
+ * aioschema --version
10
+ * aioschema --help
11
+ */
12
+
13
+ const fs = require("node:fs");
14
+ const path = require("node:path");
15
+ const aios = require("./aioschema_v055.js");
16
+
17
+ const { generateManifest, verifyManifest, sidecarPath, SPEC_VERSION } = aios;
18
+
19
+ // ── Argument parsing ──────────────────────────────────────────────────────────
20
+
21
+ const args = process.argv.slice(2);
22
+
23
+ if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
24
+ printHelp();
25
+ process.exit(0);
26
+ }
27
+
28
+ if (args[0] === "--version" || args[0] === "-v") {
29
+ console.log(`AIOSchema v${SPEC_VERSION}`);
30
+ process.exit(0);
31
+ }
32
+
33
+ const command = args[0];
34
+
35
+ if (command === "generate") {
36
+ runGenerate(args.slice(1));
37
+ } else if (command === "verify") {
38
+ runVerify(args.slice(1));
39
+ } else {
40
+ console.error(`Unknown command: ${command}`);
41
+ console.error(`Run 'aioschema --help' for usage.`);
42
+ process.exit(1);
43
+ }
44
+
45
+ // ── Commands ──────────────────────────────────────────────────────────────────
46
+
47
+ function runGenerate(args) {
48
+ // Parse: <file> [--algorithm sha256|sha384] [--creator-id <id>]
49
+ const positional = [];
50
+ const opts = {};
51
+
52
+ for (let i = 0; i < args.length; i++) {
53
+ if (args[i] === "--algorithm" || args[i] === "-a") {
54
+ opts.hashAlgorithm = args[++i];
55
+ } else if (args[i] === "--creator-id") {
56
+ opts.creatorId = args[++i];
57
+ } else {
58
+ positional.push(args[i]);
59
+ }
60
+ }
61
+
62
+ const filePath = positional[0];
63
+ if (!filePath) {
64
+ console.error("Error: file path required.\nUsage: aioschema generate <file>");
65
+ process.exit(1);
66
+ }
67
+ if (!fs.existsSync(filePath)) {
68
+ console.error(`Error: file not found: ${filePath}`);
69
+ process.exit(1);
70
+ }
71
+
72
+ try {
73
+ const manifest = generateManifest(filePath, opts);
74
+ const out = sidecarPath(filePath);
75
+ console.log(`✓ Manifest written: ${out}`);
76
+ console.log(` asset_id: ${manifest.core.asset_id}`);
77
+ console.log(` hash_original: ${Array.isArray(manifest.core.hash_original)
78
+ ? manifest.core.hash_original.join(", ")
79
+ : manifest.core.hash_original}`);
80
+ console.log(` core_fingerprint: ${manifest.core.core_fingerprint}`);
81
+ console.log(` creator_id: ${manifest.core.creator_id}`);
82
+ } catch (err) {
83
+ console.error(`Error generating manifest: ${err.message}`);
84
+ process.exit(1);
85
+ }
86
+ }
87
+
88
+ async function runVerify(args) {
89
+ const filePath = args[0];
90
+ const manifestPath = args[1];
91
+
92
+ if (!filePath || !manifestPath) {
93
+ console.error("Error: file path and manifest path required.");
94
+ console.error("Usage: aioschema verify <file> <manifest.aios.json>");
95
+ process.exit(1);
96
+ }
97
+ if (!fs.existsSync(filePath)) {
98
+ console.error(`Error: file not found: ${filePath}`);
99
+ process.exit(1);
100
+ }
101
+ if (!fs.existsSync(manifestPath)) {
102
+ console.error(`Error: manifest not found: ${manifestPath}`);
103
+ process.exit(1);
104
+ }
105
+
106
+ let manifest;
107
+ try {
108
+ manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
109
+ } catch (err) {
110
+ console.error(`Error reading manifest: ${err.message}`);
111
+ process.exit(1);
112
+ }
113
+
114
+ try {
115
+ const result = await verifyManifest(filePath, manifest);
116
+
117
+ if (result.success) {
118
+ console.log(`◈ VERIFIED`);
119
+ console.log(` match_type: ${result.match_type}`);
120
+ if (result.signature_verified) console.log(` signature: verified`);
121
+ if (result.warnings && result.warnings.length > 0) {
122
+ result.warnings.forEach(w => console.log(` warning: ${w}`));
123
+ }
124
+ } else {
125
+ console.log(`✗ FAILED`);
126
+ console.log(` reason: ${result.message}`);
127
+ process.exit(2);
128
+ }
129
+ } catch (err) {
130
+ console.error(`Error during verification: ${err.message}`);
131
+ process.exit(1);
132
+ }
133
+ }
134
+
135
+ // ── Help ──────────────────────────────────────────────────────────────────────
136
+
137
+ function printHelp() {
138
+ console.log(`
139
+ AIOSchema v${SPEC_VERSION} — Cryptographic content provenance
140
+
141
+ USAGE
142
+ aioschema generate <file> [options]
143
+ aioschema verify <file> <manifest.aios.json>
144
+
145
+ COMMANDS
146
+ generate Generate a .aios.json manifest for a file
147
+ verify Verify a file against its manifest
148
+
149
+ OPTIONS (generate)
150
+ --algorithm, -a Hash algorithm: sha256 (default) or sha384
151
+ --creator-id Creator ID in ed25519-fp-<hex> format
152
+
153
+ GLOBAL
154
+ --version, -v Print version
155
+ --help, -h Print this help
156
+
157
+ EXAMPLES
158
+ aioschema generate report.pdf
159
+ aioschema generate image.png --algorithm sha384
160
+ aioschema verify report.pdf report.pdf.aios.json
161
+
162
+ SPEC https://aioschema.org
163
+ HUB https://aioschemahub.com
164
+ `);
165
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@aioschema/cli",
3
+ "version": "0.5.5",
4
+ "description": "AIOSchema v0.5.5 — command-line tool for generating and verifying provenance manifests.",
5
+ "main": "cli.js",
6
+ "bin": {
7
+ "aioschema": "./cli.js"
8
+ },
9
+ "files": [
10
+ "cli.js",
11
+ "README.md",
12
+ "LICENSE.md"
13
+ ],
14
+ "dependencies": {
15
+ "@aioschema/js": "0.5.5"
16
+ },
17
+ "keywords": [
18
+ "aioschema",
19
+ "provenance",
20
+ "cli",
21
+ "content-integrity",
22
+ "manifest",
23
+ "cryptographic-hash"
24
+ ],
25
+ "author": "Ovidiu Ancuta <ovidiu@aioschema.org>",
26
+ "license": "SEE LICENSE IN LICENSE.md",
27
+ "homepage": "https://aioschema.org",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/aioschema/aioschema.git",
31
+ "directory": "cli"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/aioschema/aioschema/issues"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
38
+ }
39
+ }