Skip to content

Commit

Permalink
fix: update proxy to add identity encoding to icp requests (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
keplervital authored Aug 24, 2023
1 parent 4439aee commit 5118c9f
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 201 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=for-the-badge)](LICENSE)
[![GitHub license](https://img.shields.io/badge/install-MacOSX-blue.svg?style=for-the-badge&logo=apple)](https://github.com/dfinity/http-proxy/releases/download/0.0.3-alpha/ic-http-proxy-mac-universal-0.0.3-alpha.dmg)
[![GitHub license](https://img.shields.io/badge/install-Windows-blue.svg?style=for-the-badge&logo=windows)](https://github.com/dfinity/http-proxy/releases/download/0.0.3-alpha/ic-http-proxy-win-x64-0.0.3-alpha.exe)
[![GitHub license](https://img.shields.io/badge/install-MacOSX-blue.svg?style=for-the-badge&logo=apple)](https://github.com/dfinity/http-proxy/releases/download/0.0.4-alpha/ic-http-proxy-mac-universal-0.0.4-alpha.dmg)
[![GitHub license](https://img.shields.io/badge/install-Windows-blue.svg?style=for-the-badge&logo=windows)](https://github.com/dfinity/http-proxy/releases/download/0.0.4-alpha/ic-http-proxy-win-x64-0.0.4-alpha.exe)

# IC HTTP Proxy
> This application is currently only a proof of concept implementation and should be used at your own risk.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"description": "HTTP Proxy to enable trustless access to the Internet Computer.",
"author": "Kepler Vital <[email protected]>",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-core",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"description": "Gateway server to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/daemon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-daemon",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"description": "Daemon process to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down Expand Up @@ -59,7 +59,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@dfinity/http-proxy-core": "0.0.3-alpha",
"@dfinity/http-proxy-core": "0.0.4-alpha",
"http-proxy": "^1.18.1",
"node-cache": "^5.1.2",
"node-forge": "^1.3.1",
Expand Down
14 changes: 7 additions & 7 deletions packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-server",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"description": "Gateway server to enable trustless access to the Internet Computer.",
"main": "built/main.js",
"types": "built/main.d.ts",
Expand Down Expand Up @@ -49,12 +49,12 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@dfinity/agent": "^0.15.6",
"@dfinity/candid": "^0.15.6",
"@dfinity/http-proxy-core": "0.0.3-alpha",
"@dfinity/http-proxy-daemon": "0.0.3-alpha",
"@dfinity/principal": "^0.15.6",
"@dfinity/response-verification": "^0.2.1",
"@dfinity/agent": "^0.19.0",
"@dfinity/candid": "^0.19.0",
"@dfinity/http-proxy-core": "0.0.4-alpha",
"@dfinity/http-proxy-daemon": "0.0.4-alpha",
"@dfinity/principal": "^0.19.0",
"@dfinity/response-verification": "^1.0.2",
"http-proxy": "^1.18.1",
"isomorphic-fetch": "^3.0.0",
"node-cache": "^5.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/commons/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EnvironmentConfiguration } from './typings';

const environment: EnvironmentConfiguration = {
platform: os.platform(),
userAgent: 'ICHttpProxy/0.0.3-alpha',
userAgent: 'ICHttpProxy/0.0.4-alpha',
certificate: {
storage: {
folder: 'certs',
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/servers/icp/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const DEFAULT_GATEWAY = new URL('https://icp-api.io');

export const hostnameCanisterIdMap: Map<string, Principal> = new Map(
Object.entries({
'oc.app': Principal.from('6hsbt-vqaaa-aaaaf-aaafq-cai'),
'identity.ic0.app': Principal.from('rdmx6-jaaaa-aaaaa-aaadq-cai'),
'nns.ic0.app': Principal.from('qoctq-giaaa-aaaaa-aaaea-cai'),
'nns.icp': Principal.from('qoctq-giaaa-aaaaa-aaaea-cai'), // this is a crypto domain
Expand Down
13 changes: 11 additions & 2 deletions packages/server/src/servers/icp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getMaxVerificationVersion,
getMinVerificationVersion,
verifyRequestResponsePair,
} from '@dfinity/response-verification/nodejs/nodejs.js';
} from '@dfinity/response-verification/dist/nodejs/nodejs';
import { IncomingMessage } from 'http';
import fetch from 'isomorphic-fetch';
import { inflate, ungzip } from 'pako';
Expand Down Expand Up @@ -87,6 +87,14 @@ export const fetchAsset = async ({
// See TT-30.
return;
}

if (
key.toLowerCase() === 'accept-encoding' &&
!value.includes('identity')
) {
value = `${value}, identity`;
}

requestHeaders.push([key, value]);
});

Expand Down Expand Up @@ -345,6 +353,7 @@ export const fetchFromInternetComputer = async (
headers: assetFetchResult.request.headers,
method: assetFetchResult.request.method,
url: assetFetchResult.request.url,
body: assetFetchResult.request.body,
},
{
statusCode: assetFetchResult.response.statusCode,
Expand All @@ -358,7 +367,7 @@ export const fetchFromInternetComputer = async (
minAllowedVerificationVersion
);

if (assetCertification.passed && assetCertification.response) {
if (assetCertification.response) {
const certifiedResponseHeaders = fromResponseVerificationHeaders(
assetCertification.response.headers
);
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/http-proxy-ui",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"description": "Desktop interface to facilitate user interaction with the HTTP Proxy server.",
"main": "built/main.js",
"scripts": {
Expand Down Expand Up @@ -37,8 +37,8 @@
},
"homepage": "https://github.com/dfinity/http-proxy/tree/main/packages/ui#readme",
"dependencies": {
"@dfinity/http-proxy-core": "0.0.3-alpha",
"@dfinity/http-proxy-server": "0.0.3-alpha"
"@dfinity/http-proxy-core": "0.0.4-alpha",
"@dfinity/http-proxy-server": "0.0.4-alpha"
},
"devDependencies": {
"@types/node": "^18.14.0",
Expand Down
Loading

0 comments on commit 5118c9f

Please sign in to comment.