@continuonai/rcan-ts 0.8.0 → 1.2.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 +1 -0
- package/dist/browser.d.mts +482 -39
- package/dist/browser.mjs +627 -73
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +482 -39
- package/dist/index.d.ts +482 -39
- package/dist/index.js +665 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +627 -73
- package/dist/index.mjs.map +1 -1
- package/dist/rcan-validate.js +22 -2
- package/dist/rcan.iife.js +16 -3
- package/package.json +28 -5
package/dist/index.d.mts
CHANGED
|
@@ -86,12 +86,18 @@ declare enum MessageType {
|
|
|
86
86
|
CONTRIBUTE_RESULT = 34,
|
|
87
87
|
CONTRIBUTE_CANCEL = 35,
|
|
88
88
|
TRAINING_DATA = 36,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
|
|
89
|
+
COMPETITION_ENTER = 37,
|
|
90
|
+
COMPETITION_SCORE = 38,
|
|
91
|
+
SEASON_STANDING = 39,
|
|
92
|
+
PERSONAL_RESEARCH_RESULT = 40,
|
|
93
|
+
/** authority → robot: EU AI Act Art. 16(j) audit data request */
|
|
94
|
+
AUTHORITY_ACCESS = 41,
|
|
95
|
+
/** robot → authority: audit data response */
|
|
96
|
+
AUTHORITY_RESPONSE = 42,
|
|
97
|
+
/** robot → RRF: publish signed firmware manifest */
|
|
98
|
+
FIRMWARE_ATTESTATION = 43,
|
|
99
|
+
/** robot → RRF: publish updated CycloneDX SBOM */
|
|
100
|
+
SBOM_UPDATE = 44
|
|
95
101
|
}
|
|
96
102
|
/** §8.5 — Sender Type and Service Identity */
|
|
97
103
|
type SenderType = "robot" | "human" | "cloud_function" | "system";
|
|
@@ -108,6 +114,12 @@ interface SignatureBlock {
|
|
|
108
114
|
kid: string;
|
|
109
115
|
sig: string;
|
|
110
116
|
}
|
|
117
|
+
/** v2.2: Post-quantum (ML-DSA-65) signature block */
|
|
118
|
+
interface PQSignatureBlock {
|
|
119
|
+
alg: "ml-dsa-65";
|
|
120
|
+
kid: string;
|
|
121
|
+
sig: string;
|
|
122
|
+
}
|
|
111
123
|
interface RCANMessageData {
|
|
112
124
|
rcan?: string;
|
|
113
125
|
/** v1.5: explicit protocol version field (defaults to SPEC_VERSION) */
|
|
@@ -142,6 +154,12 @@ interface RCANMessageData {
|
|
|
142
154
|
transportEncoding?: string;
|
|
143
155
|
/** v1.6: GAP-18 multi-modal media chunks */
|
|
144
156
|
mediaChunks?: Array<Record<string, unknown>>;
|
|
157
|
+
/** v2.1: SHA-256 of sender's firmware manifest (envelope field 13). Required at L2+. */
|
|
158
|
+
firmwareHash?: string;
|
|
159
|
+
/** v2.1: URI to sender's SBOM attestation endpoint (envelope field 14). Required at L2+. */
|
|
160
|
+
attestationRef?: string;
|
|
161
|
+
/** v2.2: ML-DSA-65 post-quantum signature block (field 16, FIPS 204). Hybrid mode alongside Ed25519. */
|
|
162
|
+
pqSig?: PQSignatureBlock | undefined;
|
|
145
163
|
[key: string]: unknown;
|
|
146
164
|
}
|
|
147
165
|
declare class RCANMessageError extends Error {
|
|
@@ -174,6 +192,12 @@ declare class RCANMessage {
|
|
|
174
192
|
readonly transportEncoding: string | undefined;
|
|
175
193
|
/** v1.6: GAP-18 multi-modal media chunks */
|
|
176
194
|
readonly mediaChunks: Array<Record<string, unknown>> | undefined;
|
|
195
|
+
/** v2.1: SHA-256 of sender's firmware manifest */
|
|
196
|
+
readonly firmwareHash: string | undefined;
|
|
197
|
+
/** v2.1: URI to sender's SBOM attestation endpoint */
|
|
198
|
+
readonly attestationRef: string | undefined;
|
|
199
|
+
/** v2.2: ML-DSA-65 post-quantum signature (field 16, FIPS 204). Hybrid alongside Ed25519. */
|
|
200
|
+
readonly pqSig: PQSignatureBlock | undefined;
|
|
177
201
|
constructor(data: RCANMessageData);
|
|
178
202
|
/** Whether this message has a signature block */
|
|
179
203
|
get isSigned(): boolean;
|
|
@@ -741,14 +765,13 @@ declare function makeTransparencyMessage(ruri: string, disclosure: string, deleg
|
|
|
741
765
|
* §3.5 — Protocol Version Compatibility
|
|
742
766
|
*/
|
|
743
767
|
/** The RCAN spec version this SDK implements. */
|
|
744
|
-
declare const SPEC_VERSION = "
|
|
768
|
+
declare const SPEC_VERSION = "2.2.0";
|
|
745
769
|
/** The SDK release version. */
|
|
746
|
-
declare const SDK_VERSION = "
|
|
770
|
+
declare const SDK_VERSION = "1.2.0";
|
|
747
771
|
/**
|
|
748
772
|
* Validate version compatibility.
|
|
749
773
|
*
|
|
750
|
-
*
|
|
751
|
-
* and lower-or-equal MINOR version. MAJOR mismatch → incompatible.
|
|
774
|
+
* MAJOR must match. Lower-or-equal MINOR is acceptable.
|
|
752
775
|
*
|
|
753
776
|
* @param incomingVersion - The rcanVersion from the incoming message
|
|
754
777
|
* @param localVersion - The local SPEC_VERSION (defaults to SPEC_VERSION)
|
|
@@ -1012,7 +1035,7 @@ interface RevocationStatus {
|
|
|
1012
1035
|
/**
|
|
1013
1036
|
* RevocationCache — TTL-based cache for revocation status records.
|
|
1014
1037
|
*/
|
|
1015
|
-
declare class RevocationCache {
|
|
1038
|
+
declare class RevocationCache$1 {
|
|
1016
1039
|
private readonly _cache;
|
|
1017
1040
|
/** Get a cached status if still fresh */
|
|
1018
1041
|
get(rrn: string, nowMs?: number): RevocationStatus | undefined;
|
|
@@ -1031,7 +1054,7 @@ declare class RevocationCache {
|
|
|
1031
1054
|
* @param registryUrl - Base URL of the registry (e.g. "https://registry.rcan.dev")
|
|
1032
1055
|
* @param cache - Optional RevocationCache to use (creates ephemeral one if not provided)
|
|
1033
1056
|
*/
|
|
1034
|
-
declare function checkRevocation(rrn: string, registryUrl: string, cache?: RevocationCache): Promise<RevocationStatus>;
|
|
1057
|
+
declare function checkRevocation(rrn: string, registryUrl: string, cache?: RevocationCache$1): Promise<RevocationStatus>;
|
|
1035
1058
|
/**
|
|
1036
1059
|
* Build a ROBOT_REVOCATION broadcast message.
|
|
1037
1060
|
*
|
|
@@ -1205,43 +1228,94 @@ interface AuditExportRequest {
|
|
|
1205
1228
|
}
|
|
1206
1229
|
|
|
1207
1230
|
/**
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1231
|
+
* rcan/identity — RCAN v2.1 Role-Based Access Control and Identity.
|
|
1232
|
+
*
|
|
1233
|
+
* Defines the seven-level role hierarchy (§2), JWT claim parsing, scope
|
|
1234
|
+
* validation, and identity record types.
|
|
1235
|
+
*
|
|
1236
|
+
* Roles (v2.1):
|
|
1237
|
+
* GUEST (JWT 1) — read-only, anonymous
|
|
1238
|
+
* OPERATOR (JWT 2) — operational control
|
|
1239
|
+
* CONTRIBUTOR (JWT 2.5) — idle compute donation scope
|
|
1240
|
+
* ADMIN (JWT 3) — configuration, user management
|
|
1241
|
+
* M2M_PEER (JWT 4) — robot-to-robot; issued by ADMIN
|
|
1242
|
+
* CREATOR (JWT 5) — full hardware/software control
|
|
1243
|
+
* M2M_TRUSTED (JWT 6) — fleet orchestration; RRF-issued only
|
|
1244
|
+
*
|
|
1245
|
+
* Spec: §2 — Role-Based Access Control
|
|
1246
|
+
*/
|
|
1247
|
+
/** RCAN v2.1 role hierarchy. Use ROLE_JWT_LEVEL to map to JWT level values. */
|
|
1248
|
+
declare enum Role {
|
|
1249
|
+
GUEST = 1,
|
|
1250
|
+
OPERATOR = 2,
|
|
1251
|
+
CONTRIBUTOR = 3,// JWT level 2.5
|
|
1252
|
+
ADMIN = 4,// JWT level 3
|
|
1253
|
+
M2M_PEER = 5,// JWT level 4
|
|
1254
|
+
CREATOR = 6,// JWT level 5
|
|
1255
|
+
M2M_TRUSTED = 7
|
|
1256
|
+
}
|
|
1257
|
+
/** @deprecated Use Role instead. Kept for v1.x backward compatibility. */
|
|
1258
|
+
declare const LevelOfAssurance: typeof Role;
|
|
1259
|
+
type LevelOfAssurance = Role;
|
|
1260
|
+
/** Maps Role enum value to JWT rcan_role level (fractional for CONTRIBUTOR). */
|
|
1261
|
+
declare const ROLE_JWT_LEVEL: Record<Role, number>;
|
|
1262
|
+
/** Return the Role for a JWT rcan_role numeric level, or undefined. */
|
|
1263
|
+
declare function roleFromJwtLevel(level: number): Role | undefined;
|
|
1264
|
+
declare const SCOPE_MIN_ROLE: Record<string, Role>;
|
|
1265
|
+
interface IdentityRecord {
|
|
1266
|
+
/** Subject identifier (UUID, RRN, or orchestrator id). */
|
|
1267
|
+
sub: string;
|
|
1268
|
+
/** RCAN v2.1 Role. */
|
|
1269
|
+
role: Role;
|
|
1270
|
+
/** JWT-level value for this role. */
|
|
1271
|
+
jwtLevel: number;
|
|
1272
|
+
/** Registry that issued this identity. */
|
|
1273
|
+
registryUrl?: string;
|
|
1274
|
+
/** Granted scopes. */
|
|
1275
|
+
scopes: string[];
|
|
1276
|
+
/** UTC ISO-8601 timestamp of most recent verification. */
|
|
1277
|
+
verifiedAt?: string;
|
|
1278
|
+
/** For M2M_PEER tokens — the authorized peer's RRN. */
|
|
1279
|
+
peerRrn?: string;
|
|
1280
|
+
/** For M2M_TRUSTED tokens — explicit fleet allowlist. */
|
|
1281
|
+
fleetRrns?: string[];
|
|
1217
1282
|
}
|
|
1218
1283
|
interface LoaPolicy {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1284
|
+
minRoleForDiscover: Role;
|
|
1285
|
+
minRoleForStatus: Role;
|
|
1286
|
+
minRoleForChat: Role;
|
|
1287
|
+
minRoleForControl: Role;
|
|
1288
|
+
minRoleForSafety: Role;
|
|
1224
1289
|
}
|
|
1225
|
-
/** Backward-compatible policy — every scope accepts
|
|
1290
|
+
/** Backward-compatible default policy — every scope accepts GUEST callers. */
|
|
1226
1291
|
declare const DEFAULT_LOA_POLICY: LoaPolicy;
|
|
1227
|
-
/** Production-hardened policy — control needs
|
|
1292
|
+
/** Production-hardened policy — control needs OPERATOR, safety needs CREATOR. */
|
|
1228
1293
|
declare const PRODUCTION_LOA_POLICY: LoaPolicy;
|
|
1229
1294
|
/**
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1295
|
+
* Parse an RCAN v2.1 JWT and return the Role.
|
|
1296
|
+
*
|
|
1297
|
+
* Reads `rcan_role` (v2.1) with fallback to `loa` (v1.x).
|
|
1298
|
+
* Defaults to GUEST on parse failure.
|
|
1232
1299
|
*/
|
|
1233
|
-
declare function
|
|
1300
|
+
declare function extractRoleFromJwt(token: string): Role;
|
|
1301
|
+
/** @deprecated Use extractRoleFromJwt. Kept for v1.x backward compatibility. */
|
|
1302
|
+
declare function extractLoaFromJwt(token: string): Role;
|
|
1234
1303
|
/**
|
|
1235
|
-
*
|
|
1304
|
+
* Parse an RCAN v2.1 JWT and return a full IdentityRecord.
|
|
1236
1305
|
*
|
|
1237
|
-
*
|
|
1238
|
-
* @param scope - One of discover | status | chat | control | safety
|
|
1239
|
-
* @param policy - Defaults to DEFAULT_LOA_POLICY (backward compatible)
|
|
1306
|
+
* Does NOT verify the JWT signature.
|
|
1240
1307
|
*/
|
|
1241
|
-
declare function
|
|
1242
|
-
|
|
1308
|
+
declare function extractIdentityFromJwt(token: string): IdentityRecord;
|
|
1309
|
+
interface ScopeValidationResult {
|
|
1310
|
+
ok: boolean;
|
|
1243
1311
|
reason: string;
|
|
1244
|
-
}
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Check whether `role` meets the minimum requirement for `scope`.
|
|
1315
|
+
*/
|
|
1316
|
+
declare function validateRoleForScope(role: Role, scope: string): ScopeValidationResult;
|
|
1317
|
+
/** @deprecated Use validateRoleForScope. */
|
|
1318
|
+
declare function validateLoaForScope(role: Role, scope: string): ScopeValidationResult;
|
|
1245
1319
|
|
|
1246
1320
|
/**
|
|
1247
1321
|
* RCAN Federation — cross-registry trust and sync (GAP-16).
|
|
@@ -1496,6 +1570,375 @@ declare function validateContributeScope(scopeLevel: number, action?: "request"
|
|
|
1496
1570
|
*/
|
|
1497
1571
|
declare function isPreemptedBy(scopeLevel: number): boolean;
|
|
1498
1572
|
|
|
1573
|
+
/**
|
|
1574
|
+
* rcan/competition — Competition protocol messages and scope.
|
|
1575
|
+
*
|
|
1576
|
+
* Implements the competition scope and message types for RCAN v1.10+.
|
|
1577
|
+
* Robots can enter competitions, publish scores, receive season standings,
|
|
1578
|
+
* and log private personal research results.
|
|
1579
|
+
*
|
|
1580
|
+
* Spec: §3 MessageTypes 37–40
|
|
1581
|
+
*/
|
|
1582
|
+
|
|
1583
|
+
/** Competition scope level — chat-level scope (observation, not control). */
|
|
1584
|
+
declare const COMPETITION_SCOPE_LEVEL = 2;
|
|
1585
|
+
type CompetitionFormat = "sprint" | "endurance" | "precision" | "efficiency";
|
|
1586
|
+
type CompetitionBadge = "gold" | "silver" | "bronze" | "participant";
|
|
1587
|
+
type RunType = "personal" | "community";
|
|
1588
|
+
interface StandingEntry {
|
|
1589
|
+
rank: number;
|
|
1590
|
+
rrn: string;
|
|
1591
|
+
score: number;
|
|
1592
|
+
badge: CompetitionBadge;
|
|
1593
|
+
}
|
|
1594
|
+
interface ResearchMetrics {
|
|
1595
|
+
success_rate: number;
|
|
1596
|
+
p66_rate: number;
|
|
1597
|
+
token_efficiency: number;
|
|
1598
|
+
latency_score: number;
|
|
1599
|
+
[key: string]: number;
|
|
1600
|
+
}
|
|
1601
|
+
interface CompetitionEnter {
|
|
1602
|
+
type: typeof MessageType.COMPETITION_ENTER;
|
|
1603
|
+
competition_id: string;
|
|
1604
|
+
competition_format: CompetitionFormat;
|
|
1605
|
+
hardware_tier: string;
|
|
1606
|
+
model_id: string;
|
|
1607
|
+
robot_rrn: string;
|
|
1608
|
+
entered_at: number;
|
|
1609
|
+
}
|
|
1610
|
+
interface CompetitionScore {
|
|
1611
|
+
type: typeof MessageType.COMPETITION_SCORE;
|
|
1612
|
+
competition_id: string;
|
|
1613
|
+
candidate_id: string;
|
|
1614
|
+
score: number;
|
|
1615
|
+
hardware_tier: string;
|
|
1616
|
+
verified: boolean;
|
|
1617
|
+
submitted_at: number;
|
|
1618
|
+
}
|
|
1619
|
+
interface SeasonStanding {
|
|
1620
|
+
type: typeof MessageType.SEASON_STANDING;
|
|
1621
|
+
season_id: string;
|
|
1622
|
+
class_id: string;
|
|
1623
|
+
standings: StandingEntry[];
|
|
1624
|
+
days_remaining: number;
|
|
1625
|
+
broadcast_at: number;
|
|
1626
|
+
}
|
|
1627
|
+
interface PersonalResearchResult {
|
|
1628
|
+
type: typeof MessageType.PERSONAL_RESEARCH_RESULT;
|
|
1629
|
+
run_id: string;
|
|
1630
|
+
run_type: RunType;
|
|
1631
|
+
candidate_id: string;
|
|
1632
|
+
score: number;
|
|
1633
|
+
hardware_tier: string;
|
|
1634
|
+
model_id: string;
|
|
1635
|
+
owner_uid: string;
|
|
1636
|
+
metrics: ResearchMetrics;
|
|
1637
|
+
submitted_to_community: boolean;
|
|
1638
|
+
created_at: number;
|
|
1639
|
+
}
|
|
1640
|
+
declare function makeCompetitionEnter(params?: Partial<Omit<CompetitionEnter, "type">>): CompetitionEnter;
|
|
1641
|
+
declare function makeCompetitionScore(params?: Partial<Omit<CompetitionScore, "type">>): CompetitionScore;
|
|
1642
|
+
declare function makeSeasonStanding(params?: Partial<Omit<SeasonStanding, "type">>): SeasonStanding;
|
|
1643
|
+
declare function makePersonalResearchResult(params?: Partial<Omit<PersonalResearchResult, "type">>): PersonalResearchResult;
|
|
1644
|
+
/**
|
|
1645
|
+
* Check if the given scope level permits competition operations.
|
|
1646
|
+
* Competition messages require scope >= 2.0 (chat level).
|
|
1647
|
+
*/
|
|
1648
|
+
declare function validateCompetitionScope(scopeLevel: number): boolean;
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* rcan/firmware — RCAN v2.1 Firmware Manifest types and helpers.
|
|
1652
|
+
*
|
|
1653
|
+
* Every RCAN v2.1 robot MUST publish a signed firmware manifest at:
|
|
1654
|
+
* {ruri}/.well-known/rcan-firmware-manifest.json
|
|
1655
|
+
*
|
|
1656
|
+
* The manifest is Ed25519-signed by the manufacturer's key registered in the RRF.
|
|
1657
|
+
* The envelope field `firmwareHash` (field 13) carries a SHA-256 of the manifest.
|
|
1658
|
+
*
|
|
1659
|
+
* Spec: §11 — Firmware Manifests
|
|
1660
|
+
*/
|
|
1661
|
+
/** Well-known endpoint path for firmware manifests. */
|
|
1662
|
+
declare const FIRMWARE_MANIFEST_PATH = "/.well-known/rcan-firmware-manifest.json";
|
|
1663
|
+
/** A single component entry in the firmware manifest. */
|
|
1664
|
+
interface FirmwareComponent {
|
|
1665
|
+
/** Component name, e.g. "brain-runtime" */
|
|
1666
|
+
name: string;
|
|
1667
|
+
/** Semantic version string */
|
|
1668
|
+
version: string;
|
|
1669
|
+
/** SHA-256 hash prefixed with "sha256:" */
|
|
1670
|
+
hash: string;
|
|
1671
|
+
}
|
|
1672
|
+
/** RCAN v2.1 firmware manifest. */
|
|
1673
|
+
interface FirmwareManifest {
|
|
1674
|
+
/** Robot Registration Number */
|
|
1675
|
+
rrn: string;
|
|
1676
|
+
/** Semver or CalVer version string */
|
|
1677
|
+
firmwareVersion: string;
|
|
1678
|
+
/** SHA-256 of the full firmware bundle, prefixed "sha256:" */
|
|
1679
|
+
buildHash: string;
|
|
1680
|
+
/** Per-component records */
|
|
1681
|
+
components: FirmwareComponent[];
|
|
1682
|
+
/** UTC ISO-8601 timestamp when the manifest was signed */
|
|
1683
|
+
signedAt: string;
|
|
1684
|
+
/** Ed25519 signature over canonical JSON (base64url), empty if unsigned */
|
|
1685
|
+
signature?: string;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Serialized (wire) format of a firmware manifest.
|
|
1689
|
+
* Uses snake_case keys to match the JSON spec.
|
|
1690
|
+
*/
|
|
1691
|
+
interface FirmwareManifestWire {
|
|
1692
|
+
rrn: string;
|
|
1693
|
+
firmware_version: string;
|
|
1694
|
+
build_hash: string;
|
|
1695
|
+
components: FirmwareComponent[];
|
|
1696
|
+
signed_at: string;
|
|
1697
|
+
signature?: string;
|
|
1698
|
+
}
|
|
1699
|
+
/** Convert a camelCase FirmwareManifest to the wire (snake_case) format. */
|
|
1700
|
+
declare function manifestToWire(m: FirmwareManifest): FirmwareManifestWire;
|
|
1701
|
+
/** Parse a wire-format manifest into the typed FirmwareManifest. */
|
|
1702
|
+
declare function manifestFromWire(w: FirmwareManifestWire): FirmwareManifest;
|
|
1703
|
+
/**
|
|
1704
|
+
* Return the canonical JSON bytes of a manifest (no signature field, sorted keys).
|
|
1705
|
+
* This is the byte string that the Ed25519 signature covers.
|
|
1706
|
+
*/
|
|
1707
|
+
declare function canonicalManifestJson(m: FirmwareManifest): string;
|
|
1708
|
+
/** Thrown when firmware manifest signature verification fails. */
|
|
1709
|
+
declare class FirmwareIntegrityError extends Error {
|
|
1710
|
+
constructor(message: string);
|
|
1711
|
+
}
|
|
1712
|
+
/** Validate a manifest structure and return a list of errors. */
|
|
1713
|
+
declare function validateManifest(m: FirmwareManifest): string[];
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* rcan/authority — RCAN v2.1 Authority Access Protocol (EU AI Act §16(j)).
|
|
1717
|
+
*
|
|
1718
|
+
* Defines payload types for AUTHORITY_ACCESS (41) and AUTHORITY_RESPONSE (42)
|
|
1719
|
+
* message types, and helpers for building/validating authority requests.
|
|
1720
|
+
*
|
|
1721
|
+
* The authority access protocol enables regulatory bodies to request audit data
|
|
1722
|
+
* from robots under EU AI Act Article 16(j) and similar frameworks.
|
|
1723
|
+
*
|
|
1724
|
+
* Spec: §13 (Authority Access) — EU AI Act Art. 16 mapping
|
|
1725
|
+
*/
|
|
1726
|
+
/** Allowed audit data categories that an authority may request. */
|
|
1727
|
+
type AuthorityDataCategory = "audit_chain" | "transparency_records" | "sbom" | "firmware_manifest";
|
|
1728
|
+
/** Payload for AUTHORITY_ACCESS (41) — sent by a regulatory authority to a robot. */
|
|
1729
|
+
interface AuthorityAccessPayload {
|
|
1730
|
+
/** Unique request identifier (correlated in the response). */
|
|
1731
|
+
requestId: string;
|
|
1732
|
+
/** Authority identifier, e.g. "EU-AI-ACT-NCA-DE" */
|
|
1733
|
+
authorityId: string;
|
|
1734
|
+
/** Audit data categories requested. */
|
|
1735
|
+
requestedData: AuthorityDataCategory[];
|
|
1736
|
+
/** Human-readable justification for the request. */
|
|
1737
|
+
justification: string;
|
|
1738
|
+
/** Unix timestamp — request must be responded to before this time. */
|
|
1739
|
+
expiresAt: number;
|
|
1740
|
+
}
|
|
1741
|
+
/** Provided audit data in an AUTHORITY_RESPONSE. */
|
|
1742
|
+
interface AuthorityResponseData {
|
|
1743
|
+
auditChain?: unknown[];
|
|
1744
|
+
transparencyRecords?: unknown[];
|
|
1745
|
+
sbomUrl?: string;
|
|
1746
|
+
firmwareManifestUrl?: string;
|
|
1747
|
+
}
|
|
1748
|
+
/** Payload for AUTHORITY_RESPONSE (42) — sent by the robot in reply. */
|
|
1749
|
+
interface AuthorityResponsePayload {
|
|
1750
|
+
/** Correlates with the AUTHORITY_ACCESS requestId. */
|
|
1751
|
+
requestId: string;
|
|
1752
|
+
/** Robot Registration Number of the responding robot. */
|
|
1753
|
+
rrn: string;
|
|
1754
|
+
/** Unix timestamp when the data was packaged. */
|
|
1755
|
+
providedAt: number;
|
|
1756
|
+
/** Provided audit data. */
|
|
1757
|
+
data: AuthorityResponseData;
|
|
1758
|
+
}
|
|
1759
|
+
/** Convert AuthorityAccessPayload to/from snake_case wire format. */
|
|
1760
|
+
interface AuthorityAccessPayloadWire {
|
|
1761
|
+
request_id: string;
|
|
1762
|
+
authority_id: string;
|
|
1763
|
+
requested_data: AuthorityDataCategory[];
|
|
1764
|
+
justification: string;
|
|
1765
|
+
expires_at: number;
|
|
1766
|
+
}
|
|
1767
|
+
declare function authorityAccessToWire(p: AuthorityAccessPayload): AuthorityAccessPayloadWire;
|
|
1768
|
+
declare function authorityAccessFromWire(w: AuthorityAccessPayloadWire): AuthorityAccessPayload;
|
|
1769
|
+
/**
|
|
1770
|
+
* Validate an authority access payload.
|
|
1771
|
+
* Returns an array of error strings (empty = valid).
|
|
1772
|
+
*/
|
|
1773
|
+
declare function validateAuthorityAccess(p: AuthorityAccessPayload): string[];
|
|
1774
|
+
/** Return true if an AUTHORITY_ACCESS request is still within its deadline. */
|
|
1775
|
+
declare function isAuthorityRequestValid(p: AuthorityAccessPayload): boolean;
|
|
1776
|
+
declare const AUTHORITY_ERROR_CODES: {
|
|
1777
|
+
readonly NOT_RECOGNIZED: "AUTHORITY_NOT_RECOGNIZED";
|
|
1778
|
+
readonly REQUEST_EXPIRED: "AUTHORITY_REQUEST_EXPIRED";
|
|
1779
|
+
readonly INVALID_TOKEN: "AUTHORITY_INVALID_TOKEN";
|
|
1780
|
+
readonly RATE_LIMITED: "AUTHORITY_RATE_LIMITED";
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1783
|
+
declare const RRF_REVOCATION_URL = "https://api.rrf.rcan.dev/v2/revocations";
|
|
1784
|
+
declare const M2M_TRUSTED_ISSUER = "rrf.rcan.dev";
|
|
1785
|
+
/** Revocation cache TTL in milliseconds (≤ 60 s per spec). */
|
|
1786
|
+
declare const RRF_REVOCATION_CACHE_TTL_MS = 55000;
|
|
1787
|
+
/** Parsed claims from an M2M_PEER JWT. */
|
|
1788
|
+
interface M2MPeerClaims {
|
|
1789
|
+
/** Subject RRN of the peer robot. */
|
|
1790
|
+
sub: string;
|
|
1791
|
+
/** The robot this peer is authorized to command. */
|
|
1792
|
+
peerRrn: string;
|
|
1793
|
+
/** Authorized scopes. */
|
|
1794
|
+
scopes: string[];
|
|
1795
|
+
/** Unix expiry timestamp. */
|
|
1796
|
+
exp: number;
|
|
1797
|
+
/** Issuing principal (ADMIN or CREATOR RRN). */
|
|
1798
|
+
iss: string;
|
|
1799
|
+
}
|
|
1800
|
+
/** Parsed claims from an M2M_TRUSTED JWT (RRF-issued). */
|
|
1801
|
+
interface M2MTrustedClaims {
|
|
1802
|
+
/** Orchestrator identifier (not a robot RRN). */
|
|
1803
|
+
sub: string;
|
|
1804
|
+
/** Explicit allowlist of robots this token may command. */
|
|
1805
|
+
fleetRrns: string[];
|
|
1806
|
+
/** Must include "fleet.trusted". */
|
|
1807
|
+
scopes: string[];
|
|
1808
|
+
/** Unix expiry timestamp (max 24 h from issuance). */
|
|
1809
|
+
exp: number;
|
|
1810
|
+
/** Must be "rrf.rcan.dev". */
|
|
1811
|
+
iss: string;
|
|
1812
|
+
/** RRF Ed25519 signature over claims (base64url). */
|
|
1813
|
+
rrfSig: string;
|
|
1814
|
+
}
|
|
1815
|
+
/** Thrown when M2M token verification fails. */
|
|
1816
|
+
declare class M2MAuthError extends Error {
|
|
1817
|
+
constructor(message: string);
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Parse an M2M_PEER JWT without signature verification.
|
|
1821
|
+
* Validates expiry and required claims.
|
|
1822
|
+
*/
|
|
1823
|
+
declare function parseM2mPeerToken(token: string): M2MPeerClaims;
|
|
1824
|
+
/**
|
|
1825
|
+
* Parse an M2M_TRUSTED JWT claims WITHOUT signature verification.
|
|
1826
|
+
*
|
|
1827
|
+
* Checks issuer, scope, and expiry. Does not contact RRF.
|
|
1828
|
+
* For full verification use `verifyM2mTrustedTokenClaims`.
|
|
1829
|
+
*/
|
|
1830
|
+
declare function parseM2mTrustedToken(token: string): M2MTrustedClaims;
|
|
1831
|
+
/**
|
|
1832
|
+
* Verify M2M_TRUSTED token claims and check that it authorizes `targetRrn`.
|
|
1833
|
+
*
|
|
1834
|
+
* This method validates claims structure only (no RRF network call).
|
|
1835
|
+
* In production, also check the RRF revocation list with `RRFRevocationCache`.
|
|
1836
|
+
*/
|
|
1837
|
+
declare function verifyM2mTrustedTokenClaims(token: string, targetRrn: string): M2MTrustedClaims;
|
|
1838
|
+
interface RevocationCache {
|
|
1839
|
+
revokedOrchestrators: Set<string>;
|
|
1840
|
+
revokedJtis: Set<string>;
|
|
1841
|
+
fetchedAt: number;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Fetch the RRF revocation list and cache it.
|
|
1845
|
+
*
|
|
1846
|
+
* Uses `fetch()` (available in Node 18+ and all modern browsers).
|
|
1847
|
+
* TTL: 55 s (spec max: 60 s).
|
|
1848
|
+
*/
|
|
1849
|
+
declare function fetchRRFRevocations(url?: string): Promise<RevocationCache>;
|
|
1850
|
+
/**
|
|
1851
|
+
* Check whether an M2M_TRUSTED orchestrator sub is revoked.
|
|
1852
|
+
* Fetches the revocation list if the cache is stale.
|
|
1853
|
+
*/
|
|
1854
|
+
declare function isM2mTrustedRevoked(claims: M2MTrustedClaims, jti?: string): Promise<boolean>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Full async M2M_TRUSTED verification: claims check + revocation list.
|
|
1857
|
+
*
|
|
1858
|
+
* Note: Signature verification requires the RRF public key and is typically
|
|
1859
|
+
* done server-side using the rcan-py SDK or castor.auth middleware.
|
|
1860
|
+
*/
|
|
1861
|
+
declare function verifyM2mTrustedToken(token: string, targetRrn: string, options?: {
|
|
1862
|
+
skipRevocationCheck?: boolean;
|
|
1863
|
+
}): Promise<M2MTrustedClaims>;
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* RCAN v2.2 Post-Quantum Hybrid Signing — ML-DSA-65 (NIST FIPS 204)
|
|
1867
|
+
*
|
|
1868
|
+
* Provides MLDSAKeyPair for post-quantum signing alongside the existing
|
|
1869
|
+
* Ed25519 SignatureBlock. In hybrid mode a message carries both:
|
|
1870
|
+
* - `signature` — Ed25519 SignatureBlock (backward-compat with v2.1)
|
|
1871
|
+
* - `pqSig` — MLDSASignatureBlock (new in v2.2)
|
|
1872
|
+
*
|
|
1873
|
+
* Key sizes (ML-DSA-65, NIST security level 3):
|
|
1874
|
+
* Public key: 1952 bytes
|
|
1875
|
+
* Private key: 4032 bytes
|
|
1876
|
+
* Signature: 3309 bytes
|
|
1877
|
+
*
|
|
1878
|
+
* Requires: @noble/post-quantum (npm install @noble/post-quantum)
|
|
1879
|
+
*
|
|
1880
|
+
* Spec: https://rcan.dev/spec#section-7-2
|
|
1881
|
+
*/
|
|
1882
|
+
|
|
1883
|
+
/** @deprecated use PQSignatureBlock */
|
|
1884
|
+
type MLDSASignatureBlock = PQSignatureBlock;
|
|
1885
|
+
interface MLDSAKeyPairData {
|
|
1886
|
+
/** Public key bytes (1952 bytes) */
|
|
1887
|
+
publicKey: Uint8Array;
|
|
1888
|
+
/** Private key bytes (4032 bytes). Absent for verify-only key pairs. */
|
|
1889
|
+
secretKey?: Uint8Array;
|
|
1890
|
+
/** 8-char hex key ID */
|
|
1891
|
+
keyId: string;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* An ML-DSA-65 (CRYSTALS-Dilithium, NIST FIPS 204) key pair.
|
|
1895
|
+
*
|
|
1896
|
+
* Immutable value object. Build via {@link MLDSAKeyPair.generate} or
|
|
1897
|
+
* {@link MLDSAKeyPair.fromPublicKey}.
|
|
1898
|
+
*/
|
|
1899
|
+
declare class MLDSAKeyPair {
|
|
1900
|
+
readonly keyId: string;
|
|
1901
|
+
readonly publicKey: Uint8Array;
|
|
1902
|
+
readonly secretKey: Uint8Array | undefined;
|
|
1903
|
+
private constructor();
|
|
1904
|
+
/** Generate a new ML-DSA-65 key pair. */
|
|
1905
|
+
static generate(): Promise<MLDSAKeyPair>;
|
|
1906
|
+
/** Build a verify-only key pair from raw public key bytes. */
|
|
1907
|
+
static fromPublicKey(publicKey: Uint8Array): Promise<MLDSAKeyPair>;
|
|
1908
|
+
/** Build a full key pair from saved bytes (public + secret). */
|
|
1909
|
+
static fromKeyMaterial(publicKey: Uint8Array, secretKey: Uint8Array): Promise<MLDSAKeyPair>;
|
|
1910
|
+
get hasPrivateKey(): boolean;
|
|
1911
|
+
/** Sign raw bytes; returns ML-DSA-65 signature (3309 bytes). */
|
|
1912
|
+
signBytes(data: Uint8Array): Promise<Uint8Array>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Verify an ML-DSA-65 signature.
|
|
1915
|
+
* @returns true if valid
|
|
1916
|
+
* @throws {Error} on invalid signature
|
|
1917
|
+
*/
|
|
1918
|
+
verifyBytes(data: Uint8Array, signature: Uint8Array): Promise<void>;
|
|
1919
|
+
toString(): string;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Add an ML-DSA-65 signature (`pqSig`) to an RCAN message.
|
|
1923
|
+
*
|
|
1924
|
+
* This is the v2.2 hybrid complement to the existing Ed25519 signature.
|
|
1925
|
+
* Call {@link signMessageEd25519} (or the existing signing path) first to set
|
|
1926
|
+
* `signature`, then call this to append `pqSig`.
|
|
1927
|
+
*
|
|
1928
|
+
* @param msg RCAN message (mutated in place — sets `pqSig`)
|
|
1929
|
+
* @param keypair ML-DSA-65 key pair with private key
|
|
1930
|
+
* @returns The same message cast to include `pqSig`
|
|
1931
|
+
*/
|
|
1932
|
+
declare function addPQSignature(msg: RCANMessage, keypair: MLDSAKeyPair): Promise<RCANMessage>;
|
|
1933
|
+
/**
|
|
1934
|
+
* Verify the ML-DSA-65 signature (`pqSig`) on an RCAN message.
|
|
1935
|
+
*
|
|
1936
|
+
* @param msg Message with a `pqSig` field
|
|
1937
|
+
* @param trustedKeys Trusted ML-DSA public key pairs
|
|
1938
|
+
* @param requirePQ If true, raise when `pqSig` is absent (for post-2028 hard mode)
|
|
1939
|
+
*/
|
|
1940
|
+
declare function verifyPQSignature(msg: RCANMessage, trustedKeys: MLDSAKeyPair[], requirePQ?: boolean): Promise<void>;
|
|
1941
|
+
|
|
1499
1942
|
/**
|
|
1500
1943
|
* rcan-ts — Official TypeScript SDK for RCAN v1.6
|
|
1501
1944
|
* Robot Communication and Accountability Network
|
|
@@ -1508,4 +1951,4 @@ declare const VERSION = "0.6.0";
|
|
|
1508
1951
|
/** @deprecated Use SPEC_VERSION from ./version instead */
|
|
1509
1952
|
declare const RCAN_VERSION = "1.6";
|
|
1510
1953
|
|
|
1511
|
-
export { type ApprovalStatus, AuditChain, AuditError, type AuditExportRequest, CONTRIBUTE_SCOPE_LEVEL, type CachedKey, type ChainVerifyResult, ClockDriftError, type ClockSyncStatus, CommitmentRecord, type CommitmentRecordData, type CommitmentRecordJSON, type ComputeResource, ConfidenceGate, type ConsentRequestParams, type ConsentResponseParams, type ConsentType, type ContributeCancel, type ContributeRequest, type ContributeResult, DEFAULT_LOA_POLICY, DataCategory, type DelegationHop, FaultCode, type FaultReportParams, type FaultSeverity, type FederationSyncPayload, FederationSyncType, GateError, HiTLGate, type JWKEntry, type JWKSDocument, KeyStore, LevelOfAssurance, type ListResult, type LoaPolicy, type MediaChunk, MediaEncoding, MessageType, NodeClient, type OfflineCommandResult, OfflineModeManager, type OfflineState, PRODUCTION_LOA_POLICY, type PendingApproval, QoSAckTimeoutError, QoSLevel, QoSManager, type QoSResult, type QoSSendOptions, RCANAddressError, type RCANAgentConfig, type RCANConfig, RCANConfigAuthorizationError, RCANDelegationChainError, RCANError, RCANGateError, RCANMessage, type RCANMessageData, type RCANMessageEnvelope, RCANMessageError, type RCANMetadata, RCANNodeError, RCANNodeNotFoundError, RCANNodeSyncError, RCANNodeTrustError, RCANRegistryError, type RCANRegistryNode, RCANReplayAttackError, type RCANResolveResult, RCANSignatureError, RCANValidationError, RCANVersionIncompatibleError, RCAN_VERSION, type RegistrationResult, RegistryClient, type RegistryIdentity, RegistryTier, ReplayCache, type ReplayCheckResult, type ReplayableMessage, RevocationCache, type RevocationStatus, type RevocationStatusValue, type Robot, type RobotRegistration, RobotURI, RobotURIError, type RobotURIOptions, SAFETY_MESSAGE_TYPE, SDK_VERSION, SPEC_VERSION, type SafetyEvent, type SafetyMessage, type SenderType, type SignatureBlock, type StreamChunk, type TrainingConsentRequestParams, type TransparencyMessage, TransportEncoding, TransportError, TrustAnchorCache, VERSION, type ValidationResult, type WorkUnitStatus, addDelegationHop, addMediaInline, addMediaRef, assertClockSynced, checkClockSync, checkRevocation, decodeBleFrames, decodeCompact, decodeMinimal, encodeBleFrames, encodeCompact, encodeMinimal, extractLoaFromJwt, fetchCanonicalSchema, isPreemptedBy, isSafetyMessage, makeCloudRelayMessage, makeConfigUpdate, makeConsentDeny, makeConsentGrant, makeConsentRequest, makeContributeCancel, makeContributeRequest, makeContributeResult, makeEstopMessage, makeEstopWithQoS, makeFaultReport, makeFederationSync, makeKeyRotationMessage, makeResumeMessage, makeRevocationBroadcast, makeStopMessage, makeStreamChunk, makeTrainingConsentDeny, makeTrainingConsentGrant, makeTrainingConsentRequest, makeTrainingDataMessage, makeTransparencyMessage, selectTransport, validateConfig, validateConfigAgainstSchema, validateConfigUpdate, validateConsentMessage, validateContributeScope, validateCrossRegistryCommand, validateDelegationChain, validateLoaForScope, validateMediaChunks, validateMessage, validateNodeAgainstSchema, validateReplay, validateSafetyMessage, validateTrainingDataMessage, validateURI, validateVersionCompat };
|
|
1954
|
+
export { AUTHORITY_ERROR_CODES, type ApprovalStatus, AuditChain, AuditError, type AuditExportRequest, type AuthorityAccessPayload, type AuthorityAccessPayloadWire, type AuthorityDataCategory, type AuthorityResponseData, type AuthorityResponsePayload, COMPETITION_SCOPE_LEVEL, CONTRIBUTE_SCOPE_LEVEL, type CachedKey, type ChainVerifyResult, ClockDriftError, type ClockSyncStatus, CommitmentRecord, type CommitmentRecordData, type CommitmentRecordJSON, type CompetitionBadge, type CompetitionEnter, type CompetitionFormat, type CompetitionScore, type ComputeResource, ConfidenceGate, type ConsentRequestParams, type ConsentResponseParams, type ConsentType, type ContributeCancel, type ContributeRequest, type ContributeResult, DEFAULT_LOA_POLICY, DataCategory, type DelegationHop, FIRMWARE_MANIFEST_PATH, FaultCode, type FaultReportParams, type FaultSeverity, type FederationSyncPayload, FederationSyncType, type FirmwareComponent, FirmwareIntegrityError, type FirmwareManifest, type FirmwareManifestWire, GateError, HiTLGate, type IdentityRecord, type JWKEntry, type JWKSDocument, KeyStore, LevelOfAssurance, type ListResult, type LoaPolicy, M2MAuthError, type M2MPeerClaims, type M2MTrustedClaims, M2M_TRUSTED_ISSUER, MLDSAKeyPair, type MLDSAKeyPairData, type MLDSASignatureBlock, type MediaChunk, MediaEncoding, MessageType, NodeClient, type OfflineCommandResult, OfflineModeManager, type OfflineState, PRODUCTION_LOA_POLICY, type PendingApproval, type PersonalResearchResult, QoSAckTimeoutError, QoSLevel, QoSManager, type QoSResult, type QoSSendOptions, RCANAddressError, type RCANAgentConfig, type RCANConfig, RCANConfigAuthorizationError, RCANDelegationChainError, RCANError, RCANGateError, RCANMessage, type RCANMessageData, type RCANMessageEnvelope, RCANMessageError, type RCANMetadata, RCANNodeError, RCANNodeNotFoundError, RCANNodeSyncError, RCANNodeTrustError, RCANRegistryError, type RCANRegistryNode, RCANReplayAttackError, type RCANResolveResult, RCANSignatureError, RCANValidationError, RCANVersionIncompatibleError, RCAN_VERSION, ROLE_JWT_LEVEL, RRF_REVOCATION_CACHE_TTL_MS, RRF_REVOCATION_URL, type RegistrationResult, RegistryClient, type RegistryIdentity, RegistryTier, ReplayCache, type ReplayCheckResult, type ReplayableMessage, type ResearchMetrics, RevocationCache$1 as RevocationCache, type RevocationStatus, type RevocationStatusValue, type Robot, type RobotRegistration, RobotURI, RobotURIError, type RobotURIOptions, Role, type RunType, SAFETY_MESSAGE_TYPE, SCOPE_MIN_ROLE, SDK_VERSION, SPEC_VERSION, type SafetyEvent, type SafetyMessage, type ScopeValidationResult, type SeasonStanding, type SenderType, type SignatureBlock, type StandingEntry, type StreamChunk, type TrainingConsentRequestParams, type TransparencyMessage, TransportEncoding, TransportError, TrustAnchorCache, VERSION, type ValidationResult, type WorkUnitStatus, addDelegationHop, addMediaInline, addMediaRef, addPQSignature, assertClockSynced, authorityAccessFromWire, authorityAccessToWire, canonicalManifestJson, checkClockSync, checkRevocation, decodeBleFrames, decodeCompact, decodeMinimal, encodeBleFrames, encodeCompact, encodeMinimal, extractIdentityFromJwt, extractLoaFromJwt, extractRoleFromJwt, fetchCanonicalSchema, fetchRRFRevocations, isAuthorityRequestValid, isM2mTrustedRevoked, isPreemptedBy, isSafetyMessage, makeCloudRelayMessage, makeCompetitionEnter, makeCompetitionScore, makeConfigUpdate, makeConsentDeny, makeConsentGrant, makeConsentRequest, makeContributeCancel, makeContributeRequest, makeContributeResult, makeEstopMessage, makeEstopWithQoS, makeFaultReport, makeFederationSync, makeKeyRotationMessage, makePersonalResearchResult, makeResumeMessage, makeRevocationBroadcast, makeSeasonStanding, makeStopMessage, makeStreamChunk, makeTrainingConsentDeny, makeTrainingConsentGrant, makeTrainingConsentRequest, makeTrainingDataMessage, makeTransparencyMessage, manifestFromWire, manifestToWire, parseM2mPeerToken, parseM2mTrustedToken, roleFromJwtLevel, selectTransport, validateAuthorityAccess, validateCompetitionScope, validateConfig, validateConfigAgainstSchema, validateConfigUpdate, validateConsentMessage, validateContributeScope, validateCrossRegistryCommand, validateDelegationChain, validateLoaForScope, validateManifest, validateMediaChunks, validateMessage, validateNodeAgainstSchema, validateReplay, validateRoleForScope, validateSafetyMessage, validateTrainingDataMessage, validateURI, validateVersionCompat, verifyM2mTrustedToken, verifyM2mTrustedTokenClaims, verifyPQSignature };
|