@vereefy/sdk 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -2
- package/dist/index.cjs +257 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +107 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.mjs +226 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +41 -4
package/README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vereefy/sdk — Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
VEREEFY Node.js SDK für EU AI Act Compliance-Infrastruktur.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vereefy/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Node.js ≥ 18 erforderlich (natives `fetch` und `AbortSignal.timeout`).
|
|
12
|
+
|
|
13
|
+
## Schnellstart
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Verefy, Hasher } from "@vereefy/sdk";
|
|
17
|
+
|
|
18
|
+
const v = new Verefy({ apiKey: "vfy_..." });
|
|
19
|
+
|
|
20
|
+
const nachweis = await v.logInteraction({
|
|
21
|
+
provider: "openai",
|
|
22
|
+
modelName: "gpt-4o",
|
|
23
|
+
purpose: "Kundenberatung Retail-Banking",
|
|
24
|
+
sector: "financial_services",
|
|
25
|
+
inputContent: messages, // wird lokal gehasht — verlässt nie Ihre Umgebung
|
|
26
|
+
outputContent: antwort,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(nachweis.riskClass); // z. B. "limited_risk"
|
|
30
|
+
console.log(nachweis.complianceScore); // 0–100
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Client-seitiges Hashing
|
|
34
|
+
|
|
35
|
+
Rohinhalt verlässt nie Ihre Umgebung — nur der SHA-256-Hash wird übermittelt.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const h = Hasher.canonicalHash(meinObjekt);
|
|
39
|
+
await v.logInteraction({ inputHash: h, outputHash: h2, ... });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Float-Verhalten: 1.0 vs. 1 (Node ≠ Python)
|
|
43
|
+
|
|
44
|
+
> **Dokumentierter Unterschied:** In JavaScript ist `1.0 === 1` — beide Werte haben denselben IEEE-754-Typ und `JSON.stringify` gibt `"1"` aus. In Python gibt `json.dumps({"x": 1.0})` `'{"x": 1.0}'` aus (mit Dezimalpunkt).
|
|
45
|
+
|
|
46
|
+
| Sprache | Eingabe | JSON-Serialisierung | SHA-256 (erste 8 Zeichen) |
|
|
47
|
+
|---------|---------------|---------------------|---------------------------|
|
|
48
|
+
| Python | `{"x": 1.0}` | `{"x":1.0}` | `bf32f562…` |
|
|
49
|
+
| Node.js | `{ x: 1.0 }` | `{"x":1}` | `5041bf1f…` |
|
|
50
|
+
| Node.js | `{ x: 1 }` | `{"x":1}` | `5041bf1f…` |
|
|
51
|
+
|
|
52
|
+
**Workaround**, wenn Python-Kompatibilität für Float-Werte benötigt wird:
|
|
53
|
+
- Entweder den Hash auf Python-Seite berechnen und via `inputHash` übergeben.
|
|
54
|
+
- Oder den Float als String kodieren: `{ x: "1.0" }` (Absprache mit dem Gegenstück erforderlich).
|
|
55
|
+
- Oder `Hasher.canonicalHash` auf Python-Seite aufrufen und das Ergebnis direkt nutzen.
|
|
56
|
+
|
|
57
|
+
Nicht-ganzzahlige Floats (z. B. `1.5`, `3.14`) sind identisch in beiden Sprachen.
|
|
58
|
+
|
|
59
|
+
## Fehlerbehandlung
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { VerefyAPIError, VerefyConnectionError, VerefyValidationError } from "@vereefy/sdk";
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
await v.logInteraction({ ... });
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (e instanceof VerefyAPIError) console.error(e.statusCode, e.detail);
|
|
68
|
+
if (e instanceof VerefyConnectionError) console.error("Netzwerkfehler:", e.message);
|
|
69
|
+
if (e instanceof VerefyValidationError) console.error("Eingabefehler:", e.message);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Lizenz
|
|
74
|
+
|
|
75
|
+
MIT © VEREEFY AG
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Hasher: () => Hasher,
|
|
24
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
25
|
+
Verefy: () => Verefy,
|
|
26
|
+
VerefyAPIError: () => VerefyAPIError,
|
|
27
|
+
VerefyConnectionError: () => VerefyConnectionError,
|
|
28
|
+
VerefyError: () => VerefyError,
|
|
29
|
+
VerefyValidationError: () => VerefyValidationError
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
var import_node_crypto = require("crypto");
|
|
33
|
+
var SDK_VERSION = "1.0.0";
|
|
34
|
+
var DEFAULT_API_URL = "https://api.vereefy.ai";
|
|
35
|
+
var Hasher = class _Hasher {
|
|
36
|
+
static canonicalHash(content) {
|
|
37
|
+
if (content === null || content === void 0) {
|
|
38
|
+
return (0, import_node_crypto.createHash)("sha256").update("null").digest("hex");
|
|
39
|
+
}
|
|
40
|
+
if (Buffer.isBuffer(content)) {
|
|
41
|
+
return (0, import_node_crypto.createHash)("sha256").update(content).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
if (typeof content === "string") {
|
|
44
|
+
return (0, import_node_crypto.createHash)("sha256").update(content.trim(), "utf8").digest("hex");
|
|
45
|
+
}
|
|
46
|
+
if (typeof content === "object" || Array.isArray(content)) {
|
|
47
|
+
const canonical = JSON.stringify(
|
|
48
|
+
content,
|
|
49
|
+
Object.keys(content).sort()
|
|
50
|
+
// JSON.stringify sortiert nicht automatisch — separater Schritt nötig
|
|
51
|
+
);
|
|
52
|
+
const c = _Hasher._deepSortJson(content);
|
|
53
|
+
return (0, import_node_crypto.createHash)("sha256").update(c, "utf8").digest("hex");
|
|
54
|
+
}
|
|
55
|
+
return (0, import_node_crypto.createHash)("sha256").update(String(content), "utf8").digest("hex");
|
|
56
|
+
}
|
|
57
|
+
static hashMessages(messages) {
|
|
58
|
+
const normalized = messages.map((m) => ({
|
|
59
|
+
role: m.role ?? "",
|
|
60
|
+
content: m.content ?? ""
|
|
61
|
+
}));
|
|
62
|
+
return _Hasher.canonicalHash(normalized);
|
|
63
|
+
}
|
|
64
|
+
/** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */
|
|
65
|
+
static _deepSortJson(value) {
|
|
66
|
+
if (value === null || value === void 0) return "null";
|
|
67
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
68
|
+
if (typeof value === "number") return String(value);
|
|
69
|
+
if (typeof value === "string") {
|
|
70
|
+
return _Hasher._ensureAsciiString(value);
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
return "[" + value.map((v) => _Hasher._deepSortJson(v)).join(",") + "]";
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "object") {
|
|
76
|
+
const keys = Object.keys(value).sort();
|
|
77
|
+
const pairs = keys.map(
|
|
78
|
+
(k) => _Hasher._ensureAsciiString(k) + ":" + _Hasher._deepSortJson(value[k])
|
|
79
|
+
);
|
|
80
|
+
return "{" + pairs.join(",") + "}";
|
|
81
|
+
}
|
|
82
|
+
return _Hasher._ensureAsciiString(String(value));
|
|
83
|
+
}
|
|
84
|
+
/** JSON.stringify + escape non-ASCII as \uXXXX (Python ensure_ascii=True) */
|
|
85
|
+
static _ensureAsciiString(s) {
|
|
86
|
+
const jsJson = JSON.stringify(s);
|
|
87
|
+
return jsJson.replace(/[\u0080-]/g, (c) => {
|
|
88
|
+
const code = c.charCodeAt(0);
|
|
89
|
+
return "\\u" + code.toString(16).padStart(4, "0");
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var VerefyError = class extends Error {
|
|
94
|
+
};
|
|
95
|
+
var VerefyAPIError = class extends VerefyError {
|
|
96
|
+
constructor(statusCode, detail) {
|
|
97
|
+
super(`VEREEFY API ${statusCode}: ${detail}`);
|
|
98
|
+
this.statusCode = statusCode;
|
|
99
|
+
this.detail = detail;
|
|
100
|
+
this.name = "VerefyAPIError";
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var VerefyConnectionError = class extends VerefyError {
|
|
104
|
+
constructor(message) {
|
|
105
|
+
super(message);
|
|
106
|
+
this.name = "VerefyConnectionError";
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var VerefyValidationError = class extends VerefyError {
|
|
110
|
+
constructor(message) {
|
|
111
|
+
super(message);
|
|
112
|
+
this.name = "VerefyValidationError";
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var Verefy = class {
|
|
116
|
+
constructor(options) {
|
|
117
|
+
if (!options.apiKey.startsWith("vfy_")) {
|
|
118
|
+
throw new VerefyValidationError("API-Schl\xFCssel muss mit 'vfy_' beginnen.");
|
|
119
|
+
}
|
|
120
|
+
this.apiKey = options.apiKey;
|
|
121
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
122
|
+
this.timeout = options.timeout ?? 15e3;
|
|
123
|
+
this.maxRetries = options.maxRetries ?? 3;
|
|
124
|
+
}
|
|
125
|
+
async _request(method, path, body) {
|
|
126
|
+
const url = this.baseUrl + path;
|
|
127
|
+
const headers = {
|
|
128
|
+
"X-API-Key": this.apiKey,
|
|
129
|
+
"Content-Type": "application/json",
|
|
130
|
+
"X-SDK-Version": SDK_VERSION
|
|
131
|
+
};
|
|
132
|
+
let lastErr;
|
|
133
|
+
for (let attempt = 0; attempt < this.maxRetries; attempt++) {
|
|
134
|
+
try {
|
|
135
|
+
const signal = AbortSignal.timeout(this.timeout);
|
|
136
|
+
const resp = await fetch(url, {
|
|
137
|
+
method,
|
|
138
|
+
headers,
|
|
139
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
140
|
+
signal
|
|
141
|
+
});
|
|
142
|
+
if (resp.status < 500) return resp;
|
|
143
|
+
const text = await resp.text();
|
|
144
|
+
lastErr = new VerefyAPIError(resp.status, text);
|
|
145
|
+
if (attempt < this.maxRetries - 1) {
|
|
146
|
+
await new Promise((r) => setTimeout(r, 2 ** attempt * 1e3));
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
lastErr = new VerefyConnectionError(String(e));
|
|
150
|
+
if (attempt < this.maxRetries - 1) {
|
|
151
|
+
await new Promise((r) => setTimeout(r, 2 ** attempt * 1e3));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
throw lastErr;
|
|
156
|
+
}
|
|
157
|
+
async logInteraction(opts) {
|
|
158
|
+
let inputHash;
|
|
159
|
+
if (opts.inputContent !== void 0) {
|
|
160
|
+
inputHash = Hasher.canonicalHash(opts.inputContent);
|
|
161
|
+
} else if (opts.inputHash !== void 0) {
|
|
162
|
+
inputHash = opts.inputHash;
|
|
163
|
+
} else {
|
|
164
|
+
throw new VerefyValidationError("inputContent oder inputHash angeben.");
|
|
165
|
+
}
|
|
166
|
+
let outputHash;
|
|
167
|
+
if (opts.outputContent !== void 0) {
|
|
168
|
+
outputHash = Hasher.canonicalHash(opts.outputContent);
|
|
169
|
+
} else if (opts.outputHash !== void 0) {
|
|
170
|
+
outputHash = opts.outputHash;
|
|
171
|
+
} else {
|
|
172
|
+
throw new VerefyValidationError("outputContent oder outputHash angeben.");
|
|
173
|
+
}
|
|
174
|
+
const payload = {
|
|
175
|
+
provider: opts.provider,
|
|
176
|
+
model_name: opts.modelName,
|
|
177
|
+
purpose: opts.purpose,
|
|
178
|
+
sector: opts.sector,
|
|
179
|
+
input_hash: inputHash,
|
|
180
|
+
output_hash: outputHash
|
|
181
|
+
};
|
|
182
|
+
if (opts.modelVersion !== void 0) payload.model_version = opts.modelVersion;
|
|
183
|
+
if (opts.interactionType !== void 0) payload.interaction_type = opts.interactionType;
|
|
184
|
+
if (opts.customerFacing !== void 0) payload.customer_facing = opts.customerFacing;
|
|
185
|
+
if (opts.automationLevel !== void 0) payload.automation_level = opts.automationLevel;
|
|
186
|
+
if (opts.decisionImpact !== void 0) payload.decision_impact = opts.decisionImpact;
|
|
187
|
+
if (opts.userRole !== void 0) payload.user_role = opts.userRole;
|
|
188
|
+
if (opts.jurisdiction !== void 0) payload.jurisdiction = opts.jurisdiction;
|
|
189
|
+
if (opts.externalRef !== void 0) payload.external_ref = opts.externalRef;
|
|
190
|
+
if (opts.responseTimeMs !== void 0) payload.response_time_ms = opts.responseTimeMs;
|
|
191
|
+
if (opts.extraData !== void 0) payload.extra_data = opts.extraData;
|
|
192
|
+
const resp = await this._request("POST", "/v1/interactions", payload);
|
|
193
|
+
if (resp.status === 201) {
|
|
194
|
+
const data = await resp.json();
|
|
195
|
+
return this._mapEvidence(data);
|
|
196
|
+
}
|
|
197
|
+
const err = await resp.json().catch(() => ({ detail: resp.statusText }));
|
|
198
|
+
throw new VerefyAPIError(resp.status, String(err.detail ?? resp.statusText));
|
|
199
|
+
}
|
|
200
|
+
async getInteraction(interactionId) {
|
|
201
|
+
const resp = await this._request("GET", `/v1/interactions/${interactionId}`);
|
|
202
|
+
if (resp.status === 200) return resp.json();
|
|
203
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
204
|
+
}
|
|
205
|
+
async verifyChain(interactionId) {
|
|
206
|
+
const resp = await this._request("GET", `/v1/audit/${interactionId}/chain`);
|
|
207
|
+
if (resp.status === 200) return resp.json();
|
|
208
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
209
|
+
}
|
|
210
|
+
async requestReport(options = {}) {
|
|
211
|
+
const payload = {
|
|
212
|
+
report_type: options.reportType ?? "eu_ai_act",
|
|
213
|
+
format: options.format ?? "json"
|
|
214
|
+
};
|
|
215
|
+
if (options.dateFrom) payload.date_from = options.dateFrom;
|
|
216
|
+
if (options.dateTo) payload.date_to = options.dateTo;
|
|
217
|
+
if (options.interactionIds) payload.interaction_ids = options.interactionIds;
|
|
218
|
+
const resp = await this._request("POST", "/v1/reports", payload);
|
|
219
|
+
if (resp.status === 200 || resp.status === 202) {
|
|
220
|
+
return resp.json();
|
|
221
|
+
}
|
|
222
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
223
|
+
}
|
|
224
|
+
async getReport(reportId) {
|
|
225
|
+
const resp = await this._request("GET", `/v1/reports/${reportId}`);
|
|
226
|
+
if (resp.status === 200) return resp.json();
|
|
227
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
228
|
+
}
|
|
229
|
+
_mapEvidence(data) {
|
|
230
|
+
return {
|
|
231
|
+
interactionId: String(data.interaction_id),
|
|
232
|
+
riskClass: String(data.risk_class),
|
|
233
|
+
articleMatches: data.article_matches ?? [],
|
|
234
|
+
requiredActions: data.required_actions ?? [],
|
|
235
|
+
requiredDisclosures: data.required_disclosures ?? [],
|
|
236
|
+
regulatoryFlags: data.regulatory_flags ?? [],
|
|
237
|
+
confidence: String(data.confidence),
|
|
238
|
+
complianceScore: Number(data.compliance_score),
|
|
239
|
+
auditEntryId: String(data.audit_entry_id),
|
|
240
|
+
chainTipHash: String(data.chain_tip_hash),
|
|
241
|
+
timestamp: String(data.timestamp),
|
|
242
|
+
classificationVersion: String(data.classification_version),
|
|
243
|
+
policyVersion: String(data.policy_version)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
248
|
+
0 && (module.exports = {
|
|
249
|
+
Hasher,
|
|
250
|
+
SDK_VERSION,
|
|
251
|
+
Verefy,
|
|
252
|
+
VerefyAPIError,
|
|
253
|
+
VerefyConnectionError,
|
|
254
|
+
VerefyError,
|
|
255
|
+
VerefyValidationError
|
|
256
|
+
});
|
|
257
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * VEREEFY Node.js SDK v1.0\n *\n * Verwendung:\n * import { Verefy, Hasher } from \"@vereefy/sdk\";\n * const v = new Verefy({ apiKey: \"vfy_...\" });\n * const nachweis = await v.logInteraction({\n * provider: \"openai\", modelName: \"gpt-4o\",\n * purpose: \"Kundenberatung Retail-Banking\",\n * sector: \"financial_services\",\n * inputContent: nachrichten,\n * outputContent: antwort,\n * });\n */\n\nimport { createHash } from \"node:crypto\";\n\nexport const SDK_VERSION = \"1.0.0\";\nconst DEFAULT_API_URL = \"https://api.vereefy.ai\";\n\n// ── Typen ─────────────────────────────────────────────────────────────────\n\nexport interface ComplianceEvidence {\n interactionId: string;\n riskClass: string;\n articleMatches: string[];\n requiredActions: string[];\n requiredDisclosures: string[];\n regulatoryFlags: string[];\n confidence: string;\n complianceScore: number;\n auditEntryId: string;\n chainTipHash: string;\n timestamp: string;\n classificationVersion: string;\n policyVersion: string;\n}\n\nexport interface LogInteractionOptions {\n provider: string;\n modelName: string;\n purpose: string;\n sector: string;\n /** Pass raw content OR a pre-computed hash — never both. */\n inputContent?: unknown;\n inputHash?: string;\n outputContent?: unknown;\n outputHash?: string;\n modelVersion?: string;\n interactionType?: string;\n customerFacing?: boolean;\n automationLevel?: string;\n decisionImpact?: string;\n userRole?: string;\n jurisdiction?: string;\n externalRef?: string;\n responseTimeMs?: number;\n extraData?: Record<string, unknown>;\n}\n\nexport interface VerefyOptions {\n apiKey: string;\n baseUrl?: string;\n timeout?: number;\n maxRetries?: number;\n}\n\n// ── Hasher ────────────────────────────────────────────────────────────────\n\n/**\n * Client-seitiges Hashing. Rohinhalte verlassen nie Ihre Umgebung.\n * Identische Algorithmen wie Python SDK (cross-language kompatibel).\n */\nexport class Hasher {\n static canonicalHash(content: unknown): string {\n if (content === null || content === undefined) {\n return createHash(\"sha256\").update(\"null\").digest(\"hex\");\n }\n if (Buffer.isBuffer(content)) {\n return createHash(\"sha256\").update(content).digest(\"hex\");\n }\n if (typeof content === \"string\") {\n return createHash(\"sha256\")\n .update(content.trim(), \"utf8\")\n .digest(\"hex\");\n }\n if (typeof content === \"object\" || Array.isArray(content)) {\n const canonical = JSON.stringify(\n content,\n Object.keys(content as object).sort(),\n // JSON.stringify sortiert nicht automatisch — separater Schritt nötig\n );\n // sort_keys=True wie Python: deepSortKeys\n const c = Hasher._deepSortJson(content);\n return createHash(\"sha256\").update(c, \"utf8\").digest(\"hex\");\n }\n return createHash(\"sha256\")\n .update(String(content), \"utf8\")\n .digest(\"hex\");\n }\n\n static hashMessages(messages: Array<{ role: string; content: string }>): string {\n const normalized = messages.map((m) => ({\n role: m.role ?? \"\",\n content: m.content ?? \"\",\n }));\n return Hasher.canonicalHash(normalized);\n }\n\n /** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */\n private static _deepSortJson(value: unknown): string {\n if (value === null || value === undefined) return \"null\";\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n if (typeof value === \"number\") return String(value);\n if (typeof value === \"string\") {\n return Hasher._ensureAsciiString(value);\n }\n if (Array.isArray(value)) {\n return \"[\" + value.map((v) => Hasher._deepSortJson(v)).join(\",\") + \"]\";\n }\n if (typeof value === \"object\") {\n const keys = Object.keys(value as object).sort();\n const pairs = keys.map(\n (k) =>\n Hasher._ensureAsciiString(k) +\n \":\" +\n Hasher._deepSortJson((value as Record<string, unknown>)[k]),\n );\n return \"{\" + pairs.join(\",\") + \"}\";\n }\n return Hasher._ensureAsciiString(String(value));\n }\n\n /** JSON.stringify + escape non-ASCII as \\uXXXX (Python ensure_ascii=True) */\n private static _ensureAsciiString(s: string): string {\n // JSON.stringify handles all control chars, backslash, quotes\n const jsJson = JSON.stringify(s); // → \"...\" with escaping\n // Additionally escape any non-ASCII (code >= 0x80) that JSON.stringify left through\n return jsJson.replace(/[\\u0080-]/g, (c) => {\n const code = c.charCodeAt(0);\n return \"\\\\u\" + code.toString(16).padStart(4, \"0\");\n });\n }\n}\n\n// ── Errors ────────────────────────────────────────────────────────────────\n\nexport class VerefyError extends Error {}\n\nexport class VerefyAPIError extends VerefyError {\n constructor(\n public readonly statusCode: number,\n public readonly detail: string,\n ) {\n super(`VEREEFY API ${statusCode}: ${detail}`);\n this.name = \"VerefyAPIError\";\n }\n}\n\nexport class VerefyConnectionError extends VerefyError {\n constructor(message: string) {\n super(message);\n this.name = \"VerefyConnectionError\";\n }\n}\n\nexport class VerefyValidationError extends VerefyError {\n constructor(message: string) {\n super(message);\n this.name = \"VerefyValidationError\";\n }\n}\n\n// ── Verefy-Client ─────────────────────────────────────────────────────────\n\nexport class Verefy {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n\n constructor(options: VerefyOptions) {\n if (!options.apiKey.startsWith(\"vfy_\")) {\n throw new VerefyValidationError(\"API-Schlüssel muss mit 'vfy_' beginnen.\");\n }\n this.apiKey = options.apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_API_URL).replace(/\\/$/, \"\");\n this.timeout = options.timeout ?? 15_000;\n this.maxRetries = options.maxRetries ?? 3;\n }\n\n private async _request(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const url = this.baseUrl + path;\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"X-SDK-Version\": SDK_VERSION,\n };\n let lastErr: Error | undefined;\n for (let attempt = 0; attempt < this.maxRetries; attempt++) {\n try {\n const signal = AbortSignal.timeout(this.timeout);\n const resp = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal,\n });\n if (resp.status < 500) return resp;\n const text = await resp.text();\n lastErr = new VerefyAPIError(resp.status, text);\n if (attempt < this.maxRetries - 1) {\n await new Promise((r) => setTimeout(r, 2 ** attempt * 1000));\n }\n } catch (e) {\n lastErr = new VerefyConnectionError(String(e));\n if (attempt < this.maxRetries - 1) {\n await new Promise((r) => setTimeout(r, 2 ** attempt * 1000));\n }\n }\n }\n throw lastErr!;\n }\n\n async logInteraction(opts: LogInteractionOptions): Promise<ComplianceEvidence> {\n let inputHash: string;\n if (opts.inputContent !== undefined) {\n inputHash = Hasher.canonicalHash(opts.inputContent);\n } else if (opts.inputHash !== undefined) {\n inputHash = opts.inputHash;\n } else {\n throw new VerefyValidationError(\"inputContent oder inputHash angeben.\");\n }\n\n let outputHash: string;\n if (opts.outputContent !== undefined) {\n outputHash = Hasher.canonicalHash(opts.outputContent);\n } else if (opts.outputHash !== undefined) {\n outputHash = opts.outputHash;\n } else {\n throw new VerefyValidationError(\"outputContent oder outputHash angeben.\");\n }\n\n const payload: Record<string, unknown> = {\n provider: opts.provider,\n model_name: opts.modelName,\n purpose: opts.purpose,\n sector: opts.sector,\n input_hash: inputHash,\n output_hash: outputHash,\n };\n if (opts.modelVersion !== undefined) payload.model_version = opts.modelVersion;\n if (opts.interactionType !== undefined) payload.interaction_type = opts.interactionType;\n if (opts.customerFacing !== undefined) payload.customer_facing = opts.customerFacing;\n if (opts.automationLevel !== undefined) payload.automation_level = opts.automationLevel;\n if (opts.decisionImpact !== undefined) payload.decision_impact = opts.decisionImpact;\n if (opts.userRole !== undefined) payload.user_role = opts.userRole;\n if (opts.jurisdiction !== undefined) payload.jurisdiction = opts.jurisdiction;\n if (opts.externalRef !== undefined) payload.external_ref = opts.externalRef;\n if (opts.responseTimeMs !== undefined) payload.response_time_ms = opts.responseTimeMs;\n if (opts.extraData !== undefined) payload.extra_data = opts.extraData;\n\n const resp = await this._request(\"POST\", \"/v1/interactions\", payload);\n if (resp.status === 201) {\n const data = await resp.json() as Record<string, unknown>;\n return this._mapEvidence(data);\n }\n const err = await resp.json().catch(() => ({ detail: resp.statusText })) as Record<string, unknown>;\n throw new VerefyAPIError(resp.status, String(err.detail ?? resp.statusText));\n }\n\n async getInteraction(interactionId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/interactions/${interactionId}`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async verifyChain(interactionId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/audit/${interactionId}/chain`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async requestReport(options: {\n reportType?: string;\n dateFrom?: string;\n dateTo?: string;\n interactionIds?: string[];\n format?: string;\n } = {}): Promise<Record<string, unknown>> {\n const payload: Record<string, unknown> = {\n report_type: options.reportType ?? \"eu_ai_act\",\n format: options.format ?? \"json\",\n };\n if (options.dateFrom) payload.date_from = options.dateFrom;\n if (options.dateTo) payload.date_to = options.dateTo;\n if (options.interactionIds) payload.interaction_ids = options.interactionIds;\n\n const resp = await this._request(\"POST\", \"/v1/reports\", payload);\n if (resp.status === 200 || resp.status === 202) {\n return resp.json() as Promise<Record<string, unknown>>;\n }\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async getReport(reportId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/reports/${reportId}`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n private _mapEvidence(data: Record<string, unknown>): ComplianceEvidence {\n return {\n interactionId: String(data.interaction_id),\n riskClass: String(data.risk_class),\n articleMatches: (data.article_matches as string[]) ?? [],\n requiredActions: (data.required_actions as string[]) ?? [],\n requiredDisclosures: (data.required_disclosures as string[]) ?? [],\n regulatoryFlags: (data.regulatory_flags as string[]) ?? [],\n confidence: String(data.confidence),\n complianceScore: Number(data.compliance_score),\n auditEntryId: String(data.audit_entry_id),\n chainTipHash: String(data.chain_tip_hash),\n timestamp: String(data.timestamp),\n classificationVersion: String(data.classification_version),\n policyVersion: String(data.policy_version),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,yBAA2B;AAEpB,IAAM,cAAc;AAC3B,IAAM,kBAAkB;AAuDjB,IAAM,SAAN,MAAM,QAAO;AAAA,EAClB,OAAO,cAAc,SAA0B;AAC7C,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC7C,iBAAO,+BAAW,QAAQ,EAAE,OAAO,MAAM,EAAE,OAAO,KAAK;AAAA,IACzD;AACA,QAAI,OAAO,SAAS,OAAO,GAAG;AAC5B,iBAAO,+BAAW,QAAQ,EAAE,OAAO,OAAO,EAAE,OAAO,KAAK;AAAA,IAC1D;AACA,QAAI,OAAO,YAAY,UAAU;AAC/B,iBAAO,+BAAW,QAAQ,EACvB,OAAO,QAAQ,KAAK,GAAG,MAAM,EAC7B,OAAO,KAAK;AAAA,IACjB;AACA,QAAI,OAAO,YAAY,YAAY,MA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AAO,KAAK,SAAS;AAAA,MAChC,uBAAuB,OAAO,KAAK,sBAAsB;AAAA,MACzD,eAAe,OAAO,KAAK,cAAc;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VEREEFY Node.js SDK v1.0
|
|
3
|
+
*
|
|
4
|
+
* Verwendung:
|
|
5
|
+
* import { Verefy, Hasher } from "@vereefy/sdk";
|
|
6
|
+
* const v = new Verefy({ apiKey: "vfy_..." });
|
|
7
|
+
* const nachweis = await v.logInteraction({
|
|
8
|
+
* provider: "openai", modelName: "gpt-4o",
|
|
9
|
+
* purpose: "Kundenberatung Retail-Banking",
|
|
10
|
+
* sector: "financial_services",
|
|
11
|
+
* inputContent: nachrichten,
|
|
12
|
+
* outputContent: antwort,
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
declare const SDK_VERSION = "1.0.0";
|
|
16
|
+
interface ComplianceEvidence {
|
|
17
|
+
interactionId: string;
|
|
18
|
+
riskClass: string;
|
|
19
|
+
articleMatches: string[];
|
|
20
|
+
requiredActions: string[];
|
|
21
|
+
requiredDisclosures: string[];
|
|
22
|
+
regulatoryFlags: string[];
|
|
23
|
+
confidence: string;
|
|
24
|
+
complianceScore: number;
|
|
25
|
+
auditEntryId: string;
|
|
26
|
+
chainTipHash: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
classificationVersion: string;
|
|
29
|
+
policyVersion: string;
|
|
30
|
+
}
|
|
31
|
+
interface LogInteractionOptions {
|
|
32
|
+
provider: string;
|
|
33
|
+
modelName: string;
|
|
34
|
+
purpose: string;
|
|
35
|
+
sector: string;
|
|
36
|
+
/** Pass raw content OR a pre-computed hash — never both. */
|
|
37
|
+
inputContent?: unknown;
|
|
38
|
+
inputHash?: string;
|
|
39
|
+
outputContent?: unknown;
|
|
40
|
+
outputHash?: string;
|
|
41
|
+
modelVersion?: string;
|
|
42
|
+
interactionType?: string;
|
|
43
|
+
customerFacing?: boolean;
|
|
44
|
+
automationLevel?: string;
|
|
45
|
+
decisionImpact?: string;
|
|
46
|
+
userRole?: string;
|
|
47
|
+
jurisdiction?: string;
|
|
48
|
+
externalRef?: string;
|
|
49
|
+
responseTimeMs?: number;
|
|
50
|
+
extraData?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
interface VerefyOptions {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
maxRetries?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Client-seitiges Hashing. Rohinhalte verlassen nie Ihre Umgebung.
|
|
60
|
+
* Identische Algorithmen wie Python SDK (cross-language kompatibel).
|
|
61
|
+
*/
|
|
62
|
+
declare class Hasher {
|
|
63
|
+
static canonicalHash(content: unknown): string;
|
|
64
|
+
static hashMessages(messages: Array<{
|
|
65
|
+
role: string;
|
|
66
|
+
content: string;
|
|
67
|
+
}>): string;
|
|
68
|
+
/** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */
|
|
69
|
+
private static _deepSortJson;
|
|
70
|
+
/** JSON.stringify + escape non-ASCII as \uXXXX (Python ensure_ascii=True) */
|
|
71
|
+
private static _ensureAsciiString;
|
|
72
|
+
}
|
|
73
|
+
declare class VerefyError extends Error {
|
|
74
|
+
}
|
|
75
|
+
declare class VerefyAPIError extends VerefyError {
|
|
76
|
+
readonly statusCode: number;
|
|
77
|
+
readonly detail: string;
|
|
78
|
+
constructor(statusCode: number, detail: string);
|
|
79
|
+
}
|
|
80
|
+
declare class VerefyConnectionError extends VerefyError {
|
|
81
|
+
constructor(message: string);
|
|
82
|
+
}
|
|
83
|
+
declare class VerefyValidationError extends VerefyError {
|
|
84
|
+
constructor(message: string);
|
|
85
|
+
}
|
|
86
|
+
declare class Verefy {
|
|
87
|
+
private readonly apiKey;
|
|
88
|
+
private readonly baseUrl;
|
|
89
|
+
private readonly timeout;
|
|
90
|
+
private readonly maxRetries;
|
|
91
|
+
constructor(options: VerefyOptions);
|
|
92
|
+
private _request;
|
|
93
|
+
logInteraction(opts: LogInteractionOptions): Promise<ComplianceEvidence>;
|
|
94
|
+
getInteraction(interactionId: string): Promise<Record<string, unknown>>;
|
|
95
|
+
verifyChain(interactionId: string): Promise<Record<string, unknown>>;
|
|
96
|
+
requestReport(options?: {
|
|
97
|
+
reportType?: string;
|
|
98
|
+
dateFrom?: string;
|
|
99
|
+
dateTo?: string;
|
|
100
|
+
interactionIds?: string[];
|
|
101
|
+
format?: string;
|
|
102
|
+
}): Promise<Record<string, unknown>>;
|
|
103
|
+
getReport(reportId: string): Promise<Record<string, unknown>>;
|
|
104
|
+
private _mapEvidence;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { type ComplianceEvidence, Hasher, type LogInteractionOptions, SDK_VERSION, Verefy, VerefyAPIError, VerefyConnectionError, VerefyError, type VerefyOptions, VerefyValidationError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VEREEFY Node.js SDK v1.0
|
|
3
|
+
*
|
|
4
|
+
* Verwendung:
|
|
5
|
+
* import { Verefy, Hasher } from "@vereefy/sdk";
|
|
6
|
+
* const v = new Verefy({ apiKey: "vfy_..." });
|
|
7
|
+
* const nachweis = await v.logInteraction({
|
|
8
|
+
* provider: "openai", modelName: "gpt-4o",
|
|
9
|
+
* purpose: "Kundenberatung Retail-Banking",
|
|
10
|
+
* sector: "financial_services",
|
|
11
|
+
* inputContent: nachrichten,
|
|
12
|
+
* outputContent: antwort,
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
declare const SDK_VERSION = "1.0.0";
|
|
16
|
+
interface ComplianceEvidence {
|
|
17
|
+
interactionId: string;
|
|
18
|
+
riskClass: string;
|
|
19
|
+
articleMatches: string[];
|
|
20
|
+
requiredActions: string[];
|
|
21
|
+
requiredDisclosures: string[];
|
|
22
|
+
regulatoryFlags: string[];
|
|
23
|
+
confidence: string;
|
|
24
|
+
complianceScore: number;
|
|
25
|
+
auditEntryId: string;
|
|
26
|
+
chainTipHash: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
classificationVersion: string;
|
|
29
|
+
policyVersion: string;
|
|
30
|
+
}
|
|
31
|
+
interface LogInteractionOptions {
|
|
32
|
+
provider: string;
|
|
33
|
+
modelName: string;
|
|
34
|
+
purpose: string;
|
|
35
|
+
sector: string;
|
|
36
|
+
/** Pass raw content OR a pre-computed hash — never both. */
|
|
37
|
+
inputContent?: unknown;
|
|
38
|
+
inputHash?: string;
|
|
39
|
+
outputContent?: unknown;
|
|
40
|
+
outputHash?: string;
|
|
41
|
+
modelVersion?: string;
|
|
42
|
+
interactionType?: string;
|
|
43
|
+
customerFacing?: boolean;
|
|
44
|
+
automationLevel?: string;
|
|
45
|
+
decisionImpact?: string;
|
|
46
|
+
userRole?: string;
|
|
47
|
+
jurisdiction?: string;
|
|
48
|
+
externalRef?: string;
|
|
49
|
+
responseTimeMs?: number;
|
|
50
|
+
extraData?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
interface VerefyOptions {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
maxRetries?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Client-seitiges Hashing. Rohinhalte verlassen nie Ihre Umgebung.
|
|
60
|
+
* Identische Algorithmen wie Python SDK (cross-language kompatibel).
|
|
61
|
+
*/
|
|
62
|
+
declare class Hasher {
|
|
63
|
+
static canonicalHash(content: unknown): string;
|
|
64
|
+
static hashMessages(messages: Array<{
|
|
65
|
+
role: string;
|
|
66
|
+
content: string;
|
|
67
|
+
}>): string;
|
|
68
|
+
/** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */
|
|
69
|
+
private static _deepSortJson;
|
|
70
|
+
/** JSON.stringify + escape non-ASCII as \uXXXX (Python ensure_ascii=True) */
|
|
71
|
+
private static _ensureAsciiString;
|
|
72
|
+
}
|
|
73
|
+
declare class VerefyError extends Error {
|
|
74
|
+
}
|
|
75
|
+
declare class VerefyAPIError extends VerefyError {
|
|
76
|
+
readonly statusCode: number;
|
|
77
|
+
readonly detail: string;
|
|
78
|
+
constructor(statusCode: number, detail: string);
|
|
79
|
+
}
|
|
80
|
+
declare class VerefyConnectionError extends VerefyError {
|
|
81
|
+
constructor(message: string);
|
|
82
|
+
}
|
|
83
|
+
declare class VerefyValidationError extends VerefyError {
|
|
84
|
+
constructor(message: string);
|
|
85
|
+
}
|
|
86
|
+
declare class Verefy {
|
|
87
|
+
private readonly apiKey;
|
|
88
|
+
private readonly baseUrl;
|
|
89
|
+
private readonly timeout;
|
|
90
|
+
private readonly maxRetries;
|
|
91
|
+
constructor(options: VerefyOptions);
|
|
92
|
+
private _request;
|
|
93
|
+
logInteraction(opts: LogInteractionOptions): Promise<ComplianceEvidence>;
|
|
94
|
+
getInteraction(interactionId: string): Promise<Record<string, unknown>>;
|
|
95
|
+
verifyChain(interactionId: string): Promise<Record<string, unknown>>;
|
|
96
|
+
requestReport(options?: {
|
|
97
|
+
reportType?: string;
|
|
98
|
+
dateFrom?: string;
|
|
99
|
+
dateTo?: string;
|
|
100
|
+
interactionIds?: string[];
|
|
101
|
+
format?: string;
|
|
102
|
+
}): Promise<Record<string, unknown>>;
|
|
103
|
+
getReport(reportId: string): Promise<Record<string, unknown>>;
|
|
104
|
+
private _mapEvidence;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { type ComplianceEvidence, Hasher, type LogInteractionOptions, SDK_VERSION, Verefy, VerefyAPIError, VerefyConnectionError, VerefyError, type VerefyOptions, VerefyValidationError };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
var SDK_VERSION = "1.0.0";
|
|
4
|
+
var DEFAULT_API_URL = "https://api.vereefy.ai";
|
|
5
|
+
var Hasher = class _Hasher {
|
|
6
|
+
static canonicalHash(content) {
|
|
7
|
+
if (content === null || content === void 0) {
|
|
8
|
+
return createHash("sha256").update("null").digest("hex");
|
|
9
|
+
}
|
|
10
|
+
if (Buffer.isBuffer(content)) {
|
|
11
|
+
return createHash("sha256").update(content).digest("hex");
|
|
12
|
+
}
|
|
13
|
+
if (typeof content === "string") {
|
|
14
|
+
return createHash("sha256").update(content.trim(), "utf8").digest("hex");
|
|
15
|
+
}
|
|
16
|
+
if (typeof content === "object" || Array.isArray(content)) {
|
|
17
|
+
const canonical = JSON.stringify(
|
|
18
|
+
content,
|
|
19
|
+
Object.keys(content).sort()
|
|
20
|
+
// JSON.stringify sortiert nicht automatisch — separater Schritt nötig
|
|
21
|
+
);
|
|
22
|
+
const c = _Hasher._deepSortJson(content);
|
|
23
|
+
return createHash("sha256").update(c, "utf8").digest("hex");
|
|
24
|
+
}
|
|
25
|
+
return createHash("sha256").update(String(content), "utf8").digest("hex");
|
|
26
|
+
}
|
|
27
|
+
static hashMessages(messages) {
|
|
28
|
+
const normalized = messages.map((m) => ({
|
|
29
|
+
role: m.role ?? "",
|
|
30
|
+
content: m.content ?? ""
|
|
31
|
+
}));
|
|
32
|
+
return _Hasher.canonicalHash(normalized);
|
|
33
|
+
}
|
|
34
|
+
/** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */
|
|
35
|
+
static _deepSortJson(value) {
|
|
36
|
+
if (value === null || value === void 0) return "null";
|
|
37
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
38
|
+
if (typeof value === "number") return String(value);
|
|
39
|
+
if (typeof value === "string") {
|
|
40
|
+
return _Hasher._ensureAsciiString(value);
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return "[" + value.map((v) => _Hasher._deepSortJson(v)).join(",") + "]";
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "object") {
|
|
46
|
+
const keys = Object.keys(value).sort();
|
|
47
|
+
const pairs = keys.map(
|
|
48
|
+
(k) => _Hasher._ensureAsciiString(k) + ":" + _Hasher._deepSortJson(value[k])
|
|
49
|
+
);
|
|
50
|
+
return "{" + pairs.join(",") + "}";
|
|
51
|
+
}
|
|
52
|
+
return _Hasher._ensureAsciiString(String(value));
|
|
53
|
+
}
|
|
54
|
+
/** JSON.stringify + escape non-ASCII as \uXXXX (Python ensure_ascii=True) */
|
|
55
|
+
static _ensureAsciiString(s) {
|
|
56
|
+
const jsJson = JSON.stringify(s);
|
|
57
|
+
return jsJson.replace(/[\u0080-]/g, (c) => {
|
|
58
|
+
const code = c.charCodeAt(0);
|
|
59
|
+
return "\\u" + code.toString(16).padStart(4, "0");
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var VerefyError = class extends Error {
|
|
64
|
+
};
|
|
65
|
+
var VerefyAPIError = class extends VerefyError {
|
|
66
|
+
constructor(statusCode, detail) {
|
|
67
|
+
super(`VEREEFY API ${statusCode}: ${detail}`);
|
|
68
|
+
this.statusCode = statusCode;
|
|
69
|
+
this.detail = detail;
|
|
70
|
+
this.name = "VerefyAPIError";
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var VerefyConnectionError = class extends VerefyError {
|
|
74
|
+
constructor(message) {
|
|
75
|
+
super(message);
|
|
76
|
+
this.name = "VerefyConnectionError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var VerefyValidationError = class extends VerefyError {
|
|
80
|
+
constructor(message) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.name = "VerefyValidationError";
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var Verefy = class {
|
|
86
|
+
constructor(options) {
|
|
87
|
+
if (!options.apiKey.startsWith("vfy_")) {
|
|
88
|
+
throw new VerefyValidationError("API-Schl\xFCssel muss mit 'vfy_' beginnen.");
|
|
89
|
+
}
|
|
90
|
+
this.apiKey = options.apiKey;
|
|
91
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
92
|
+
this.timeout = options.timeout ?? 15e3;
|
|
93
|
+
this.maxRetries = options.maxRetries ?? 3;
|
|
94
|
+
}
|
|
95
|
+
async _request(method, path, body) {
|
|
96
|
+
const url = this.baseUrl + path;
|
|
97
|
+
const headers = {
|
|
98
|
+
"X-API-Key": this.apiKey,
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
"X-SDK-Version": SDK_VERSION
|
|
101
|
+
};
|
|
102
|
+
let lastErr;
|
|
103
|
+
for (let attempt = 0; attempt < this.maxRetries; attempt++) {
|
|
104
|
+
try {
|
|
105
|
+
const signal = AbortSignal.timeout(this.timeout);
|
|
106
|
+
const resp = await fetch(url, {
|
|
107
|
+
method,
|
|
108
|
+
headers,
|
|
109
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
110
|
+
signal
|
|
111
|
+
});
|
|
112
|
+
if (resp.status < 500) return resp;
|
|
113
|
+
const text = await resp.text();
|
|
114
|
+
lastErr = new VerefyAPIError(resp.status, text);
|
|
115
|
+
if (attempt < this.maxRetries - 1) {
|
|
116
|
+
await new Promise((r) => setTimeout(r, 2 ** attempt * 1e3));
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
lastErr = new VerefyConnectionError(String(e));
|
|
120
|
+
if (attempt < this.maxRetries - 1) {
|
|
121
|
+
await new Promise((r) => setTimeout(r, 2 ** attempt * 1e3));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
throw lastErr;
|
|
126
|
+
}
|
|
127
|
+
async logInteraction(opts) {
|
|
128
|
+
let inputHash;
|
|
129
|
+
if (opts.inputContent !== void 0) {
|
|
130
|
+
inputHash = Hasher.canonicalHash(opts.inputContent);
|
|
131
|
+
} else if (opts.inputHash !== void 0) {
|
|
132
|
+
inputHash = opts.inputHash;
|
|
133
|
+
} else {
|
|
134
|
+
throw new VerefyValidationError("inputContent oder inputHash angeben.");
|
|
135
|
+
}
|
|
136
|
+
let outputHash;
|
|
137
|
+
if (opts.outputContent !== void 0) {
|
|
138
|
+
outputHash = Hasher.canonicalHash(opts.outputContent);
|
|
139
|
+
} else if (opts.outputHash !== void 0) {
|
|
140
|
+
outputHash = opts.outputHash;
|
|
141
|
+
} else {
|
|
142
|
+
throw new VerefyValidationError("outputContent oder outputHash angeben.");
|
|
143
|
+
}
|
|
144
|
+
const payload = {
|
|
145
|
+
provider: opts.provider,
|
|
146
|
+
model_name: opts.modelName,
|
|
147
|
+
purpose: opts.purpose,
|
|
148
|
+
sector: opts.sector,
|
|
149
|
+
input_hash: inputHash,
|
|
150
|
+
output_hash: outputHash
|
|
151
|
+
};
|
|
152
|
+
if (opts.modelVersion !== void 0) payload.model_version = opts.modelVersion;
|
|
153
|
+
if (opts.interactionType !== void 0) payload.interaction_type = opts.interactionType;
|
|
154
|
+
if (opts.customerFacing !== void 0) payload.customer_facing = opts.customerFacing;
|
|
155
|
+
if (opts.automationLevel !== void 0) payload.automation_level = opts.automationLevel;
|
|
156
|
+
if (opts.decisionImpact !== void 0) payload.decision_impact = opts.decisionImpact;
|
|
157
|
+
if (opts.userRole !== void 0) payload.user_role = opts.userRole;
|
|
158
|
+
if (opts.jurisdiction !== void 0) payload.jurisdiction = opts.jurisdiction;
|
|
159
|
+
if (opts.externalRef !== void 0) payload.external_ref = opts.externalRef;
|
|
160
|
+
if (opts.responseTimeMs !== void 0) payload.response_time_ms = opts.responseTimeMs;
|
|
161
|
+
if (opts.extraData !== void 0) payload.extra_data = opts.extraData;
|
|
162
|
+
const resp = await this._request("POST", "/v1/interactions", payload);
|
|
163
|
+
if (resp.status === 201) {
|
|
164
|
+
const data = await resp.json();
|
|
165
|
+
return this._mapEvidence(data);
|
|
166
|
+
}
|
|
167
|
+
const err = await resp.json().catch(() => ({ detail: resp.statusText }));
|
|
168
|
+
throw new VerefyAPIError(resp.status, String(err.detail ?? resp.statusText));
|
|
169
|
+
}
|
|
170
|
+
async getInteraction(interactionId) {
|
|
171
|
+
const resp = await this._request("GET", `/v1/interactions/${interactionId}`);
|
|
172
|
+
if (resp.status === 200) return resp.json();
|
|
173
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
174
|
+
}
|
|
175
|
+
async verifyChain(interactionId) {
|
|
176
|
+
const resp = await this._request("GET", `/v1/audit/${interactionId}/chain`);
|
|
177
|
+
if (resp.status === 200) return resp.json();
|
|
178
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
179
|
+
}
|
|
180
|
+
async requestReport(options = {}) {
|
|
181
|
+
const payload = {
|
|
182
|
+
report_type: options.reportType ?? "eu_ai_act",
|
|
183
|
+
format: options.format ?? "json"
|
|
184
|
+
};
|
|
185
|
+
if (options.dateFrom) payload.date_from = options.dateFrom;
|
|
186
|
+
if (options.dateTo) payload.date_to = options.dateTo;
|
|
187
|
+
if (options.interactionIds) payload.interaction_ids = options.interactionIds;
|
|
188
|
+
const resp = await this._request("POST", "/v1/reports", payload);
|
|
189
|
+
if (resp.status === 200 || resp.status === 202) {
|
|
190
|
+
return resp.json();
|
|
191
|
+
}
|
|
192
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
193
|
+
}
|
|
194
|
+
async getReport(reportId) {
|
|
195
|
+
const resp = await this._request("GET", `/v1/reports/${reportId}`);
|
|
196
|
+
if (resp.status === 200) return resp.json();
|
|
197
|
+
throw new VerefyAPIError(resp.status, await resp.text());
|
|
198
|
+
}
|
|
199
|
+
_mapEvidence(data) {
|
|
200
|
+
return {
|
|
201
|
+
interactionId: String(data.interaction_id),
|
|
202
|
+
riskClass: String(data.risk_class),
|
|
203
|
+
articleMatches: data.article_matches ?? [],
|
|
204
|
+
requiredActions: data.required_actions ?? [],
|
|
205
|
+
requiredDisclosures: data.required_disclosures ?? [],
|
|
206
|
+
regulatoryFlags: data.regulatory_flags ?? [],
|
|
207
|
+
confidence: String(data.confidence),
|
|
208
|
+
complianceScore: Number(data.compliance_score),
|
|
209
|
+
auditEntryId: String(data.audit_entry_id),
|
|
210
|
+
chainTipHash: String(data.chain_tip_hash),
|
|
211
|
+
timestamp: String(data.timestamp),
|
|
212
|
+
classificationVersion: String(data.classification_version),
|
|
213
|
+
policyVersion: String(data.policy_version)
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
export {
|
|
218
|
+
Hasher,
|
|
219
|
+
SDK_VERSION,
|
|
220
|
+
Verefy,
|
|
221
|
+
VerefyAPIError,
|
|
222
|
+
VerefyConnectionError,
|
|
223
|
+
VerefyError,
|
|
224
|
+
VerefyValidationError
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * VEREEFY Node.js SDK v1.0\n *\n * Verwendung:\n * import { Verefy, Hasher } from \"@vereefy/sdk\";\n * const v = new Verefy({ apiKey: \"vfy_...\" });\n * const nachweis = await v.logInteraction({\n * provider: \"openai\", modelName: \"gpt-4o\",\n * purpose: \"Kundenberatung Retail-Banking\",\n * sector: \"financial_services\",\n * inputContent: nachrichten,\n * outputContent: antwort,\n * });\n */\n\nimport { createHash } from \"node:crypto\";\n\nexport const SDK_VERSION = \"1.0.0\";\nconst DEFAULT_API_URL = \"https://api.vereefy.ai\";\n\n// ── Typen ─────────────────────────────────────────────────────────────────\n\nexport interface ComplianceEvidence {\n interactionId: string;\n riskClass: string;\n articleMatches: string[];\n requiredActions: string[];\n requiredDisclosures: string[];\n regulatoryFlags: string[];\n confidence: string;\n complianceScore: number;\n auditEntryId: string;\n chainTipHash: string;\n timestamp: string;\n classificationVersion: string;\n policyVersion: string;\n}\n\nexport interface LogInteractionOptions {\n provider: string;\n modelName: string;\n purpose: string;\n sector: string;\n /** Pass raw content OR a pre-computed hash — never both. */\n inputContent?: unknown;\n inputHash?: string;\n outputContent?: unknown;\n outputHash?: string;\n modelVersion?: string;\n interactionType?: string;\n customerFacing?: boolean;\n automationLevel?: string;\n decisionImpact?: string;\n userRole?: string;\n jurisdiction?: string;\n externalRef?: string;\n responseTimeMs?: number;\n extraData?: Record<string, unknown>;\n}\n\nexport interface VerefyOptions {\n apiKey: string;\n baseUrl?: string;\n timeout?: number;\n maxRetries?: number;\n}\n\n// ── Hasher ────────────────────────────────────────────────────────────────\n\n/**\n * Client-seitiges Hashing. Rohinhalte verlassen nie Ihre Umgebung.\n * Identische Algorithmen wie Python SDK (cross-language kompatibel).\n */\nexport class Hasher {\n static canonicalHash(content: unknown): string {\n if (content === null || content === undefined) {\n return createHash(\"sha256\").update(\"null\").digest(\"hex\");\n }\n if (Buffer.isBuffer(content)) {\n return createHash(\"sha256\").update(content).digest(\"hex\");\n }\n if (typeof content === \"string\") {\n return createHash(\"sha256\")\n .update(content.trim(), \"utf8\")\n .digest(\"hex\");\n }\n if (typeof content === \"object\" || Array.isArray(content)) {\n const canonical = JSON.stringify(\n content,\n Object.keys(content as object).sort(),\n // JSON.stringify sortiert nicht automatisch — separater Schritt nötig\n );\n // sort_keys=True wie Python: deepSortKeys\n const c = Hasher._deepSortJson(content);\n return createHash(\"sha256\").update(c, \"utf8\").digest(\"hex\");\n }\n return createHash(\"sha256\")\n .update(String(content), \"utf8\")\n .digest(\"hex\");\n }\n\n static hashMessages(messages: Array<{ role: string; content: string }>): string {\n const normalized = messages.map((m) => ({\n role: m.role ?? \"\",\n content: m.content ?? \"\",\n }));\n return Hasher.canonicalHash(normalized);\n }\n\n /** json.dumps(sort_keys=True, ensure_ascii=True, separators=(',',':')) */\n private static _deepSortJson(value: unknown): string {\n if (value === null || value === undefined) return \"null\";\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n if (typeof value === \"number\") return String(value);\n if (typeof value === \"string\") {\n return Hasher._ensureAsciiString(value);\n }\n if (Array.isArray(value)) {\n return \"[\" + value.map((v) => Hasher._deepSortJson(v)).join(\",\") + \"]\";\n }\n if (typeof value === \"object\") {\n const keys = Object.keys(value as object).sort();\n const pairs = keys.map(\n (k) =>\n Hasher._ensureAsciiString(k) +\n \":\" +\n Hasher._deepSortJson((value as Record<string, unknown>)[k]),\n );\n return \"{\" + pairs.join(\",\") + \"}\";\n }\n return Hasher._ensureAsciiString(String(value));\n }\n\n /** JSON.stringify + escape non-ASCII as \\uXXXX (Python ensure_ascii=True) */\n private static _ensureAsciiString(s: string): string {\n // JSON.stringify handles all control chars, backslash, quotes\n const jsJson = JSON.stringify(s); // → \"...\" with escaping\n // Additionally escape any non-ASCII (code >= 0x80) that JSON.stringify left through\n return jsJson.replace(/[\\u0080-]/g, (c) => {\n const code = c.charCodeAt(0);\n return \"\\\\u\" + code.toString(16).padStart(4, \"0\");\n });\n }\n}\n\n// ── Errors ────────────────────────────────────────────────────────────────\n\nexport class VerefyError extends Error {}\n\nexport class VerefyAPIError extends VerefyError {\n constructor(\n public readonly statusCode: number,\n public readonly detail: string,\n ) {\n super(`VEREEFY API ${statusCode}: ${detail}`);\n this.name = \"VerefyAPIError\";\n }\n}\n\nexport class VerefyConnectionError extends VerefyError {\n constructor(message: string) {\n super(message);\n this.name = \"VerefyConnectionError\";\n }\n}\n\nexport class VerefyValidationError extends VerefyError {\n constructor(message: string) {\n super(message);\n this.name = \"VerefyValidationError\";\n }\n}\n\n// ── Verefy-Client ─────────────────────────────────────────────────────────\n\nexport class Verefy {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n\n constructor(options: VerefyOptions) {\n if (!options.apiKey.startsWith(\"vfy_\")) {\n throw new VerefyValidationError(\"API-Schlüssel muss mit 'vfy_' beginnen.\");\n }\n this.apiKey = options.apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_API_URL).replace(/\\/$/, \"\");\n this.timeout = options.timeout ?? 15_000;\n this.maxRetries = options.maxRetries ?? 3;\n }\n\n private async _request(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const url = this.baseUrl + path;\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"X-SDK-Version\": SDK_VERSION,\n };\n let lastErr: Error | undefined;\n for (let attempt = 0; attempt < this.maxRetries; attempt++) {\n try {\n const signal = AbortSignal.timeout(this.timeout);\n const resp = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal,\n });\n if (resp.status < 500) return resp;\n const text = await resp.text();\n lastErr = new VerefyAPIError(resp.status, text);\n if (attempt < this.maxRetries - 1) {\n await new Promise((r) => setTimeout(r, 2 ** attempt * 1000));\n }\n } catch (e) {\n lastErr = new VerefyConnectionError(String(e));\n if (attempt < this.maxRetries - 1) {\n await new Promise((r) => setTimeout(r, 2 ** attempt * 1000));\n }\n }\n }\n throw lastErr!;\n }\n\n async logInteraction(opts: LogInteractionOptions): Promise<ComplianceEvidence> {\n let inputHash: string;\n if (opts.inputContent !== undefined) {\n inputHash = Hasher.canonicalHash(opts.inputContent);\n } else if (opts.inputHash !== undefined) {\n inputHash = opts.inputHash;\n } else {\n throw new VerefyValidationError(\"inputContent oder inputHash angeben.\");\n }\n\n let outputHash: string;\n if (opts.outputContent !== undefined) {\n outputHash = Hasher.canonicalHash(opts.outputContent);\n } else if (opts.outputHash !== undefined) {\n outputHash = opts.outputHash;\n } else {\n throw new VerefyValidationError(\"outputContent oder outputHash angeben.\");\n }\n\n const payload: Record<string, unknown> = {\n provider: opts.provider,\n model_name: opts.modelName,\n purpose: opts.purpose,\n sector: opts.sector,\n input_hash: inputHash,\n output_hash: outputHash,\n };\n if (opts.modelVersion !== undefined) payload.model_version = opts.modelVersion;\n if (opts.interactionType !== undefined) payload.interaction_type = opts.interactionType;\n if (opts.customerFacing !== undefined) payload.customer_facing = opts.customerFacing;\n if (opts.automationLevel !== undefined) payload.automation_level = opts.automationLevel;\n if (opts.decisionImpact !== undefined) payload.decision_impact = opts.decisionImpact;\n if (opts.userRole !== undefined) payload.user_role = opts.userRole;\n if (opts.jurisdiction !== undefined) payload.jurisdiction = opts.jurisdiction;\n if (opts.externalRef !== undefined) payload.external_ref = opts.externalRef;\n if (opts.responseTimeMs !== undefined) payload.response_time_ms = opts.responseTimeMs;\n if (opts.extraData !== undefined) payload.extra_data = opts.extraData;\n\n const resp = await this._request(\"POST\", \"/v1/interactions\", payload);\n if (resp.status === 201) {\n const data = await resp.json() as Record<string, unknown>;\n return this._mapEvidence(data);\n }\n const err = await resp.json().catch(() => ({ detail: resp.statusText })) as Record<string, unknown>;\n throw new VerefyAPIError(resp.status, String(err.detail ?? resp.statusText));\n }\n\n async getInteraction(interactionId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/interactions/${interactionId}`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async verifyChain(interactionId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/audit/${interactionId}/chain`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async requestReport(options: {\n reportType?: string;\n dateFrom?: string;\n dateTo?: string;\n interactionIds?: string[];\n format?: string;\n } = {}): Promise<Record<string, unknown>> {\n const payload: Record<string, unknown> = {\n report_type: options.reportType ?? \"eu_ai_act\",\n format: options.format ?? \"json\",\n };\n if (options.dateFrom) payload.date_from = options.dateFrom;\n if (options.dateTo) payload.date_to = options.dateTo;\n if (options.interactionIds) payload.interaction_ids = options.interactionIds;\n\n const resp = await this._request(\"POST\", \"/v1/reports\", payload);\n if (resp.status === 200 || resp.status === 202) {\n return resp.json() as Promise<Record<string, unknown>>;\n }\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n async getReport(reportId: string): Promise<Record<string, unknown>> {\n const resp = await this._request(\"GET\", `/v1/reports/${reportId}`);\n if (resp.status === 200) return resp.json() as Promise<Record<string, unknown>>;\n throw new VerefyAPIError(resp.status, await resp.text());\n }\n\n private _mapEvidence(data: Record<string, unknown>): ComplianceEvidence {\n return {\n interactionId: String(data.interaction_id),\n riskClass: String(data.risk_class),\n articleMatches: (data.article_matches as string[]) ?? [],\n requiredActions: (data.required_actions as string[]) ?? [],\n requiredDisclosures: (data.required_disclosures as string[]) ?? [],\n regulatoryFlags: (data.regulatory_flags as string[]) ?? [],\n confidence: String(data.confidence),\n complianceScore: Number(data.compliance_score),\n auditEntryId: String(data.audit_entry_id),\n chainTipHash: String(data.chain_tip_hash),\n timestamp: String(data.timestamp),\n classificationVersion: String(data.classification_version),\n policyVersion: String(data.policy_version),\n };\n }\n}\n"],"mappings":";AAeA,SAAS,kBAAkB;AAEpB,IAAM,cAAc;AAC3B,IAAM,kBAAkB;AAuDjB,IAAM,SAAN,MAAM,QAAO;AAAA,EAClB,OAAO,cAAc,SAA0B;AAC7C,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC7C,aAAO,WAAW,QAAQ,EAAE,OAAO,MAAM,EAAE,OAAO,KAAK;AAAA,IACzD;AACA,QAAI,OAAO,SAAS,OAAO,GAAG;AAC5B,aAAO,WAAW,QAAQ,EAAE,OAAO,OAAO,EAAE,OAAO,KAAK;AAAA,IAC1D;AACA,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO,WAAW,QAAQ,EACvB,OAAO,QAAQ,KAAK,GAAG,MAAM,EAC7B,OAAO,KAAK;AAAA,IACjB;AACA,QAAI,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;AACzD,YAAM,YAAY,KAAK;AAAA,QACrB;AAAA,QACA,OAAO,KAAK,OAAiB,EAAE,KAAK;AAAA;AAAA,MAEtC;AAEA,YAAM,IAAI,QAAO,cAAc,OAAO;AACtC,aAAO,WAAW,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,KAAK;AAAA,IAC5D;AACA,WAAO,WAAW,QAAQ,EACvB,OAAO,OAAO,OAAO,GAAG,MAAM,EAC9B,OAAO,KAAK;AAAA,EACjB;AAAA,EAEA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compliance-Infrastruktur",
|
|
5
|
+
"keywords": ["EU AI Act", "compliance", "KI", "audit", "vereefy"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "VEREEFY <hello@vereefy.ai>",
|
|
8
|
+
"homepage": "https://vereefy.ai",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/vereefy-ai/vereefy-node"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
33
|
+
"typecheck": "tsc --noEmit"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/jest": "^29.5.14",
|
|
37
|
+
"@types/node": "^22.10.1",
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"ts-jest": "^29.2.5",
|
|
40
|
+
"tsup": "^8.3.5",
|
|
41
|
+
"typescript": "^5.7.2"
|
|
42
|
+
}
|
|
43
|
+
}
|