Skip to content

Commit 79173c0

Browse files
committed
add comments
1 parent fe8d3cb commit 79173c0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/agent/src/oidc.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,16 @@ function encryptAuthResponse({
602602
}
603603

604604
function shouldUseDelegatePermission(scope: DwnPermissionScope): boolean {
605+
// Currently all record permissions are treated as delegated permissions
606+
// In the future only methods that modify state will be delegated and the rest will be normal permissions
605607
if (isRecordPermissionScope(scope)) {
606608
return true;
607609
} else if (scope.interface === DwnInterfaceName.Protocols && scope.method === DwnMethodName.Configure) {
610+
// ProtocolConfigure messages are also delegated, as they modify state
608611
return true;
609612
}
610613

614+
// All other permissions are not treated as delegated
611615
return false;
612616
}
613617

@@ -626,7 +630,6 @@ async function createPermissionGrants(
626630
// TODO: cleanup all grants if one fails by deleting them from the DWN: https://github.com/TBD54566975/web5-js/issues/849
627631
const permissionGrants = await Promise.all(
628632
scopes.map((scope) => {
629-
630633
// check if the scope is a records permission scope, or a protocol configure scope, if so it should use a delegated permission.
631634
const delegated = shouldUseDelegatePermission(scope);
632635
return permissionsApi.createGrant({

packages/api/src/dwn-api.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,10 @@ export class DwnApi {
481481
// If the protocol is public, the query should be successful. This allows the app to query for public protocols without having a grant.
482482

483483
try {
484-
const protocolFromRequest = request.message.filter?.protocol;
485484
const { grant: { id: permissionGrantId } } = await this.permissionsApi.getPermissionForRequest({
486485
connectedDid : this.connectedDid,
487486
delegateDid : this.delegateDid,
488-
protocol : protocolFromRequest,
487+
protocol : request.message.filter.protocol,
489488
cached : true,
490489
messageType : agentRequest.messageType
491490
});

0 commit comments

Comments
 (0)