@watchtowerobservability/activity 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +55 -2
- package/dist/ed25519ph.d.ts +2 -0
- package/dist/ed25519ph.test.d.ts +1 -0
- package/dist/index.cjs +931 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.cts +213 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.js +908 -0
- package/dist/index.js.map +7 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/model3.d.ts +30 -0
- package/dist/model3.test.d.ts +1 -0
- package/dist/model4.d.ts +74 -0
- package/dist/model4.test.d.ts +1 -0
- package/dist/types.d.ts +457 -0
- package/dist/verify.d.ts +104 -0
- package/dist/verify.test.d.ts +1 -0
- package/package.json +56 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/** `id` is required except for `type: "anonymous"` (stored as `anonymous`). */
|
|
2
|
+
export interface ActorIn {
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
/** "user" | "api_key" | "service" | "system" | "support" | "anonymous" or your own. */
|
|
6
|
+
type?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
/** Up to 50 keys, 40-character keys, depth 5 (every metadata object shares the 16 KB budget). */
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
/** An administrator or other privileged actor (PCI DSS 10.2.1.2); query `privileged:true`. */
|
|
12
|
+
privileged?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** One hop of a delegation chain: an AI agent, service or support tool acting for the actor. */
|
|
15
|
+
export interface ViaHop {
|
|
16
|
+
actor: {
|
|
17
|
+
id: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
};
|
|
21
|
+
/** The credential the hop used (`type`, `id`, never the secret). */
|
|
22
|
+
credential?: {
|
|
23
|
+
type: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
};
|
|
26
|
+
/** For AI agents: the model, e.g. `claude-opus-4`. */
|
|
27
|
+
model?: string;
|
|
28
|
+
/** The tool or function the agent called. */
|
|
29
|
+
tool?: string;
|
|
30
|
+
/** Who approved the hop's action (a human-in-the-loop). */
|
|
31
|
+
approved_by?: string;
|
|
32
|
+
/** Optional Ed25519 signature of the hop (same shape as the event `signature`). */
|
|
33
|
+
sig?: {
|
|
34
|
+
kid: string;
|
|
35
|
+
sig: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface TargetIn {
|
|
39
|
+
type: string;
|
|
40
|
+
id: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export interface Change {
|
|
46
|
+
field: string;
|
|
47
|
+
old?: unknown;
|
|
48
|
+
new?: unknown;
|
|
49
|
+
}
|
|
50
|
+
export type AuthMethod = 'password' | 'sso' | 'oauth' | 'passkey' | 'magic_link' | 'otp' | 'api_key' | 'certificate' | 'other';
|
|
51
|
+
export interface Context {
|
|
52
|
+
ip?: string;
|
|
53
|
+
user_agent?: string;
|
|
54
|
+
request_id?: string;
|
|
55
|
+
session_id?: string;
|
|
56
|
+
device_id?: string;
|
|
57
|
+
/** How the actor authenticated. */
|
|
58
|
+
auth_method?: AuthMethod;
|
|
59
|
+
/** A second factor was used. */
|
|
60
|
+
mfa?: boolean;
|
|
61
|
+
/** Your clock source, e.g. `ntp:pool.ntp.org` (with clock-skew checks). */
|
|
62
|
+
time_source?: string;
|
|
63
|
+
}
|
|
64
|
+
export type Outcome = 'success' | 'failure' | 'denied';
|
|
65
|
+
export type Severity = 'info' | 'notice' | 'warning' | 'critical';
|
|
66
|
+
export type Operation = 'create' | 'read' | 'update' | 'delete' | 'access' | 'auth';
|
|
67
|
+
export interface EventIn {
|
|
68
|
+
/** Optional: the server derives SHA-256 of the canonical event when absent; the SDK sends a UUID. */
|
|
69
|
+
idempotency_key?: string;
|
|
70
|
+
account_id: string;
|
|
71
|
+
action: string;
|
|
72
|
+
occurred_at?: string;
|
|
73
|
+
/** Schema version of the action. */
|
|
74
|
+
version?: number;
|
|
75
|
+
actor: ActorIn;
|
|
76
|
+
/** The impersonated user when `actor` is staff (shown as "via support"). */
|
|
77
|
+
on_behalf_of?: {
|
|
78
|
+
id: string;
|
|
79
|
+
name?: string;
|
|
80
|
+
};
|
|
81
|
+
/** `fingerprint` is a SHA-256 of the key, never the key itself. */
|
|
82
|
+
credential?: {
|
|
83
|
+
type: string;
|
|
84
|
+
id?: string;
|
|
85
|
+
fingerprint?: string;
|
|
86
|
+
};
|
|
87
|
+
target?: TargetIn;
|
|
88
|
+
/** Up to 10. */
|
|
89
|
+
targets?: TargetIn[];
|
|
90
|
+
/** Up to 50. */
|
|
91
|
+
changes?: Change[];
|
|
92
|
+
context?: Context;
|
|
93
|
+
outcome?: Outcome;
|
|
94
|
+
severity?: Severity;
|
|
95
|
+
operation?: Operation;
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
/** Alias of context.ip. */
|
|
98
|
+
ip?: string;
|
|
99
|
+
trace_id?: string;
|
|
100
|
+
span_id?: string;
|
|
101
|
+
/** Delegation chain, up to 5 hops: `via[0]` acted for `actor`, the last hop called you. */
|
|
102
|
+
via?: ViaHop[];
|
|
103
|
+
/** Count repeats of `key` within `window_secs` (default 60) instead of storing each one. */
|
|
104
|
+
coalesce?: {
|
|
105
|
+
key: string;
|
|
106
|
+
window_secs?: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export interface ActivityEvent extends Omit<EventIn, 'idempotency_key' | 'occurred_at' | 'context'> {
|
|
110
|
+
id: string;
|
|
111
|
+
occurred_at: string;
|
|
112
|
+
received_at: string;
|
|
113
|
+
context?: Context & {
|
|
114
|
+
country?: string;
|
|
115
|
+
region?: string;
|
|
116
|
+
asn?: number;
|
|
117
|
+
};
|
|
118
|
+
schema_version?: number;
|
|
119
|
+
/** The schema's event code plus `S`/`F`/`D` by outcome. */
|
|
120
|
+
code?: string;
|
|
121
|
+
observed_skew_ms?: number;
|
|
122
|
+
skew_flagged?: boolean;
|
|
123
|
+
/** A coalescing summary: `{of, key, count, first_at, last_at}`. */
|
|
124
|
+
coalesced?: {
|
|
125
|
+
of: string;
|
|
126
|
+
key: string;
|
|
127
|
+
count: number;
|
|
128
|
+
first_at: string;
|
|
129
|
+
last_at: string;
|
|
130
|
+
};
|
|
131
|
+
/** Lookup table values of the actor and targets. */
|
|
132
|
+
labels?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
/** A signed write receipt (`receipts: true`): where the event sits in its account's chain and Merkle log. */
|
|
135
|
+
export interface Receipt {
|
|
136
|
+
index: number;
|
|
137
|
+
id: string;
|
|
138
|
+
account_id: string;
|
|
139
|
+
seq: number;
|
|
140
|
+
leaf_index: number;
|
|
141
|
+
chain_hash: string;
|
|
142
|
+
received_at: string;
|
|
143
|
+
/** A signed tree head with at least `leaf_index + 1` leaves exists by then. */
|
|
144
|
+
sth_promise_by: string;
|
|
145
|
+
duplicate?: boolean;
|
|
146
|
+
kid: string;
|
|
147
|
+
/** The signed JSON array `["wt.activity.receipt.v1", project, account, seq, chain_hash, leaf_index, received_unix, promise_unix]`. */
|
|
148
|
+
message: string;
|
|
149
|
+
/** Base64url Ed25519 over `message`. */
|
|
150
|
+
sig: string;
|
|
151
|
+
}
|
|
152
|
+
export interface Batch {
|
|
153
|
+
id: string;
|
|
154
|
+
state: 'pending' | 'done' | 'failed';
|
|
155
|
+
created_at: string;
|
|
156
|
+
finished_at: string | null;
|
|
157
|
+
result: RecordResult | null;
|
|
158
|
+
error: string | null;
|
|
159
|
+
}
|
|
160
|
+
export interface Problem {
|
|
161
|
+
type?: string;
|
|
162
|
+
title?: string;
|
|
163
|
+
status?: number;
|
|
164
|
+
detail?: string;
|
|
165
|
+
[k: string]: unknown;
|
|
166
|
+
}
|
|
167
|
+
export interface RecordResult {
|
|
168
|
+
accepted: number;
|
|
169
|
+
/** Only with `partial: true`. */
|
|
170
|
+
rejected?: {
|
|
171
|
+
index: number;
|
|
172
|
+
problem: Problem;
|
|
173
|
+
}[];
|
|
174
|
+
/** Schema `warn` mode, profile misses, clock skew. */
|
|
175
|
+
warnings?: {
|
|
176
|
+
index: number;
|
|
177
|
+
message: string;
|
|
178
|
+
}[];
|
|
179
|
+
/** With `receipts: true`. */
|
|
180
|
+
receipts?: Receipt[];
|
|
181
|
+
/** Events counted into a coalescing window. */
|
|
182
|
+
coalesced?: {
|
|
183
|
+
index: number;
|
|
184
|
+
key: string;
|
|
185
|
+
repeats: number;
|
|
186
|
+
}[];
|
|
187
|
+
/** With `async: true`: the queued batch per request of 100 (1000 with `partial`); poll `batch(id)`. */
|
|
188
|
+
batch_ids?: string[];
|
|
189
|
+
}
|
|
190
|
+
/** POST /v1/activity/events/validate: per event, the normalized stored form, warnings and detector hits; nothing is stored. */
|
|
191
|
+
export interface ValidateResult {
|
|
192
|
+
data: {
|
|
193
|
+
index: number;
|
|
194
|
+
ok: boolean;
|
|
195
|
+
/** Why the event would be refused. */
|
|
196
|
+
problem?: string;
|
|
197
|
+
/** The event as it would be stored (after defaults and redaction). */
|
|
198
|
+
event?: ActivityEvent;
|
|
199
|
+
warnings: string[];
|
|
200
|
+
/** The theme has no display template for the action. */
|
|
201
|
+
missing_template: boolean;
|
|
202
|
+
/** Values redaction would mask or drop: `{path, kind}`. */
|
|
203
|
+
pii: {
|
|
204
|
+
path: string;
|
|
205
|
+
kind: string;
|
|
206
|
+
}[];
|
|
207
|
+
}[];
|
|
208
|
+
}
|
|
209
|
+
export type Capability = 'read' | 'export' | 'verify' | 'manage_streams' | 'manage_tokens' | 'manage_alerts';
|
|
210
|
+
export interface ViewerSessionOptions {
|
|
211
|
+
accountId: string;
|
|
212
|
+
actorId?: string;
|
|
213
|
+
/** Seconds, 60 to 3600. */
|
|
214
|
+
expiresIn?: number;
|
|
215
|
+
/** Default ["read"]. */
|
|
216
|
+
capabilities?: Capability[];
|
|
217
|
+
/** BCP 47, e.g. "de" or "pt-BR". */
|
|
218
|
+
locale?: string;
|
|
219
|
+
/** IANA, e.g. "Europe/Berlin". */
|
|
220
|
+
timeZone?: string;
|
|
221
|
+
/** Show one object inside the account, e.g. a workspace. */
|
|
222
|
+
subScope?: {
|
|
223
|
+
targetType: string;
|
|
224
|
+
targetId: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export interface ViewerSession {
|
|
228
|
+
token: string;
|
|
229
|
+
url: string;
|
|
230
|
+
expiresAt: string;
|
|
231
|
+
jti?: string;
|
|
232
|
+
}
|
|
233
|
+
export interface ListFilters {
|
|
234
|
+
accountId?: string;
|
|
235
|
+
actorId?: string;
|
|
236
|
+
action?: string;
|
|
237
|
+
targetType?: string;
|
|
238
|
+
targetId?: string;
|
|
239
|
+
/** Search: free text and qualifiers such as `actor:ada action:team.* -outcome:success created:>=2026-01-01`. */
|
|
240
|
+
q?: string;
|
|
241
|
+
outcome?: Outcome;
|
|
242
|
+
severity?: Severity;
|
|
243
|
+
/** Default `desc` (newest first). */
|
|
244
|
+
order?: 'asc' | 'desc';
|
|
245
|
+
from?: string;
|
|
246
|
+
to?: string;
|
|
247
|
+
limit?: number;
|
|
248
|
+
/** `archive`: events restored from cold archives (`archives().restore`). */
|
|
249
|
+
source?: 'live' | 'archive';
|
|
250
|
+
/** RFC 3339: only events received after it. */
|
|
251
|
+
since?: string;
|
|
252
|
+
}
|
|
253
|
+
export interface AccountToken {
|
|
254
|
+
id: string;
|
|
255
|
+
name: string;
|
|
256
|
+
capabilities: Capability[];
|
|
257
|
+
created_at: string;
|
|
258
|
+
last_used_at?: string;
|
|
259
|
+
/** After this the token is refused (absent: never expires). */
|
|
260
|
+
expires_at?: string;
|
|
261
|
+
/** Source networks allowed to use the token (empty: any). */
|
|
262
|
+
allowed_cidrs: string[];
|
|
263
|
+
/** `wta_acct_...`, only in the create response; shown once. Revoked tokens leave the list. */
|
|
264
|
+
token?: string;
|
|
265
|
+
}
|
|
266
|
+
export interface AccountTokenIn {
|
|
267
|
+
name: string;
|
|
268
|
+
capabilities?: Capability[];
|
|
269
|
+
/** 1 to 366 days (default: never expires). */
|
|
270
|
+
expires_in_days?: number;
|
|
271
|
+
/** Up to 20 networks (`192.0.2.0/24`, `2001:db8::/32` or one address); default any. */
|
|
272
|
+
allowed_cidrs?: string[];
|
|
273
|
+
}
|
|
274
|
+
/** POST .../accounts/{account_id}/invite: emails a one-time link to the hosted page. */
|
|
275
|
+
export interface InviteIn {
|
|
276
|
+
email: string;
|
|
277
|
+
capabilities?: Capability[];
|
|
278
|
+
/** Seconds, 300 to 604800 (default 3 days). */
|
|
279
|
+
expires_in?: number;
|
|
280
|
+
locale?: string;
|
|
281
|
+
}
|
|
282
|
+
export interface Invite {
|
|
283
|
+
jti: string;
|
|
284
|
+
expires_at: string;
|
|
285
|
+
queued: boolean;
|
|
286
|
+
}
|
|
287
|
+
export type StreamKind = 's3' | 'gcs' | 'azure_blob' | 'webhook' | 'https' | 'syslog' | 'kafka' | 'datadog' | 'splunk_hec' | 'sentinel' | 'elastic' | 'event_hubs' | 'snowflake' | 'sumo' | 'panther' | 'crowdstrike' | 'google_secops' | 'eventbridge' | 'coralogix';
|
|
288
|
+
export interface StreamIn {
|
|
289
|
+
/** Omit for the SaaS's own stream of every account. */
|
|
290
|
+
account_id?: string | null;
|
|
291
|
+
kind: StreamKind;
|
|
292
|
+
/** Per kind, e.g. splunk_hec `{url, index?, sourcetype?}`, s3 `{bucket, region?, endpoint?, prefix?}`, kafka `{brokers: [..], topic}`. */
|
|
293
|
+
config: Record<string, unknown>;
|
|
294
|
+
/** Write-only, never returned, e.g. splunk_hec `{token}`, s3 `{access_key_id, secret_access_key}`. Webhooks take none. */
|
|
295
|
+
credentials?: Record<string, string>;
|
|
296
|
+
format?: 'json' | 'ocsf';
|
|
297
|
+
/** One address that gets an email when the stream breaks (at most daily). */
|
|
298
|
+
notify_email?: string | null;
|
|
299
|
+
}
|
|
300
|
+
/** PATCH: `notify_email: ""` clears it. */
|
|
301
|
+
export type StreamPatch = Partial<Pick<StreamIn, 'config' | 'credentials' | 'format' | 'notify_email'>> & {
|
|
302
|
+
state?: 'active' | 'paused';
|
|
303
|
+
};
|
|
304
|
+
export interface Stream {
|
|
305
|
+
id: string;
|
|
306
|
+
account_id: string | null;
|
|
307
|
+
kind: StreamKind;
|
|
308
|
+
config: Record<string, unknown>;
|
|
309
|
+
format: 'json' | 'ocsf';
|
|
310
|
+
state: 'active' | 'paused' | 'error' | 'invalid';
|
|
311
|
+
has_credentials: boolean;
|
|
312
|
+
last_error: string | null;
|
|
313
|
+
last_delivered_at: string | null;
|
|
314
|
+
/** `received_at` of the last delivered event. */
|
|
315
|
+
cursor: string;
|
|
316
|
+
test_pending: boolean;
|
|
317
|
+
last_test: {
|
|
318
|
+
at: string;
|
|
319
|
+
ok: boolean;
|
|
320
|
+
error: string | null;
|
|
321
|
+
} | null;
|
|
322
|
+
/** `webhook` only, create response only: the Standard Webhooks signing secret. */
|
|
323
|
+
signing_secret?: string;
|
|
324
|
+
created_at: string;
|
|
325
|
+
/** Seconds behind the newest event. */
|
|
326
|
+
lag_seconds: number;
|
|
327
|
+
delivered_24h: number;
|
|
328
|
+
failed_24h: number;
|
|
329
|
+
bytes_24h: number;
|
|
330
|
+
/** The last 7 UTC days. */
|
|
331
|
+
daily: {
|
|
332
|
+
day: string;
|
|
333
|
+
delivered: number;
|
|
334
|
+
failed: number;
|
|
335
|
+
bytes: number;
|
|
336
|
+
}[];
|
|
337
|
+
notify_email: string | null;
|
|
338
|
+
/** S3 / EventBridge role streams: put it in your trust policy. */
|
|
339
|
+
external_id: string | null;
|
|
340
|
+
/** The AWS principal that assumes your role. */
|
|
341
|
+
aws_principal: string | null;
|
|
342
|
+
}
|
|
343
|
+
export interface RuleIn {
|
|
344
|
+
/** 1 to 100 characters. */
|
|
345
|
+
name: string;
|
|
346
|
+
account_id?: string | null;
|
|
347
|
+
/** Actions are exact names or prefixes ending in `*`; `severity` is a minimum. */
|
|
348
|
+
match: {
|
|
349
|
+
actions: string[];
|
|
350
|
+
outcome?: Outcome;
|
|
351
|
+
severity?: Severity;
|
|
352
|
+
};
|
|
353
|
+
channel: {
|
|
354
|
+
kind: 'email';
|
|
355
|
+
to: string;
|
|
356
|
+
} | {
|
|
357
|
+
kind: 'slack' | 'webhook';
|
|
358
|
+
url: string;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
export interface Rule {
|
|
362
|
+
id: string;
|
|
363
|
+
account_id: string | null;
|
|
364
|
+
name: string;
|
|
365
|
+
match: RuleIn['match'];
|
|
366
|
+
/** URLs are not returned. */
|
|
367
|
+
channel: {
|
|
368
|
+
kind: 'email' | 'slack' | 'webhook';
|
|
369
|
+
to?: string;
|
|
370
|
+
};
|
|
371
|
+
enabled: boolean;
|
|
372
|
+
/** `webhook` only, create response only: the `X-Watchtower-Signature` HMAC secret. */
|
|
373
|
+
signing_secret?: string;
|
|
374
|
+
created_at: string;
|
|
375
|
+
}
|
|
376
|
+
export type RuleChannel = RuleIn['channel'];
|
|
377
|
+
export type RulePatch = Partial<Pick<RuleIn, 'name' | 'match'>> & {
|
|
378
|
+
enabled?: boolean;
|
|
379
|
+
channel?: RuleChannel;
|
|
380
|
+
};
|
|
381
|
+
export interface ExportRequest {
|
|
382
|
+
format?: 'csv' | 'ndjson' | 'ocsf';
|
|
383
|
+
filters?: {
|
|
384
|
+
account_id?: string;
|
|
385
|
+
actor_id?: string;
|
|
386
|
+
action?: string;
|
|
387
|
+
target_type?: string;
|
|
388
|
+
outcome?: Outcome;
|
|
389
|
+
severity?: Severity;
|
|
390
|
+
from?: string;
|
|
391
|
+
to?: string;
|
|
392
|
+
};
|
|
393
|
+
/** Gets a 24 h signed download link when the file is ready. */
|
|
394
|
+
notify_email?: string;
|
|
395
|
+
}
|
|
396
|
+
export interface Export {
|
|
397
|
+
id: string;
|
|
398
|
+
state: 'pending' | 'running' | 'done' | 'failed' | 'expired';
|
|
399
|
+
format: string;
|
|
400
|
+
filters: ExportRequest['filters'];
|
|
401
|
+
rows: number | null;
|
|
402
|
+
error: string | null;
|
|
403
|
+
expires_at: string | null;
|
|
404
|
+
created_at: string;
|
|
405
|
+
/** Signed link that works without credentials while the file exists. */
|
|
406
|
+
download_url: string | null;
|
|
407
|
+
}
|
|
408
|
+
/** A schedule goes to a storage stream (`stream_id`) or by email (`emails`, 1 to 5), never both. */
|
|
409
|
+
export interface Schedule {
|
|
410
|
+
id: string;
|
|
411
|
+
name: string;
|
|
412
|
+
cron: string;
|
|
413
|
+
format: string;
|
|
414
|
+
stream_id: string | null;
|
|
415
|
+
emails: string[] | null;
|
|
416
|
+
next_run_at: string;
|
|
417
|
+
last_run_at: string | null;
|
|
418
|
+
last_error: string | null;
|
|
419
|
+
}
|
|
420
|
+
export interface Archive {
|
|
421
|
+
id: string;
|
|
422
|
+
account_id: string;
|
|
423
|
+
from: string;
|
|
424
|
+
to: string;
|
|
425
|
+
rows: number;
|
|
426
|
+
sha256: string;
|
|
427
|
+
created_at: string;
|
|
428
|
+
restore_pending: boolean;
|
|
429
|
+
restored_until: string | null;
|
|
430
|
+
restore_error: string | null;
|
|
431
|
+
}
|
|
432
|
+
export interface Page<T> {
|
|
433
|
+
data: T[];
|
|
434
|
+
next_cursor?: string | null;
|
|
435
|
+
}
|
|
436
|
+
/** A server-side saved view of an account token. */
|
|
437
|
+
export interface SavedView {
|
|
438
|
+
id: string;
|
|
439
|
+
name: string;
|
|
440
|
+
q: string;
|
|
441
|
+
params: Record<string, string>;
|
|
442
|
+
created_at: string;
|
|
443
|
+
}
|
|
444
|
+
/** POST .../actors/{id}/erase with approval, and GET .../erasures. */
|
|
445
|
+
export interface ErasureRequest {
|
|
446
|
+
id: string;
|
|
447
|
+
actor_id: string;
|
|
448
|
+
requested_by: string;
|
|
449
|
+
approved_by?: string | null;
|
|
450
|
+
state: 'pending' | 'done' | 'cancelled';
|
|
451
|
+
created_at: string;
|
|
452
|
+
}
|
|
453
|
+
export interface ErasureResult {
|
|
454
|
+
accounts: number;
|
|
455
|
+
rows: number;
|
|
456
|
+
fields_erased: number;
|
|
457
|
+
}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Receipt } from './types';
|
|
2
|
+
type Bytes = Uint8Array<ArrayBuffer>;
|
|
3
|
+
export interface Key {
|
|
4
|
+
kid: string;
|
|
5
|
+
x: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Signed {
|
|
8
|
+
kid: string;
|
|
9
|
+
message: string;
|
|
10
|
+
signature?: string;
|
|
11
|
+
sig?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ChainRow {
|
|
14
|
+
seq: number;
|
|
15
|
+
prev_hash: string;
|
|
16
|
+
hash: string;
|
|
17
|
+
body: string;
|
|
18
|
+
id?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function fromHex(s: string): Bytes;
|
|
21
|
+
export declare function fromB64(s: string): Bytes;
|
|
22
|
+
export declare const toHex: (b: Uint8Array) => string;
|
|
23
|
+
/** Canonical JSON as the server writes it: sorted keys, no whitespace. */
|
|
24
|
+
export declare function canonical(v: unknown): string;
|
|
25
|
+
/** Hex SHA-256(prev || body) of a chain row. */
|
|
26
|
+
export declare function chainHash(prevHex: string, body: string): Promise<string>;
|
|
27
|
+
/** Rows ascending and contiguous after `anchor` (or from seq 1 with an empty link): the first bad seq, or null. */
|
|
28
|
+
export declare function verifyRows(rows: ChainRow[], anchor?: {
|
|
29
|
+
seq: number;
|
|
30
|
+
hash: string;
|
|
31
|
+
} | null): Promise<number | null>;
|
|
32
|
+
/** Ed25519 over `message` by `kid`; false for an unknown kid or a bad signature. */
|
|
33
|
+
export declare function verifySignature(s: Signed, keys: Key[]): Promise<boolean>;
|
|
34
|
+
export declare const merkleLeaf: (chainHashHex: string) => Promise<string>;
|
|
35
|
+
/** RFC 9162 tree hash of leaf hashes (hex). */
|
|
36
|
+
export declare function merkleRoot(leaves: string[]): Promise<string>;
|
|
37
|
+
/** RFC 9162 2.1.3.2: `leaf` (hex leaf hash) at `index` of a tree of `size` with `root`. */
|
|
38
|
+
export declare function verifyInclusion(leaf: string, index: number, size: number, path: string[], root: string): Promise<boolean>;
|
|
39
|
+
/** RFC 9162 2.1.4.2: the tree (m, oldRoot) is a prefix of (n, newRoot). */
|
|
40
|
+
export declare function verifyConsistency(m: number, n: number, oldRoot: string, newRoot: string, proof: string[]): Promise<boolean>;
|
|
41
|
+
/** A selectively disclosed field: SHA-256(salt || canonical(value)) equals the commitment in the chain body. */
|
|
42
|
+
export declare function verifyCommitment(f: {
|
|
43
|
+
salt: string;
|
|
44
|
+
value: unknown;
|
|
45
|
+
commitment: string;
|
|
46
|
+
}): Promise<boolean>;
|
|
47
|
+
type ReceiptLike = Pick<Receipt, 'account_id' | 'seq' | 'leaf_index' | 'chain_hash' | 'kid' | 'message' | 'sig'>;
|
|
48
|
+
/** A write receipt: signed by a project key, and its message names the receipt's own fields. */
|
|
49
|
+
export declare function verifyReceipt(r: ReceiptLike, keys: Key[], projectId?: string): Promise<boolean>;
|
|
50
|
+
export type Verdict = 'VALID' | 'VALID_UNANCHORED' | 'VALID_PRUNED' | 'INVALID';
|
|
51
|
+
type Obj = Record<string, unknown>;
|
|
52
|
+
export interface VerifyPage {
|
|
53
|
+
data: ChainRow[];
|
|
54
|
+
head_seq?: number;
|
|
55
|
+
anchor_seq?: number | null;
|
|
56
|
+
checkpoint: (Signed & {
|
|
57
|
+
seq: number;
|
|
58
|
+
hash: string;
|
|
59
|
+
}) | null;
|
|
60
|
+
pruned?: (Signed & {
|
|
61
|
+
from_seq: number;
|
|
62
|
+
to_seq: number;
|
|
63
|
+
last_hash: string;
|
|
64
|
+
})[];
|
|
65
|
+
erased?: {
|
|
66
|
+
from_seq: number;
|
|
67
|
+
to_seq: number;
|
|
68
|
+
}[];
|
|
69
|
+
}
|
|
70
|
+
export interface TreeHead extends Signed {
|
|
71
|
+
from_seq: number;
|
|
72
|
+
to_seq: number;
|
|
73
|
+
size: number;
|
|
74
|
+
root: string;
|
|
75
|
+
note?: string;
|
|
76
|
+
cosignatures?: {
|
|
77
|
+
line: string;
|
|
78
|
+
}[];
|
|
79
|
+
anchor?: {
|
|
80
|
+
top: string;
|
|
81
|
+
index: number;
|
|
82
|
+
size: number;
|
|
83
|
+
path: string[];
|
|
84
|
+
receipts: Obj[];
|
|
85
|
+
} | null;
|
|
86
|
+
}
|
|
87
|
+
/** What the verifier pins beyond the project keys: Rekor v2 logs `{origin: base64url key}`, witnesses `{name: key}`, the quorum. */
|
|
88
|
+
export interface Trust {
|
|
89
|
+
rekorLogs?: Record<string, string>;
|
|
90
|
+
witnesses?: Record<string, string>;
|
|
91
|
+
quorum?: number;
|
|
92
|
+
}
|
|
93
|
+
/** The C2SP checkpoint origin (key name) of an account's log; the account percent-encoded. */
|
|
94
|
+
export declare function origin(project: string, account: string): string;
|
|
95
|
+
/** A C2SP signed note carries a valid Ed25519 signature by key `name`. */
|
|
96
|
+
export declare function verifyNote(text: string, name: string, pk: Uint8Array): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* The spec's verdict over one account's merged verify pages (oldest first) and optionally its tree head: INVALID
|
|
99
|
+
* beats VALID_PRUNED (signed tombstones from seq 1) beats VALID (head signed, the rows' Merkle root, anchored by a
|
|
100
|
+
* Rekor v2 receipt in a trusted log, its Ed25519ph signature included, witness quorum met) beats
|
|
101
|
+
* VALID_UNANCHORED. Other receipt kinds are checked by `wtctl activity verify`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function verdict(p: VerifyPage, keys: Key[], head?: TreeHead | null, trust?: Trust): Promise<Verdict>;
|
|
104
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@watchtowerobservability/activity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Watchtower hosted activity log: server SDK (record events, mint viewer sessions, list, export)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.cts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@opentelemetry/api": ">=1.0.0 <2"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@opentelemetry/api": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "node scripts/build.mjs",
|
|
39
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"prepack": "npm run build"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "22.15.0",
|
|
45
|
+
"esbuild": "0.28.2",
|
|
46
|
+
"typescript": "5.7.2",
|
|
47
|
+
"vitest": "5.0.5"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/watchtowerobservability/watchtower-activity.git"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/watchtowerobservability/watchtower-activity#readme",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
}
|
|
58
|
+
}
|