@sealkeeper/schema 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +140 -0
- package/dist/api.js +25 -0
- package/dist/credential.d.ts +186 -1
- package/dist/credential.js +55 -8
- package/dist/db/client.d.ts +57 -0
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/standing.d.ts +35 -0
- package/dist/db/standing.js +3 -0
- package/dist/db/task-outcomes.d.ts +19 -0
- package/dist/db/task-outcomes.js +8 -1
- package/dist/db/tasks.d.ts +19 -0
- package/dist/db/tasks.js +7 -1
- package/dist/goal.d.ts +88 -0
- package/dist/goal.js +112 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/seal-conformance.js +30 -1
- package/dist/standing.d.ts +49 -0
- package/dist/standing.js +90 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ export declare const AgentResponse: z.ZodObject<{
|
|
|
72
72
|
distinct_operators: z.ZodInt;
|
|
73
73
|
safety_incidents_90d: z.ZodInt;
|
|
74
74
|
}, z.core.$strict>;
|
|
75
|
+
counted: z.ZodObject<{
|
|
76
|
+
verified_tasks: z.ZodInt;
|
|
77
|
+
seed_tasks: z.ZodInt;
|
|
78
|
+
server_checked_tasks: z.ZodInt;
|
|
79
|
+
confirmed_tasks: z.ZodInt;
|
|
80
|
+
}, z.core.$strict>;
|
|
75
81
|
history_days: z.ZodInt;
|
|
76
82
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
77
83
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -189,6 +195,12 @@ export declare const AgentSummary: z.ZodObject<{
|
|
|
189
195
|
distinct_operators: z.ZodInt;
|
|
190
196
|
safety_incidents_90d: z.ZodInt;
|
|
191
197
|
}, z.core.$strict>;
|
|
198
|
+
counted: z.ZodObject<{
|
|
199
|
+
verified_tasks: z.ZodInt;
|
|
200
|
+
seed_tasks: z.ZodInt;
|
|
201
|
+
server_checked_tasks: z.ZodInt;
|
|
202
|
+
confirmed_tasks: z.ZodInt;
|
|
203
|
+
}, z.core.$strict>;
|
|
192
204
|
history_days: z.ZodInt;
|
|
193
205
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
194
206
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -237,6 +249,12 @@ export declare const AgentsListResponse: z.ZodObject<{
|
|
|
237
249
|
distinct_operators: z.ZodInt;
|
|
238
250
|
safety_incidents_90d: z.ZodInt;
|
|
239
251
|
}, z.core.$strict>;
|
|
252
|
+
counted: z.ZodObject<{
|
|
253
|
+
verified_tasks: z.ZodInt;
|
|
254
|
+
seed_tasks: z.ZodInt;
|
|
255
|
+
server_checked_tasks: z.ZodInt;
|
|
256
|
+
confirmed_tasks: z.ZodInt;
|
|
257
|
+
}, z.core.$strict>;
|
|
240
258
|
history_days: z.ZodInt;
|
|
241
259
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
242
260
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -268,6 +286,12 @@ export declare const EventsBatchResponse: z.ZodObject<{
|
|
|
268
286
|
export type EventsBatchResponse = z.infer<typeof EventsBatchResponse>;
|
|
269
287
|
export declare const AgentRef: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
270
288
|
export type AgentRef = z.infer<typeof AgentRef>;
|
|
289
|
+
export declare const TaskOrigin: z.ZodEnum<{
|
|
290
|
+
manual: "manual";
|
|
291
|
+
routine: "routine";
|
|
292
|
+
template: "template";
|
|
293
|
+
}>;
|
|
294
|
+
export type TaskOrigin = z.infer<typeof TaskOrigin>;
|
|
271
295
|
export declare const PostTaskRequest: z.ZodObject<{
|
|
272
296
|
taskId: z.ZodUUID;
|
|
273
297
|
taskType: z.ZodString;
|
|
@@ -283,6 +307,11 @@ export declare const PostTaskRequest: z.ZodObject<{
|
|
|
283
307
|
}, z.core.$strict>], "kind">;
|
|
284
308
|
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
285
309
|
assignee: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
|
|
310
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
311
|
+
manual: "manual";
|
|
312
|
+
routine: "routine";
|
|
313
|
+
template: "template";
|
|
314
|
+
}>>;
|
|
286
315
|
}, z.core.$strict>;
|
|
287
316
|
export type PostTaskRequest = z.infer<typeof PostTaskRequest>;
|
|
288
317
|
export declare const TaskAssignee: z.ZodObject<{
|
|
@@ -340,6 +369,11 @@ export declare const TaskOutcomeRequest: z.ZodObject<{
|
|
|
340
369
|
success: "success";
|
|
341
370
|
}>;
|
|
342
371
|
evidenceHash: z.ZodOptional<z.ZodString>;
|
|
372
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
373
|
+
manual: "manual";
|
|
374
|
+
routine: "routine";
|
|
375
|
+
template: "template";
|
|
376
|
+
}>>;
|
|
343
377
|
}, z.core.$strict>;
|
|
344
378
|
export type TaskOutcomeRequest = z.infer<typeof TaskOutcomeRequest>;
|
|
345
379
|
export declare const TASK_READ_MAX_AGE_SEC = 300;
|
|
@@ -521,8 +555,19 @@ export declare const TaskView: z.ZodObject<{
|
|
|
521
555
|
handle: z.ZodString;
|
|
522
556
|
operatedBySealKeeper: z.ZodBoolean;
|
|
523
557
|
}, z.core.$strict>>;
|
|
558
|
+
origin: z.ZodEnum<{
|
|
559
|
+
manual: "manual";
|
|
560
|
+
routine: "routine";
|
|
561
|
+
template: "template";
|
|
562
|
+
}>;
|
|
524
563
|
countsForTrust: z.ZodNullable<z.ZodBoolean>;
|
|
525
564
|
evidenceWeight: z.ZodNullable<z.ZodNumber>;
|
|
565
|
+
counted: z.ZodNullable<z.ZodNumber>;
|
|
566
|
+
countedNote: z.ZodNullable<z.ZodEnum<{
|
|
567
|
+
daily_ceiling: "daily_ceiling";
|
|
568
|
+
diminishing: "diminishing";
|
|
569
|
+
outside_window: "outside_window";
|
|
570
|
+
}>>;
|
|
526
571
|
postedAt: z.ZodISODateTime;
|
|
527
572
|
claimedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
528
573
|
submittedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
@@ -566,8 +611,19 @@ export declare const TaskViewsResponse: z.ZodObject<{
|
|
|
566
611
|
handle: z.ZodString;
|
|
567
612
|
operatedBySealKeeper: z.ZodBoolean;
|
|
568
613
|
}, z.core.$strict>>;
|
|
614
|
+
origin: z.ZodEnum<{
|
|
615
|
+
manual: "manual";
|
|
616
|
+
routine: "routine";
|
|
617
|
+
template: "template";
|
|
618
|
+
}>;
|
|
569
619
|
countsForTrust: z.ZodNullable<z.ZodBoolean>;
|
|
570
620
|
evidenceWeight: z.ZodNullable<z.ZodNumber>;
|
|
621
|
+
counted: z.ZodNullable<z.ZodNumber>;
|
|
622
|
+
countedNote: z.ZodNullable<z.ZodEnum<{
|
|
623
|
+
daily_ceiling: "daily_ceiling";
|
|
624
|
+
diminishing: "diminishing";
|
|
625
|
+
outside_window: "outside_window";
|
|
626
|
+
}>>;
|
|
571
627
|
postedAt: z.ZodISODateTime;
|
|
572
628
|
claimedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
573
629
|
submittedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
@@ -683,6 +739,12 @@ export declare const MeAgent: z.ZodObject<{
|
|
|
683
739
|
distinct_operators: z.ZodInt;
|
|
684
740
|
safety_incidents_90d: z.ZodInt;
|
|
685
741
|
}, z.core.$strict>;
|
|
742
|
+
counted: z.ZodObject<{
|
|
743
|
+
verified_tasks: z.ZodInt;
|
|
744
|
+
seed_tasks: z.ZodInt;
|
|
745
|
+
server_checked_tasks: z.ZodInt;
|
|
746
|
+
confirmed_tasks: z.ZodInt;
|
|
747
|
+
}, z.core.$strict>;
|
|
686
748
|
history_days: z.ZodInt;
|
|
687
749
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
688
750
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -741,6 +803,12 @@ export declare const MeResponse: z.ZodObject<{
|
|
|
741
803
|
distinct_operators: z.ZodInt;
|
|
742
804
|
safety_incidents_90d: z.ZodInt;
|
|
743
805
|
}, z.core.$strict>;
|
|
806
|
+
counted: z.ZodObject<{
|
|
807
|
+
verified_tasks: z.ZodInt;
|
|
808
|
+
seed_tasks: z.ZodInt;
|
|
809
|
+
server_checked_tasks: z.ZodInt;
|
|
810
|
+
confirmed_tasks: z.ZodInt;
|
|
811
|
+
}, z.core.$strict>;
|
|
744
812
|
history_days: z.ZodInt;
|
|
745
813
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
746
814
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -851,6 +919,12 @@ export declare const LeaderboardEntry: z.ZodObject<{
|
|
|
851
919
|
distinct_operators: z.ZodInt;
|
|
852
920
|
safety_incidents_90d: z.ZodInt;
|
|
853
921
|
}, z.core.$strict>;
|
|
922
|
+
counted: z.ZodObject<{
|
|
923
|
+
verified_tasks: z.ZodInt;
|
|
924
|
+
seed_tasks: z.ZodInt;
|
|
925
|
+
server_checked_tasks: z.ZodInt;
|
|
926
|
+
confirmed_tasks: z.ZodInt;
|
|
927
|
+
}, z.core.$strict>;
|
|
854
928
|
history_days: z.ZodInt;
|
|
855
929
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
856
930
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -896,6 +970,12 @@ export declare const LeaderboardResponse: z.ZodObject<{
|
|
|
896
970
|
distinct_operators: z.ZodInt;
|
|
897
971
|
safety_incidents_90d: z.ZodInt;
|
|
898
972
|
}, z.core.$strict>;
|
|
973
|
+
counted: z.ZodObject<{
|
|
974
|
+
verified_tasks: z.ZodInt;
|
|
975
|
+
seed_tasks: z.ZodInt;
|
|
976
|
+
server_checked_tasks: z.ZodInt;
|
|
977
|
+
confirmed_tasks: z.ZodInt;
|
|
978
|
+
}, z.core.$strict>;
|
|
899
979
|
history_days: z.ZodInt;
|
|
900
980
|
last_active: z.ZodNullable<z.ZodISODateTime>;
|
|
901
981
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
@@ -1498,6 +1578,66 @@ export declare const SealVerifyResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1498
1578
|
}, z.core.$strict>>;
|
|
1499
1579
|
last_active: z.ZodNullable<z.ZodInt>;
|
|
1500
1580
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
1581
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1582
|
+
iss: z.ZodEnum<{
|
|
1583
|
+
"sealkeeper.run": "sealkeeper.run";
|
|
1584
|
+
"vouched.run": "vouched.run";
|
|
1585
|
+
}>;
|
|
1586
|
+
sub: z.ZodString;
|
|
1587
|
+
ver: z.ZodLiteral<2>;
|
|
1588
|
+
iat: z.ZodInt;
|
|
1589
|
+
exp: z.ZodInt;
|
|
1590
|
+
agent_version: z.ZodString;
|
|
1591
|
+
version: z.ZodString;
|
|
1592
|
+
level: z.ZodEnum<{
|
|
1593
|
+
bronze: "bronze";
|
|
1594
|
+
gold: "gold";
|
|
1595
|
+
none: "none";
|
|
1596
|
+
silver: "silver";
|
|
1597
|
+
}>;
|
|
1598
|
+
scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1599
|
+
cost_latency: "cost_latency";
|
|
1600
|
+
provenance: "provenance";
|
|
1601
|
+
reliability: "reliability";
|
|
1602
|
+
safety: "safety";
|
|
1603
|
+
}>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
|
|
1604
|
+
counts: z.ZodObject<{
|
|
1605
|
+
events: z.ZodInt;
|
|
1606
|
+
history_days: z.ZodInt;
|
|
1607
|
+
verified_tasks: z.ZodInt;
|
|
1608
|
+
seed_tasks: z.ZodInt;
|
|
1609
|
+
server_checked_tasks: z.ZodInt;
|
|
1610
|
+
confirmed_tasks: z.ZodInt;
|
|
1611
|
+
distinct_operators: z.ZodInt;
|
|
1612
|
+
safety_incidents_90d: z.ZodInt;
|
|
1613
|
+
}, z.core.$strict>;
|
|
1614
|
+
counted: z.ZodObject<{
|
|
1615
|
+
verified_tasks: z.ZodInt;
|
|
1616
|
+
seed_tasks: z.ZodInt;
|
|
1617
|
+
server_checked_tasks: z.ZodInt;
|
|
1618
|
+
confirmed_tasks: z.ZodInt;
|
|
1619
|
+
}, z.core.$strict>;
|
|
1620
|
+
operator: z.ZodObject<{
|
|
1621
|
+
verified: z.ZodBoolean;
|
|
1622
|
+
}, z.core.$strict>;
|
|
1623
|
+
identity: z.ZodArray<z.ZodObject<{
|
|
1624
|
+
provider: z.ZodURL;
|
|
1625
|
+
kind: z.ZodUnion<readonly [z.ZodEnum<{
|
|
1626
|
+
kya: "kya";
|
|
1627
|
+
oidc: "oidc";
|
|
1628
|
+
saml: "saml";
|
|
1629
|
+
verifiable_credential: "verifiable_credential";
|
|
1630
|
+
}>, z.ZodURL]>;
|
|
1631
|
+
ref: z.ZodString;
|
|
1632
|
+
subject_hash: z.ZodString;
|
|
1633
|
+
attested_at: z.ZodInt;
|
|
1634
|
+
scope: z.ZodEnum<{
|
|
1635
|
+
agent: "agent";
|
|
1636
|
+
operator: "operator";
|
|
1637
|
+
}>;
|
|
1638
|
+
}, z.core.$strict>>;
|
|
1639
|
+
last_active: z.ZodNullable<z.ZodInt>;
|
|
1640
|
+
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
1501
1641
|
}, z.core.$strict>, z.ZodObject<{
|
|
1502
1642
|
iss: z.ZodEnum<{
|
|
1503
1643
|
"sealkeeper.run": "sealkeeper.run";
|
package/dist/api.js
CHANGED
|
@@ -285,6 +285,13 @@ export const AgentRef = z.union([
|
|
|
285
285
|
AgentName.safeParse(name).success);
|
|
286
286
|
}, 'Use an agent id or a handle login/name'),
|
|
287
287
|
]);
|
|
288
|
+
// Where a task post or an outcome report came from, declared by the
|
|
289
|
+
// poster's or reporter's CLI inside the signed payload. manual is a person
|
|
290
|
+
// or an agent at work, template a post from prove's guided templates,
|
|
291
|
+
// routine anything the unattended daily routine sends. Absent means manual.
|
|
292
|
+
// All three count toward bronze and silver. Gold counts a confirmed task
|
|
293
|
+
// only when its post is manual and neither outcome report is routine.
|
|
294
|
+
export const TaskOrigin = z.enum(['manual', 'template', 'routine']);
|
|
288
295
|
// taskId is generated by the client and becomes the task id, so a retried
|
|
289
296
|
// post is a no-op. The same poster gets the existing task back, any other
|
|
290
297
|
// poster gets 409. assignee addresses the task to one agent of another
|
|
@@ -297,6 +304,7 @@ export const PostTaskRequest = z.strictObject({
|
|
|
297
304
|
verification: VerificationSpec,
|
|
298
305
|
expiresAt: Timestamp.optional(),
|
|
299
306
|
assignee: AgentRef.optional(),
|
|
307
|
+
origin: TaskOrigin.optional(),
|
|
300
308
|
});
|
|
301
309
|
// The agent an addressed task is for, as it is now.
|
|
302
310
|
export const TaskAssignee = z.strictObject({
|
|
@@ -334,10 +342,12 @@ export const SubmitTaskRequest = z.strictObject({
|
|
|
334
342
|
.refine((text) => utf8Encode(JSON.stringify(text)).length <= MAX_SUBMISSION_BYTES, `submission must be at most ${MAX_SUBMISSION_BYTES} bytes as JSON`),
|
|
335
343
|
});
|
|
336
344
|
// Named for its task like claim and submit, checked against the path.
|
|
345
|
+
// origin is the reporting side's, TaskOrigin above.
|
|
337
346
|
export const TaskOutcomeRequest = z.strictObject({
|
|
338
347
|
taskId: z.uuid(),
|
|
339
348
|
outcome: TaskOutcome,
|
|
340
349
|
evidenceHash: Sha256Hex.optional(),
|
|
350
|
+
origin: TaskOrigin.optional(),
|
|
341
351
|
});
|
|
342
352
|
// POST /v1/tasks/:id/submission, the poster's signed read of its task with
|
|
343
353
|
// the submission and both outcome reports. The public GET leaves the
|
|
@@ -416,6 +426,8 @@ export const TaskView = z.strictObject({
|
|
|
416
426
|
// The one agent that can claim an addressed task. Null for an open task,
|
|
417
427
|
// and after the assignee agent was deleted.
|
|
418
428
|
assignee: TaskParty.nullable(),
|
|
429
|
+
// Where the post came from, manual when the poster's CLI did not say.
|
|
430
|
+
origin: TaskOrigin,
|
|
419
431
|
// The scoring rule. True when the poster is the seed agent or an agent of
|
|
420
432
|
// another operator than the claimant, false when both sides share an
|
|
421
433
|
// operator or the task is addressed and came past its operator pair's
|
|
@@ -426,6 +438,19 @@ export const TaskView = z.strictObject({
|
|
|
426
438
|
// the addressed weight (0.5) for an addressed one within its pair cap, 0
|
|
427
439
|
// when countsForTrust is false. Null when countsForTrust is null.
|
|
428
440
|
evidenceWeight: z.number().min(0).max(1).nullable(),
|
|
441
|
+
// What the task adds to the claimant's counted evidence (VOU-139), after
|
|
442
|
+
// the daily ceiling and diminishing returns and times evidenceWeight. 0
|
|
443
|
+
// when countsForTrust is false, null when it is null.
|
|
444
|
+
counted: z.number().min(0).max(1).nullable(),
|
|
445
|
+
// Why a task that counts adds less than its weight, or nothing.
|
|
446
|
+
// daily_ceiling when COUNTED_EVIDENCE.dailyCeiling heavier, more valuable
|
|
447
|
+
// or earlier tasks of the claimant counted that UTC day, diminishing when
|
|
448
|
+
// it is past the first COUNTED_EVIDENCE.diminishingK of its category (its
|
|
449
|
+
// seed task type, or its poster's operator), outside_window when it was
|
|
450
|
+
// verified before the 180 day window. Null otherwise.
|
|
451
|
+
countedNote: z
|
|
452
|
+
.enum(['daily_ceiling', 'diminishing', 'outside_window'])
|
|
453
|
+
.nullable(),
|
|
429
454
|
postedAt: Timestamp,
|
|
430
455
|
claimedAt: Timestamp.nullable(),
|
|
431
456
|
submittedAt: Timestamp.nullable(),
|
package/dist/credential.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { CountedCounts } from './standing.js';
|
|
2
3
|
export declare const CREDENTIAL_ISSUER = "sealkeeper.run";
|
|
3
4
|
export declare const LEGACY_ISSUERS: readonly ['vouched.run'];
|
|
4
5
|
export declare const LEGACY_ISSUER_UNTIL: number;
|
|
@@ -13,6 +14,7 @@ export declare const CREDENTIAL_EXTENSION_URI = "https://vouched.run/ext/credent
|
|
|
13
14
|
export declare const LEGACY_SEAL_EXTENSION_URIS: readonly string[];
|
|
14
15
|
export declare const SEAL_EXTENSION_URIS: readonly string[];
|
|
15
16
|
export declare const SEAL_VERSION = 1;
|
|
17
|
+
export declare const SEAL_VERSIONS: readonly [1, 2];
|
|
16
18
|
export declare const LEGACY_UNTIL: number;
|
|
17
19
|
export declare const IdentityKind: z.ZodUnion<readonly [z.ZodEnum<{
|
|
18
20
|
kya: "kya";
|
|
@@ -94,6 +96,65 @@ export declare const CredentialPayload: z.ZodObject<{
|
|
|
94
96
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
95
97
|
}, z.core.$strict>;
|
|
96
98
|
export type CredentialPayload = z.infer<typeof CredentialPayload>;
|
|
99
|
+
export declare const CredentialPayloadV2: z.ZodObject<{
|
|
100
|
+
iss: z.ZodLiteral<"sealkeeper.run">;
|
|
101
|
+
sub: z.ZodString;
|
|
102
|
+
ver: z.ZodLiteral<2>;
|
|
103
|
+
iat: z.ZodInt;
|
|
104
|
+
exp: z.ZodInt;
|
|
105
|
+
agent_version: z.ZodString;
|
|
106
|
+
version: z.ZodString;
|
|
107
|
+
level: z.ZodEnum<{
|
|
108
|
+
bronze: "bronze";
|
|
109
|
+
gold: "gold";
|
|
110
|
+
none: "none";
|
|
111
|
+
silver: "silver";
|
|
112
|
+
}>;
|
|
113
|
+
scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
|
|
114
|
+
cost_latency: "cost_latency";
|
|
115
|
+
provenance: "provenance";
|
|
116
|
+
reliability: "reliability";
|
|
117
|
+
safety: "safety";
|
|
118
|
+
}>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
|
|
119
|
+
counts: z.ZodObject<{
|
|
120
|
+
events: z.ZodInt;
|
|
121
|
+
history_days: z.ZodInt;
|
|
122
|
+
verified_tasks: z.ZodInt;
|
|
123
|
+
seed_tasks: z.ZodInt;
|
|
124
|
+
server_checked_tasks: z.ZodInt;
|
|
125
|
+
confirmed_tasks: z.ZodInt;
|
|
126
|
+
distinct_operators: z.ZodInt;
|
|
127
|
+
safety_incidents_90d: z.ZodInt;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
counted: z.ZodObject<{
|
|
130
|
+
verified_tasks: z.ZodInt;
|
|
131
|
+
seed_tasks: z.ZodInt;
|
|
132
|
+
server_checked_tasks: z.ZodInt;
|
|
133
|
+
confirmed_tasks: z.ZodInt;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
operator: z.ZodObject<{
|
|
136
|
+
verified: z.ZodBoolean;
|
|
137
|
+
}, z.core.$strict>;
|
|
138
|
+
identity: z.ZodArray<z.ZodObject<{
|
|
139
|
+
provider: z.ZodURL;
|
|
140
|
+
kind: z.ZodUnion<readonly [z.ZodEnum<{
|
|
141
|
+
kya: "kya";
|
|
142
|
+
oidc: "oidc";
|
|
143
|
+
saml: "saml";
|
|
144
|
+
verifiable_credential: "verifiable_credential";
|
|
145
|
+
}>, z.ZodURL]>;
|
|
146
|
+
ref: z.ZodString;
|
|
147
|
+
subject_hash: z.ZodString;
|
|
148
|
+
attested_at: z.ZodInt;
|
|
149
|
+
scope: z.ZodEnum<{
|
|
150
|
+
agent: "agent";
|
|
151
|
+
operator: "operator";
|
|
152
|
+
}>;
|
|
153
|
+
}, z.core.$strict>>;
|
|
154
|
+
last_active: z.ZodNullable<z.ZodInt>;
|
|
155
|
+
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
156
|
+
}, z.core.$strict>;
|
|
157
|
+
export type CredentialPayloadV2 = z.infer<typeof CredentialPayloadV2>;
|
|
97
158
|
export declare const LegacyCredentialPayload: z.ZodObject<{
|
|
98
159
|
iss: z.ZodLiteral<"sealkeeper.run">;
|
|
99
160
|
sub: z.ZodString;
|
|
@@ -169,6 +230,68 @@ export declare const VerifiedCredentialPayload: z.ZodObject<{
|
|
|
169
230
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
170
231
|
}, z.core.$strict>;
|
|
171
232
|
export type VerifiedCredentialPayload = z.infer<typeof VerifiedCredentialPayload>;
|
|
233
|
+
export declare const VerifiedCredentialPayloadV2: z.ZodObject<{
|
|
234
|
+
iss: z.ZodEnum<{
|
|
235
|
+
"sealkeeper.run": "sealkeeper.run";
|
|
236
|
+
"vouched.run": "vouched.run";
|
|
237
|
+
}>;
|
|
238
|
+
sub: z.ZodString;
|
|
239
|
+
ver: z.ZodLiteral<2>;
|
|
240
|
+
iat: z.ZodInt;
|
|
241
|
+
exp: z.ZodInt;
|
|
242
|
+
agent_version: z.ZodString;
|
|
243
|
+
version: z.ZodString;
|
|
244
|
+
level: z.ZodEnum<{
|
|
245
|
+
bronze: "bronze";
|
|
246
|
+
gold: "gold";
|
|
247
|
+
none: "none";
|
|
248
|
+
silver: "silver";
|
|
249
|
+
}>;
|
|
250
|
+
scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
|
|
251
|
+
cost_latency: "cost_latency";
|
|
252
|
+
provenance: "provenance";
|
|
253
|
+
reliability: "reliability";
|
|
254
|
+
safety: "safety";
|
|
255
|
+
}>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
|
|
256
|
+
counts: z.ZodObject<{
|
|
257
|
+
events: z.ZodInt;
|
|
258
|
+
history_days: z.ZodInt;
|
|
259
|
+
verified_tasks: z.ZodInt;
|
|
260
|
+
seed_tasks: z.ZodInt;
|
|
261
|
+
server_checked_tasks: z.ZodInt;
|
|
262
|
+
confirmed_tasks: z.ZodInt;
|
|
263
|
+
distinct_operators: z.ZodInt;
|
|
264
|
+
safety_incidents_90d: z.ZodInt;
|
|
265
|
+
}, z.core.$strict>;
|
|
266
|
+
counted: z.ZodObject<{
|
|
267
|
+
verified_tasks: z.ZodInt;
|
|
268
|
+
seed_tasks: z.ZodInt;
|
|
269
|
+
server_checked_tasks: z.ZodInt;
|
|
270
|
+
confirmed_tasks: z.ZodInt;
|
|
271
|
+
}, z.core.$strict>;
|
|
272
|
+
operator: z.ZodObject<{
|
|
273
|
+
verified: z.ZodBoolean;
|
|
274
|
+
}, z.core.$strict>;
|
|
275
|
+
identity: z.ZodArray<z.ZodObject<{
|
|
276
|
+
provider: z.ZodURL;
|
|
277
|
+
kind: z.ZodUnion<readonly [z.ZodEnum<{
|
|
278
|
+
kya: "kya";
|
|
279
|
+
oidc: "oidc";
|
|
280
|
+
saml: "saml";
|
|
281
|
+
verifiable_credential: "verifiable_credential";
|
|
282
|
+
}>, z.ZodURL]>;
|
|
283
|
+
ref: z.ZodString;
|
|
284
|
+
subject_hash: z.ZodString;
|
|
285
|
+
attested_at: z.ZodInt;
|
|
286
|
+
scope: z.ZodEnum<{
|
|
287
|
+
agent: "agent";
|
|
288
|
+
operator: "operator";
|
|
289
|
+
}>;
|
|
290
|
+
}, z.core.$strict>>;
|
|
291
|
+
last_active: z.ZodNullable<z.ZodInt>;
|
|
292
|
+
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
293
|
+
}, z.core.$strict>;
|
|
294
|
+
export type VerifiedCredentialPayloadV2 = z.infer<typeof VerifiedCredentialPayloadV2>;
|
|
172
295
|
export declare const VerifiedLegacyCredentialPayload: z.ZodObject<{
|
|
173
296
|
iss: z.ZodEnum<{
|
|
174
297
|
"sealkeeper.run": "sealkeeper.run";
|
|
@@ -245,6 +368,66 @@ export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
245
368
|
}, z.core.$strict>>;
|
|
246
369
|
last_active: z.ZodNullable<z.ZodInt>;
|
|
247
370
|
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
371
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
372
|
+
iss: z.ZodEnum<{
|
|
373
|
+
"sealkeeper.run": "sealkeeper.run";
|
|
374
|
+
"vouched.run": "vouched.run";
|
|
375
|
+
}>;
|
|
376
|
+
sub: z.ZodString;
|
|
377
|
+
ver: z.ZodLiteral<2>;
|
|
378
|
+
iat: z.ZodInt;
|
|
379
|
+
exp: z.ZodInt;
|
|
380
|
+
agent_version: z.ZodString;
|
|
381
|
+
version: z.ZodString;
|
|
382
|
+
level: z.ZodEnum<{
|
|
383
|
+
bronze: "bronze";
|
|
384
|
+
gold: "gold";
|
|
385
|
+
none: "none";
|
|
386
|
+
silver: "silver";
|
|
387
|
+
}>;
|
|
388
|
+
scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
|
|
389
|
+
cost_latency: "cost_latency";
|
|
390
|
+
provenance: "provenance";
|
|
391
|
+
reliability: "reliability";
|
|
392
|
+
safety: "safety";
|
|
393
|
+
}>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
|
|
394
|
+
counts: z.ZodObject<{
|
|
395
|
+
events: z.ZodInt;
|
|
396
|
+
history_days: z.ZodInt;
|
|
397
|
+
verified_tasks: z.ZodInt;
|
|
398
|
+
seed_tasks: z.ZodInt;
|
|
399
|
+
server_checked_tasks: z.ZodInt;
|
|
400
|
+
confirmed_tasks: z.ZodInt;
|
|
401
|
+
distinct_operators: z.ZodInt;
|
|
402
|
+
safety_incidents_90d: z.ZodInt;
|
|
403
|
+
}, z.core.$strict>;
|
|
404
|
+
counted: z.ZodObject<{
|
|
405
|
+
verified_tasks: z.ZodInt;
|
|
406
|
+
seed_tasks: z.ZodInt;
|
|
407
|
+
server_checked_tasks: z.ZodInt;
|
|
408
|
+
confirmed_tasks: z.ZodInt;
|
|
409
|
+
}, z.core.$strict>;
|
|
410
|
+
operator: z.ZodObject<{
|
|
411
|
+
verified: z.ZodBoolean;
|
|
412
|
+
}, z.core.$strict>;
|
|
413
|
+
identity: z.ZodArray<z.ZodObject<{
|
|
414
|
+
provider: z.ZodURL;
|
|
415
|
+
kind: z.ZodUnion<readonly [z.ZodEnum<{
|
|
416
|
+
kya: "kya";
|
|
417
|
+
oidc: "oidc";
|
|
418
|
+
saml: "saml";
|
|
419
|
+
verifiable_credential: "verifiable_credential";
|
|
420
|
+
}>, z.ZodURL]>;
|
|
421
|
+
ref: z.ZodString;
|
|
422
|
+
subject_hash: z.ZodString;
|
|
423
|
+
attested_at: z.ZodInt;
|
|
424
|
+
scope: z.ZodEnum<{
|
|
425
|
+
agent: "agent";
|
|
426
|
+
operator: "operator";
|
|
427
|
+
}>;
|
|
428
|
+
}, z.core.$strict>>;
|
|
429
|
+
last_active: z.ZodNullable<z.ZodInt>;
|
|
430
|
+
dormant_days: z.ZodNullable<z.ZodInt>;
|
|
248
431
|
}, z.core.$strict>, z.ZodObject<{
|
|
249
432
|
iss: z.ZodEnum<{
|
|
250
433
|
"sealkeeper.run": "sealkeeper.run";
|
|
@@ -267,7 +450,9 @@ export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
267
450
|
}, z.core.$strict>;
|
|
268
451
|
}, z.core.$strict>]>;
|
|
269
452
|
export type SealPayload = z.infer<typeof SealPayload>;
|
|
270
|
-
export
|
|
453
|
+
export type VersionedSealPayload = VerifiedCredentialPayload | VerifiedCredentialPayloadV2;
|
|
454
|
+
export declare const isSealV1: (p: SealPayload) => p is VersionedSealPayload;
|
|
455
|
+
export declare const sealCounted: (p: SealPayload) => CountedCounts | null;
|
|
271
456
|
export declare function sealVersionProblem(raw: unknown, nowSeconds: number): 'unsupported_version' | null;
|
|
272
457
|
export declare function sealIatProblem(iat: number, nowSeconds: number): 'not_yet_valid' | null;
|
|
273
458
|
export type SealPayloadResult = {
|
package/dist/credential.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AgentId, Ed25519PublicKey } from './agent-id.js';
|
|
|
3
3
|
import { Dimension } from './dimensions.js';
|
|
4
4
|
import { Jws } from './envelope.js';
|
|
5
5
|
import { Version } from './events.js';
|
|
6
|
-
import { Level, StandingCounts } from './standing.js';
|
|
6
|
+
import { CountedCounts, Level, StandingCounts } from './standing.js';
|
|
7
7
|
// The issuer every SEAL carries as iss from the SealKeeper cutover on.
|
|
8
8
|
export const CREDENTIAL_ISSUER = 'sealkeeper.run';
|
|
9
9
|
// Issuers a verifier still accepts for a while after the cutover. A SEAL
|
|
@@ -50,6 +50,12 @@ const Seconds = z.int().min(0);
|
|
|
50
50
|
const Count = z.int().min(0);
|
|
51
51
|
// The version of the SEAL standard this issuer writes, carried as ver.
|
|
52
52
|
export const SEAL_VERSION = 1;
|
|
53
|
+
// Every version a verifier understands. Version 2 is version 1 plus
|
|
54
|
+
// `counted`, the counted evidence the level read (VOU-139). CLIs 0.4.x
|
|
55
|
+
// understand version 1 only and refuse any other ver, so the issuer keeps
|
|
56
|
+
// writing version 1 until they are gone, and verifiers from this release
|
|
57
|
+
// on accept both. SEAL standard section 9.
|
|
58
|
+
export const SEAL_VERSIONS = [1, 2];
|
|
53
59
|
// SEALs issued before version 1 carry no ver. Verifiers accept them as
|
|
54
60
|
// legacy until the end of 25 September 2026 UTC, which is past the 24 hour
|
|
55
61
|
// life of any SEAL issued before the deploy. From then on a SEAL without
|
|
@@ -125,6 +131,35 @@ const v1Payload = (iss) => z
|
|
|
125
131
|
.refine((c) => c.exp > c.iat, 'exp must be after iat')
|
|
126
132
|
.refine(withinMaxTtl, MAX_TTL_MESSAGE)
|
|
127
133
|
.refine((c) => c.version === c.agent_version, 'version must equal agent_version');
|
|
134
|
+
/*
|
|
135
|
+
* Version 2. Every version 1 field with the same meaning, plus counted, the
|
|
136
|
+
* counted evidence the level read (CountedCounts). counts stay the raw
|
|
137
|
+
* facts. Each counted value is at most its raw count.
|
|
138
|
+
*/
|
|
139
|
+
const v2Payload = (iss) => z
|
|
140
|
+
.strictObject({
|
|
141
|
+
iss,
|
|
142
|
+
sub: AgentId,
|
|
143
|
+
ver: z.literal(2),
|
|
144
|
+
iat: Seconds,
|
|
145
|
+
exp: Seconds,
|
|
146
|
+
agent_version: Version,
|
|
147
|
+
version: Version,
|
|
148
|
+
level: Level,
|
|
149
|
+
scores: Scores,
|
|
150
|
+
counts: StandingCounts,
|
|
151
|
+
counted: CountedCounts,
|
|
152
|
+
operator: z.strictObject({ verified: z.boolean() }),
|
|
153
|
+
identity: z.array(IdentityReference).max(16),
|
|
154
|
+
last_active: Seconds.nullable(),
|
|
155
|
+
dormant_days: Count.nullable(),
|
|
156
|
+
})
|
|
157
|
+
.refine((c) => c.exp > c.iat, 'exp must be after iat')
|
|
158
|
+
.refine(withinMaxTtl, MAX_TTL_MESSAGE)
|
|
159
|
+
.refine((c) => c.version === c.agent_version, 'version must equal agent_version')
|
|
160
|
+
.refine((c) => c.counted.seed_tasks <= c.counts.seed_tasks &&
|
|
161
|
+
c.counted.server_checked_tasks <= c.counts.server_checked_tasks &&
|
|
162
|
+
c.counted.confirmed_tasks <= c.counts.confirmed_tasks, 'counted must not exceed counts');
|
|
128
163
|
// The payload issued before version 1, with no ver. Accepted by verifiers
|
|
129
164
|
// until LEGACY_UNTIL, never issued again. seed_tasks is optional because a
|
|
130
165
|
// SEAL issued before it was added has none.
|
|
@@ -146,25 +181,31 @@ const legacyPayload = (iss) => z
|
|
|
146
181
|
.refine(withinMaxTtl, MAX_TTL_MESSAGE);
|
|
147
182
|
// The issuer side. iss is CREDENTIAL_ISSUER only.
|
|
148
183
|
export const CredentialPayload = v1Payload(IssuedIssuer);
|
|
184
|
+
export const CredentialPayloadV2 = v2Payload(IssuedIssuer);
|
|
149
185
|
export const LegacyCredentialPayload = legacyPayload(IssuedIssuer);
|
|
150
186
|
// The verifier side. iss may also be a LEGACY_ISSUERS entry. The shape has
|
|
151
187
|
// no clock, so read these through parseSealPayload, never on their own.
|
|
152
188
|
export const VerifiedCredentialPayload = v1Payload(VerifiedIssuer);
|
|
189
|
+
export const VerifiedCredentialPayloadV2 = v2Payload(VerifiedIssuer);
|
|
153
190
|
export const VerifiedLegacyCredentialPayload = legacyPayload(VerifiedIssuer);
|
|
154
|
-
// Any payload a verifier accepts today, version 1 or legacy,
|
|
155
|
-
// current issuer or a legacy one.
|
|
191
|
+
// Any payload a verifier accepts today, version 1, version 2 or legacy,
|
|
192
|
+
// from the current issuer or a legacy one.
|
|
156
193
|
export const SealPayload = z.union([
|
|
157
194
|
VerifiedCredentialPayload,
|
|
195
|
+
VerifiedCredentialPayloadV2,
|
|
158
196
|
VerifiedLegacyCredentialPayload,
|
|
159
197
|
]);
|
|
160
|
-
// A
|
|
161
|
-
//
|
|
198
|
+
// A versioned payload carries every legacy field too, so the guard is on
|
|
199
|
+
// ver, the narrower of the two. Its false branch is the legacy shape. The
|
|
200
|
+
// name is kept from when version 1 was the only one.
|
|
162
201
|
export const isSealV1 = (p) => 'ver' in p;
|
|
202
|
+
// The counted evidence a SEAL carries, version 2 on, null before.
|
|
203
|
+
export const sealCounted = (p) => 'counted' in p ? p.counted : null;
|
|
163
204
|
const hasVer = (raw) => typeof raw === 'object' && raw !== null && 'ver' in raw;
|
|
164
205
|
/*
|
|
165
206
|
* Whether a verifier understands the version of a signed payload. Read
|
|
166
207
|
* after the signature and the issuer check out and before the shape. ver 1
|
|
167
|
-
*
|
|
208
|
+
* and 2 (SEAL_VERSIONS) are understood. Any other ver is unsupported_version, as section 9 of the
|
|
168
209
|
* standard says, never valid with an unknown meaning. No ver at all is a
|
|
169
210
|
* legacy SEAL, accepted before LEGACY_UNTIL and unsupported_version from
|
|
170
211
|
* then on. Anything that is not an object is left to the shape check.
|
|
@@ -173,7 +214,9 @@ export function sealVersionProblem(raw, nowSeconds) {
|
|
|
173
214
|
if (typeof raw !== 'object' || raw === null)
|
|
174
215
|
return null;
|
|
175
216
|
if (hasVer(raw)) {
|
|
176
|
-
return raw.ver
|
|
217
|
+
return SEAL_VERSIONS.includes(raw.ver)
|
|
218
|
+
? null
|
|
219
|
+
: 'unsupported_version';
|
|
177
220
|
}
|
|
178
221
|
return nowSeconds < LEGACY_UNTIL ? null : 'unsupported_version';
|
|
179
222
|
}
|
|
@@ -202,7 +245,11 @@ export function parseSealPayload(raw, nowSeconds) {
|
|
|
202
245
|
const problem = sealVersionProblem(raw, nowSeconds);
|
|
203
246
|
if (problem)
|
|
204
247
|
return { ok: false, reason: problem };
|
|
205
|
-
const parsed = (hasVer(raw)
|
|
248
|
+
const parsed = (!hasVer(raw)
|
|
249
|
+
? VerifiedLegacyCredentialPayload
|
|
250
|
+
: raw.ver === 2
|
|
251
|
+
? VerifiedCredentialPayloadV2
|
|
252
|
+
: VerifiedCredentialPayload).safeParse(raw);
|
|
206
253
|
return parsed.success
|
|
207
254
|
? { ok: true, payload: parsed.data }
|
|
208
255
|
: { ok: false, reason: 'malformed' };
|