attest-client 2.0.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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/cli.js +103 -0
  3. package/index.cjs +67 -0
  4. package/index.js +68 -0
  5. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 97115104 (Austin Harshberger)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/cli.js ADDED
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+
3
+ // attest-client CLI
4
+ // Usage: npx attest-client --content README.md --model claude-opus-4 --role collaborated
5
+
6
+ const args = process.argv.slice(2);
7
+
8
+ function flag(name) {
9
+ const i = args.indexOf(`--${name}`);
10
+ if (i === -1) return undefined;
11
+ return args[i + 1];
12
+ }
13
+
14
+ const help = args.includes('--help') || args.includes('-h');
15
+ if (help) {
16
+ console.log(`attest — open protocol for AI content attribution
17
+
18
+ Usage:
19
+ attest --content <name> [options]
20
+ attest --discover
21
+ attest --metrics
22
+
23
+ Options:
24
+ --content <name> Content name or filename (required for attestation)
25
+ --model <model> AI model used (default: gpt-4)
26
+ --role <role> authored | collaborated | generated (default: collaborated)
27
+ --author <name> Author or agent name (default: Anonymous)
28
+ --type <type> human | collab | ai (overrides role)
29
+ --host <url> API host (default: https://attest.97115104.com)
30
+ --discover Show API discovery info
31
+ --metrics Show platform metrics
32
+ --json Output raw JSON
33
+ --help, -h Show this help`);
34
+ process.exit(0);
35
+ }
36
+
37
+ const host = flag('host') || 'https://attest.97115104.com';
38
+ const headers = { 'User-Agent': 'attest-client/2.0.0 cli' };
39
+
40
+ async function run() {
41
+ if (args.includes('--discover')) {
42
+ const res = await fetch(`${host}/.well-known/attest.json`, { headers });
43
+ const data = await res.json();
44
+ console.log(JSON.stringify(data, null, 2));
45
+ return;
46
+ }
47
+
48
+ if (args.includes('--metrics')) {
49
+ const res = await fetch(`${host}/api/metrics`, { headers });
50
+ const data = await res.json();
51
+ if (args.includes('--json')) {
52
+ console.log(JSON.stringify(data, null, 2));
53
+ } else {
54
+ console.log(`attestations: ${data.total_attestations}`);
55
+ console.log(`verifications: ${data.total_verifications}`);
56
+ console.log(`agent visits: ${data.total_agent_visits}`);
57
+ console.log(`top model: ${data.top_model?.model || 'none'} (${data.top_model?.count || 0})`);
58
+ console.log(`top type: ${data.top_type?.authorship_type || 'none'} (${data.top_type?.count || 0})`);
59
+ }
60
+ return;
61
+ }
62
+
63
+ const content_name = flag('content');
64
+ if (!content_name) {
65
+ console.error('error: --content is required. Use --help for usage.');
66
+ process.exit(1);
67
+ }
68
+
69
+ const params = new URLSearchParams();
70
+ params.set('content_name', content_name);
71
+ const model = flag('model');
72
+ if (model) params.set('model', model);
73
+ const role = flag('role');
74
+ if (role) params.set('role', role);
75
+ const author = flag('author');
76
+ if (author) params.set('author', author);
77
+ const type = flag('type');
78
+ if (type) params.set('authorship_type', type);
79
+
80
+ const res = await fetch(`${host}/api/create?${params}`, { headers });
81
+ const data = await res.json();
82
+
83
+ if (!data.success) {
84
+ console.error(`error: ${data.error || 'unknown error'}`);
85
+ process.exit(1);
86
+ }
87
+
88
+ if (args.includes('--json')) {
89
+ console.log(JSON.stringify(data, null, 2));
90
+ } else {
91
+ console.log(`attested: ${data.attestation.content_name}`);
92
+ console.log(`type: ${data.attestation.authorship_type}`);
93
+ console.log(`model: ${data.attestation.model}`);
94
+ console.log(`id: ${data.attestation.id}`);
95
+ console.log(`short: ${data.urls.short}`);
96
+ console.log(`verify: ${data.urls.verify}`);
97
+ }
98
+ }
99
+
100
+ run().catch(err => {
101
+ console.error(`error: ${err.message}`);
102
+ process.exit(1);
103
+ });
package/index.cjs ADDED
@@ -0,0 +1,67 @@
1
+ // attest-client — CJS build
2
+ // https://attest.97115104.com
3
+
4
+ const DEFAULT_HOST = 'https://attest.97115104.com';
5
+
6
+ function createClient(options = {}) {
7
+ const host = (options.host || DEFAULT_HOST).replace(/\/+$/, '');
8
+ const author = options.author || 'Anonymous';
9
+ const headers = { 'User-Agent': 'attest-client/2.0.0' };
10
+
11
+ async function create({ content_name, model, role, author: overrideAuthor, content, authorship_type }) {
12
+ if (!content_name) throw new Error('attest-client: content_name is required');
13
+
14
+ const params = new URLSearchParams();
15
+ params.set('content_name', content_name);
16
+ if (model) params.set('model', model);
17
+ if (role) params.set('role', role);
18
+ params.set('author', overrideAuthor || author);
19
+ if (content) params.set('content', content);
20
+ if (authorship_type) params.set('authorship_type', authorship_type);
21
+
22
+ const res = await fetch(`${host}/api/create?${params}`, { headers });
23
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
24
+
25
+ const data = await res.json();
26
+ if (!data.success) throw new Error(`attest-client: ${data.error || 'unknown error'}`);
27
+ return data;
28
+ }
29
+
30
+ async function createFromUrl({ url, model, role, author: overrideAuthor }) {
31
+ if (!url) throw new Error('attest-client: url is required');
32
+
33
+ const body = { url, model, role, author: overrideAuthor || author };
34
+ const res = await fetch(`${host}/api/create-url`, {
35
+ method: 'POST',
36
+ headers: { ...headers, 'Content-Type': 'application/json' },
37
+ body: JSON.stringify(body),
38
+ });
39
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
40
+
41
+ const data = await res.json();
42
+ if (!data.success) throw new Error(`attest-client: ${data.error || 'unknown error'}`);
43
+ return data;
44
+ }
45
+
46
+ async function metrics() {
47
+ const res = await fetch(`${host}/api/metrics`, { headers });
48
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
49
+ return res.json();
50
+ }
51
+
52
+ async function discover() {
53
+ const res = await fetch(`${host}/.well-known/attest.json`, { headers });
54
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
55
+ return res.json();
56
+ }
57
+
58
+ return { create, createFromUrl, metrics, discover };
59
+ }
60
+
61
+ async function attest(options) {
62
+ const { host, author, ...params } = options;
63
+ const client = createClient({ host, author });
64
+ return client.create(params);
65
+ }
66
+
67
+ module.exports = { createClient, attest, default: attest };
package/index.js ADDED
@@ -0,0 +1,68 @@
1
+ // attest-client — SDK for the attest open attribution protocol
2
+ // https://attest.97115104.com
3
+
4
+ const DEFAULT_HOST = 'https://attest.97115104.com';
5
+
6
+ export function createClient(options = {}) {
7
+ const host = (options.host || DEFAULT_HOST).replace(/\/+$/, '');
8
+ const author = options.author || 'Anonymous';
9
+ const headers = { 'User-Agent': `attest-client/2.0.0` };
10
+
11
+ async function create({ content_name, model, role, author: overrideAuthor, content, authorship_type }) {
12
+ if (!content_name) throw new Error('attest-client: content_name is required');
13
+
14
+ const params = new URLSearchParams();
15
+ params.set('content_name', content_name);
16
+ if (model) params.set('model', model);
17
+ if (role) params.set('role', role);
18
+ params.set('author', overrideAuthor || author);
19
+ if (content) params.set('content', content);
20
+ if (authorship_type) params.set('authorship_type', authorship_type);
21
+
22
+ const res = await fetch(`${host}/api/create?${params}`, { headers });
23
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
24
+
25
+ const data = await res.json();
26
+ if (!data.success) throw new Error(`attest-client: ${data.error || 'unknown error'}`);
27
+ return data;
28
+ }
29
+
30
+ async function createFromUrl({ url, model, role, author: overrideAuthor }) {
31
+ if (!url) throw new Error('attest-client: url is required');
32
+
33
+ const body = { url, model, role, author: overrideAuthor || author };
34
+ const res = await fetch(`${host}/api/create-url`, {
35
+ method: 'POST',
36
+ headers: { ...headers, 'Content-Type': 'application/json' },
37
+ body: JSON.stringify(body),
38
+ });
39
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
40
+
41
+ const data = await res.json();
42
+ if (!data.success) throw new Error(`attest-client: ${data.error || 'unknown error'}`);
43
+ return data;
44
+ }
45
+
46
+ async function metrics() {
47
+ const res = await fetch(`${host}/api/metrics`, { headers });
48
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
49
+ return res.json();
50
+ }
51
+
52
+ async function discover() {
53
+ const res = await fetch(`${host}/.well-known/attest.json`, { headers });
54
+ if (!res.ok) throw new Error(`attest-client: HTTP ${res.status} ${res.statusText}`);
55
+ return res.json();
56
+ }
57
+
58
+ return { create, createFromUrl, metrics, discover };
59
+ }
60
+
61
+ // Convenience: one-shot attestation without creating a client
62
+ export async function attest(options) {
63
+ const { host, author, ...params } = options;
64
+ const client = createClient({ host, author });
65
+ return client.create(params);
66
+ }
67
+
68
+ export default attest;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "attest-client",
3
+ "version": "2.0.0",
4
+ "description": "Client SDK for attest, the open protocol for AI content attribution",
5
+ "type": "module",
6
+ "main": "index.cjs",
7
+ "module": "index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./index.js",
11
+ "require": "./index.cjs"
12
+ }
13
+ },
14
+ "bin": {
15
+ "attest": "./cli.js"
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "index.cjs",
20
+ "cli.js",
21
+ "LICENSE"
22
+ ],
23
+ "keywords": [
24
+ "attest",
25
+ "attestation",
26
+ "ai",
27
+ "attribution",
28
+ "content",
29
+ "provenance",
30
+ "transparency",
31
+ "llm",
32
+ "agent"
33
+ ],
34
+ "author": "97115104",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/97115104/attest.git",
39
+ "directory": "sdk"
40
+ },
41
+ "homepage": "https://attest.97115104.com",
42
+ "engines": {
43
+ "node": ">=18"
44
+ }
45
+ }