Skip to content

Commit

Permalink
feat: Dual-mode: JSPI or NO_JSPI (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
rentallect authored Oct 30, 2023
1 parent ec5f6b3 commit 6680c27
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
]
},
"dependencies": {
"@openziti/ziti-browzer-core": "^0.30.0",
"@openziti/ziti-browzer-core": "^0.31.0",
"async-mutex": "^0.3.2",
"cheerio": "^1.0.0-rc.12",
"jwt-decode": "^3.1.2",
Expand Down
7 changes: 6 additions & 1 deletion src/ZitiFirstStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class ZitiFirstStrategy extends CacheFirst /* NetworkFirst */ {

await this._zitiContext.initialize({
loadWASM: true, // unlike the ZBR, here in the ZBSW, we always instantiate the internal WebAssembly
jspi: this._zitiBrowzerServiceWorkerGlobalScope._zitiConfig.jspi,
target: this._zitiBrowzerServiceWorkerGlobalScope._zitiConfig.browzer.bootstrapper.target
});

Expand Down Expand Up @@ -485,6 +486,10 @@ class ZitiFirstStrategy extends CacheFirst /* NetworkFirst */ {

result.routeOverZiti = false; // default is to route over raw internet

let url = new URL(request.url);
let targetHost = url.host;
this.logger.trace(`_shouldRouteOverZiti targetHost is: ${targetHost}`);

try {

// We want to intercept fetch requests that target the Ziti HTTP Agent... that is...
Expand All @@ -496,7 +501,7 @@ class ZitiFirstStrategy extends CacheFirst /* NetworkFirst */ {
let connectAppData = await this._zitiContext.getConnectAppDataByServiceName (this._zitiBrowzerServiceWorkerGlobalScope._zitiConfig.browzer.bootstrapper.target.service);
var targetServiceRegex = new RegExp( targetserviceHost , 'g' );

if (request.url.match( regex )) { // yes, the request is targeting the Ziti HTTP Agent
if (isEqual(targetHost, this._zitiBrowzerServiceWorkerGlobalScope._zitiConfig.browzer.bootstrapper.self.host)) { // yes, the request is targeting the Ziti HTTP Agent

// let isExpired = await this._zitiContext.isCertExpired();

Expand Down
19 changes: 10 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -961,20 +961,20 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@openziti/libcrypto-js@^0.16.1":
version "0.16.1"
resolved "https://registry.yarnpkg.com/@openziti/libcrypto-js/-/libcrypto-js-0.16.1.tgz#8e4e63ad9e594b145448abb45a79e280150b70a0"
integrity sha512-xawZ2E8bc+z0s1T1rXu8/KDy4MGwesPdNbtfaftWkuJ1gbDtKyTwpT/+gm6JnZJUzqlnNfx5T0M7NJW2Y3WTKw==
"@openziti/libcrypto-js@^0.18.2":
version "0.18.2"
resolved "https://registry.yarnpkg.com/@openziti/libcrypto-js/-/libcrypto-js-0.18.2.tgz#25036edb7cda3a1baad98772d23e12082e4c85b1"
integrity sha512-BhrcMLthScoC58T9v9aHpUtnM5tJjySC9Ftzikp2MfQl1IIZyPxSqXiQSeiV+D/L2OP/Mh628LOKgzFkMobo8w==
dependencies:
"@types/emscripten" "^1.39.6"
"@wasmer/wasi" "^1.0.2"

"@openziti/ziti-browzer-core@^0.30.0":
version "0.30.0"
resolved "https://registry.yarnpkg.com/@openziti/ziti-browzer-core/-/ziti-browzer-core-0.30.0.tgz#d3aa1f1d29962c21a590cd26c99f7dc9a71cfef0"
integrity sha512-SlbU/g/2Pirj85bE+zhhiJsATu7iHrSJXZxz/LX+mDO7qWiWaJSJeov9qKvv/Rm5Rwjwjp4wcOm6EgwuhGZ6gQ==
"@openziti/ziti-browzer-core@^0.31.0":
version "0.31.0"
resolved "https://registry.yarnpkg.com/@openziti/ziti-browzer-core/-/ziti-browzer-core-0.31.0.tgz#0654b7149da7bf0b01e6f62713a15ec5ec91b86b"
integrity sha512-K0O+HxlraJkBdsZMKz/8+VDkNNBJ3ElPfhhK6EppvGttghkJEiEvM7tNw514qjyrjo8xNudOn4aCQIbPJXgSsw==
dependencies:
"@openziti/libcrypto-js" "^0.16.1"
"@openziti/libcrypto-js" "^0.18.2"
"@openziti/ziti-browzer-edge-client" "^0.6.2"
asn1js "^2.4.0"
assert "^2.0.0"
Expand All @@ -983,6 +983,7 @@
buffer "^6.0.3"
bufferutil "^4.0.6"
chnl "^1.2.0"
es6-object-assign "^1.1.0"
events "^3.3.0"
fast-memoize "^2.5.2"
format-message "^6.2.4"
Expand Down

0 comments on commit 6680c27

Please sign in to comment.