@xproof/xproof 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xProof
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/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # xproof
2
+
3
+ Official TypeScript/JavaScript SDK for the [xProof](https://xproof.app) blockchain certification API — proof and accountability layer for autonomous agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xproof/xproof
9
+ ```
10
+
11
+ Requires Node.js 18+ (uses native `fetch`).
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { XProofClient } from "@xproof/xproof";
17
+
18
+ // 1. Register (zero-friction, no wallet needed)
19
+ const client = await XProofClient.register("my-agent");
20
+ console.log(client.registration?.trial.remaining); // 10 free certs
21
+
22
+ // 2. Certify a file (hashes locally, sends hash to API)
23
+ const cert = await client.certify("./report.pdf", "my-agent");
24
+ console.log(cert.transactionHash);
25
+
26
+ // 3. Verify
27
+ const proof = await client.verifyHash(cert.fileHash);
28
+ console.log(proof.id);
29
+ ```
30
+
31
+ Or use an existing API key:
32
+
33
+ ```typescript
34
+ const client = new XProofClient({ apiKey: "pm_your_key" });
35
+ ```
36
+
37
+ ## 4W Framework (WHO / WHAT / WHEN / WHY)
38
+
39
+ Certifications support the 4W accountability framework:
40
+
41
+ ```typescript
42
+ import { XProofClient, hashString } from "@xproof/xproof";
43
+
44
+ const client = new XProofClient({ apiKey: "pm_your_key" });
45
+
46
+ const cert = await client.certifyHash(
47
+ hashString('{"action": "generate_report"}'),
48
+ "agent-action.json",
49
+ "research-agent",
50
+ {
51
+ who: "erd1abc...or-agent-id",
52
+ what: hashString("generate_report"),
53
+ when: new Date().toISOString(),
54
+ why: hashString("Summarize Q1 earnings"),
55
+ metadata: { model: "gpt-4", session: "sess-123" },
56
+ }
57
+ );
58
+ ```
59
+
60
+ ## Batch Certification
61
+
62
+ Certify up to 50 files in a single call:
63
+
64
+ ```typescript
65
+ const result = await client.batchCertify([
66
+ { fileHash: "abc123...", fileName: "file1.pdf", author: "my-agent" },
67
+ { fileHash: "def456...", fileName: "file2.pdf" },
68
+ ]);
69
+
70
+ console.log(result.summary.total); // 2
71
+ console.log(result.summary.created); // 2
72
+ ```
73
+
74
+ ## Hash Utilities
75
+
76
+ ```typescript
77
+ import { hashFile, hashBuffer, hashString } from "@xproof/xproof";
78
+
79
+ const fileHash = await hashFile("./document.pdf");
80
+ const bufferHash = hashBuffer(Buffer.from("hello"));
81
+ const stringHash = hashString("hello world");
82
+ ```
83
+
84
+ ## Pricing
85
+
86
+ ```typescript
87
+ const pricing = await client.getPricing();
88
+ console.log(pricing.priceUsd);
89
+ ```
90
+
91
+ ## Error Handling
92
+
93
+ ```typescript
94
+ import {
95
+ XProofError,
96
+ AuthenticationError,
97
+ ConflictError,
98
+ RateLimitError,
99
+ } from "@xproof/xproof";
100
+
101
+ try {
102
+ await client.certifyHash(hash, name, author);
103
+ } catch (err) {
104
+ if (err instanceof ConflictError) {
105
+ console.log("Already certified:", err.certificationId);
106
+ } else if (err instanceof RateLimitError) {
107
+ console.log("Slow down, retry later");
108
+ } else if (err instanceof AuthenticationError) {
109
+ console.log("Check your API key");
110
+ }
111
+ }
112
+ ```
113
+
114
+ ## API Reference
115
+
116
+ ### `new XProofClient(options?)`
117
+
118
+ | Option | Type | Default |
119
+ |-----------|----------|-------------------------|
120
+ | `apiKey` | `string` | `""` |
121
+ | `baseUrl` | `string` | `"https://xproof.app"` |
122
+ | `timeout` | `number` | `30000` (ms) |
123
+
124
+ ### Methods
125
+
126
+ | Method | Description |
127
+ |--------|-------------|
128
+ | `XProofClient.register(agentName)` | Register agent, get trial key |
129
+ | `certify(path, author, fileName?, fourW?)` | Certify file (hashes locally) |
130
+ | `certifyHash(hash, name, author, fourW?)` | Certify by pre-computed hash |
131
+ | `batchCertify(files)` | Batch certify (up to 50) |
132
+ | `verify(proofId)` | Look up by proof ID |
133
+ | `verifyHash(fileHash)` | Look up by file hash |
134
+ | `getPricing()` | Get current pricing |
135
+
136
+ ## License
137
+
138
+ MIT
@@ -0,0 +1,93 @@
1
+ interface Certification {
2
+ id: string;
3
+ fileName: string;
4
+ fileHash: string;
5
+ transactionHash: string;
6
+ transactionUrl: string;
7
+ createdAt: string;
8
+ authorName: string;
9
+ blockchainStatus: string;
10
+ isPublic: boolean;
11
+ certificateUrl: string;
12
+ verifyUrl: string;
13
+ }
14
+ interface BatchResultSummary {
15
+ total: number;
16
+ created: number;
17
+ existing: number;
18
+ certified: number;
19
+ failed: number;
20
+ }
21
+ interface BatchResult {
22
+ batchId: string;
23
+ results: Certification[];
24
+ summary: BatchResultSummary;
25
+ }
26
+ interface PricingTier {
27
+ minCertifications: number;
28
+ maxCertifications: number | null;
29
+ priceUsd: number;
30
+ }
31
+ interface PricingInfo {
32
+ protocol: string;
33
+ version: string;
34
+ priceUsd: number;
35
+ tiers: PricingTier[];
36
+ paymentMethods: Array<Record<string, string>>;
37
+ raw: Record<string, unknown>;
38
+ }
39
+ interface TrialInfo {
40
+ quota: number;
41
+ used: number;
42
+ remaining: number;
43
+ }
44
+ interface RegistrationResult {
45
+ apiKey: string;
46
+ agentName: string;
47
+ trial: TrialInfo;
48
+ endpoints: Record<string, string>;
49
+ raw: Record<string, unknown>;
50
+ }
51
+ interface FourWOptions {
52
+ who?: string;
53
+ what?: string;
54
+ when?: string;
55
+ why?: string;
56
+ metadata?: Record<string, unknown>;
57
+ }
58
+ interface CertifyHashOptions extends FourWOptions {
59
+ fileHash: string;
60
+ fileName: string;
61
+ author: string;
62
+ }
63
+ interface BatchFileEntry {
64
+ fileHash: string;
65
+ fileName?: string;
66
+ author?: string;
67
+ metadata?: Record<string, unknown>;
68
+ }
69
+ interface XProofClientOptions {
70
+ apiKey?: string;
71
+ baseUrl?: string;
72
+ timeout?: number;
73
+ }
74
+
75
+ declare class XProofClient {
76
+ private apiKey;
77
+ private baseUrl;
78
+ private timeout;
79
+ registration: RegistrationResult | null;
80
+ constructor(options?: XProofClientOptions);
81
+ static register(agentName: string, options?: Omit<XProofClientOptions, "apiKey">): Promise<XProofClient>;
82
+ certify(path: string, author: string, fileName?: string, fourW?: FourWOptions): Promise<Certification>;
83
+ certifyHash(fileHash: string, fileName: string, author: string, fourW?: FourWOptions): Promise<Certification>;
84
+ batchCertify(files: BatchFileEntry[]): Promise<BatchResult>;
85
+ verify(proofId: string): Promise<Certification>;
86
+ verifyHash(fileHash: string): Promise<Certification>;
87
+ getPricing(): Promise<PricingInfo>;
88
+ private requireAuth;
89
+ private request;
90
+ private handleError;
91
+ }
92
+
93
+ export { type BatchFileEntry as B, type Certification as C, type FourWOptions as F, type PricingInfo as P, type RegistrationResult as R, type TrialInfo as T, XProofClient as X, type BatchResult as a, type BatchResultSummary as b, type CertifyHashOptions as c, type PricingTier as d, type XProofClientOptions as e };
@@ -0,0 +1,93 @@
1
+ interface Certification {
2
+ id: string;
3
+ fileName: string;
4
+ fileHash: string;
5
+ transactionHash: string;
6
+ transactionUrl: string;
7
+ createdAt: string;
8
+ authorName: string;
9
+ blockchainStatus: string;
10
+ isPublic: boolean;
11
+ certificateUrl: string;
12
+ verifyUrl: string;
13
+ }
14
+ interface BatchResultSummary {
15
+ total: number;
16
+ created: number;
17
+ existing: number;
18
+ certified: number;
19
+ failed: number;
20
+ }
21
+ interface BatchResult {
22
+ batchId: string;
23
+ results: Certification[];
24
+ summary: BatchResultSummary;
25
+ }
26
+ interface PricingTier {
27
+ minCertifications: number;
28
+ maxCertifications: number | null;
29
+ priceUsd: number;
30
+ }
31
+ interface PricingInfo {
32
+ protocol: string;
33
+ version: string;
34
+ priceUsd: number;
35
+ tiers: PricingTier[];
36
+ paymentMethods: Array<Record<string, string>>;
37
+ raw: Record<string, unknown>;
38
+ }
39
+ interface TrialInfo {
40
+ quota: number;
41
+ used: number;
42
+ remaining: number;
43
+ }
44
+ interface RegistrationResult {
45
+ apiKey: string;
46
+ agentName: string;
47
+ trial: TrialInfo;
48
+ endpoints: Record<string, string>;
49
+ raw: Record<string, unknown>;
50
+ }
51
+ interface FourWOptions {
52
+ who?: string;
53
+ what?: string;
54
+ when?: string;
55
+ why?: string;
56
+ metadata?: Record<string, unknown>;
57
+ }
58
+ interface CertifyHashOptions extends FourWOptions {
59
+ fileHash: string;
60
+ fileName: string;
61
+ author: string;
62
+ }
63
+ interface BatchFileEntry {
64
+ fileHash: string;
65
+ fileName?: string;
66
+ author?: string;
67
+ metadata?: Record<string, unknown>;
68
+ }
69
+ interface XProofClientOptions {
70
+ apiKey?: string;
71
+ baseUrl?: string;
72
+ timeout?: number;
73
+ }
74
+
75
+ declare class XProofClient {
76
+ private apiKey;
77
+ private baseUrl;
78
+ private timeout;
79
+ registration: RegistrationResult | null;
80
+ constructor(options?: XProofClientOptions);
81
+ static register(agentName: string, options?: Omit<XProofClientOptions, "apiKey">): Promise<XProofClient>;
82
+ certify(path: string, author: string, fileName?: string, fourW?: FourWOptions): Promise<Certification>;
83
+ certifyHash(fileHash: string, fileName: string, author: string, fourW?: FourWOptions): Promise<Certification>;
84
+ batchCertify(files: BatchFileEntry[]): Promise<BatchResult>;
85
+ verify(proofId: string): Promise<Certification>;
86
+ verifyHash(fileHash: string): Promise<Certification>;
87
+ getPricing(): Promise<PricingInfo>;
88
+ private requireAuth;
89
+ private request;
90
+ private handleError;
91
+ }
92
+
93
+ export { type BatchFileEntry as B, type Certification as C, type FourWOptions as F, type PricingInfo as P, type RegistrationResult as R, type TrialInfo as T, XProofClient as X, type BatchResult as a, type BatchResultSummary as b, type CertifyHashOptions as c, type PricingTier as d, type XProofClientOptions as e };
@@ -0,0 +1,32 @@
1
+ export { B as BatchFileEntry, a as BatchResult, b as BatchResultSummary, C as Certification, c as CertifyHashOptions, F as FourWOptions, P as PricingInfo, d as PricingTier, R as RegistrationResult, T as TrialInfo, X as XProofClient, e as XProofClientOptions } from './client-DOH3QHZm.mjs';
2
+
3
+ declare class XProofError extends Error {
4
+ statusCode: number;
5
+ response: Record<string, unknown> | null;
6
+ constructor(message: string, statusCode?: number, response?: Record<string, unknown> | null);
7
+ }
8
+ declare class AuthenticationError extends XProofError {
9
+ constructor(message?: string, response?: Record<string, unknown> | null);
10
+ }
11
+ declare class ValidationError extends XProofError {
12
+ constructor(message?: string, response?: Record<string, unknown> | null);
13
+ }
14
+ declare class NotFoundError extends XProofError {
15
+ constructor(message?: string, response?: Record<string, unknown> | null);
16
+ }
17
+ declare class ConflictError extends XProofError {
18
+ certificationId: string;
19
+ constructor(message?: string, certificationId?: string, response?: Record<string, unknown> | null);
20
+ }
21
+ declare class RateLimitError extends XProofError {
22
+ constructor(message?: string, response?: Record<string, unknown> | null);
23
+ }
24
+ declare class ServerError extends XProofError {
25
+ constructor(message?: string, statusCode?: number, response?: Record<string, unknown> | null);
26
+ }
27
+
28
+ declare function hashFile(path: string): Promise<string>;
29
+ declare function hashBuffer(data: Buffer | Uint8Array): string;
30
+ declare function hashString(data: string): string;
31
+
32
+ export { AuthenticationError, ConflictError, NotFoundError, RateLimitError, ServerError, ValidationError, XProofError, hashBuffer, hashFile, hashString };
@@ -0,0 +1,32 @@
1
+ export { B as BatchFileEntry, a as BatchResult, b as BatchResultSummary, C as Certification, c as CertifyHashOptions, F as FourWOptions, P as PricingInfo, d as PricingTier, R as RegistrationResult, T as TrialInfo, X as XProofClient, e as XProofClientOptions } from './client-DOH3QHZm.js';
2
+
3
+ declare class XProofError extends Error {
4
+ statusCode: number;
5
+ response: Record<string, unknown> | null;
6
+ constructor(message: string, statusCode?: number, response?: Record<string, unknown> | null);
7
+ }
8
+ declare class AuthenticationError extends XProofError {
9
+ constructor(message?: string, response?: Record<string, unknown> | null);
10
+ }
11
+ declare class ValidationError extends XProofError {
12
+ constructor(message?: string, response?: Record<string, unknown> | null);
13
+ }
14
+ declare class NotFoundError extends XProofError {
15
+ constructor(message?: string, response?: Record<string, unknown> | null);
16
+ }
17
+ declare class ConflictError extends XProofError {
18
+ certificationId: string;
19
+ constructor(message?: string, certificationId?: string, response?: Record<string, unknown> | null);
20
+ }
21
+ declare class RateLimitError extends XProofError {
22
+ constructor(message?: string, response?: Record<string, unknown> | null);
23
+ }
24
+ declare class ServerError extends XProofError {
25
+ constructor(message?: string, statusCode?: number, response?: Record<string, unknown> | null);
26
+ }
27
+
28
+ declare function hashFile(path: string): Promise<string>;
29
+ declare function hashBuffer(data: Buffer | Uint8Array): string;
30
+ declare function hashString(data: string): string;
31
+
32
+ export { AuthenticationError, ConflictError, NotFoundError, RateLimitError, ServerError, ValidationError, XProofError, hashBuffer, hashFile, hashString };