Skip to content

Commit

Permalink
Merge branch 'frederik/sw-update' into 'master'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Frederik Rothenberger committed Apr 22, 2022
2 parents 2300d64 + 0b954fe commit 86e4ff7
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 94 deletions.
1 change: 1 addition & 0 deletions typescript/service-worker/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
timers: 'fake',
reporters: ['default', 'jest-junit'],
globals: {
'ts-jest': {
Expand Down
58 changes: 29 additions & 29 deletions typescript/service-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions typescript/service-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"directory": "typescript/service-worker"
},
"dependencies": {
"@dfinity/agent": "^0.11.0",
"@dfinity/candid": "^0.11.0",
"@dfinity/principal": "^0.11.0",
"@dfinity/agent": "^0.11.1",
"@dfinity/candid": "^0.11.1",
"@dfinity/principal": "^0.11.1",
"base64-arraybuffer": "^1.0.2",
"pako": "^2.0.3"
},
Expand Down Expand Up @@ -54,7 +54,8 @@
"clean": "rm -fr dist dist-dev dist-prod coverage",
"build": "rm -fr dist dist-prod && NODE_OPTIONS=--openssl-legacy-provider webpack && mv dist dist-prod",
"build-dev": "rm -fr dist dist-dev && NODE_OPTIONS=--openssl-legacy-provider FORCE_FETCH_ROOT_KEY=1 webpack --mode development && mv dist dist-dev",
"start": "NODE_OPTIONS=--openssl-legacy-provider npm run build-dev && http-server dist-dev --proxy https://identity.dfinity.network/",
"start": "npm run build-dev && http-server dist-dev --proxy https://ic0.app/",
"start-testnet": "npm run build-dev && http-server dist-dev --proxy https://identity.dfinity.network/",
"lint": "npx eslint src",
"lint:fix": "npx eslint --fix src",
"test:coverage": "jest --verbose --collectCoverage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const idlFactory = ({ IDL }) => {
token: tokenType,
callback: IDL.Func(
[tokenType],
[streamingCallbackHttpResponseType],
[IDL.Opt(streamingCallbackHttpResponseType)],
['query']
),
}),
Expand All @@ -28,9 +28,11 @@ export const idlFactory = ({ IDL }) => {
headers: IDL.Vec(HeaderField),
streaming_strategy: IDL.Opt(StreamingStrategy),
status_code: IDL.Nat16,
upgrade: IDL.Opt(IDL.Bool),
});
return IDL.Service({
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
http_request_update: IDL.Func([HttpRequest], [HttpResponse]),
});
};
export const init = ({ IDL }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface HttpResponse {
headers: Array<HeaderField>;
streaming_strategy: [] | [StreamingStrategy];
status_code: number;
upgrade: [] | [boolean];
}
export interface StreamingCallbackHttpResponse {
token: [] | [Token];
Expand All @@ -24,4 +25,5 @@ export type StreamingStrategy = {
export type Token = { type: () => IDL.Type };
export interface _SERVICE {
http_request: (arg_0: HttpRequest) => Promise<HttpResponse>;
http_request_update: (arg_0: HttpRequest) => Promise<HttpResponse>;
}
Loading

0 comments on commit 86e4ff7

Please sign in to comment.