Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add github.dev and gitpod.io to known hosts #822

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
'gitpod.io',
];
const hostname = location?.hostname;
let knownHost;
if (hostname && typeof hostname === 'string') {
Expand Down
Loading