Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Jun 13, 2024
1 parent 998e52d commit 955da16
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/core/records-grant-authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class RecordsGrantAuthorization {
});

// NOTE: validated the invoked permission is for Records in GrantAuthorization.performBaseValidation()
RecordsGrantAuthorization.verifyProtocolRecordScope(recordsWriteMessage, permissionGrant.scope as RecordsPermissionScope);
RecordsGrantAuthorization.verifyScope(recordsWriteMessage, permissionGrant.scope as RecordsPermissionScope);

RecordsGrantAuthorization.verifyConditions(recordsWriteMessage, permissionGrant.conditions);
}
Expand Down Expand Up @@ -61,7 +61,7 @@ export class RecordsGrantAuthorization {
});

// NOTE: validated the invoked permission is for Records in GrantAuthorization.performBaseValidation()
RecordsGrantAuthorization.verifyProtocolRecordScope(recordsWriteMessageToBeRead, permissionGrant.scope as RecordsPermissionScope);
RecordsGrantAuthorization.verifyScope(recordsWriteMessageToBeRead, permissionGrant.scope as RecordsPermissionScope);
}

/**
Expand Down Expand Up @@ -138,9 +138,9 @@ export class RecordsGrantAuthorization {
}

/**
* Verifies a protocol record against the scope of the given grant.
* Verifies a record against the scope of the given grant.
*/
private static verifyProtocolRecordScope(
private static verifyScope(
recordsWriteMessage: RecordsWriteMessage,
grantScope: RecordsPermissionScope
): void {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/records-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class RecordsWriteHandler implements MethodHandler {
const permissionGrantId = recordsWriteMessage.descriptor.parentId!;
const grant = await PermissionsProtocol.fetchGrant(tenant, this.messageStore, permissionGrantId);
const revokeTagProtocol = recordsWriteMessage.descriptor.tags?.protocol;
const grantProtocol = PermissionsProtocol.isRecordPermissionScope(grant.scope) ? grant.scope.protocol : undefined;
const grantProtocol = 'protocol' in grant.scope ? grant.scope.protocol : undefined;
if (grantProtocol !== revokeTagProtocol) {
throw new DwnError(
DwnErrorCode.PermissionsProtocolValidateRevocationProtocolTagMismatch,
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class PermissionsProtocol {
/**
* Type guard to determine if the scope is a record permission scope.
*/
public static isRecordPermissionScope(scope: PermissionScope): scope is RecordsPermissionScope {
private static isRecordPermissionScope(scope: PermissionScope): scope is RecordsPermissionScope {
return scope.interface === 'Records';
}

Expand Down
4 changes: 2 additions & 2 deletions tests/features/permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function testPermissions(): void {
const permissionScope: PermissionScope = {
interface : DwnInterfaceName.Records,
method : DwnMethodName.Write,
protocol : `any-protocol` // URL will normalize to `http://any-protocol`
protocol : `any-protocol`
};

const requestToAlice = await PermissionsProtocol.createRequest({
Expand Down Expand Up @@ -371,7 +371,7 @@ export function testPermissions(): void {
).to.throw(DwnErrorCode.PermissionsProtocolValidateSchemaUnexpectedRecord);
});

it('performs additional validation to tagged protocol in a Revocation message matches the Grant it is revoking', async () => {
it('performs additional validation to the tagged protocol in a Revocation message ensuring it matches the Grant it is revoking', async () => {
const alice = await TestDataGenerator.generateDidKeyPersona();
const bob = await TestDataGenerator.generateDidKeyPersona();

Expand Down

0 comments on commit 955da16

Please sign in to comment.