Skip to content

Commit 86e4ff7

Browse files
author
Frederik Rothenberger
committed
Merge branch 'frederik/sw-update' into 'master'
service-worker: implement support for upgrade flag Implements support for the `upgrade` flag as per HTTP gateway specification: dfinity/interface-spec#20 See merge request dfinity-lab/public/ic!4476
2 parents 2300d64 + 0b954fe commit 86e4ff7

7 files changed

Lines changed: 212 additions & 94 deletions

File tree

typescript/service-worker/jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
transform: {
1010
'^.+\\.[tj]s$': 'ts-jest',
1111
},
12+
timers: 'fake',
1213
reporters: ['default', 'jest-junit'],
1314
globals: {
1415
'ts-jest': {

typescript/service-worker/package-lock.json

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/service-worker/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"directory": "typescript/service-worker"
1616
},
1717
"dependencies": {
18-
"@dfinity/agent": "^0.11.0",
19-
"@dfinity/candid": "^0.11.0",
20-
"@dfinity/principal": "^0.11.0",
18+
"@dfinity/agent": "^0.11.1",
19+
"@dfinity/candid": "^0.11.1",
20+
"@dfinity/principal": "^0.11.1",
2121
"base64-arraybuffer": "^1.0.2",
2222
"pako": "^2.0.3"
2323
},
@@ -54,7 +54,8 @@
5454
"clean": "rm -fr dist dist-dev dist-prod coverage",
5555
"build": "rm -fr dist dist-prod && NODE_OPTIONS=--openssl-legacy-provider webpack && mv dist dist-prod",
5656
"build-dev": "rm -fr dist dist-dev && NODE_OPTIONS=--openssl-legacy-provider FORCE_FETCH_ROOT_KEY=1 webpack --mode development && mv dist dist-dev",
57-
"start": "NODE_OPTIONS=--openssl-legacy-provider npm run build-dev && http-server dist-dev --proxy https://identity.dfinity.network/",
57+
"start": "npm run build-dev && http-server dist-dev --proxy https://ic0.app/",
58+
"start-testnet": "npm run build-dev && http-server dist-dev --proxy https://identity.dfinity.network/",
5859
"lint": "npx eslint src",
5960
"lint:fix": "npx eslint --fix src",
6061
"test:coverage": "jest --verbose --collectCoverage",

typescript/service-worker/src/http-interface/canister_http_interface.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const idlFactory = ({ IDL }) => {
1818
token: tokenType,
1919
callback: IDL.Func(
2020
[tokenType],
21-
[streamingCallbackHttpResponseType],
21+
[IDL.Opt(streamingCallbackHttpResponseType)],
2222
['query']
2323
),
2424
}),
@@ -28,9 +28,11 @@ export const idlFactory = ({ IDL }) => {
2828
headers: IDL.Vec(HeaderField),
2929
streaming_strategy: IDL.Opt(StreamingStrategy),
3030
status_code: IDL.Nat16,
31+
upgrade: IDL.Opt(IDL.Bool),
3132
});
3233
return IDL.Service({
3334
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
35+
http_request_update: IDL.Func([HttpRequest], [HttpResponse]),
3436
});
3537
};
3638
export const init = ({ IDL }) => {

typescript/service-worker/src/http-interface/canister_http_interface_types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface HttpResponse {
1313
headers: Array<HeaderField>;
1414
streaming_strategy: [] | [StreamingStrategy];
1515
status_code: number;
16+
upgrade: [] | [boolean];
1617
}
1718
export interface StreamingCallbackHttpResponse {
1819
token: [] | [Token];
@@ -24,4 +25,5 @@ export type StreamingStrategy = {
2425
export type Token = { type: () => IDL.Type };
2526
export interface _SERVICE {
2627
http_request: (arg_0: HttpRequest) => Promise<HttpResponse>;
28+
http_request_update: (arg_0: HttpRequest) => Promise<HttpResponse>;
2729
}

0 commit comments

Comments
 (0)