@continuonai/rcan-ts 0.6.0 → 0.8.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 +90 -182
- package/dist/browser.d.mts +90 -14
- package/dist/browser.mjs +102 -19
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +90 -14
- package/dist/index.d.ts +90 -14
- package/dist/index.js +118 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -19
- package/dist/index.mjs.map +1 -1
- package/dist/rcan-validate.js +1 -1
- package/dist/rcan.iife.js +3 -3
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -56,18 +56,18 @@ declare enum MessageType {
|
|
|
56
56
|
HEARTBEAT = 4,
|
|
57
57
|
CONFIG = 5,
|
|
58
58
|
SAFETY = 6,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
AUTH = 7,
|
|
60
|
+
ERROR = 8,
|
|
61
61
|
DISCOVER = 9,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
PENDING_AUTH = 10,
|
|
63
|
+
INVOKE = 11,
|
|
64
|
+
INVOKE_RESULT = 12,
|
|
65
|
+
INVOKE_CANCEL = 13,
|
|
66
|
+
REGISTRY_REGISTER = 14,
|
|
67
|
+
REGISTRY_RESOLVE = 15,
|
|
68
|
+
TRANSPARENCY = 16,// EU AI Act Art. 13 audit record
|
|
69
69
|
COMMAND_ACK = 17,
|
|
70
|
-
|
|
70
|
+
COMMAND_NACK = 18,
|
|
71
71
|
ROBOT_REVOCATION = 19,
|
|
72
72
|
CONSENT_REQUEST = 20,
|
|
73
73
|
CONSENT_GRANT = 21,
|
|
@@ -76,7 +76,22 @@ declare enum MessageType {
|
|
|
76
76
|
SUBSCRIBE = 24,
|
|
77
77
|
UNSUBSCRIBE = 25,
|
|
78
78
|
FAULT_REPORT = 26,
|
|
79
|
-
|
|
79
|
+
KEY_ROTATION = 27,
|
|
80
|
+
COMMAND_COMMIT = 28,
|
|
81
|
+
SENSOR_DATA = 29,
|
|
82
|
+
TRAINING_CONSENT_REQUEST = 30,
|
|
83
|
+
TRAINING_CONSENT_GRANT = 31,
|
|
84
|
+
TRAINING_CONSENT_DENY = 32,
|
|
85
|
+
CONTRIBUTE_REQUEST = 33,
|
|
86
|
+
CONTRIBUTE_RESULT = 34,
|
|
87
|
+
CONTRIBUTE_CANCEL = 35,
|
|
88
|
+
TRAINING_DATA = 36,
|
|
89
|
+
/** @deprecated Use FLEET_COMMAND (23) */
|
|
90
|
+
FEDERATION_SYNC = 23,
|
|
91
|
+
/** @deprecated Use FAULT_REPORT (26) */
|
|
92
|
+
ALERT = 26,
|
|
93
|
+
/** @deprecated Use TRANSPARENCY (16) */
|
|
94
|
+
AUDIT = 16
|
|
80
95
|
}
|
|
81
96
|
/** §8.5 — Sender Type and Service Identity */
|
|
82
97
|
type SenderType = "robot" | "human" | "cloud_function" | "system";
|
|
@@ -726,9 +741,9 @@ declare function makeTransparencyMessage(ruri: string, disclosure: string, deleg
|
|
|
726
741
|
* §3.5 — Protocol Version Compatibility
|
|
727
742
|
*/
|
|
728
743
|
/** The RCAN spec version this SDK implements. */
|
|
729
|
-
declare const SPEC_VERSION = "1.
|
|
744
|
+
declare const SPEC_VERSION = "1.9.0";
|
|
730
745
|
/** The SDK release version. */
|
|
731
|
-
declare const SDK_VERSION = "0.
|
|
746
|
+
declare const SDK_VERSION = "0.8.0";
|
|
732
747
|
/**
|
|
733
748
|
* Validate version compatibility.
|
|
734
749
|
*
|
|
@@ -1420,6 +1435,67 @@ declare function makeTrainingDataMessage(media: Array<{
|
|
|
1420
1435
|
*/
|
|
1421
1436
|
declare function makeStreamChunk(streamId: string, data: Uint8Array, mimeType: string, chunkIndex: number, isFinal: boolean): Promise<RCANMessage>;
|
|
1422
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* rcan/contribute — Idle Compute Contribution messages and scope.
|
|
1440
|
+
*
|
|
1441
|
+
* Implements the contribute scope and message types for RCAN v1.7+.
|
|
1442
|
+
* Robots can donate idle NPU/GPU/CPU compute to distributed science projects.
|
|
1443
|
+
*
|
|
1444
|
+
* Spec: §3 MessageTypes 33–35, Identity scope level 2.5
|
|
1445
|
+
*/
|
|
1446
|
+
|
|
1447
|
+
/** Contribute scope level — between chat (2) and control (3). */
|
|
1448
|
+
declare const CONTRIBUTE_SCOPE_LEVEL = 2.5;
|
|
1449
|
+
type WorkUnitStatus = "pending" | "running" | "completed" | "failed" | "cancelled" | "preempted";
|
|
1450
|
+
type ComputeResource = "npu" | "gpu" | "cpu" | "sensor";
|
|
1451
|
+
interface ContributeRequest {
|
|
1452
|
+
type: typeof MessageType.CONTRIBUTE_REQUEST;
|
|
1453
|
+
request_id: string;
|
|
1454
|
+
project_id: string;
|
|
1455
|
+
project_name: string;
|
|
1456
|
+
work_unit_id: string;
|
|
1457
|
+
resource_type: ComputeResource;
|
|
1458
|
+
estimated_duration_s: number;
|
|
1459
|
+
priority: number;
|
|
1460
|
+
payload: Record<string, unknown>;
|
|
1461
|
+
timestamp: number;
|
|
1462
|
+
}
|
|
1463
|
+
interface ContributeResult {
|
|
1464
|
+
type: typeof MessageType.CONTRIBUTE_RESULT;
|
|
1465
|
+
request_id: string;
|
|
1466
|
+
work_unit_id: string;
|
|
1467
|
+
status: WorkUnitStatus;
|
|
1468
|
+
resource_type: ComputeResource;
|
|
1469
|
+
duration_s: number;
|
|
1470
|
+
compute_units: number;
|
|
1471
|
+
result_payload: Record<string, unknown>;
|
|
1472
|
+
error_message?: string;
|
|
1473
|
+
timestamp: number;
|
|
1474
|
+
}
|
|
1475
|
+
interface ContributeCancel {
|
|
1476
|
+
type: typeof MessageType.CONTRIBUTE_CANCEL;
|
|
1477
|
+
request_id: string;
|
|
1478
|
+
work_unit_id: string;
|
|
1479
|
+
reason: string;
|
|
1480
|
+
timestamp: number;
|
|
1481
|
+
}
|
|
1482
|
+
declare function makeContributeRequest(params?: Partial<Omit<ContributeRequest, "type">>): ContributeRequest;
|
|
1483
|
+
declare function makeContributeResult(params?: Partial<Omit<ContributeResult, "type">>): ContributeResult;
|
|
1484
|
+
declare function makeContributeCancel(params?: Partial<Omit<ContributeCancel, "type">>): ContributeCancel;
|
|
1485
|
+
/**
|
|
1486
|
+
* Check if the given scope level permits contribute operations.
|
|
1487
|
+
*
|
|
1488
|
+
* Contribute requires scope >= 2.5 (between chat and control).
|
|
1489
|
+
*/
|
|
1490
|
+
declare function validateContributeScope(scopeLevel: number, action?: "request" | "result" | "cancel"): boolean;
|
|
1491
|
+
/**
|
|
1492
|
+
* Check if the given scope level preempts contribution.
|
|
1493
|
+
*
|
|
1494
|
+
* Any scope >= control (3.0) preempts contribute immediately.
|
|
1495
|
+
* This is the P66 safety invariant — non-negotiable.
|
|
1496
|
+
*/
|
|
1497
|
+
declare function isPreemptedBy(scopeLevel: number): boolean;
|
|
1498
|
+
|
|
1423
1499
|
/**
|
|
1424
1500
|
* rcan-ts — Official TypeScript SDK for RCAN v1.6
|
|
1425
1501
|
* Robot Communication and Accountability Network
|
|
@@ -1432,4 +1508,4 @@ declare const VERSION = "0.6.0";
|
|
|
1432
1508
|
/** @deprecated Use SPEC_VERSION from ./version instead */
|
|
1433
1509
|
declare const RCAN_VERSION = "1.6";
|
|
1434
1510
|
|
|
1435
|
-
export { type ApprovalStatus, AuditChain, AuditError, type AuditExportRequest, type CachedKey, type ChainVerifyResult, ClockDriftError, type ClockSyncStatus, CommitmentRecord, type CommitmentRecordData, type CommitmentRecordJSON, ConfidenceGate, type ConsentRequestParams, type ConsentResponseParams, type ConsentType, 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, addDelegationHop, addMediaInline, addMediaRef, assertClockSynced, checkClockSync, checkRevocation, decodeBleFrames, decodeCompact, decodeMinimal, encodeBleFrames, encodeCompact, encodeMinimal, extractLoaFromJwt, fetchCanonicalSchema, isSafetyMessage, makeCloudRelayMessage, makeConfigUpdate, makeConsentDeny, makeConsentGrant, makeConsentRequest, makeEstopMessage, makeEstopWithQoS, makeFaultReport, makeFederationSync, makeKeyRotationMessage, makeResumeMessage, makeRevocationBroadcast, makeStopMessage, makeStreamChunk, makeTrainingConsentDeny, makeTrainingConsentGrant, makeTrainingConsentRequest, makeTrainingDataMessage, makeTransparencyMessage, selectTransport, validateConfig, validateConfigAgainstSchema, validateConfigUpdate, validateConsentMessage, validateCrossRegistryCommand, validateDelegationChain, validateLoaForScope, validateMediaChunks, validateMessage, validateNodeAgainstSchema, validateReplay, validateSafetyMessage, validateTrainingDataMessage, validateURI, validateVersionCompat };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,18 +56,18 @@ declare enum MessageType {
|
|
|
56
56
|
HEARTBEAT = 4,
|
|
57
57
|
CONFIG = 5,
|
|
58
58
|
SAFETY = 6,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
AUTH = 7,
|
|
60
|
+
ERROR = 8,
|
|
61
61
|
DISCOVER = 9,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
PENDING_AUTH = 10,
|
|
63
|
+
INVOKE = 11,
|
|
64
|
+
INVOKE_RESULT = 12,
|
|
65
|
+
INVOKE_CANCEL = 13,
|
|
66
|
+
REGISTRY_REGISTER = 14,
|
|
67
|
+
REGISTRY_RESOLVE = 15,
|
|
68
|
+
TRANSPARENCY = 16,// EU AI Act Art. 13 audit record
|
|
69
69
|
COMMAND_ACK = 17,
|
|
70
|
-
|
|
70
|
+
COMMAND_NACK = 18,
|
|
71
71
|
ROBOT_REVOCATION = 19,
|
|
72
72
|
CONSENT_REQUEST = 20,
|
|
73
73
|
CONSENT_GRANT = 21,
|
|
@@ -76,7 +76,22 @@ declare enum MessageType {
|
|
|
76
76
|
SUBSCRIBE = 24,
|
|
77
77
|
UNSUBSCRIBE = 25,
|
|
78
78
|
FAULT_REPORT = 26,
|
|
79
|
-
|
|
79
|
+
KEY_ROTATION = 27,
|
|
80
|
+
COMMAND_COMMIT = 28,
|
|
81
|
+
SENSOR_DATA = 29,
|
|
82
|
+
TRAINING_CONSENT_REQUEST = 30,
|
|
83
|
+
TRAINING_CONSENT_GRANT = 31,
|
|
84
|
+
TRAINING_CONSENT_DENY = 32,
|
|
85
|
+
CONTRIBUTE_REQUEST = 33,
|
|
86
|
+
CONTRIBUTE_RESULT = 34,
|
|
87
|
+
CONTRIBUTE_CANCEL = 35,
|
|
88
|
+
TRAINING_DATA = 36,
|
|
89
|
+
/** @deprecated Use FLEET_COMMAND (23) */
|
|
90
|
+
FEDERATION_SYNC = 23,
|
|
91
|
+
/** @deprecated Use FAULT_REPORT (26) */
|
|
92
|
+
ALERT = 26,
|
|
93
|
+
/** @deprecated Use TRANSPARENCY (16) */
|
|
94
|
+
AUDIT = 16
|
|
80
95
|
}
|
|
81
96
|
/** §8.5 — Sender Type and Service Identity */
|
|
82
97
|
type SenderType = "robot" | "human" | "cloud_function" | "system";
|
|
@@ -726,9 +741,9 @@ declare function makeTransparencyMessage(ruri: string, disclosure: string, deleg
|
|
|
726
741
|
* §3.5 — Protocol Version Compatibility
|
|
727
742
|
*/
|
|
728
743
|
/** The RCAN spec version this SDK implements. */
|
|
729
|
-
declare const SPEC_VERSION = "1.
|
|
744
|
+
declare const SPEC_VERSION = "1.9.0";
|
|
730
745
|
/** The SDK release version. */
|
|
731
|
-
declare const SDK_VERSION = "0.
|
|
746
|
+
declare const SDK_VERSION = "0.8.0";
|
|
732
747
|
/**
|
|
733
748
|
* Validate version compatibility.
|
|
734
749
|
*
|
|
@@ -1420,6 +1435,67 @@ declare function makeTrainingDataMessage(media: Array<{
|
|
|
1420
1435
|
*/
|
|
1421
1436
|
declare function makeStreamChunk(streamId: string, data: Uint8Array, mimeType: string, chunkIndex: number, isFinal: boolean): Promise<RCANMessage>;
|
|
1422
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* rcan/contribute — Idle Compute Contribution messages and scope.
|
|
1440
|
+
*
|
|
1441
|
+
* Implements the contribute scope and message types for RCAN v1.7+.
|
|
1442
|
+
* Robots can donate idle NPU/GPU/CPU compute to distributed science projects.
|
|
1443
|
+
*
|
|
1444
|
+
* Spec: §3 MessageTypes 33–35, Identity scope level 2.5
|
|
1445
|
+
*/
|
|
1446
|
+
|
|
1447
|
+
/** Contribute scope level — between chat (2) and control (3). */
|
|
1448
|
+
declare const CONTRIBUTE_SCOPE_LEVEL = 2.5;
|
|
1449
|
+
type WorkUnitStatus = "pending" | "running" | "completed" | "failed" | "cancelled" | "preempted";
|
|
1450
|
+
type ComputeResource = "npu" | "gpu" | "cpu" | "sensor";
|
|
1451
|
+
interface ContributeRequest {
|
|
1452
|
+
type: typeof MessageType.CONTRIBUTE_REQUEST;
|
|
1453
|
+
request_id: string;
|
|
1454
|
+
project_id: string;
|
|
1455
|
+
project_name: string;
|
|
1456
|
+
work_unit_id: string;
|
|
1457
|
+
resource_type: ComputeResource;
|
|
1458
|
+
estimated_duration_s: number;
|
|
1459
|
+
priority: number;
|
|
1460
|
+
payload: Record<string, unknown>;
|
|
1461
|
+
timestamp: number;
|
|
1462
|
+
}
|
|
1463
|
+
interface ContributeResult {
|
|
1464
|
+
type: typeof MessageType.CONTRIBUTE_RESULT;
|
|
1465
|
+
request_id: string;
|
|
1466
|
+
work_unit_id: string;
|
|
1467
|
+
status: WorkUnitStatus;
|
|
1468
|
+
resource_type: ComputeResource;
|
|
1469
|
+
duration_s: number;
|
|
1470
|
+
compute_units: number;
|
|
1471
|
+
result_payload: Record<string, unknown>;
|
|
1472
|
+
error_message?: string;
|
|
1473
|
+
timestamp: number;
|
|
1474
|
+
}
|
|
1475
|
+
interface ContributeCancel {
|
|
1476
|
+
type: typeof MessageType.CONTRIBUTE_CANCEL;
|
|
1477
|
+
request_id: string;
|
|
1478
|
+
work_unit_id: string;
|
|
1479
|
+
reason: string;
|
|
1480
|
+
timestamp: number;
|
|
1481
|
+
}
|
|
1482
|
+
declare function makeContributeRequest(params?: Partial<Omit<ContributeRequest, "type">>): ContributeRequest;
|
|
1483
|
+
declare function makeContributeResult(params?: Partial<Omit<ContributeResult, "type">>): ContributeResult;
|
|
1484
|
+
declare function makeContributeCancel(params?: Partial<Omit<ContributeCancel, "type">>): ContributeCancel;
|
|
1485
|
+
/**
|
|
1486
|
+
* Check if the given scope level permits contribute operations.
|
|
1487
|
+
*
|
|
1488
|
+
* Contribute requires scope >= 2.5 (between chat and control).
|
|
1489
|
+
*/
|
|
1490
|
+
declare function validateContributeScope(scopeLevel: number, action?: "request" | "result" | "cancel"): boolean;
|
|
1491
|
+
/**
|
|
1492
|
+
* Check if the given scope level preempts contribution.
|
|
1493
|
+
*
|
|
1494
|
+
* Any scope >= control (3.0) preempts contribute immediately.
|
|
1495
|
+
* This is the P66 safety invariant — non-negotiable.
|
|
1496
|
+
*/
|
|
1497
|
+
declare function isPreemptedBy(scopeLevel: number): boolean;
|
|
1498
|
+
|
|
1423
1499
|
/**
|
|
1424
1500
|
* rcan-ts — Official TypeScript SDK for RCAN v1.6
|
|
1425
1501
|
* Robot Communication and Accountability Network
|
|
@@ -1432,4 +1508,4 @@ declare const VERSION = "0.6.0";
|
|
|
1432
1508
|
/** @deprecated Use SPEC_VERSION from ./version instead */
|
|
1433
1509
|
declare const RCAN_VERSION = "1.6";
|
|
1434
1510
|
|
|
1435
|
-
export { type ApprovalStatus, AuditChain, AuditError, type AuditExportRequest, type CachedKey, type ChainVerifyResult, ClockDriftError, type ClockSyncStatus, CommitmentRecord, type CommitmentRecordData, type CommitmentRecordJSON, ConfidenceGate, type ConsentRequestParams, type ConsentResponseParams, type ConsentType, 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, addDelegationHop, addMediaInline, addMediaRef, assertClockSynced, checkClockSync, checkRevocation, decodeBleFrames, decodeCompact, decodeMinimal, encodeBleFrames, encodeCompact, encodeMinimal, extractLoaFromJwt, fetchCanonicalSchema, isSafetyMessage, makeCloudRelayMessage, makeConfigUpdate, makeConsentDeny, makeConsentGrant, makeConsentRequest, makeEstopMessage, makeEstopWithQoS, makeFaultReport, makeFederationSync, makeKeyRotationMessage, makeResumeMessage, makeRevocationBroadcast, makeStopMessage, makeStreamChunk, makeTrainingConsentDeny, makeTrainingConsentGrant, makeTrainingConsentRequest, makeTrainingDataMessage, makeTransparencyMessage, selectTransport, validateConfig, validateConfigAgainstSchema, validateConfigUpdate, validateConsentMessage, validateCrossRegistryCommand, validateDelegationChain, validateLoaForScope, validateMediaChunks, validateMessage, validateNodeAgainstSchema, validateReplay, validateSafetyMessage, validateTrainingDataMessage, validateURI, validateVersionCompat };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -22,6 +32,7 @@ var index_exports = {};
|
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
AuditChain: () => AuditChain,
|
|
24
34
|
AuditError: () => AuditError,
|
|
35
|
+
CONTRIBUTE_SCOPE_LEVEL: () => CONTRIBUTE_SCOPE_LEVEL,
|
|
25
36
|
ClockDriftError: () => ClockDriftError,
|
|
26
37
|
CommitmentRecord: () => CommitmentRecord,
|
|
27
38
|
ConfidenceGate: () => ConfidenceGate,
|
|
@@ -85,12 +96,16 @@ __export(index_exports, {
|
|
|
85
96
|
encodeMinimal: () => encodeMinimal,
|
|
86
97
|
extractLoaFromJwt: () => extractLoaFromJwt,
|
|
87
98
|
fetchCanonicalSchema: () => fetchCanonicalSchema,
|
|
99
|
+
isPreemptedBy: () => isPreemptedBy,
|
|
88
100
|
isSafetyMessage: () => isSafetyMessage,
|
|
89
101
|
makeCloudRelayMessage: () => makeCloudRelayMessage,
|
|
90
102
|
makeConfigUpdate: () => makeConfigUpdate,
|
|
91
103
|
makeConsentDeny: () => makeConsentDeny,
|
|
92
104
|
makeConsentGrant: () => makeConsentGrant,
|
|
93
105
|
makeConsentRequest: () => makeConsentRequest,
|
|
106
|
+
makeContributeCancel: () => makeContributeCancel,
|
|
107
|
+
makeContributeRequest: () => makeContributeRequest,
|
|
108
|
+
makeContributeResult: () => makeContributeResult,
|
|
94
109
|
makeEstopMessage: () => makeEstopMessage,
|
|
95
110
|
makeEstopWithQoS: () => makeEstopWithQoS,
|
|
96
111
|
makeFaultReport: () => makeFaultReport,
|
|
@@ -110,6 +125,7 @@ __export(index_exports, {
|
|
|
110
125
|
validateConfigAgainstSchema: () => validateConfigAgainstSchema,
|
|
111
126
|
validateConfigUpdate: () => validateConfigUpdate,
|
|
112
127
|
validateConsentMessage: () => validateConsentMessage,
|
|
128
|
+
validateContributeScope: () => validateContributeScope,
|
|
113
129
|
validateCrossRegistryCommand: () => validateCrossRegistryCommand,
|
|
114
130
|
validateDelegationChain: () => validateDelegationChain,
|
|
115
131
|
validateLoaForScope: () => validateLoaForScope,
|
|
@@ -215,8 +231,8 @@ var RobotURI = class _RobotURI {
|
|
|
215
231
|
};
|
|
216
232
|
|
|
217
233
|
// src/version.ts
|
|
218
|
-
var SPEC_VERSION = "1.
|
|
219
|
-
var SDK_VERSION = "0.
|
|
234
|
+
var SPEC_VERSION = "1.9.0";
|
|
235
|
+
var SDK_VERSION = "0.8.0";
|
|
220
236
|
function validateVersionCompat(incomingVersion, localVersion = SPEC_VERSION) {
|
|
221
237
|
const parseParts = (v) => {
|
|
222
238
|
const parts = v.split(".");
|
|
@@ -237,18 +253,18 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
237
253
|
MessageType2[MessageType2["HEARTBEAT"] = 4] = "HEARTBEAT";
|
|
238
254
|
MessageType2[MessageType2["CONFIG"] = 5] = "CONFIG";
|
|
239
255
|
MessageType2[MessageType2["SAFETY"] = 6] = "SAFETY";
|
|
240
|
-
MessageType2[MessageType2["
|
|
241
|
-
MessageType2[MessageType2["
|
|
256
|
+
MessageType2[MessageType2["AUTH"] = 7] = "AUTH";
|
|
257
|
+
MessageType2[MessageType2["ERROR"] = 8] = "ERROR";
|
|
242
258
|
MessageType2[MessageType2["DISCOVER"] = 9] = "DISCOVER";
|
|
243
|
-
MessageType2[MessageType2["
|
|
244
|
-
MessageType2[MessageType2["
|
|
245
|
-
MessageType2[MessageType2["
|
|
246
|
-
MessageType2[MessageType2["
|
|
247
|
-
MessageType2[MessageType2["
|
|
248
|
-
MessageType2[MessageType2["
|
|
249
|
-
MessageType2[MessageType2["
|
|
259
|
+
MessageType2[MessageType2["PENDING_AUTH"] = 10] = "PENDING_AUTH";
|
|
260
|
+
MessageType2[MessageType2["INVOKE"] = 11] = "INVOKE";
|
|
261
|
+
MessageType2[MessageType2["INVOKE_RESULT"] = 12] = "INVOKE_RESULT";
|
|
262
|
+
MessageType2[MessageType2["INVOKE_CANCEL"] = 13] = "INVOKE_CANCEL";
|
|
263
|
+
MessageType2[MessageType2["REGISTRY_REGISTER"] = 14] = "REGISTRY_REGISTER";
|
|
264
|
+
MessageType2[MessageType2["REGISTRY_RESOLVE"] = 15] = "REGISTRY_RESOLVE";
|
|
265
|
+
MessageType2[MessageType2["TRANSPARENCY"] = 16] = "TRANSPARENCY";
|
|
250
266
|
MessageType2[MessageType2["COMMAND_ACK"] = 17] = "COMMAND_ACK";
|
|
251
|
-
MessageType2[MessageType2["
|
|
267
|
+
MessageType2[MessageType2["COMMAND_NACK"] = 18] = "COMMAND_NACK";
|
|
252
268
|
MessageType2[MessageType2["ROBOT_REVOCATION"] = 19] = "ROBOT_REVOCATION";
|
|
253
269
|
MessageType2[MessageType2["CONSENT_REQUEST"] = 20] = "CONSENT_REQUEST";
|
|
254
270
|
MessageType2[MessageType2["CONSENT_GRANT"] = 21] = "CONSENT_GRANT";
|
|
@@ -257,7 +273,19 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
257
273
|
MessageType2[MessageType2["SUBSCRIBE"] = 24] = "SUBSCRIBE";
|
|
258
274
|
MessageType2[MessageType2["UNSUBSCRIBE"] = 25] = "UNSUBSCRIBE";
|
|
259
275
|
MessageType2[MessageType2["FAULT_REPORT"] = 26] = "FAULT_REPORT";
|
|
260
|
-
MessageType2[MessageType2["
|
|
276
|
+
MessageType2[MessageType2["KEY_ROTATION"] = 27] = "KEY_ROTATION";
|
|
277
|
+
MessageType2[MessageType2["COMMAND_COMMIT"] = 28] = "COMMAND_COMMIT";
|
|
278
|
+
MessageType2[MessageType2["SENSOR_DATA"] = 29] = "SENSOR_DATA";
|
|
279
|
+
MessageType2[MessageType2["TRAINING_CONSENT_REQUEST"] = 30] = "TRAINING_CONSENT_REQUEST";
|
|
280
|
+
MessageType2[MessageType2["TRAINING_CONSENT_GRANT"] = 31] = "TRAINING_CONSENT_GRANT";
|
|
281
|
+
MessageType2[MessageType2["TRAINING_CONSENT_DENY"] = 32] = "TRAINING_CONSENT_DENY";
|
|
282
|
+
MessageType2[MessageType2["CONTRIBUTE_REQUEST"] = 33] = "CONTRIBUTE_REQUEST";
|
|
283
|
+
MessageType2[MessageType2["CONTRIBUTE_RESULT"] = 34] = "CONTRIBUTE_RESULT";
|
|
284
|
+
MessageType2[MessageType2["CONTRIBUTE_CANCEL"] = 35] = "CONTRIBUTE_CANCEL";
|
|
285
|
+
MessageType2[MessageType2["TRAINING_DATA"] = 36] = "TRAINING_DATA";
|
|
286
|
+
MessageType2[MessageType2["FEDERATION_SYNC"] = 23] = "FEDERATION_SYNC";
|
|
287
|
+
MessageType2[MessageType2["ALERT"] = 26] = "ALERT";
|
|
288
|
+
MessageType2[MessageType2["AUDIT"] = 16] = "AUDIT";
|
|
261
289
|
return MessageType2;
|
|
262
290
|
})(MessageType || {});
|
|
263
291
|
var RCANMessageError = class extends Error {
|
|
@@ -1377,6 +1405,7 @@ async function fetchCanonicalSchema(schemaName) {
|
|
|
1377
1405
|
try {
|
|
1378
1406
|
const controller = new AbortController();
|
|
1379
1407
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
1408
|
+
timer.unref?.();
|
|
1380
1409
|
const res = await fetch(`${SCHEMA_BASE}/${schemaName}`, { signal: controller.signal });
|
|
1381
1410
|
clearTimeout(timer);
|
|
1382
1411
|
if (!res.ok) return null;
|
|
@@ -2017,7 +2046,7 @@ function makeTrainingConsentDeny(params) {
|
|
|
2017
2046
|
return makeConsentDeny(params);
|
|
2018
2047
|
}
|
|
2019
2048
|
function validateTrainingDataMessage(msg) {
|
|
2020
|
-
if (msg.params.message_type !==
|
|
2049
|
+
if (msg.params.message_type !== 36 /* TRAINING_DATA */) {
|
|
2021
2050
|
return { valid: false, reason: "not a TRAINING_DATA message" };
|
|
2022
2051
|
}
|
|
2023
2052
|
const token = msg.params.consent_token;
|
|
@@ -2207,6 +2236,9 @@ function minLoaForScope(scope, policy) {
|
|
|
2207
2236
|
return policy.minLoaStatus;
|
|
2208
2237
|
case "chat":
|
|
2209
2238
|
return policy.minLoaChat;
|
|
2239
|
+
case "contribute":
|
|
2240
|
+
return policy.minLoaChat;
|
|
2241
|
+
// v1.7: between chat and control
|
|
2210
2242
|
case "control":
|
|
2211
2243
|
return policy.minLoaControl;
|
|
2212
2244
|
case "safety":
|
|
@@ -2356,7 +2388,7 @@ function makeFederationSync(source, target, syncType, payload) {
|
|
|
2356
2388
|
cmd: "federation_sync",
|
|
2357
2389
|
target,
|
|
2358
2390
|
params: {
|
|
2359
|
-
msg_type:
|
|
2391
|
+
msg_type: 23 /* FEDERATION_SYNC */,
|
|
2360
2392
|
msg_id: generateId5(),
|
|
2361
2393
|
source_registry: source,
|
|
2362
2394
|
target_registry: target,
|
|
@@ -2482,7 +2514,8 @@ async function sha256Bytes(input) {
|
|
|
2482
2514
|
const encoded = new TextEncoder().encode(input);
|
|
2483
2515
|
const ab = new ArrayBuffer(encoded.byteLength);
|
|
2484
2516
|
new Uint8Array(ab).set(encoded);
|
|
2485
|
-
const
|
|
2517
|
+
const subtle = globalThis.crypto?.subtle ?? (await import("crypto")).webcrypto.subtle;
|
|
2518
|
+
const hashBuffer = await subtle.digest("SHA-256", ab);
|
|
2486
2519
|
return new Uint8Array(hashBuffer);
|
|
2487
2520
|
}
|
|
2488
2521
|
async function encodeMinimal(message) {
|
|
@@ -2633,9 +2666,10 @@ function generateId6() {
|
|
|
2633
2666
|
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
2634
2667
|
}
|
|
2635
2668
|
async function computeSha256Hex(data) {
|
|
2669
|
+
const subtle = globalThis.crypto?.subtle ?? (await import("crypto")).webcrypto.subtle;
|
|
2636
2670
|
const ab = new ArrayBuffer(data.byteLength);
|
|
2637
2671
|
new Uint8Array(ab).set(data);
|
|
2638
|
-
const hashBuffer = await
|
|
2672
|
+
const hashBuffer = await subtle.digest("SHA-256", ab);
|
|
2639
2673
|
const hashArray = new Uint8Array(hashBuffer);
|
|
2640
2674
|
return Array.from(hashArray).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2641
2675
|
}
|
|
@@ -2728,7 +2762,7 @@ async function makeTrainingDataMessage(media) {
|
|
|
2728
2762
|
cmd: "training_data",
|
|
2729
2763
|
target: "rcan://training/data",
|
|
2730
2764
|
params: {
|
|
2731
|
-
msg_type:
|
|
2765
|
+
msg_type: 36 /* TRAINING_DATA */,
|
|
2732
2766
|
msg_id: generateId6()
|
|
2733
2767
|
},
|
|
2734
2768
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2761,7 +2795,7 @@ async function makeStreamChunk(streamId, data, mimeType, chunkIndex, isFinal) {
|
|
|
2761
2795
|
cmd: "stream_chunk",
|
|
2762
2796
|
target: "rcan://streaming/chunk",
|
|
2763
2797
|
params: {
|
|
2764
|
-
msg_type:
|
|
2798
|
+
msg_type: 29 /* SENSOR_DATA */,
|
|
2765
2799
|
msg_id: generateId6(),
|
|
2766
2800
|
stream_chunk: streamChunkMeta
|
|
2767
2801
|
},
|
|
@@ -2771,6 +2805,65 @@ async function makeStreamChunk(streamId, data, mimeType, chunkIndex, isFinal) {
|
|
|
2771
2805
|
return msg;
|
|
2772
2806
|
}
|
|
2773
2807
|
|
|
2808
|
+
// src/contribute.ts
|
|
2809
|
+
var CONTRIBUTE_SCOPE_LEVEL = 2.5;
|
|
2810
|
+
var _idCounter = 0;
|
|
2811
|
+
function _generateId() {
|
|
2812
|
+
return `cr-${Date.now()}-${++_idCounter}`;
|
|
2813
|
+
}
|
|
2814
|
+
function makeContributeRequest(params = {}) {
|
|
2815
|
+
return {
|
|
2816
|
+
type: 33 /* CONTRIBUTE_REQUEST */,
|
|
2817
|
+
request_id: params.request_id ?? _generateId(),
|
|
2818
|
+
project_id: params.project_id ?? "",
|
|
2819
|
+
project_name: params.project_name ?? "",
|
|
2820
|
+
work_unit_id: params.work_unit_id ?? "",
|
|
2821
|
+
resource_type: params.resource_type ?? "cpu",
|
|
2822
|
+
estimated_duration_s: params.estimated_duration_s ?? 0,
|
|
2823
|
+
priority: params.priority ?? 0,
|
|
2824
|
+
payload: params.payload ?? {},
|
|
2825
|
+
timestamp: params.timestamp ?? Date.now() / 1e3
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
function makeContributeResult(params = {}) {
|
|
2829
|
+
const result = {
|
|
2830
|
+
type: 34 /* CONTRIBUTE_RESULT */,
|
|
2831
|
+
request_id: params.request_id ?? "",
|
|
2832
|
+
work_unit_id: params.work_unit_id ?? "",
|
|
2833
|
+
status: params.status ?? "completed",
|
|
2834
|
+
resource_type: params.resource_type ?? "cpu",
|
|
2835
|
+
duration_s: params.duration_s ?? 0,
|
|
2836
|
+
compute_units: params.compute_units ?? 0,
|
|
2837
|
+
result_payload: params.result_payload ?? {},
|
|
2838
|
+
timestamp: params.timestamp ?? Date.now() / 1e3
|
|
2839
|
+
};
|
|
2840
|
+
if (params.error_message !== void 0) {
|
|
2841
|
+
result.error_message = params.error_message;
|
|
2842
|
+
}
|
|
2843
|
+
return result;
|
|
2844
|
+
}
|
|
2845
|
+
function makeContributeCancel(params = {}) {
|
|
2846
|
+
return {
|
|
2847
|
+
type: 35 /* CONTRIBUTE_CANCEL */,
|
|
2848
|
+
request_id: params.request_id ?? "",
|
|
2849
|
+
work_unit_id: params.work_unit_id ?? "",
|
|
2850
|
+
reason: params.reason ?? "",
|
|
2851
|
+
timestamp: params.timestamp ?? Date.now() / 1e3
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
function validateContributeScope(scopeLevel, action = "request") {
|
|
2855
|
+
if (action === "request" || action === "result") {
|
|
2856
|
+
return scopeLevel >= CONTRIBUTE_SCOPE_LEVEL;
|
|
2857
|
+
}
|
|
2858
|
+
if (action === "cancel") {
|
|
2859
|
+
return scopeLevel >= 2;
|
|
2860
|
+
}
|
|
2861
|
+
return false;
|
|
2862
|
+
}
|
|
2863
|
+
function isPreemptedBy(scopeLevel) {
|
|
2864
|
+
return scopeLevel >= 3;
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2774
2867
|
// src/index.ts
|
|
2775
2868
|
var VERSION = "0.6.0";
|
|
2776
2869
|
var RCAN_VERSION = "1.6";
|
|
@@ -2778,6 +2871,7 @@ var RCAN_VERSION = "1.6";
|
|
|
2778
2871
|
0 && (module.exports = {
|
|
2779
2872
|
AuditChain,
|
|
2780
2873
|
AuditError,
|
|
2874
|
+
CONTRIBUTE_SCOPE_LEVEL,
|
|
2781
2875
|
ClockDriftError,
|
|
2782
2876
|
CommitmentRecord,
|
|
2783
2877
|
ConfidenceGate,
|
|
@@ -2841,12 +2935,16 @@ var RCAN_VERSION = "1.6";
|
|
|
2841
2935
|
encodeMinimal,
|
|
2842
2936
|
extractLoaFromJwt,
|
|
2843
2937
|
fetchCanonicalSchema,
|
|
2938
|
+
isPreemptedBy,
|
|
2844
2939
|
isSafetyMessage,
|
|
2845
2940
|
makeCloudRelayMessage,
|
|
2846
2941
|
makeConfigUpdate,
|
|
2847
2942
|
makeConsentDeny,
|
|
2848
2943
|
makeConsentGrant,
|
|
2849
2944
|
makeConsentRequest,
|
|
2945
|
+
makeContributeCancel,
|
|
2946
|
+
makeContributeRequest,
|
|
2947
|
+
makeContributeResult,
|
|
2850
2948
|
makeEstopMessage,
|
|
2851
2949
|
makeEstopWithQoS,
|
|
2852
2950
|
makeFaultReport,
|
|
@@ -2866,6 +2964,7 @@ var RCAN_VERSION = "1.6";
|
|
|
2866
2964
|
validateConfigAgainstSchema,
|
|
2867
2965
|
validateConfigUpdate,
|
|
2868
2966
|
validateConsentMessage,
|
|
2967
|
+
validateContributeScope,
|
|
2869
2968
|
validateCrossRegistryCommand,
|
|
2870
2969
|
validateDelegationChain,
|
|
2871
2970
|
validateLoaForScope,
|