Skip to content

Commit

Permalink
fix optional cache
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Sep 2, 2024
1 parent e9f709d commit e4c08f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/agent/src/permissions-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class AgentPermissionsApi implements PermissionsApi {
// Currently we only support finding grants based on protocols
// A different approach may be necessary when we introduce `protocolPath` and `contextId` specific impersonation
const cacheKey = [ connectedDid, delegateDid, messageType, protocol ].join('~');
const cachedGrant = this._cachedPermissions?.get(cacheKey);
const cachedGrant = cached ? this._cachedPermissions.get(cacheKey) : undefined;
if (cachedGrant) {
return cachedGrant;
}

Check warning on line 44 in packages/agent/src/permissions-api.ts

View check run for this annotation

Codecov / codecov/patch

packages/agent/src/permissions-api.ts#L43-L44

Added lines #L43 - L44 were not covered by tests
Expand All @@ -63,7 +63,7 @@ export class AgentPermissionsApi implements PermissionsApi {
throw new Error(`CachedPermissions: No permissions found for ${messageType}: ${protocol}`);
}

this._cachedPermissions?.set(cacheKey, grant);
this._cachedPermissions.set(cacheKey, grant);
return grant;
}

Expand Down Expand Up @@ -313,7 +313,7 @@ export class AgentPermissionsApi implements PermissionsApi {
}

async clear():Promise<void> {
this._cachedPermissions?.clear();
this._cachedPermissions.clear();
}

/**
Expand Down

0 comments on commit e4c08f2

Please sign in to comment.