@@ -477,7 +477,7 @@ export class ContextGraphResolveMethods extends DKGAgentBase {
477477 return {
478478 contextGraphId : parsed . contextGraphId ,
479479 offset : parsed . offset ?? 0 ,
480- limit : Math . min ( parsed . limit ?? SYNC_PAGE_SIZE , SYNC_PAGE_SIZE ) ,
480+ limit : parsed . limit ?? SYNC_PAGE_SIZE ,
481481 includeSharedMemory : parsed . includeSharedMemory ?? false ,
482482 phase : normalizeSyncPhase ( parsed . phase ) ,
483483 snapshotRef : typeof parsed . snapshotRef === 'string' ? parsed . snapshotRef : undefined ,
@@ -489,6 +489,8 @@ export class ContextGraphResolveMethods extends DKGAgentBase {
489489 requesterAgentAddress : parsed . requesterAgentAddress ,
490490 requesterSignatureR : parsed . requesterSignatureR ,
491491 requesterSignatureVS : parsed . requesterSignatureVS ,
492+ authPurpose : typeof parsed . authPurpose === 'string' ? parsed . authPurpose : undefined ,
493+ authSelector : typeof parsed . authSelector === 'string' ? parsed . authSelector : undefined ,
492494 // Phase C: unsigned delta hint. Validated/normalised in the responder.
493495 sinceBatchId : typeof parsed . sinceBatchId === 'string' ? parsed . sinceBatchId : undefined ,
494496 } ;
@@ -644,27 +646,34 @@ export class ContextGraphResolveMethods extends DKGAgentBase {
644646 requestId : string | undefined ,
645647 issuedAtMs : number | undefined ,
646648 requesterAgentAddress : string | undefined ,
649+ authPurpose ?: string ,
650+ authSelector ?: string ,
647651 ) : Uint8Array {
648652 // `requesterAgentAddress` participates in the digest so the
649653 // "on behalf of" claim is signed, not free-form envelope data.
650654 // Without it, the responder's delegation lookup can be steered by
651655 // tampering with `requesterAgentAddress` after the signature was
652656 // produced — which would be a way to bypass the per-agent
653657 // delegation binding in `request-authorize`.
658+ const baseTypes = [ 'string' , 'uint256' , 'uint256' , 'bool' , 'string' , 'string' , 'string' , 'uint256' , 'string' ] ;
659+ const baseValues = [
660+ contextGraphId ,
661+ BigInt ( offset ) ,
662+ BigInt ( limit ) ,
663+ includeSharedMemory ,
664+ targetPeerId ,
665+ requesterPeerId ?? '' ,
666+ requestId ?? '' ,
667+ BigInt ( issuedAtMs ?? 0 ) ,
668+ ( requesterAgentAddress ?? '' ) . toLowerCase ( ) ,
669+ ] ;
670+ if ( ! authPurpose && ! authSelector ) {
671+ return ethers . getBytes ( ethers . solidityPackedKeccak256 ( baseTypes , baseValues ) ) ;
672+ }
654673 return ethers . getBytes (
655674 ethers . solidityPackedKeccak256 (
656- [ 'string' , 'uint256' , 'uint256' , 'bool' , 'string' , 'string' , 'string' , 'uint256' , 'string' ] ,
657- [
658- contextGraphId ,
659- BigInt ( offset ) ,
660- BigInt ( limit ) ,
661- includeSharedMemory ,
662- targetPeerId ,
663- requesterPeerId ?? '' ,
664- requestId ?? '' ,
665- BigInt ( issuedAtMs ?? 0 ) ,
666- ( requesterAgentAddress ?? '' ) . toLowerCase ( ) ,
667- ] ,
675+ [ ...baseTypes , 'string' , 'string' ] ,
676+ [ ...baseValues , authPurpose ?? '' , authSelector ?? '' ] ,
668677 ) ,
669678 ) ;
670679 }
0 commit comments