Skip to content

Commit 91442fd

Browse files
committed
Minor fixes from review:
- Use current timestamp for revocationMetadata recordedAt fields for permissions marked with legacy isRevoked - removed an errant isRevoked: false that was included on a new permission object
1 parent c42eb7b commit 91442fd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/gator-permissions-snap/src/profileSync/profileSync.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ function safeDeserializeStoredGrantedPermission(
6262
// handle legacy storage where `isRevoked` is set instead of `revocationMetadata`
6363
if (parsed.isRevoked && validated.revocationMetadata === undefined) {
6464
validated.revocationMetadata = {
65-
recordedAt: 0,
65+
// We haven't persisted the `recordedAt` timestamp, so we just use the
66+
// current timestamp to indicate that it was "noticed" just now. This
67+
// should never really happen in production, as only permissions revoked
68+
// with pre-production versions would have been marked with `isRevoked`
69+
// instead of `revocationMetadata`. The value is inconsequential, as
70+
// it's only included for debugging purposes.
71+
recordedAt: Math.floor(Date.now() / 1000),
6672
};
6773
}
6874

packages/gator-permissions-snap/src/rpc/rpcHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export function createRpcHandler({
115115
const storedPermission: StoredGrantedPermission = {
116116
permissionResponse: permissionResponse.response,
117117
siteOrigin,
118-
isRevoked: false,
119118
};
120119
permissionsToStore.push(storedPermission);
121120
}

packages/gator-permissions-snap/test/profileSync/profileSync.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ describe('profileSync', () => {
155155
{
156156
...mockStoredGrantedPermission,
157157
revocationMetadata: {
158-
recordedAt: 0,
158+
// this will be set to the current timestamp when the permission is retrieved
159+
recordedAt: expect.any(Number)
159160
},
160161
},
161162
]);

0 commit comments

Comments
 (0)