@certivu/sdk 1.0.0 → 1.4.1
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 +86 -41
- package/dist/client.d.ts +9 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -1275
- package/dist/methods/sign.d.ts +1 -1
- package/dist/methods/sign.d.ts.map +1 -1
- package/dist/types/options.d.ts +65 -3
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/responses.d.ts +1 -1
- package/dist/types/responses.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -22,15 +22,14 @@ import { CertivuClient } from '@certivu/sdk'
|
|
|
22
22
|
const certivu = new CertivuClient({
|
|
23
23
|
apiKey: 'ctv_key_abc123',
|
|
24
24
|
generatorId: 'gen_xyz',
|
|
25
|
-
privateKey: '<base64-encoded ML-DSA private key>',
|
|
26
25
|
})
|
|
27
26
|
|
|
28
|
-
// Sign AI-generated content
|
|
29
|
-
const { token } = await certivu.sign({
|
|
30
|
-
content: imageBuffer, // Buffer
|
|
27
|
+
// Sign AI-generated content — returns the watermarked image + token
|
|
28
|
+
const { token, record_id, watermarkedContent } = await certivu.sign({
|
|
29
|
+
content: imageBuffer, // Buffer or Uint8Array
|
|
31
30
|
model: 'stable-diffusion-xl',
|
|
32
31
|
})
|
|
33
|
-
//
|
|
32
|
+
// watermarkedContent is a Uint8Array — store and serve this, not the original
|
|
34
33
|
|
|
35
34
|
// Verify — token optional, extracted automatically from XMP or watermark
|
|
36
35
|
const result = await certivu.verify({ content: imageBuffer })
|
|
@@ -52,36 +51,33 @@ Get your API key and generator credentials at [dashboard.certivu.ai](https://das
|
|
|
52
51
|
|---|---|---|---|
|
|
53
52
|
| `apiKey` | `string` | Yes | API key from the dashboard (`ctv_key_...`) |
|
|
54
53
|
| `generatorId` | `string` | No | Default generator ID for sign calls |
|
|
55
|
-
| `privateKey` | `string` | No | Base64-encoded ML-DSA private key for sign calls |
|
|
56
54
|
| `baseUrl` | `string` | No | Override API base URL (default: `https://api.certivu.ai`) |
|
|
57
55
|
|
|
58
56
|
---
|
|
59
57
|
|
|
60
58
|
### `certivu.sign(input)`
|
|
61
59
|
|
|
62
|
-
Signs AI-generated content and
|
|
60
|
+
Signs AI-generated content server-side — watermarking, hashing, and ML-DSA signing all happen in the API. Returns the signed, watermarked image.
|
|
63
61
|
|
|
64
62
|
```typescript
|
|
65
|
-
const { token, record_id } = await certivu.sign({
|
|
66
|
-
content: imageBuffer, // Uint8Array |
|
|
63
|
+
const { token, record_id, watermarkedContent } = await certivu.sign({
|
|
64
|
+
content: imageBuffer, // Uint8Array | Buffer
|
|
67
65
|
model: 'stable-diffusion-xl', // model identifier
|
|
68
66
|
generatorId: 'gen_xyz', // overrides config.generatorId
|
|
69
|
-
privateKey: '...', // overrides config.privateKey
|
|
70
67
|
})
|
|
68
|
+
// watermarkedContent — Uint8Array with ctv_ token in XMP + DCT watermark embedded
|
|
71
69
|
```
|
|
72
70
|
|
|
73
|
-
Returns `{ token: string, record_id: string }`. Embed the `token` in XMP metadata or store it alongside the content.
|
|
74
|
-
|
|
75
71
|
---
|
|
76
72
|
|
|
77
73
|
### `certivu.verify(input)`
|
|
78
74
|
|
|
79
|
-
Verifies content authenticity. Token is optional —
|
|
75
|
+
Verifies content authenticity. Token is optional — extracted automatically from XMP metadata or the frequency-domain watermark.
|
|
80
76
|
|
|
81
77
|
```typescript
|
|
82
78
|
const result = await certivu.verify({
|
|
83
|
-
content: imageBuffer, // Uint8Array |
|
|
84
|
-
token: 'ctv_...', // optional
|
|
79
|
+
content: imageBuffer, // Uint8Array | Buffer
|
|
80
|
+
token: 'ctv_...', // optional
|
|
85
81
|
})
|
|
86
82
|
```
|
|
87
83
|
|
|
@@ -103,20 +99,18 @@ const result = await certivu.verify({
|
|
|
103
99
|
model: string,
|
|
104
100
|
signed_at: string,
|
|
105
101
|
} | null,
|
|
106
|
-
reason?: string,
|
|
102
|
+
reason?: string,
|
|
107
103
|
}
|
|
108
104
|
```
|
|
109
105
|
|
|
110
|
-
**Confidence levels:**
|
|
111
|
-
|
|
112
106
|
| Confidence | Meaning |
|
|
113
107
|
|---|---|
|
|
114
108
|
| `high` | Watermark + record + signature all valid |
|
|
115
|
-
| `medium` | Record + signature valid, no watermark
|
|
116
|
-
| `low` | Partial signals
|
|
117
|
-
| `none` | No provenance
|
|
109
|
+
| `medium` | Record + signature valid, no watermark |
|
|
110
|
+
| `low` | Partial signals |
|
|
111
|
+
| `none` | No provenance found — no claim either way |
|
|
118
112
|
|
|
119
|
-
> Absence of provenance does **not** imply human origin.
|
|
113
|
+
> Absence of provenance does **not** imply human origin.
|
|
120
114
|
|
|
121
115
|
---
|
|
122
116
|
|
|
@@ -127,51 +121,102 @@ Verify up to 50 items in a single request.
|
|
|
127
121
|
```typescript
|
|
128
122
|
const { results } = await certivu.verifyBatch([
|
|
129
123
|
{ content: image1, token: token1 },
|
|
130
|
-
{ content: image2 },
|
|
124
|
+
{ content: image2 },
|
|
131
125
|
])
|
|
132
|
-
|
|
133
|
-
for (const result of results) {
|
|
134
|
-
console.log(result.authentic, result.confidence)
|
|
135
|
-
}
|
|
136
126
|
```
|
|
137
127
|
|
|
138
128
|
---
|
|
139
129
|
|
|
140
130
|
### `certivu.getAuditLog(options?)`
|
|
141
131
|
|
|
142
|
-
|
|
132
|
+
```typescript
|
|
133
|
+
const { events, total } = await certivu.getAuditLog({ page: 1, limit: 50 })
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### `certivu.getTokenStatus(token)`
|
|
139
|
+
|
|
140
|
+
Lightweight CDN-cacheable status lookup — no image upload needed.
|
|
143
141
|
|
|
144
142
|
```typescript
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
const status = await certivu.getTokenStatus('ctv_7f3kx9mq2...')
|
|
144
|
+
// { generator_status: 'active' | 'revoked', model, signed_at, org_id }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `certivu.getAnalyticsOverview(days?)`
|
|
150
|
+
|
|
151
|
+
Verification analytics summary. Plan-gated: Free = 7-day, Starter = 30-day, Growth+ = 90-day.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const overview = await certivu.getAnalyticsOverview(30)
|
|
155
|
+
// { total_verifications, tamper_count, authentic_count, daily_trend, top_records, period_days }
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `certivu.getRecordAnalytics(recordId)`
|
|
161
|
+
|
|
162
|
+
Per-record verification drill-down. Growth+ required.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const record = await certivu.getRecordAnalytics('rec-uuid')
|
|
166
|
+
// { confidence_breakdown: { high, medium, low, none }, recent_events, ... }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### `certivu.listWebhooks()`
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const { endpoints, webhooks_enabled } = await certivu.listWebhooks()
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### `certivu.createWebhook(input)`
|
|
180
|
+
|
|
181
|
+
Register a new HTTPS endpoint. Growth+ required. The `secret` in the response is shown **once**.
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const endpoint = await certivu.createWebhook({
|
|
185
|
+
url: 'https://your-app.example.com/certivu',
|
|
186
|
+
events: ['record.created', 'verify.tamper_detected', 'quota.warning'],
|
|
148
187
|
})
|
|
149
188
|
```
|
|
150
189
|
|
|
151
190
|
---
|
|
152
191
|
|
|
153
|
-
|
|
192
|
+
### `certivu.deleteWebhook(webhookId)`
|
|
154
193
|
|
|
155
|
-
|
|
194
|
+
```typescript
|
|
195
|
+
await certivu.deleteWebhook('webhook-uuid')
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Error handling
|
|
156
201
|
|
|
157
202
|
```typescript
|
|
158
203
|
try {
|
|
159
204
|
await certivu.sign({ content, model: 'sdxl' })
|
|
160
205
|
} catch (e) {
|
|
161
206
|
if (e instanceof Error) {
|
|
162
|
-
console.error(e.message)
|
|
207
|
+
console.error(e.message)
|
|
163
208
|
}
|
|
164
209
|
}
|
|
165
210
|
```
|
|
166
211
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
| Code | Meaning |
|
|
212
|
+
| Status | Meaning |
|
|
170
213
|
|---|---|
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
214
|
+
| `400` | Validation error |
|
|
215
|
+
| `401` | Bad API key |
|
|
216
|
+
| `402` | Quota exhausted (free tier) |
|
|
217
|
+
| `403` | Generator doesn't belong to your org |
|
|
218
|
+
| `404` | Generator not found or revoked |
|
|
219
|
+
| `413` | Upload exceeds 20 MB limit |
|
|
175
220
|
|
|
176
221
|
---
|
|
177
222
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import type { VerificationResult } from "@certivu/types";
|
|
2
|
-
import type { AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, SignInput, SignResponse, VerifyInput } from "./types/options";
|
|
2
|
+
import type { AnalyticsOverview, AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, CreateWebhookInput, RecordAnalytics, SignInput, SignResponse, TokenStatus, VerifyInput, WebhookEndpoint, WebhookListResponse } from "./types/options";
|
|
3
3
|
export declare class CertivuClient {
|
|
4
4
|
private readonly apiKey;
|
|
5
5
|
private readonly baseUrl;
|
|
6
6
|
private readonly generatorId;
|
|
7
|
-
private readonly privateKey;
|
|
8
7
|
constructor(config: ClientConfig);
|
|
9
8
|
sign(input: SignInput): Promise<SignResponse>;
|
|
10
9
|
verify(input: VerifyInput): Promise<VerificationResult>;
|
|
11
10
|
verifyBatch(items: BatchItem[]): Promise<BatchVerifyResponse>;
|
|
12
11
|
getAuditLog(options?: AuditOptions): Promise<AuditPage>;
|
|
12
|
+
getTokenStatus(token: string): Promise<TokenStatus>;
|
|
13
|
+
getAnalyticsOverview(days?: number): Promise<AnalyticsOverview>;
|
|
14
|
+
getRecordAnalytics(recordId: string): Promise<RecordAnalytics>;
|
|
15
|
+
listWebhooks(): Promise<WebhookListResponse>;
|
|
16
|
+
createWebhook(input: CreateWebhookInput): Promise<WebhookEndpoint & {
|
|
17
|
+
secret: string;
|
|
18
|
+
}>;
|
|
19
|
+
deleteWebhook(webhookId: string): Promise<void>;
|
|
13
20
|
}
|
|
14
21
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,EACpB,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;gBAErC,MAAM,EAAE,YAAY;IAM1B,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAM7C,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;IAIvD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IASnD,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAW/D,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAW9D,YAAY,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAW5C,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAavF,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUtD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { CertivuClient } from "./client";
|
|
2
|
-
export type { AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, SignInput, SignResponse, VerifyInput, } from "./types/options";
|
|
2
|
+
export type { AuditOptions, AuditPage, BatchItem, BatchVerifyResponse, ClientConfig, SignInput, SignResponse, TokenStatus, VerifyInput, } from "./types/options";
|
|
3
3
|
export type { AuditEvent, VerificationResult } from "@certivu/types";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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,EACX,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|