diff --git a/packages/api/src/dwn-api.ts b/packages/api/src/dwn-api.ts index e91f21622..a0d5b2028 100644 --- a/packages/api/src/dwn-api.ts +++ b/packages/api/src/dwn-api.ts @@ -699,6 +699,7 @@ export class DwnApi { */ remoteOrigin : request.from, delegateDid : this.delegateDid, + protocolRole: request.message.protocolRole, ...entry as DwnMessage[DwnInterface.RecordsWrite] }; const record = new Record(this.agent, recordOptions, this.permissionsApi); @@ -787,6 +788,7 @@ export class DwnApi { * payload must be read again (e.g., if the data stream is consumed). */ remoteOrigin : request.from, + protocolRole: request.message.protocolRole, delegateDid : this.delegateDid, data : entry.data, initialWrite : entry.initialWrite, @@ -829,6 +831,7 @@ export class DwnApi { connectedDid : this.connectedDid, delegateDid : this.delegateDid, permissionsApi : this.permissionsApi, + protocolRole : request.message.protocolRole, request }) }; diff --git a/packages/api/src/record.ts b/packages/api/src/record.ts index 47b703c24..306f53656 100644 --- a/packages/api/src/record.ts +++ b/packages/api/src/record.ts @@ -1023,7 +1023,7 @@ export class Record implements RecordModel { private async readRecordData({ target, isRemote }: { target: string, isRemote: boolean }) { const readRequest: ProcessDwnRequest = { author : this._connectedDid, - messageParams : { filter: { recordId: this.id } }, + messageParams : { filter: { recordId: this.id }, protocolRole: this._protocolRole }, messageType : DwnInterface.RecordsRead, target, }; diff --git a/packages/api/src/subscription-util.ts b/packages/api/src/subscription-util.ts index 5316733d0..88a6f16d2 100644 --- a/packages/api/src/subscription-util.ts +++ b/packages/api/src/subscription-util.ts @@ -9,10 +9,11 @@ export class SubscriptionUtil { /** * Creates a record subscription handler that can be used to process incoming {Record} messages. */ - static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, permissionsApi }:{ + static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }:{ agent: Web5Agent; connectedDid: string; delegateDid?: string; + protocolRole?: string; permissionsApi?: PermissionsApi; request: RecordsSubscribeRequest; }): DwnRecordSubscriptionHandler { @@ -31,6 +32,7 @@ export class SubscriptionUtil { const record = new Record(agent, { ...message, ...recordOptions, + protocolRole, delegateDid: delegateDid, }, permissionsApi);