Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Jun 22, 2024
1 parent d4ac40f commit c4cc98a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/events-grant-authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { MessageStore } from '../types/message-store.js';
import type { PermissionGrant } from '../protocols/permission-grant.js';

import { GrantAuthorization } from './grant-authorization.js';
import { PermissionsProtocol } from '../protocols/permissions.js';
import { DwnError, DwnErrorCode } from './dwn-error.js';

export class EventsGrantAuthorization {
Expand All @@ -29,7 +30,7 @@ export class EventsGrantAuthorization {
});

// if the grant is scoped to a specific protocol, ensure that all of the query filters must include that protocol
if ('protocol' in permissionGrant.scope && permissionGrant.scope.protocol !== undefined) {
if (PermissionsProtocol.hasProtocolScope(permissionGrant.scope)) {
const scopedProtocol = permissionGrant.scope.protocol;
for (const filter of eventsQueryMessage.descriptor.filters) {
if (filter.protocol !== scopedProtocol) {
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class PermissionsProtocol {
/**
* Type guard to determine if the permission is a protocol-scoped
*/
private static hasProtocolScope(scope: PermissionScope): scope is PermissionScope & { protocol: string } {
public static hasProtocolScope(scope: PermissionScope): scope is PermissionScope & { protocol: string } {
return 'protocol' in scope && scope.protocol !== undefined;
}

Expand Down

0 comments on commit c4cc98a

Please sign in to comment.