Skip to content

Commit 5118c9f

Browse files
authored
fix: update proxy to add identity encoding to icp requests (#19)
1 parent 4439aee commit 5118c9f

10 files changed

Lines changed: 74 additions & 201 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=for-the-badge)](LICENSE)
2-
[![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)
3-
[![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)
2+
[![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)
3+
[![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)
44

55
# IC HTTP Proxy
66
> This application is currently only a proof of concept implementation and should be used at your own risk.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dfinity/http-proxy",
3-
"version": "0.0.3-alpha",
3+
"version": "0.0.4-alpha",
44
"description": "HTTP Proxy to enable trustless access to the Internet Computer.",
55
"author": "Kepler Vital <kepler.vital@dfinity.org>",
66
"license": "Apache-2.0",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dfinity/http-proxy-core",
3-
"version": "0.0.3-alpha",
3+
"version": "0.0.4-alpha",
44
"description": "Gateway server to enable trustless access to the Internet Computer.",
55
"main": "built/main.js",
66
"types": "built/main.d.ts",

packages/daemon/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dfinity/http-proxy-daemon",
3-
"version": "0.0.3-alpha",
3+
"version": "0.0.4-alpha",
44
"description": "Daemon process to enable trustless access to the Internet Computer.",
55
"main": "built/main.js",
66
"types": "built/main.d.ts",
@@ -59,7 +59,7 @@
5959
"typescript": "^4.9.5"
6060
},
6161
"dependencies": {
62-
"@dfinity/http-proxy-core": "0.0.3-alpha",
62+
"@dfinity/http-proxy-core": "0.0.4-alpha",
6363
"http-proxy": "^1.18.1",
6464
"node-cache": "^5.1.2",
6565
"node-forge": "^1.3.1",

packages/server/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dfinity/http-proxy-server",
3-
"version": "0.0.3-alpha",
3+
"version": "0.0.4-alpha",
44
"description": "Gateway server to enable trustless access to the Internet Computer.",
55
"main": "built/main.js",
66
"types": "built/main.d.ts",
@@ -49,12 +49,12 @@
4949
"typescript": "^4.9.5"
5050
},
5151
"dependencies": {
52-
"@dfinity/agent": "^0.15.6",
53-
"@dfinity/candid": "^0.15.6",
54-
"@dfinity/http-proxy-core": "0.0.3-alpha",
55-
"@dfinity/http-proxy-daemon": "0.0.3-alpha",
56-
"@dfinity/principal": "^0.15.6",
57-
"@dfinity/response-verification": "^0.2.1",
52+
"@dfinity/agent": "^0.19.0",
53+
"@dfinity/candid": "^0.19.0",
54+
"@dfinity/http-proxy-core": "0.0.4-alpha",
55+
"@dfinity/http-proxy-daemon": "0.0.4-alpha",
56+
"@dfinity/principal": "^0.19.0",
57+
"@dfinity/response-verification": "^1.0.2",
5858
"http-proxy": "^1.18.1",
5959
"isomorphic-fetch": "^3.0.0",
6060
"node-cache": "^5.1.2",

packages/server/src/commons/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EnvironmentConfiguration } from './typings';
33

44
const environment: EnvironmentConfiguration = {
55
platform: os.platform(),
6-
userAgent: 'ICHttpProxy/0.0.3-alpha',
6+
userAgent: 'ICHttpProxy/0.0.4-alpha',
77
certificate: {
88
storage: {
99
folder: 'certs',

packages/server/src/servers/icp/static.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const DEFAULT_GATEWAY = new URL('https://icp-api.io');
55

66
export const hostnameCanisterIdMap: Map<string, Principal> = new Map(
77
Object.entries({
8+
'oc.app': Principal.from('6hsbt-vqaaa-aaaaf-aaafq-cai'),
89
'identity.ic0.app': Principal.from('rdmx6-jaaaa-aaaaa-aaadq-cai'),
910
'nns.ic0.app': Principal.from('qoctq-giaaa-aaaaa-aaaea-cai'),
1011
'nns.icp': Principal.from('qoctq-giaaa-aaaaa-aaaea-cai'), // this is a crypto domain

packages/server/src/servers/icp/utils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
getMaxVerificationVersion,
66
getMinVerificationVersion,
77
verifyRequestResponsePair,
8-
} from '@dfinity/response-verification/nodejs/nodejs.js';
8+
} from '@dfinity/response-verification/dist/nodejs/nodejs';
99
import { IncomingMessage } from 'http';
1010
import fetch from 'isomorphic-fetch';
1111
import { inflate, ungzip } from 'pako';
@@ -87,6 +87,14 @@ export const fetchAsset = async ({
8787
// See TT-30.
8888
return;
8989
}
90+
91+
if (
92+
key.toLowerCase() === 'accept-encoding' &&
93+
!value.includes('identity')
94+
) {
95+
value = `${value}, identity`;
96+
}
97+
9098
requestHeaders.push([key, value]);
9199
});
92100

@@ -345,6 +353,7 @@ export const fetchFromInternetComputer = async (
345353
headers: assetFetchResult.request.headers,
346354
method: assetFetchResult.request.method,
347355
url: assetFetchResult.request.url,
356+
body: assetFetchResult.request.body,
348357
},
349358
{
350359
statusCode: assetFetchResult.response.statusCode,
@@ -358,7 +367,7 @@ export const fetchFromInternetComputer = async (
358367
minAllowedVerificationVersion
359368
);
360369

361-
if (assetCertification.passed && assetCertification.response) {
370+
if (assetCertification.response) {
362371
const certifiedResponseHeaders = fromResponseVerificationHeaders(
363372
assetCertification.response.headers
364373
);

packages/ui/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dfinity/http-proxy-ui",
3-
"version": "0.0.3-alpha",
3+
"version": "0.0.4-alpha",
44
"description": "Desktop interface to facilitate user interaction with the HTTP Proxy server.",
55
"main": "built/main.js",
66
"scripts": {
@@ -37,8 +37,8 @@
3737
},
3838
"homepage": "https://github.com/dfinity/http-proxy/tree/main/packages/ui#readme",
3939
"dependencies": {
40-
"@dfinity/http-proxy-core": "0.0.3-alpha",
41-
"@dfinity/http-proxy-server": "0.0.3-alpha"
40+
"@dfinity/http-proxy-core": "0.0.4-alpha",
41+
"@dfinity/http-proxy-server": "0.0.4-alpha"
4242
},
4343
"devDependencies": {
4444
"@types/node": "^18.14.0",

0 commit comments

Comments
 (0)