@certivu/sdk 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 +180 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1385 -0
- package/dist/methods/audit.d.ts +3 -0
- package/dist/methods/audit.d.ts.map +1 -0
- package/dist/methods/sign.d.ts +3 -0
- package/dist/methods/sign.d.ts.map +1 -0
- package/dist/methods/verify.d.ts +5 -0
- package/dist/methods/verify.d.ts.map +1 -0
- package/dist/types/options.d.ts +40 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/responses.d.ts +3 -0
- package/dist/types/responses.d.ts.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# @certivu/sdk
|
|
2
|
+
|
|
3
|
+
Official SDK for [Certivu](https://certivu.ai) — quantum-resistant provenance for AI-generated content.
|
|
4
|
+
|
|
5
|
+
Certivu signs AI-generated content with ML-DSA (NIST FIPS 204) cryptographic signatures and invisible frequency-domain watermarks. Anyone can verify signed content without an account.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @certivu/sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add @certivu/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js 18+ (uses built-in `fetch`, `Blob`, `crypto`).
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { CertivuClient } from '@certivu/sdk'
|
|
21
|
+
|
|
22
|
+
const certivu = new CertivuClient({
|
|
23
|
+
apiKey: 'ctv_key_abc123',
|
|
24
|
+
generatorId: 'gen_xyz',
|
|
25
|
+
privateKey: '<base64-encoded ML-DSA private key>',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Sign AI-generated content
|
|
29
|
+
const { token } = await certivu.sign({
|
|
30
|
+
content: imageBuffer, // Buffer, Uint8Array, or string
|
|
31
|
+
model: 'stable-diffusion-xl',
|
|
32
|
+
})
|
|
33
|
+
// Embed `token` in XMP metadata or pass alongside content for verification
|
|
34
|
+
|
|
35
|
+
// Verify — token optional, extracted automatically from XMP or watermark
|
|
36
|
+
const result = await certivu.verify({ content: imageBuffer })
|
|
37
|
+
|
|
38
|
+
if (result.authentic && result.confidence === 'high') {
|
|
39
|
+
console.log('Verified:', result.provenance?.org, result.provenance?.signed_at)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Get your API key and generator credentials at [dashboard.certivu.ai](https://dashboard.certivu.ai).
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## API Reference
|
|
48
|
+
|
|
49
|
+
### `new CertivuClient(config)`
|
|
50
|
+
|
|
51
|
+
| Field | Type | Required | Description |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| `apiKey` | `string` | Yes | API key from the dashboard (`ctv_key_...`) |
|
|
54
|
+
| `generatorId` | `string` | No | Default generator ID for sign calls |
|
|
55
|
+
| `privateKey` | `string` | No | Base64-encoded ML-DSA private key for sign calls |
|
|
56
|
+
| `baseUrl` | `string` | No | Override API base URL (default: `https://api.certivu.ai`) |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### `certivu.sign(input)`
|
|
61
|
+
|
|
62
|
+
Signs AI-generated content and stores a provenance record.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const { token, record_id } = await certivu.sign({
|
|
66
|
+
content: imageBuffer, // Uint8Array | string
|
|
67
|
+
model: 'stable-diffusion-xl', // model identifier
|
|
68
|
+
generatorId: 'gen_xyz', // overrides config.generatorId
|
|
69
|
+
privateKey: '...', // overrides config.privateKey
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Returns `{ token: string, record_id: string }`. Embed the `token` in XMP metadata or store it alongside the content.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### `certivu.verify(input)`
|
|
78
|
+
|
|
79
|
+
Verifies content authenticity. Token is optional — Certivu extracts it automatically from XMP metadata or the frequency-domain watermark.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const result = await certivu.verify({
|
|
83
|
+
content: imageBuffer, // Uint8Array | string
|
|
84
|
+
token: 'ctv_...', // optional — skip to let Certivu extract it
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Response shape:**
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
{
|
|
92
|
+
authentic: boolean,
|
|
93
|
+
tampered: boolean,
|
|
94
|
+
confidence: 'high' | 'medium' | 'low' | 'none',
|
|
95
|
+
token_source: 'provided' | 'xmp' | 'watermark',
|
|
96
|
+
signals: {
|
|
97
|
+
watermark_found: boolean,
|
|
98
|
+
record_found: boolean,
|
|
99
|
+
signature_valid: boolean,
|
|
100
|
+
},
|
|
101
|
+
provenance: {
|
|
102
|
+
org: string,
|
|
103
|
+
model: string,
|
|
104
|
+
signed_at: string,
|
|
105
|
+
} | null,
|
|
106
|
+
reason?: string, // present when authentic: false
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Confidence levels:**
|
|
111
|
+
|
|
112
|
+
| Confidence | Meaning |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `high` | Watermark + record + signature all valid |
|
|
115
|
+
| `medium` | Record + signature valid, no watermark (e.g. re-uploaded without it) |
|
|
116
|
+
| `low` | Partial signals — something is off |
|
|
117
|
+
| `none` | No provenance data found — no claim either way |
|
|
118
|
+
|
|
119
|
+
> Absence of provenance does **not** imply human origin. Certivu verifies declared provenance; it does not detect all AI content.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### `certivu.verifyBatch(items)`
|
|
124
|
+
|
|
125
|
+
Verify up to 50 items in a single request.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const { results } = await certivu.verifyBatch([
|
|
129
|
+
{ content: image1, token: token1 },
|
|
130
|
+
{ content: image2 }, // token optional per item
|
|
131
|
+
])
|
|
132
|
+
|
|
133
|
+
for (const result of results) {
|
|
134
|
+
console.log(result.authentic, result.confidence)
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### `certivu.getAuditLog(options?)`
|
|
141
|
+
|
|
142
|
+
Fetch a paginated audit log of sign, verify, and key events for your org.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const { events, total, page, limit } = await certivu.getAuditLog({
|
|
146
|
+
page: 1,
|
|
147
|
+
limit: 50,
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Error handling
|
|
154
|
+
|
|
155
|
+
All methods throw an `Error` with a descriptive message on API or network failure.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
try {
|
|
159
|
+
await certivu.sign({ content, model: 'sdxl' })
|
|
160
|
+
} catch (e) {
|
|
161
|
+
if (e instanceof Error) {
|
|
162
|
+
console.error(e.message) // e.g. "signature_limit_reached"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Common error codes:
|
|
168
|
+
|
|
169
|
+
| Code | Meaning |
|
|
170
|
+
|---|---|
|
|
171
|
+
| `signature_limit_reached` | Free plan 500/mo limit hit — upgrade at certivu.ai/pricing |
|
|
172
|
+
| `generator_not_found` | `generatorId` doesn't exist or belongs to another org |
|
|
173
|
+
| `generator_revoked` | Generator has been revoked — all its signatures are invalid |
|
|
174
|
+
| `invalid_api_key` | API key is missing, malformed, or revoked |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Docs
|
|
179
|
+
|
|
180
|
+
Full documentation at [docs.certivu.ai](https://docs.certivu.ai).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { VerificationResult } from "@certivu/types";
|
|
2
|
+
import type { AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, SignInput, SignResponse, VerifyInput } from "./types/options";
|
|
3
|
+
export declare class CertivuClient {
|
|
4
|
+
private readonly apiKey;
|
|
5
|
+
private readonly baseUrl;
|
|
6
|
+
private readonly generatorId;
|
|
7
|
+
private readonly privateKey;
|
|
8
|
+
constructor(config: ClientConfig);
|
|
9
|
+
sign(input: SignInput): Promise<SignResponse>;
|
|
10
|
+
verify(input: VerifyInput): Promise<VerificationResult>;
|
|
11
|
+
verifyBatch(items: BatchItem[]): Promise<BatchVerifyResponse>;
|
|
12
|
+
getAuditLog(options?: AuditOptions): Promise<AuditPage>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIzD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAEpC,MAAM,EAAE,YAAY;IAO1B,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAU7C,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIvD,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI7D,WAAW,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;CAG9D"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CertivuClient } from "./client";
|
|
2
|
+
export type { AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, SignInput, SignResponse, VerifyInput, } from "./types/options";
|
|
3
|
+
export type { AuditEvent, VerificationResult } from "@certivu/types";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|