Skip to content

Commit

Permalink
feat: add github.dev and gitpod.io to known hosts (#822)
Browse files Browse the repository at this point in the history
* Add 'github.dev' and 'gitpod.io' to known hosts

* Update comment / tests
  • Loading branch information
rvanasa authored Jan 18, 2024
1 parent fdcfb45 commit 3feefc1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/generated/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h2>Version x.x.x</h2>
<li>feat: enhances `.from` methods on public key classes to support unknown types, including PublicKey instances, ArrayBuffer-like objects, DER encoded public keys, and hex strings. Also introduces a new `bufFromBufLike` util</li>
<li>feat: introduces partial identities from public keys for authentication flows</li>
<li>fix: honor disableIdle flag</li>
<li>fix: add `github.dev` and `gitpod.io` to known hosts</li>
</ul>
<h2>Version 0.20.2</h2>
<ul>
Expand Down
8 changes: 4 additions & 4 deletions packages/agent/src/agent/http/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ describe('default host', () => {
expect((agent as any)._host.hostname).toBe('icp-api.io');
});
it('should use the existing host if the agent is used on a known hostname', () => {
const knownHosts = ['ic0.app', 'icp0.io', '127.0.0.1', '127.0.0.1'];
const knownHosts = ['ic0.app', 'icp0.io', '127.0.0.1', 'localhost', 'github.dev', 'gitpod.io'];
for (const host of knownHosts) {
delete (window as any).location;
(window as any).location = {
Expand All @@ -745,7 +745,7 @@ describe('default host', () => {
}
});
it('should correctly handle subdomains on known hosts', () => {
const knownHosts = ['ic0.app', 'icp0.io', '127.0.0.1', '127.0.0.1'];
const knownHosts = ['ic0.app', 'icp0.io', '127.0.0.1', 'localhost', 'github.dev', 'gitpod.io'];
for (const host of knownHosts) {
delete (window as any).location;
(window as any).location = {
Expand All @@ -757,8 +757,8 @@ describe('default host', () => {
expect((agent as any)._host.hostname).toBe(host);
}
});
it('should handle port numbers for 127.0.0.1', () => {
const knownHosts = ['127.0.0.1', '127.0.0.1'];
it('should handle port numbers for 127.0.0.1 and localhost', () => {
const knownHosts = ['127.0.0.1', 'localhost'];
for (const host of knownHosts) {
delete (window as any).location;
// hostname is different from host when port is specified
Expand Down
11 changes: 9 additions & 2 deletions packages/agent/src/agent/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,15 @@ export class HttpAgent implements Agent {
'Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning.',
);
}
// Mainnet and local will have the api route available
const knownHosts = ['ic0.app', 'icp0.io', '127.0.0.1', 'localhost'];
// Mainnet, local, and remote environments will have the api route available
const knownHosts = [
'ic0.app',
'icp0.io',
'127.0.0.1',
'localhost',
'github.dev',
'gitpod.io',
];
const hostname = location?.hostname;
let knownHost;
if (hostname && typeof hostname === 'string') {
Expand Down

0 comments on commit 3feefc1

Please sign in to comment.