Skip to content

Commit

Permalink
Expose WebSocket for network access (#696)
Browse files Browse the repository at this point in the history
* Expose XMLHttpRequest for network access endowment

* Add WebSocket

* Fix linting

* Remove XmlHttpRequest since its not available in Node.js
  • Loading branch information
FrederikBolding authored and MajorLift committed Oct 11, 2023
1 parent a90b102 commit 7f73e5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/permissions/endowments/network-access.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('endowment:network-access', () => {
allowedCaveats: null,
});

expect(specification.endowmentGetter()).toStrictEqual(['fetch']);
expect(specification.endowmentGetter()).toStrictEqual([
'fetch',
'WebSocket',
]);
});
});
4 changes: 2 additions & 2 deletions src/permissions/endowments/network-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const permissionName = 'endowment:network-access';
type NetworkAccessEndowmentSpecification = ValidPermissionSpecification<{
permissionType: PermissionType.Endowment;
targetKey: typeof permissionName;
endowmentGetter: (_options?: any) => ['fetch'];
endowmentGetter: (_options?: any) => ['fetch', 'WebSocket'];
allowedCaveats: null;
}>;

Expand All @@ -32,7 +32,7 @@ const specificationBuilder: PermissionSpecificationBuilder<
targetKey: permissionName,
allowedCaveats: null,
endowmentGetter: (_getterOptions?: EndowmentGetterParams) => {
return ['fetch'];
return ['fetch', 'WebSocket'];
},
};
};
Expand Down

0 comments on commit 7f73e5c

Please sign in to comment.