Skip to content

Commit

Permalink
make sure protocolRole persists between requests
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Oct 1, 2024
1 parent ecc7161 commit 56a783d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/api/src/dwn-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
...responseRecord,
};
Expand Down Expand Up @@ -827,6 +829,7 @@ export class DwnApi {
connectedDid : this.connectedDid,
delegateDid : this.delegateDid,
permissionsApi : this.permissionsApi,
protocolRole : request.message.protocolRole,
request
})
};
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ export class Record implements RecordModel {
private async readRecordData({ target, isRemote }: { target: string, isRemote: boolean }) {
const readRequest: ProcessDwnRequest<DwnInterface.RecordsRead> = {
author : this._connectedDid,
messageParams : { filter: { recordId: this.id } },
messageParams : { filter: { recordId: this.id }, protocolRole: this._protocolRole },
messageType : DwnInterface.RecordsRead,
target,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/subscription-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -31,6 +32,7 @@ export class SubscriptionUtil {
const record = new Record(agent, {
...message,
...recordOptions,
protocolRole,
delegateDid: delegateDid,
}, permissionsApi);

Expand Down

0 comments on commit 56a783d

Please sign in to comment.