@xproof/xproof 0.1.2 → 0.1.4

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.
@@ -60,6 +60,35 @@ interface CertifyHashOptions extends FourWOptions {
60
60
  fileName: string;
61
61
  author: string;
62
62
  }
63
+ type ThresholdStage = "initial" | "partial" | "pre-commitment" | "final";
64
+ interface ConfidenceOptions {
65
+ confidenceLevel: number;
66
+ thresholdStage: ThresholdStage;
67
+ decisionId: string;
68
+ }
69
+ interface ConfidenceTrailStage {
70
+ proofId: string;
71
+ fileName: string;
72
+ fileHash: string;
73
+ confidenceLevel: number | null;
74
+ thresholdStage: string | null;
75
+ author: string;
76
+ blockchain: {
77
+ transactionHash: string;
78
+ explorerUrl: string;
79
+ status: string;
80
+ };
81
+ anchoredAt: string;
82
+ metadata: Record<string, unknown>;
83
+ }
84
+ interface ConfidenceTrail {
85
+ decisionId: string;
86
+ totalAnchors: number;
87
+ currentConfidence: number | null;
88
+ currentStage: string | null;
89
+ isFinalized: boolean;
90
+ stages: ConfidenceTrailStage[];
91
+ }
63
92
  interface BatchFileEntry {
64
93
  fileHash: string;
65
94
  fileName?: string;
@@ -71,6 +100,32 @@ interface XProofClientOptions {
71
100
  baseUrl?: string;
72
101
  timeout?: number;
73
102
  }
103
+ interface ExecutionContext {
104
+ model_hash: string | null;
105
+ tools_version: string | null;
106
+ strategy_snapshot: string | null;
107
+ operator_scope: string | null;
108
+ [key: string]: string | null;
109
+ }
110
+ interface ContextDriftStage {
111
+ proofId: string;
112
+ stageIndex: number;
113
+ anchoredAt: string;
114
+ executionContext: ExecutionContext;
115
+ contextBreak: boolean;
116
+ driftedFields: string[];
117
+ }
118
+ interface ContextDrift {
119
+ decisionId: string;
120
+ contextCoherent: boolean;
121
+ driftScore: number;
122
+ fieldsMonitored: string[];
123
+ fieldsDrifted: string[];
124
+ fieldsStable: string[];
125
+ fieldsAbsent: string[];
126
+ totalAnchors: number;
127
+ stages: ContextDriftStage[];
128
+ }
74
129
 
75
130
  declare class XProofClient {
76
131
  private apiKey;
@@ -84,10 +139,13 @@ declare class XProofClient {
84
139
  batchCertify(files: BatchFileEntry[]): Promise<BatchResult>;
85
140
  verify(proofId: string): Promise<Certification>;
86
141
  verifyHash(fileHash: string): Promise<Certification>;
142
+ certifyWithConfidence(fileHash: string, fileName: string, author: string, confidence: ConfidenceOptions, fourW?: FourWOptions): Promise<Certification>;
143
+ getConfidenceTrail(decisionId: string): Promise<ConfidenceTrail>;
144
+ getContextDrift(decisionId: string): Promise<ContextDrift>;
87
145
  getPricing(): Promise<PricingInfo>;
88
146
  private requireAuth;
89
147
  private request;
90
148
  private handleError;
91
149
  }
92
150
 
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 };
151
+ export { type BatchFileEntry as B, type Certification as C, type ExecutionContext as E, type FourWOptions as F, type PricingInfo as P, type RegistrationResult as R, type ThresholdStage as T, XProofClient as X, type BatchResult as a, type BatchResultSummary as b, type CertifyHashOptions as c, type ConfidenceOptions as d, type ConfidenceTrail as e, type ConfidenceTrailStage as f, type ContextDrift as g, type ContextDriftStage as h, type PricingTier as i, type TrialInfo as j, type XProofClientOptions as k };
@@ -60,6 +60,35 @@ interface CertifyHashOptions extends FourWOptions {
60
60
  fileName: string;
61
61
  author: string;
62
62
  }
63
+ type ThresholdStage = "initial" | "partial" | "pre-commitment" | "final";
64
+ interface ConfidenceOptions {
65
+ confidenceLevel: number;
66
+ thresholdStage: ThresholdStage;
67
+ decisionId: string;
68
+ }
69
+ interface ConfidenceTrailStage {
70
+ proofId: string;
71
+ fileName: string;
72
+ fileHash: string;
73
+ confidenceLevel: number | null;
74
+ thresholdStage: string | null;
75
+ author: string;
76
+ blockchain: {
77
+ transactionHash: string;
78
+ explorerUrl: string;
79
+ status: string;
80
+ };
81
+ anchoredAt: string;
82
+ metadata: Record<string, unknown>;
83
+ }
84
+ interface ConfidenceTrail {
85
+ decisionId: string;
86
+ totalAnchors: number;
87
+ currentConfidence: number | null;
88
+ currentStage: string | null;
89
+ isFinalized: boolean;
90
+ stages: ConfidenceTrailStage[];
91
+ }
63
92
  interface BatchFileEntry {
64
93
  fileHash: string;
65
94
  fileName?: string;
@@ -71,6 +100,32 @@ interface XProofClientOptions {
71
100
  baseUrl?: string;
72
101
  timeout?: number;
73
102
  }
103
+ interface ExecutionContext {
104
+ model_hash: string | null;
105
+ tools_version: string | null;
106
+ strategy_snapshot: string | null;
107
+ operator_scope: string | null;
108
+ [key: string]: string | null;
109
+ }
110
+ interface ContextDriftStage {
111
+ proofId: string;
112
+ stageIndex: number;
113
+ anchoredAt: string;
114
+ executionContext: ExecutionContext;
115
+ contextBreak: boolean;
116
+ driftedFields: string[];
117
+ }
118
+ interface ContextDrift {
119
+ decisionId: string;
120
+ contextCoherent: boolean;
121
+ driftScore: number;
122
+ fieldsMonitored: string[];
123
+ fieldsDrifted: string[];
124
+ fieldsStable: string[];
125
+ fieldsAbsent: string[];
126
+ totalAnchors: number;
127
+ stages: ContextDriftStage[];
128
+ }
74
129
 
75
130
  declare class XProofClient {
76
131
  private apiKey;
@@ -84,10 +139,13 @@ declare class XProofClient {
84
139
  batchCertify(files: BatchFileEntry[]): Promise<BatchResult>;
85
140
  verify(proofId: string): Promise<Certification>;
86
141
  verifyHash(fileHash: string): Promise<Certification>;
142
+ certifyWithConfidence(fileHash: string, fileName: string, author: string, confidence: ConfidenceOptions, fourW?: FourWOptions): Promise<Certification>;
143
+ getConfidenceTrail(decisionId: string): Promise<ConfidenceTrail>;
144
+ getContextDrift(decisionId: string): Promise<ContextDrift>;
87
145
  getPricing(): Promise<PricingInfo>;
88
146
  private requireAuth;
89
147
  private request;
90
148
  private handleError;
91
149
  }
92
150
 
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 };
151
+ export { type BatchFileEntry as B, type Certification as C, type ExecutionContext as E, type FourWOptions as F, type PricingInfo as P, type RegistrationResult as R, type ThresholdStage as T, XProofClient as X, type BatchResult as a, type BatchResultSummary as b, type CertifyHashOptions as c, type ConfidenceOptions as d, type ConfidenceTrail as e, type ConfidenceTrailStage as f, type ContextDrift as g, type ContextDriftStage as h, type PricingTier as i, type TrialInfo as j, type XProofClientOptions as k };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ export { B as BatchFileEntry, a as BatchResult, b as BatchResultSummary, C as Certification, c as CertifyHashOptions, d as ConfidenceOptions, e as ConfidenceTrail, f as ConfidenceTrailStage, g as ContextDrift, h as ContextDriftStage, E as ExecutionContext, F as FourWOptions, P as PricingInfo, i as PricingTier, R as RegistrationResult, T as ThresholdStage, j as TrialInfo, X as XProofClient, k as XProofClientOptions } from './client-BNp2oPhL.mjs';
2
2
 
3
3
  declare class XProofError extends Error {
4
4
  statusCode: number;
@@ -26,7 +26,7 @@ declare class ServerError extends XProofError {
26
26
  }
27
27
 
28
28
  declare function hashFile(path: string): Promise<string>;
29
- declare function hashBuffer(data: Buffer | Uint8Array): string;
29
+ declare function hashBuffer(data: Uint8Array): string;
30
30
  declare function hashString(data: string): string;
31
31
 
32
32
  export { AuthenticationError, ConflictError, NotFoundError, RateLimitError, ServerError, ValidationError, XProofError, hashBuffer, hashFile, hashString };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ export { B as BatchFileEntry, a as BatchResult, b as BatchResultSummary, C as Certification, c as CertifyHashOptions, d as ConfidenceOptions, e as ConfidenceTrail, f as ConfidenceTrailStage, g as ContextDrift, h as ContextDriftStage, E as ExecutionContext, F as FourWOptions, P as PricingInfo, i as PricingTier, R as RegistrationResult, T as ThresholdStage, j as TrialInfo, X as XProofClient, k as XProofClientOptions } from './client-BNp2oPhL.js';
2
2
 
3
3
  declare class XProofError extends Error {
4
4
  statusCode: number;
@@ -26,7 +26,7 @@ declare class ServerError extends XProofError {
26
26
  }
27
27
 
28
28
  declare function hashFile(path: string): Promise<string>;
29
- declare function hashBuffer(data: Buffer | Uint8Array): string;
29
+ declare function hashBuffer(data: Uint8Array): string;
30
30
  declare function hashString(data: string): string;
31
31
 
32
32
  export { AuthenticationError, ConflictError, NotFoundError, RateLimitError, ServerError, ValidationError, XProofError, hashBuffer, hashFile, hashString };
package/dist/index.js CHANGED
@@ -171,7 +171,7 @@ function parseRegistrationResult(data) {
171
171
  }
172
172
 
173
173
  // src/client.ts
174
- var VERSION = "0.1.0";
174
+ var VERSION = "0.1.4";
175
175
  var DEFAULT_BASE_URL = "https://xproof.app";
176
176
  var DEFAULT_TIMEOUT = 3e4;
177
177
  var XProofClient = class _XProofClient {
@@ -250,6 +250,92 @@ var XProofClient = class _XProofClient {
250
250
  });
251
251
  return parseCertification(data);
252
252
  }
253
+ async certifyWithConfidence(fileHash, fileName, author, confidence, fourW) {
254
+ this.requireAuth();
255
+ if (confidence.confidenceLevel < 0 || confidence.confidenceLevel > 1) {
256
+ throw new ValidationError(
257
+ "confidenceLevel must be between 0.0 and 1.0",
258
+ {}
259
+ );
260
+ }
261
+ if (!confidence.decisionId || confidence.decisionId.trim().length === 0) {
262
+ throw new ValidationError("decisionId is required", {});
263
+ }
264
+ const metadata = fourW?.metadata ? { ...fourW.metadata } : {};
265
+ if (fourW?.who !== void 0) metadata.who = fourW.who;
266
+ if (fourW?.what !== void 0) metadata.what = fourW.what;
267
+ if (fourW?.when !== void 0) metadata.when = fourW.when;
268
+ if (fourW?.why !== void 0) metadata.why = fourW.why;
269
+ metadata.confidence_level = confidence.confidenceLevel;
270
+ metadata.threshold_stage = confidence.thresholdStage;
271
+ metadata.decision_id = confidence.decisionId;
272
+ const payload = {
273
+ filename: fileName,
274
+ file_hash: fileHash,
275
+ author_name: author,
276
+ metadata
277
+ };
278
+ const data = await this.request("POST", "/api/proof", { body: payload });
279
+ return parseCertification(data);
280
+ }
281
+ async getConfidenceTrail(decisionId) {
282
+ const data = await this.request(
283
+ "GET",
284
+ `/api/confidence-trail/${encodeURIComponent(decisionId)}`,
285
+ { authRequired: false }
286
+ );
287
+ const rawStages = data.stages || [];
288
+ const stages = rawStages.map((s) => ({
289
+ proofId: s.proof_id || "",
290
+ fileName: s.file_name || "",
291
+ fileHash: s.file_hash || "",
292
+ confidenceLevel: s.confidence_level ?? null,
293
+ thresholdStage: s.threshold_stage ?? null,
294
+ author: s.author || "",
295
+ blockchain: {
296
+ transactionHash: s.blockchain?.transaction_hash || "",
297
+ explorerUrl: s.blockchain?.explorer_url || "",
298
+ status: s.blockchain?.status || ""
299
+ },
300
+ anchoredAt: s.anchored_at || "",
301
+ metadata: s.metadata || {}
302
+ }));
303
+ return {
304
+ decisionId: data.decision_id || decisionId,
305
+ totalAnchors: data.total_anchors || stages.length,
306
+ currentConfidence: data.current_confidence ?? null,
307
+ currentStage: data.current_stage ?? null,
308
+ isFinalized: data.is_finalized || false,
309
+ stages
310
+ };
311
+ }
312
+ async getContextDrift(decisionId) {
313
+ const data = await this.request(
314
+ "GET",
315
+ `/api/context-drift/${encodeURIComponent(decisionId)}`,
316
+ { authRequired: false }
317
+ );
318
+ const rawStages = data.stages || [];
319
+ const stages = rawStages.map((s) => ({
320
+ proofId: s.proof_id || "",
321
+ stageIndex: s.stage_index ?? 0,
322
+ anchoredAt: s.anchored_at || "",
323
+ executionContext: s.execution_context || {},
324
+ contextBreak: s.context_break || false,
325
+ driftedFields: s.drifted_fields || []
326
+ }));
327
+ return {
328
+ decisionId: data.decision_id || decisionId,
329
+ contextCoherent: data.context_coherent ?? true,
330
+ driftScore: data.drift_score ?? 0,
331
+ fieldsMonitored: data.fields_monitored || [],
332
+ fieldsDrifted: data.fields_drifted || [],
333
+ fieldsStable: data.fields_stable || [],
334
+ fieldsAbsent: data.fields_absent || [],
335
+ totalAnchors: data.total_anchors || stages.length,
336
+ stages
337
+ };
338
+ }
253
339
  async getPricing() {
254
340
  const data = await this.request("GET", "/api/pricing", {
255
341
  authRequired: false
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/errors.ts","../src/hash.ts","../src/parse.ts"],"sourcesContent":["export { XProofClient } from \"./client.js\";\nexport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nexport type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n FourWOptions,\n CertifyHashOptions,\n BatchFileEntry,\n XProofClientOptions,\n} from \"./types.js\";\nexport { hashFile, hashBuffer, hashString } from \"./hash.js\";\n","import { basename } from \"path\";\nimport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nimport { hashFile } from \"./hash.js\";\nimport {\n parseCertification,\n parseBatchResult,\n parsePricingInfo,\n parseRegistrationResult,\n} from \"./parse.js\";\nimport type {\n Certification,\n BatchResult,\n PricingInfo,\n RegistrationResult,\n FourWOptions,\n BatchFileEntry,\n XProofClientOptions,\n} from \"./types.js\";\n\nconst VERSION = \"0.1.0\";\nconst DEFAULT_BASE_URL = \"https://xproof.app\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class XProofClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n\n registration: RegistrationResult | null = null;\n\n constructor(options: XProofClientOptions = {}) {\n this.apiKey = options.apiKey ?? \"\";\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n }\n\n static async register(\n agentName: string,\n options: Omit<XProofClientOptions, \"apiKey\"> = {}\n ): Promise<XProofClient> {\n const temp = new XProofClient(options);\n const data = await temp.request(\"POST\", \"/api/agent/register\", {\n body: { agent_name: agentName },\n authRequired: false,\n });\n const result = parseRegistrationResult(data);\n const client = new XProofClient({\n ...options,\n apiKey: result.apiKey,\n });\n client.registration = result;\n return client;\n }\n\n async certify(\n path: string,\n author: string,\n fileName?: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n const fileHash = await hashFile(path);\n const resolvedName = fileName ?? basename(path);\n return this.certifyHash(fileHash, resolvedName, author, fourW);\n }\n\n async certifyHash(\n fileHash: string,\n fileName: string,\n author: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n };\n if (Object.keys(metadata).length > 0) {\n payload.metadata = metadata;\n }\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async batchCertify(files: BatchFileEntry[]): Promise<BatchResult> {\n this.requireAuth();\n\n if (files.length > 50) {\n throw new Error(\"Batch certification supports a maximum of 50 files\");\n }\n\n const entries = files.map((f) => {\n const entry: Record<string, unknown> = {\n filename: f.fileName ?? \"unknown\",\n file_hash: f.fileHash,\n };\n if (f.metadata) entry.metadata = f.metadata;\n return entry;\n });\n\n const payload: Record<string, unknown> = { files: entries };\n const author = files.find((f) => f.author)?.author;\n if (author) payload.author_name = author;\n\n const data = await this.request(\"POST\", \"/api/batch\", { body: payload });\n return parseBatchResult(data);\n }\n\n async verify(proofId: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/${proofId}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async verifyHash(fileHash: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/hash/${fileHash}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async getPricing(): Promise<PricingInfo> {\n const data = await this.request(\"GET\", \"/api/pricing\", {\n authRequired: false,\n });\n return parsePricingInfo(data);\n }\n\n private requireAuth(): void {\n if (!this.apiKey) {\n throw new Error(\n \"apiKey is required — call XProofClient.register() or pass an apiKey\"\n );\n }\n }\n\n private async request(\n method: string,\n path: string,\n options: {\n body?: Record<string, unknown>;\n authRequired?: boolean;\n } = {}\n ): Promise<Record<string, unknown>> {\n const url = `${this.baseUrl}${path}`;\n const { body, authRequired = true } = options;\n\n const headers: Record<string, string> = {\n \"User-Agent\": `xproof-js/${VERSION}`,\n };\n\n if (authRequired && this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n if (body) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let resp: Response;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new XProofError(`Request timed out after ${this.timeout}ms`);\n }\n throw new XProofError(`Request failed: ${(err as Error).message}`);\n } finally {\n clearTimeout(timer);\n }\n\n if (resp.status === 200 || resp.status === 201) {\n let data: Record<string, unknown>;\n try {\n data = (await resp.json()) as Record<string, unknown>;\n } catch {\n const text = await resp.text().catch(() => \"\");\n throw new XProofError(\n `Unexpected non-JSON response from ${method} ${url}: ${text.slice(0, 200)}`\n );\n }\n return data;\n }\n\n await this.handleError(resp);\n return {};\n }\n\n private async handleError(resp: Response): Promise<never> {\n let body: Record<string, unknown>;\n try {\n body = (await resp.json()) as Record<string, unknown>;\n } catch {\n body = { message: await resp.text().catch(() => \"\") };\n }\n\n const message =\n (body.message as string) || (body.error as string) || `HTTP ${resp.status}`;\n const status = resp.status;\n\n if (status === 400) throw new ValidationError(message, body);\n if (status === 401 || status === 403)\n throw new AuthenticationError(message, body);\n if (status === 404) throw new NotFoundError(message, body);\n if (status === 409)\n throw new ConflictError(\n message,\n (body.certificationId as string) || \"\",\n body\n );\n if (status === 429) throw new RateLimitError(message, body);\n if (status >= 500) throw new ServerError(message, status, body);\n throw new XProofError(message, status, body);\n }\n}\n","export class XProofError extends Error {\n statusCode: number;\n response: Record<string, unknown> | null;\n\n constructor(\n message: string,\n statusCode = 0,\n response: Record<string, unknown> | null = null\n ) {\n super(message);\n this.name = \"XProofError\";\n this.statusCode = statusCode;\n this.response = response;\n }\n}\n\nexport class AuthenticationError extends XProofError {\n constructor(\n message = \"Invalid or missing API key\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 401, response);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class ValidationError extends XProofError {\n constructor(\n message = \"Invalid request data\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 400, response);\n this.name = \"ValidationError\";\n }\n}\n\nexport class NotFoundError extends XProofError {\n constructor(\n message = \"Resource not found\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 404, response);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ConflictError extends XProofError {\n certificationId: string;\n\n constructor(\n message = \"File already certified\",\n certificationId = \"\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 409, response);\n this.name = \"ConflictError\";\n this.certificationId = certificationId;\n }\n}\n\nexport class RateLimitError extends XProofError {\n constructor(\n message = \"Rate limit exceeded\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 429, response);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ServerError extends XProofError {\n constructor(\n message = \"Internal server error\",\n statusCode = 500,\n response: Record<string, unknown> | null = null\n ) {\n super(message, statusCode, response);\n this.name = \"ServerError\";\n }\n}\n","import { createHash } from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport async function hashFile(path: string): Promise<string> {\n const data = await readFile(path);\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashBuffer(data: Buffer | Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashString(data: string): string {\n return createHash(\"sha256\").update(data, \"utf8\").digest(\"hex\");\n}\n","import type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n} from \"./types.js\";\n\nexport function parseCertification(data: Record<string, unknown>): Certification {\n const blockchain = (data.blockchain as Record<string, unknown>) || {};\n return {\n id: (data.id as string) || (data.proof_id as string) || \"\",\n fileName:\n (data.fileName as string) ||\n (data.filename as string) ||\n (data.file_name as string) ||\n \"\",\n fileHash:\n (data.fileHash as string) || (data.file_hash as string) || \"\",\n transactionHash:\n (data.transactionHash as string) ||\n (blockchain.transaction_hash as string) ||\n \"\",\n transactionUrl:\n (data.transactionUrl as string) ||\n (blockchain.explorer_url as string) ||\n \"\",\n createdAt:\n (data.createdAt as string) ||\n (data.created_at as string) ||\n (data.timestamp as string) ||\n \"\",\n authorName:\n (data.authorName as string) || (data.author_name as string) || \"\",\n blockchainStatus:\n (data.blockchainStatus as string) || (data.status as string) || \"\",\n isPublic: data.isPublic !== undefined ? !!data.isPublic : (data.is_public !== undefined ? !!data.is_public : true),\n certificateUrl:\n (data.certificateUrl as string) ||\n (data.certificate_url as string) ||\n \"\",\n verifyUrl:\n (data.verifyUrl as string) || (data.verify_url as string) || \"\",\n };\n}\n\nexport function parseBatchResult(data: Record<string, unknown>): BatchResult {\n const rawResults = (data.results as Array<Record<string, unknown>>) || [];\n const results = rawResults.map(parseCertification);\n const total = (data.total as number) ?? rawResults.length;\n const created = (data.created as number) ?? 0;\n const existing = (data.existing as number) ?? 0;\n\n const summary: BatchResultSummary = {\n total,\n created,\n existing,\n get certified() { return created; },\n get failed() { return total - created - existing; },\n };\n\n return {\n batchId: (data.batch_id as string) || \"\",\n results,\n summary,\n };\n}\n\nexport function parsePricingInfo(data: Record<string, unknown>): PricingInfo {\n const rawTiers = (data.tiers as Array<Record<string, unknown>>) || [];\n const tiers: PricingTier[] = rawTiers.map((t) => ({\n minCertifications:\n (t.min_certifications as number) ?? (t.min as number) ?? 0,\n maxCertifications:\n (t.max_certifications as number) ?? (t.max as number) ?? null,\n priceUsd: (t.price_usd as number) ?? (t.price as number) ?? 0,\n }));\n\n return {\n protocol: (data.protocol as string) || \"\",\n version: (data.version as string) || \"\",\n priceUsd:\n (data.price_usd as number) ?? (data.current_price as number) ?? 0,\n tiers,\n paymentMethods:\n (data.payment_methods as Array<Record<string, string>>) || [],\n raw: data,\n };\n}\n\nexport function parseRegistrationResult(\n data: Record<string, unknown>\n): RegistrationResult {\n const trialData = (data.trial as Record<string, unknown>) || {};\n const trial: TrialInfo = {\n quota: (trialData.quota as number) ?? 0,\n used: (trialData.used as number) ?? 0,\n remaining: (trialData.remaining as number) ?? 0,\n };\n return {\n apiKey: (data.api_key as string) || \"\",\n agentName: (data.agent_name as string) || \"\",\n trial,\n endpoints: (data.endpoints as Record<string, string>) || {},\n raw: data,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAyB;;;ACAlB,IAAM,cAAN,cAA0B,MAAM;AAAA,EAIrC,YACE,SACA,aAAa,GACb,WAA2C,MAC3C;AACA,UAAM,OAAO;AACb,SAAK,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AEpB,QAAI,WAAW,IAAK,OAAM,IAAI,gBAAgB,SAAS,IAAI;AAC3D,QAAI,WAAW,OAAO,WAAW;AAC/B,YAAM,IAAI,oBAAoB,SAAS,IAAI;AAC7C,QAAI,WAAW,IAAK,OAAM,IAAI,cAAc,SAAS,IAAI;AACzD,QAAI,WAAW;AACb,YAAM,IAAI;AAAA,QACR;AAAA,QACC,KAAK,mBAA8B;AAAA,QACpC;AAAA,MACF;AACF,QAAI,WAAW,IAAK,OAAM,IAAI,eAAe,SAAS,IAAI;AAC1D,QAAI,UAAU,IAAK,OAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAC9D,UAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAAA,EAC7C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/errors.ts","../src/hash.ts","../src/parse.ts"],"sourcesContent":["export { XProofClient } from \"./client.js\";\nexport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nexport type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n FourWOptions,\n CertifyHashOptions,\n BatchFileEntry,\n XProofClientOptions,\n ThresholdStage,\n ConfidenceOptions,\n ConfidenceTrail,\n ConfidenceTrailStage,\n ExecutionContext,\n ContextDriftStage,\n ContextDrift,\n} from \"./types.js\";\nexport { hashFile, hashBuffer, hashString } from \"./hash.js\";\n","import { basename } from \"path\";\nimport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nimport { hashFile } from \"./hash.js\";\nimport {\n parseCertification,\n parseBatchResult,\n parsePricingInfo,\n parseRegistrationResult,\n} from \"./parse.js\";\nimport type {\n Certification,\n BatchResult,\n PricingInfo,\n RegistrationResult,\n FourWOptions,\n BatchFileEntry,\n XProofClientOptions,\n ConfidenceOptions,\n ConfidenceTrail,\n ConfidenceTrailStage,\n ContextDrift,\n ContextDriftStage,\n ExecutionContext,\n} from \"./types.js\";\n\nconst VERSION = \"0.1.4\";\nconst DEFAULT_BASE_URL = \"https://xproof.app\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class XProofClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n\n registration: RegistrationResult | null = null;\n\n constructor(options: XProofClientOptions = {}) {\n this.apiKey = options.apiKey ?? \"\";\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n }\n\n static async register(\n agentName: string,\n options: Omit<XProofClientOptions, \"apiKey\"> = {}\n ): Promise<XProofClient> {\n const temp = new XProofClient(options);\n const data = await temp.request(\"POST\", \"/api/agent/register\", {\n body: { agent_name: agentName },\n authRequired: false,\n });\n const result = parseRegistrationResult(data);\n const client = new XProofClient({\n ...options,\n apiKey: result.apiKey,\n });\n client.registration = result;\n return client;\n }\n\n async certify(\n path: string,\n author: string,\n fileName?: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n const fileHash = await hashFile(path);\n const resolvedName = fileName ?? basename(path);\n return this.certifyHash(fileHash, resolvedName, author, fourW);\n }\n\n async certifyHash(\n fileHash: string,\n fileName: string,\n author: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n };\n if (Object.keys(metadata).length > 0) {\n payload.metadata = metadata;\n }\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async batchCertify(files: BatchFileEntry[]): Promise<BatchResult> {\n this.requireAuth();\n\n if (files.length > 50) {\n throw new Error(\"Batch certification supports a maximum of 50 files\");\n }\n\n const entries = files.map((f) => {\n const entry: Record<string, unknown> = {\n filename: f.fileName ?? \"unknown\",\n file_hash: f.fileHash,\n };\n if (f.metadata) entry.metadata = f.metadata;\n return entry;\n });\n\n const payload: Record<string, unknown> = { files: entries };\n const author = files.find((f) => f.author)?.author;\n if (author) payload.author_name = author;\n\n const data = await this.request(\"POST\", \"/api/batch\", { body: payload });\n return parseBatchResult(data);\n }\n\n async verify(proofId: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/${proofId}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async verifyHash(fileHash: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/hash/${fileHash}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async certifyWithConfidence(\n fileHash: string,\n fileName: string,\n author: string,\n confidence: ConfidenceOptions,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n if (confidence.confidenceLevel < 0 || confidence.confidenceLevel > 1) {\n throw new ValidationError(\n \"confidenceLevel must be between 0.0 and 1.0\",\n {}\n );\n }\n if (!confidence.decisionId || confidence.decisionId.trim().length === 0) {\n throw new ValidationError(\"decisionId is required\", {});\n }\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n metadata.confidence_level = confidence.confidenceLevel;\n metadata.threshold_stage = confidence.thresholdStage;\n metadata.decision_id = confidence.decisionId;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n metadata,\n };\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async getConfidenceTrail(decisionId: string): Promise<ConfidenceTrail> {\n const data = await this.request(\n \"GET\",\n `/api/confidence-trail/${encodeURIComponent(decisionId)}`,\n { authRequired: false }\n );\n\n const rawStages = (data.stages as any[]) || [];\n const stages: ConfidenceTrailStage[] = rawStages.map((s: any) => ({\n proofId: s.proof_id || \"\",\n fileName: s.file_name || \"\",\n fileHash: s.file_hash || \"\",\n confidenceLevel: s.confidence_level ?? null,\n thresholdStage: s.threshold_stage ?? null,\n author: s.author || \"\",\n blockchain: {\n transactionHash: s.blockchain?.transaction_hash || \"\",\n explorerUrl: s.blockchain?.explorer_url || \"\",\n status: s.blockchain?.status || \"\",\n },\n anchoredAt: s.anchored_at || \"\",\n metadata: s.metadata || {},\n }));\n\n return {\n decisionId: (data.decision_id as string) || decisionId,\n totalAnchors: (data.total_anchors as number) || stages.length,\n currentConfidence: (data.current_confidence as number) ?? null,\n currentStage: (data.current_stage as string) ?? null,\n isFinalized: (data.is_finalized as boolean) || false,\n stages,\n };\n }\n\n async getContextDrift(decisionId: string): Promise<ContextDrift> {\n const data = await this.request(\n \"GET\",\n `/api/context-drift/${encodeURIComponent(decisionId)}`,\n { authRequired: false }\n );\n\n const rawStages = (data.stages as any[]) || [];\n const stages: ContextDriftStage[] = rawStages.map((s: any) => ({\n proofId: s.proof_id || \"\",\n stageIndex: s.stage_index ?? 0,\n anchoredAt: s.anchored_at || \"\",\n executionContext: (s.execution_context || {}) as ExecutionContext,\n contextBreak: s.context_break || false,\n driftedFields: s.drifted_fields || [],\n }));\n\n return {\n decisionId: (data.decision_id as string) || decisionId,\n contextCoherent: (data.context_coherent as boolean) ?? true,\n driftScore: (data.drift_score as number) ?? 0,\n fieldsMonitored: (data.fields_monitored as string[]) || [],\n fieldsDrifted: (data.fields_drifted as string[]) || [],\n fieldsStable: (data.fields_stable as string[]) || [],\n fieldsAbsent: (data.fields_absent as string[]) || [],\n totalAnchors: (data.total_anchors as number) || stages.length,\n stages,\n };\n }\n\n async getPricing(): Promise<PricingInfo> {\n const data = await this.request(\"GET\", \"/api/pricing\", {\n authRequired: false,\n });\n return parsePricingInfo(data);\n }\n\n private requireAuth(): void {\n if (!this.apiKey) {\n throw new Error(\n \"apiKey is required — call XProofClient.register() or pass an apiKey\"\n );\n }\n }\n\n private async request(\n method: string,\n path: string,\n options: {\n body?: Record<string, unknown>;\n authRequired?: boolean;\n } = {}\n ): Promise<Record<string, unknown>> {\n const url = `${this.baseUrl}${path}`;\n const { body, authRequired = true } = options;\n\n const headers: Record<string, string> = {\n \"User-Agent\": `xproof-js/${VERSION}`,\n };\n\n if (authRequired && this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n if (body) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let resp: Response;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new XProofError(`Request timed out after ${this.timeout}ms`);\n }\n throw new XProofError(`Request failed: ${(err as Error).message}`);\n } finally {\n clearTimeout(timer);\n }\n\n if (resp.status === 200 || resp.status === 201) {\n let data: Record<string, unknown>;\n try {\n data = (await resp.json()) as Record<string, unknown>;\n } catch {\n const text = await resp.text().catch(() => \"\");\n throw new XProofError(\n `Unexpected non-JSON response from ${method} ${url}: ${text.slice(0, 200)}`\n );\n }\n return data;\n }\n\n await this.handleError(resp);\n return {};\n }\n\n private async handleError(resp: Response): Promise<never> {\n let body: Record<string, unknown>;\n try {\n body = (await resp.json()) as Record<string, unknown>;\n } catch {\n body = { message: await resp.text().catch(() => \"\") };\n }\n\n const message =\n (body.message as string) || (body.error as string) || `HTTP ${resp.status}`;\n const status = resp.status;\n\n if (status === 400) throw new ValidationError(message, body);\n if (status === 401 || status === 403)\n throw new AuthenticationError(message, body);\n if (status === 404) throw new NotFoundError(message, body);\n if (status === 409)\n throw new ConflictError(\n message,\n (body.certificationId as string) || \"\",\n body\n );\n if (status === 429) throw new RateLimitError(message, body);\n if (status >= 500) throw new ServerError(message, status, body);\n throw new XProofError(message, status, body);\n }\n}\n","export class XProofError extends Error {\n statusCode: number;\n response: Record<string, unknown> | null;\n\n constructor(\n message: string,\n statusCode = 0,\n response: Record<string, unknown> | null = null\n ) {\n super(message);\n this.name = \"XProofError\";\n this.statusCode = statusCode;\n this.response = response;\n }\n}\n\nexport class AuthenticationError extends XProofError {\n constructor(\n message = \"Invalid or missing API key\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 401, response);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class ValidationError extends XProofError {\n constructor(\n message = \"Invalid request data\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 400, response);\n this.name = \"ValidationError\";\n }\n}\n\nexport class NotFoundError extends XProofError {\n constructor(\n message = \"Resource not found\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 404, response);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ConflictError extends XProofError {\n certificationId: string;\n\n constructor(\n message = \"File already certified\",\n certificationId = \"\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 409, response);\n this.name = \"ConflictError\";\n this.certificationId = certificationId;\n }\n}\n\nexport class RateLimitError extends XProofError {\n constructor(\n message = \"Rate limit exceeded\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 429, response);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ServerError extends XProofError {\n constructor(\n message = \"Internal server error\",\n statusCode = 500,\n response: Record<string, unknown> | null = null\n ) {\n super(message, statusCode, response);\n this.name = \"ServerError\";\n }\n}\n","import { createHash } from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport async function hashFile(path: string): Promise<string> {\n const data = await readFile(path);\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashBuffer(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashString(data: string): string {\n return createHash(\"sha256\").update(data, \"utf8\").digest(\"hex\");\n}\n","import type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n} from \"./types.js\";\n\nexport function parseCertification(data: Record<string, unknown>): Certification {\n const blockchain = (data.blockchain as Record<string, unknown>) || {};\n return {\n id: (data.id as string) || (data.proof_id as string) || \"\",\n fileName:\n (data.fileName as string) ||\n (data.filename as string) ||\n (data.file_name as string) ||\n \"\",\n fileHash:\n (data.fileHash as string) || (data.file_hash as string) || \"\",\n transactionHash:\n (data.transactionHash as string) ||\n (blockchain.transaction_hash as string) ||\n \"\",\n transactionUrl:\n (data.transactionUrl as string) ||\n (blockchain.explorer_url as string) ||\n \"\",\n createdAt:\n (data.createdAt as string) ||\n (data.created_at as string) ||\n (data.timestamp as string) ||\n \"\",\n authorName:\n (data.authorName as string) || (data.author_name as string) || \"\",\n blockchainStatus:\n (data.blockchainStatus as string) || (data.status as string) || \"\",\n isPublic: data.isPublic !== undefined ? !!data.isPublic : (data.is_public !== undefined ? !!data.is_public : true),\n certificateUrl:\n (data.certificateUrl as string) ||\n (data.certificate_url as string) ||\n \"\",\n verifyUrl:\n (data.verifyUrl as string) || (data.verify_url as string) || \"\",\n };\n}\n\nexport function parseBatchResult(data: Record<string, unknown>): BatchResult {\n const rawResults = (data.results as Array<Record<string, unknown>>) || [];\n const results = rawResults.map(parseCertification);\n const total = (data.total as number) ?? rawResults.length;\n const created = (data.created as number) ?? 0;\n const existing = (data.existing as number) ?? 0;\n\n const summary: BatchResultSummary = {\n total,\n created,\n existing,\n get certified() { return created; },\n get failed() { return total - created - existing; },\n };\n\n return {\n batchId: (data.batch_id as string) || \"\",\n results,\n summary,\n };\n}\n\nexport function parsePricingInfo(data: Record<string, unknown>): PricingInfo {\n const rawTiers = (data.tiers as Array<Record<string, unknown>>) || [];\n const tiers: PricingTier[] = rawTiers.map((t) => ({\n minCertifications:\n (t.min_certifications as number) ?? (t.min as number) ?? 0,\n maxCertifications:\n (t.max_certifications as number) ?? (t.max as number) ?? null,\n priceUsd: (t.price_usd as number) ?? (t.price as number) ?? 0,\n }));\n\n return {\n protocol: (data.protocol as string) || \"\",\n version: (data.version as string) || \"\",\n priceUsd:\n (data.price_usd as number) ?? (data.current_price as number) ?? 0,\n tiers,\n paymentMethods:\n (data.payment_methods as Array<Record<string, string>>) || [],\n raw: data,\n };\n}\n\nexport function parseRegistrationResult(\n data: Record<string, unknown>\n): RegistrationResult {\n const trialData = (data.trial as Record<string, unknown>) || {};\n const trial: TrialInfo = {\n quota: (trialData.quota as number) ?? 0,\n used: (trialData.used as number) ?? 0,\n remaining: (trialData.remaining as number) ?? 0,\n };\n return {\n apiKey: (data.api_key as string) || \"\",\n agentName: (data.agent_name as string) || \"\",\n trial,\n endpoints: (data.endpoints as Record<string, string>) || {},\n raw: data,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAyB;;;ACAlB,IAAM,cAAN,cAA0B,MAAM;AAAA,EAIrC,YACE,SACA,aAAa,GACb,WAA2C,MAC3C;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAAA,EAClB;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YACE,UAAU,8BACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YACE,UAAU,wBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAC7C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M,IAAI,eAAe,SAAS,IAAI;AAC1D,QAAI,UAAU,IAAK,OAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAC9D,UAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAAA,EAC7C;AACF;","names":[]}
package/dist/index.mjs CHANGED
@@ -135,7 +135,7 @@ function parseRegistrationResult(data) {
135
135
  }
136
136
 
137
137
  // src/client.ts
138
- var VERSION = "0.1.0";
138
+ var VERSION = "0.1.4";
139
139
  var DEFAULT_BASE_URL = "https://xproof.app";
140
140
  var DEFAULT_TIMEOUT = 3e4;
141
141
  var XProofClient = class _XProofClient {
@@ -214,6 +214,92 @@ var XProofClient = class _XProofClient {
214
214
  });
215
215
  return parseCertification(data);
216
216
  }
217
+ async certifyWithConfidence(fileHash, fileName, author, confidence, fourW) {
218
+ this.requireAuth();
219
+ if (confidence.confidenceLevel < 0 || confidence.confidenceLevel > 1) {
220
+ throw new ValidationError(
221
+ "confidenceLevel must be between 0.0 and 1.0",
222
+ {}
223
+ );
224
+ }
225
+ if (!confidence.decisionId || confidence.decisionId.trim().length === 0) {
226
+ throw new ValidationError("decisionId is required", {});
227
+ }
228
+ const metadata = fourW?.metadata ? { ...fourW.metadata } : {};
229
+ if (fourW?.who !== void 0) metadata.who = fourW.who;
230
+ if (fourW?.what !== void 0) metadata.what = fourW.what;
231
+ if (fourW?.when !== void 0) metadata.when = fourW.when;
232
+ if (fourW?.why !== void 0) metadata.why = fourW.why;
233
+ metadata.confidence_level = confidence.confidenceLevel;
234
+ metadata.threshold_stage = confidence.thresholdStage;
235
+ metadata.decision_id = confidence.decisionId;
236
+ const payload = {
237
+ filename: fileName,
238
+ file_hash: fileHash,
239
+ author_name: author,
240
+ metadata
241
+ };
242
+ const data = await this.request("POST", "/api/proof", { body: payload });
243
+ return parseCertification(data);
244
+ }
245
+ async getConfidenceTrail(decisionId) {
246
+ const data = await this.request(
247
+ "GET",
248
+ `/api/confidence-trail/${encodeURIComponent(decisionId)}`,
249
+ { authRequired: false }
250
+ );
251
+ const rawStages = data.stages || [];
252
+ const stages = rawStages.map((s) => ({
253
+ proofId: s.proof_id || "",
254
+ fileName: s.file_name || "",
255
+ fileHash: s.file_hash || "",
256
+ confidenceLevel: s.confidence_level ?? null,
257
+ thresholdStage: s.threshold_stage ?? null,
258
+ author: s.author || "",
259
+ blockchain: {
260
+ transactionHash: s.blockchain?.transaction_hash || "",
261
+ explorerUrl: s.blockchain?.explorer_url || "",
262
+ status: s.blockchain?.status || ""
263
+ },
264
+ anchoredAt: s.anchored_at || "",
265
+ metadata: s.metadata || {}
266
+ }));
267
+ return {
268
+ decisionId: data.decision_id || decisionId,
269
+ totalAnchors: data.total_anchors || stages.length,
270
+ currentConfidence: data.current_confidence ?? null,
271
+ currentStage: data.current_stage ?? null,
272
+ isFinalized: data.is_finalized || false,
273
+ stages
274
+ };
275
+ }
276
+ async getContextDrift(decisionId) {
277
+ const data = await this.request(
278
+ "GET",
279
+ `/api/context-drift/${encodeURIComponent(decisionId)}`,
280
+ { authRequired: false }
281
+ );
282
+ const rawStages = data.stages || [];
283
+ const stages = rawStages.map((s) => ({
284
+ proofId: s.proof_id || "",
285
+ stageIndex: s.stage_index ?? 0,
286
+ anchoredAt: s.anchored_at || "",
287
+ executionContext: s.execution_context || {},
288
+ contextBreak: s.context_break || false,
289
+ driftedFields: s.drifted_fields || []
290
+ }));
291
+ return {
292
+ decisionId: data.decision_id || decisionId,
293
+ contextCoherent: data.context_coherent ?? true,
294
+ driftScore: data.drift_score ?? 0,
295
+ fieldsMonitored: data.fields_monitored || [],
296
+ fieldsDrifted: data.fields_drifted || [],
297
+ fieldsStable: data.fields_stable || [],
298
+ fieldsAbsent: data.fields_absent || [],
299
+ totalAnchors: data.total_anchors || stages.length,
300
+ stages
301
+ };
302
+ }
217
303
  async getPricing() {
218
304
  const data = await this.request("GET", "/api/pricing", {
219
305
  authRequired: false
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/errors.ts","../src/hash.ts","../src/parse.ts"],"sourcesContent":["import { basename } from \"path\";\nimport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nimport { hashFile } from \"./hash.js\";\nimport {\n parseCertification,\n parseBatchResult,\n parsePricingInfo,\n parseRegistrationResult,\n} from \"./parse.js\";\nimport type {\n Certification,\n BatchResult,\n PricingInfo,\n RegistrationResult,\n FourWOptions,\n BatchFileEntry,\n XProofClientOptions,\n} from \"./types.js\";\n\nconst VERSION = \"0.1.0\";\nconst DEFAULT_BASE_URL = \"https://xproof.app\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class XProofClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n\n registration: RegistrationResult | null = null;\n\n constructor(options: XProofClientOptions = {}) {\n this.apiKey = options.apiKey ?? \"\";\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n }\n\n static async register(\n agentName: string,\n options: Omit<XProofClientOptions, \"apiKey\"> = {}\n ): Promise<XProofClient> {\n const temp = new XProofClient(options);\n const data = await temp.request(\"POST\", \"/api/agent/register\", {\n body: { agent_name: agentName },\n authRequired: false,\n });\n const result = parseRegistrationResult(data);\n const client = new XProofClient({\n ...options,\n apiKey: result.apiKey,\n });\n client.registration = result;\n return client;\n }\n\n async certify(\n path: string,\n author: string,\n fileName?: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n const fileHash = await hashFile(path);\n const resolvedName = fileName ?? basename(path);\n return this.certifyHash(fileHash, resolvedName, author, fourW);\n }\n\n async certifyHash(\n fileHash: string,\n fileName: string,\n author: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n };\n if (Object.keys(metadata).length > 0) {\n payload.metadata = metadata;\n }\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async batchCertify(files: BatchFileEntry[]): Promise<BatchResult> {\n this.requireAuth();\n\n if (files.length > 50) {\n throw new Error(\"Batch certification supports a maximum of 50 files\");\n }\n\n const entries = files.map((f) => {\n const entry: Record<string, unknown> = {\n filename: f.fileName ?? \"unknown\",\n file_hash: f.fileHash,\n };\n if (f.metadata) entry.metadata = f.metadata;\n return entry;\n });\n\n const payload: Record<string, unknown> = { files: entries };\n const author = files.find((f) => f.author)?.author;\n if (author) payload.author_name = author;\n\n const data = await this.request(\"POST\", \"/api/batch\", { body: payload });\n return parseBatchResult(data);\n }\n\n async verify(proofId: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/${proofId}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async verifyHash(fileHash: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/hash/${fileHash}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async getPricing(): Promise<PricingInfo> {\n const data = await this.request(\"GET\", \"/api/pricing\", {\n authRequired: false,\n });\n return parsePricingInfo(data);\n }\n\n private requireAuth(): void {\n if (!this.apiKey) {\n throw new Error(\n \"apiKey is required — call XProofClient.register() or pass an apiKey\"\n );\n }\n }\n\n private async request(\n method: string,\n path: string,\n options: {\n body?: Record<string, unknown>;\n authRequired?: boolean;\n } = {}\n ): Promise<Record<string, unknown>> {\n const url = `${this.baseUrl}${path}`;\n const { body, authRequired = true } = options;\n\n const headers: Record<string, string> = {\n \"User-Agent\": `xproof-js/${VERSION}`,\n };\n\n if (authRequired && this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n if (body) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let resp: Response;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new XProofError(`Request timed out after ${this.timeout}ms`);\n }\n throw new XProofError(`Request failed: ${(err as Error).message}`);\n } finally {\n clearTimeout(timer);\n }\n\n if (resp.status === 200 || resp.status === 201) {\n let data: Record<string, unknown>;\n try {\n data = (await resp.json()) as Record<string, unknown>;\n } catch {\n const text = await resp.text().catch(() => \"\");\n throw new XProofError(\n `Unexpected non-JSON response from ${method} ${url}: ${text.slice(0, 200)}`\n );\n }\n return data;\n }\n\n await this.handleError(resp);\n return {};\n }\n\n private async handleError(resp: Response): Promise<never> {\n let body: Record<string, unknown>;\n try {\n body = (await resp.json()) as Record<string, unknown>;\n } catch {\n body = { message: await resp.text().catch(() => \"\") };\n }\n\n const message =\n (body.message as string) || (body.error as string) || `HTTP ${resp.status}`;\n const status = resp.status;\n\n if (status === 400) throw new ValidationError(message, body);\n if (status === 401 || status === 403)\n throw new AuthenticationError(message, body);\n if (status === 404) throw new NotFoundError(message, body);\n if (status === 409)\n throw new ConflictError(\n message,\n (body.certificationId as string) || \"\",\n body\n );\n if (status === 429) throw new RateLimitError(message, body);\n if (status >= 500) throw new ServerError(message, status, body);\n throw new XProofError(message, status, body);\n }\n}\n","export class XProofError extends Error {\n statusCode: number;\n response: Record<string, unknown> | null;\n\n constructor(\n message: string,\n statusCode = 0,\n response: Record<string, unknown> | null = null\n ) {\n super(message);\n this.name = \"XProofError\";\n this.statusCode = statusCode;\n this.response = response;\n }\n}\n\nexport class AuthenticationError extends XProofError {\n constructor(\n message = \"Invalid or missing API key\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 401, response);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class ValidationError extends XProofError {\n constructor(\n message = \"Invalid request data\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 400, response);\n this.name = \"ValidationError\";\n }\n}\n\nexport class NotFoundError extends XProofError {\n constructor(\n message = \"Resource not found\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 404, response);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ConflictError extends XProofError {\n certificationId: string;\n\n constructor(\n message = \"File already certified\",\n certificationId = \"\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 409, response);\n this.name = \"ConflictError\";\n this.certificationId = certificationId;\n }\n}\n\nexport class RateLimitError extends XProofError {\n constructor(\n message = \"Rate limit exceeded\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 429, response);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ServerError extends XProofError {\n constructor(\n message = \"Internal server error\",\n statusCode = 500,\n response: Record<string, unknown> | null = null\n ) {\n super(message, statusCode, response);\n this.name = \"ServerError\";\n }\n}\n","import { createHash } from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport async function hashFile(path: string): Promise<string> {\n const data = await readFile(path);\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashBuffer(data: Buffer | Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashString(data: string): string {\n return createHash(\"sha256\").update(data, \"utf8\").digest(\"hex\");\n}\n","import type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n} from \"./types.js\";\n\nexport function parseCertification(data: Record<string, unknown>): Certification {\n const blockchain = (data.blockchain as Record<string, unknown>) || {};\n return {\n id: (data.id as string) || (data.proof_id as string) || \"\",\n fileName:\n (data.fileName as string) ||\n (data.filename as string) ||\n (data.file_name as string) ||\n \"\",\n fileHash:\n (data.fileHash as string) || (data.file_hash as string) || \"\",\n transactionHash:\n (data.transactionHash as string) ||\n (blockchain.transaction_hash as string) ||\n \"\",\n transactionUrl:\n (data.transactionUrl as string) ||\n (blockchain.explorer_url as string) ||\n \"\",\n createdAt:\n (data.createdAt as string) ||\n (data.created_at as string) ||\n (data.timestamp as string) ||\n \"\",\n authorName:\n (data.authorName as string) || (data.author_name as string) || \"\",\n blockchainStatus:\n (data.blockchainStatus as string) || (data.status as string) || \"\",\n isPublic: data.isPublic !== undefined ? !!data.isPublic : (data.is_public !== undefined ? !!data.is_public : true),\n certificateUrl:\n (data.certificateUrl as string) ||\n (data.certificate_url as string) ||\n \"\",\n verifyUrl:\n (data.verifyUrl as string) || (data.verify_url as string) || \"\",\n };\n}\n\nexport function parseBatchResult(data: Record<string, unknown>): BatchResult {\n const rawResults = (data.results as Array<Record<string, unknown>>) || [];\n const results = rawResults.map(parseCertification);\n const total = (data.total as number) ?? rawResults.length;\n const created = (data.created as number) ?? 0;\n const existing = (data.existing as number) ?? 0;\n\n const summary: BatchResultSummary = {\n total,\n created,\n existing,\n get certified() { return created; },\n get failed() { return total - created - existing; },\n };\n\n return {\n batchId: (data.batch_id as string) || \"\",\n results,\n summary,\n };\n}\n\nexport function parsePricingInfo(data: Record<string, unknown>): PricingInfo {\n const rawTiers = (data.tiers as Array<Record<string, unknown>>) || [];\n const tiers: PricingTier[] = rawTiers.map((t) => ({\n minCertifications:\n (t.min_certifications as number) ?? (t.min as number) ?? 0,\n maxCertifications:\n (t.max_certifications as number) ?? (t.max as number) ?? null,\n priceUsd: (t.price_usd as number) ?? (t.price as number) ?? 0,\n }));\n\n return {\n protocol: (data.protocol as string) || \"\",\n version: (data.version as string) || \"\",\n priceUsd:\n (data.price_usd as number) ?? (data.current_price as number) ?? 0,\n tiers,\n paymentMethods:\n (data.payment_methods as Array<Record<string, string>>) || [],\n raw: data,\n };\n}\n\nexport function parseRegistrationResult(\n data: Record<string, unknown>\n): RegistrationResult {\n const trialData = (data.trial as Record<string, unknown>) || {};\n const trial: TrialInfo = {\n quota: (trialData.quota as number) ?? 0,\n used: (trialData.used as number) ?? 0,\n remaining: (trialData.remaining as number) ?? 0,\n };\n return {\n apiKey: (data.api_key as string) || \"\",\n agentName: (data.agent_name as string) || \"\",\n trial,\n endpoints: (data.endpoints as Record<string, string>) || {},\n raw: data,\n };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACAlB,IAAM,cAAN,cAA0B,MAAM;AAAA,EAIrC,YACE,SACA,aAAa,GACb,WAA2C,MAC3C;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAAA,EAClB;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YACE,UAAU,8BACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YACE,UAAU,wBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAC7C,YACE,UAAU,sBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAG7C,YACE,UAAU,0BACV,kBAAkB,IAClB,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AACZ,SAAK,kBAAkB;AAAA,EACzB;AACF;AAEO,IAAM,iBAAN,cAA6B,YAAY;AAAA,EAC9C,YACE,UAAU,uBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,cAAN,cAA0B,YAAY;AAAA,EAC3C,YACE,UAAU,yBACV,aAAa,KACb,WAA2C,MAC3C;AACA,UAAM,SAAS,YAAY,QAAQ;AACnC,S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;AAC3B,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,MAAc,YAAY,MAAgC;AACxD,QAAI;AACJ,QAAI;AACF,aAAQ,MAAM,KAAK,KAAK;AAAA,IAC1B,QAAQ;AACN,aAAO,EAAE,SAAS,MAAM,KAAK,KAAK,EAAE,MAAM,MAAM,EAAE,EAAE;AAAA,IACtD;AAEA,UAAM,UACH,KAAK,WAAuB,KAAK,SAAoB,QAAQ,KAAK,MAAM;AAC3E,UAAM,SAAS,KAAK;AAEpB,QAAI,WAAW,IAAK,OAAM,IAAI,gBAAgB,SAAS,IAAI;AAC3D,QAAI,WAAW,OAAO,WAAW;AAC/B,YAAM,IAAI,oBAAoB,SAAS,IAAI;AAC7C,QAAI,WAAW,IAAK,OAAM,IAAI,cAAc,SAAS,IAAI;AACzD,QAAI,WAAW;AACb,YAAM,IAAI;AAAA,QACR;AAAA,QACC,KAAK,mBAA8B;AAAA,QACpC;AAAA,MACF;AACF,QAAI,WAAW,IAAK,OAAM,IAAI,eAAe,SAAS,IAAI;AAC1D,QAAI,UAAU,IAAK,OAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAC9D,UAAM,IAAI,YAAY,SAAS,QAAQ,IAAI;AAAA,EAC7C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts","../src/errors.ts","../src/hash.ts","../src/parse.ts"],"sourcesContent":["import { basename } from \"path\";\nimport {\n XProofError,\n AuthenticationError,\n ValidationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ServerError,\n} from \"./errors.js\";\nimport { hashFile } from \"./hash.js\";\nimport {\n parseCertification,\n parseBatchResult,\n parsePricingInfo,\n parseRegistrationResult,\n} from \"./parse.js\";\nimport type {\n Certification,\n BatchResult,\n PricingInfo,\n RegistrationResult,\n FourWOptions,\n BatchFileEntry,\n XProofClientOptions,\n ConfidenceOptions,\n ConfidenceTrail,\n ConfidenceTrailStage,\n ContextDrift,\n ContextDriftStage,\n ExecutionContext,\n} from \"./types.js\";\n\nconst VERSION = \"0.1.4\";\nconst DEFAULT_BASE_URL = \"https://xproof.app\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class XProofClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n\n registration: RegistrationResult | null = null;\n\n constructor(options: XProofClientOptions = {}) {\n this.apiKey = options.apiKey ?? \"\";\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n }\n\n static async register(\n agentName: string,\n options: Omit<XProofClientOptions, \"apiKey\"> = {}\n ): Promise<XProofClient> {\n const temp = new XProofClient(options);\n const data = await temp.request(\"POST\", \"/api/agent/register\", {\n body: { agent_name: agentName },\n authRequired: false,\n });\n const result = parseRegistrationResult(data);\n const client = new XProofClient({\n ...options,\n apiKey: result.apiKey,\n });\n client.registration = result;\n return client;\n }\n\n async certify(\n path: string,\n author: string,\n fileName?: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n const fileHash = await hashFile(path);\n const resolvedName = fileName ?? basename(path);\n return this.certifyHash(fileHash, resolvedName, author, fourW);\n }\n\n async certifyHash(\n fileHash: string,\n fileName: string,\n author: string,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n };\n if (Object.keys(metadata).length > 0) {\n payload.metadata = metadata;\n }\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async batchCertify(files: BatchFileEntry[]): Promise<BatchResult> {\n this.requireAuth();\n\n if (files.length > 50) {\n throw new Error(\"Batch certification supports a maximum of 50 files\");\n }\n\n const entries = files.map((f) => {\n const entry: Record<string, unknown> = {\n filename: f.fileName ?? \"unknown\",\n file_hash: f.fileHash,\n };\n if (f.metadata) entry.metadata = f.metadata;\n return entry;\n });\n\n const payload: Record<string, unknown> = { files: entries };\n const author = files.find((f) => f.author)?.author;\n if (author) payload.author_name = author;\n\n const data = await this.request(\"POST\", \"/api/batch\", { body: payload });\n return parseBatchResult(data);\n }\n\n async verify(proofId: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/${proofId}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async verifyHash(fileHash: string): Promise<Certification> {\n const data = await this.request(\"GET\", `/api/proof/hash/${fileHash}`, {\n authRequired: false,\n });\n return parseCertification(data);\n }\n\n async certifyWithConfidence(\n fileHash: string,\n fileName: string,\n author: string,\n confidence: ConfidenceOptions,\n fourW?: FourWOptions\n ): Promise<Certification> {\n this.requireAuth();\n\n if (confidence.confidenceLevel < 0 || confidence.confidenceLevel > 1) {\n throw new ValidationError(\n \"confidenceLevel must be between 0.0 and 1.0\",\n {}\n );\n }\n if (!confidence.decisionId || confidence.decisionId.trim().length === 0) {\n throw new ValidationError(\"decisionId is required\", {});\n }\n\n const metadata: Record<string, unknown> = fourW?.metadata\n ? { ...fourW.metadata }\n : {};\n if (fourW?.who !== undefined) metadata.who = fourW.who;\n if (fourW?.what !== undefined) metadata.what = fourW.what;\n if (fourW?.when !== undefined) metadata.when = fourW.when;\n if (fourW?.why !== undefined) metadata.why = fourW.why;\n\n metadata.confidence_level = confidence.confidenceLevel;\n metadata.threshold_stage = confidence.thresholdStage;\n metadata.decision_id = confidence.decisionId;\n\n const payload: Record<string, unknown> = {\n filename: fileName,\n file_hash: fileHash,\n author_name: author,\n metadata,\n };\n\n const data = await this.request(\"POST\", \"/api/proof\", { body: payload });\n return parseCertification(data);\n }\n\n async getConfidenceTrail(decisionId: string): Promise<ConfidenceTrail> {\n const data = await this.request(\n \"GET\",\n `/api/confidence-trail/${encodeURIComponent(decisionId)}`,\n { authRequired: false }\n );\n\n const rawStages = (data.stages as any[]) || [];\n const stages: ConfidenceTrailStage[] = rawStages.map((s: any) => ({\n proofId: s.proof_id || \"\",\n fileName: s.file_name || \"\",\n fileHash: s.file_hash || \"\",\n confidenceLevel: s.confidence_level ?? null,\n thresholdStage: s.threshold_stage ?? null,\n author: s.author || \"\",\n blockchain: {\n transactionHash: s.blockchain?.transaction_hash || \"\",\n explorerUrl: s.blockchain?.explorer_url || \"\",\n status: s.blockchain?.status || \"\",\n },\n anchoredAt: s.anchored_at || \"\",\n metadata: s.metadata || {},\n }));\n\n return {\n decisionId: (data.decision_id as string) || decisionId,\n totalAnchors: (data.total_anchors as number) || stages.length,\n currentConfidence: (data.current_confidence as number) ?? null,\n currentStage: (data.current_stage as string) ?? null,\n isFinalized: (data.is_finalized as boolean) || false,\n stages,\n };\n }\n\n async getContextDrift(decisionId: string): Promise<ContextDrift> {\n const data = await this.request(\n \"GET\",\n `/api/context-drift/${encodeURIComponent(decisionId)}`,\n { authRequired: false }\n );\n\n const rawStages = (data.stages as any[]) || [];\n const stages: ContextDriftStage[] = rawStages.map((s: any) => ({\n proofId: s.proof_id || \"\",\n stageIndex: s.stage_index ?? 0,\n anchoredAt: s.anchored_at || \"\",\n executionContext: (s.execution_context || {}) as ExecutionContext,\n contextBreak: s.context_break || false,\n driftedFields: s.drifted_fields || [],\n }));\n\n return {\n decisionId: (data.decision_id as string) || decisionId,\n contextCoherent: (data.context_coherent as boolean) ?? true,\n driftScore: (data.drift_score as number) ?? 0,\n fieldsMonitored: (data.fields_monitored as string[]) || [],\n fieldsDrifted: (data.fields_drifted as string[]) || [],\n fieldsStable: (data.fields_stable as string[]) || [],\n fieldsAbsent: (data.fields_absent as string[]) || [],\n totalAnchors: (data.total_anchors as number) || stages.length,\n stages,\n };\n }\n\n async getPricing(): Promise<PricingInfo> {\n const data = await this.request(\"GET\", \"/api/pricing\", {\n authRequired: false,\n });\n return parsePricingInfo(data);\n }\n\n private requireAuth(): void {\n if (!this.apiKey) {\n throw new Error(\n \"apiKey is required — call XProofClient.register() or pass an apiKey\"\n );\n }\n }\n\n private async request(\n method: string,\n path: string,\n options: {\n body?: Record<string, unknown>;\n authRequired?: boolean;\n } = {}\n ): Promise<Record<string, unknown>> {\n const url = `${this.baseUrl}${path}`;\n const { body, authRequired = true } = options;\n\n const headers: Record<string, string> = {\n \"User-Agent\": `xproof-js/${VERSION}`,\n };\n\n if (authRequired && this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n if (body) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n let resp: Response;\n try {\n resp = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } catch (err) {\n clearTimeout(timer);\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new XProofError(`Request timed out after ${this.timeout}ms`);\n }\n throw new XProofError(`Request failed: ${(err as Error).message}`);\n } finally {\n clearTimeout(timer);\n }\n\n if (resp.status === 200 || resp.status === 201) {\n let data: Record<string, unknown>;\n try {\n data = (await resp.json()) as Record<string, unknown>;\n } catch {\n const text = await resp.text().catch(() => \"\");\n throw new XProofError(\n `Unexpected non-JSON response from ${method} ${url}: ${text.slice(0, 200)}`\n );\n }\n return data;\n }\n\n await this.handleError(resp);\n return {};\n }\n\n private async handleError(resp: Response): Promise<never> {\n let body: Record<string, unknown>;\n try {\n body = (await resp.json()) as Record<string, unknown>;\n } catch {\n body = { message: await resp.text().catch(() => \"\") };\n }\n\n const message =\n (body.message as string) || (body.error as string) || `HTTP ${resp.status}`;\n const status = resp.status;\n\n if (status === 400) throw new ValidationError(message, body);\n if (status === 401 || status === 403)\n throw new AuthenticationError(message, body);\n if (status === 404) throw new NotFoundError(message, body);\n if (status === 409)\n throw new ConflictError(\n message,\n (body.certificationId as string) || \"\",\n body\n );\n if (status === 429) throw new RateLimitError(message, body);\n if (status >= 500) throw new ServerError(message, status, body);\n throw new XProofError(message, status, body);\n }\n}\n","export class XProofError extends Error {\n statusCode: number;\n response: Record<string, unknown> | null;\n\n constructor(\n message: string,\n statusCode = 0,\n response: Record<string, unknown> | null = null\n ) {\n super(message);\n this.name = \"XProofError\";\n this.statusCode = statusCode;\n this.response = response;\n }\n}\n\nexport class AuthenticationError extends XProofError {\n constructor(\n message = \"Invalid or missing API key\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 401, response);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class ValidationError extends XProofError {\n constructor(\n message = \"Invalid request data\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 400, response);\n this.name = \"ValidationError\";\n }\n}\n\nexport class NotFoundError extends XProofError {\n constructor(\n message = \"Resource not found\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 404, response);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ConflictError extends XProofError {\n certificationId: string;\n\n constructor(\n message = \"File already certified\",\n certificationId = \"\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 409, response);\n this.name = \"ConflictError\";\n this.certificationId = certificationId;\n }\n}\n\nexport class RateLimitError extends XProofError {\n constructor(\n message = \"Rate limit exceeded\",\n response: Record<string, unknown> | null = null\n ) {\n super(message, 429, response);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ServerError extends XProofError {\n constructor(\n message = \"Internal server error\",\n statusCode = 500,\n response: Record<string, unknown> | null = null\n ) {\n super(message, statusCode, response);\n this.name = \"ServerError\";\n }\n}\n","import { createHash } from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport async function hashFile(path: string): Promise<string> {\n const data = await readFile(path);\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashBuffer(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nexport function hashString(data: string): string {\n return createHash(\"sha256\").update(data, \"utf8\").digest(\"hex\");\n}\n","import type {\n Certification,\n BatchResult,\n BatchResultSummary,\n PricingInfo,\n PricingTier,\n RegistrationResult,\n TrialInfo,\n} from \"./types.js\";\n\nexport function parseCertification(data: Record<string, unknown>): Certification {\n const blockchain = (data.blockchain as Record<string, unknown>) || {};\n return {\n id: (data.id as string) || (data.proof_id as string) || \"\",\n fileName:\n (data.fileName as string) ||\n (data.filename as string) ||\n (data.file_name as string) ||\n \"\",\n fileHash:\n (data.fileHash as string) || (data.file_hash as string) || \"\",\n transactionHash:\n (data.transactionHash as string) ||\n (blockchain.transaction_hash as string) ||\n \"\",\n transactionUrl:\n (data.transactionUrl as string) ||\n (blockchain.explorer_url as string) ||\n \"\",\n createdAt:\n (data.createdAt as string) ||\n (data.created_at as string) ||\n (data.timestamp as string) ||\n \"\",\n authorName:\n (data.authorName as string) || (data.author_name as string) || \"\",\n blockchainStatus:\n (data.blockchainStatus as string) || (data.status as string) || \"\",\n isPublic: data.isPublic !== undefined ? !!data.isPublic : (data.is_public !== undefined ? !!data.is_public : true),\n certificateUrl:\n (data.certificateUrl as string) ||\n (data.certificate_url as string) ||\n \"\",\n verifyUrl:\n (data.verifyUrl as string) || (data.verify_url as string) || \"\",\n };\n}\n\nexport function parseBatchResult(data: Record<string, unknown>): BatchResult {\n const rawResults = (data.results as Array<Record<string, unknown>>) || [];\n const results = rawResults.map(parseCertification);\n const total = (data.total as number) ?? rawResults.length;\n const created = (data.created as number) ?? 0;\n const existing = (data.existing as number) ?? 0;\n\n const summary: BatchResultSummary = {\n total,\n created,\n existing,\n get certified() { return created; },\n get failed() { return total - created - existing; },\n };\n\n return {\n batchId: (data.batch_id as string) || \"\",\n results,\n summary,\n };\n}\n\nexport function parsePricingInfo(data: Record<string, unknown>): PricingInfo {\n const rawTiers = (data.tiers as Array<Record<string, unknown>>) || [];\n const tiers: PricingTier[] = rawTiers.map((t) => ({\n minCertifications:\n (t.min_certifications as number) ?? (t.min as number) ?? 0,\n maxCertifications:\n (t.max_certifications as number) ?? (t.max as number) ?? null,\n priceUsd: (t.price_usd as number) ?? (t.price as number) ?? 0,\n }));\n\n return {\n protocol: (data.protocol as string) || \"\",\n version: (data.version as string) || \"\",\n priceUsd:\n (data.price_usd as number) ?? (data.current_price as number) ?? 0,\n tiers,\n paymentMethods:\n (data.payment_methods as Array<Record<string, string>>) || [],\n raw: data,\n };\n}\n\nexport function parseRegistrationResult(\n data: Record<string, unknown>\n): RegistrationResult {\n const trialData = (data.trial as Record<string, unknown>) || {};\n const trial: TrialInfo = {\n quota: (trialData.quota as number) ?? 0,\n used: (trialData.used as number) ?? 0,\n remaining: (trialData.remaining as number) ?? 0,\n };\n return {\n apiKey: (data.api_key as string) || \"\",\n agentName: (data.agent_name as string) || \"\",\n trial,\n endpoints: (data.endpoints as Record<string, string>) || {},\n raw: data,\n };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACAlB,IAAM,cAAN,cAA0B,MAAM;AAAA,EAIrC,YACE,SACA,aAAa,GACb,WAA2C,MAC3C;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAAA,EAClB;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YACE,UAAU,8BACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YACE,UAAU,wBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAC7C,YACE,UAAU,sBACV,WAA2C,MAC3C;AACA,UAAM,SAAS,KAAK,QAAQ;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAG7C,YACE,UAAU,0BACV,kBAAkB,IAClB,WAA2C,MAC3C;AACA,UAAM,SAA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client-DOH3QHZm.mjs';
1
+ import { X as XProofClient } from '../client-BNp2oPhL.mjs';
2
2
 
3
3
  /**
4
4
  * Vercel AI SDK middleware for automatic xProof certification.