Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streams API v3 #122

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
},
"dependencies": {
"@metamask/design-tokens": "^1.12.0",
"@metamask/object-multiplex": "^2.0.0",
"@metamask/post-message-stream": "^7.0.0",
"eth-phishing-detect": "^1.2.0",
"globalthis": "1.0.1",
"obj-multiplex": "^1.0.0",
"pump": "^3.0.0",
"punycode": "^2.3.0",
"readable-stream": "^3.6.2",
"ses": "^0.18.8"
},
"devDependencies": {
Expand All @@ -45,9 +45,7 @@
"@testing-library/dom": "^8.13.0",
"@testing-library/user-event": "^14.1.1",
"@types/node": "^17.0.23",
"@types/pump": "^1.1.1",
"@types/punycode": "^2.1.0",
"@types/readable-stream": "^2.3.13",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"babelify": "^10.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pump from 'pump';
import { toASCII } from 'punycode/';
import { pipeline } from 'readable-stream';
import PhishingDetector from 'eth-phishing-detect/src/detector';
import { WindowPostMessageStream } from '@metamask/post-message-stream';
import ObjectMultiplex from 'obj-multiplex';
import ObjectMultiplex from '@metamask/object-multiplex';

const MAX = Number.MAX_SAFE_INTEGER;

Expand Down Expand Up @@ -149,7 +149,7 @@ function start() {

// setup connectionStream multiplexing
const mux = new ObjectMultiplex();
pump(metamaskStream, mux, metamaskStream, (error) => [
pipeline(metamaskStream, mux, metamaskStream, (error) => [
console.error('Disconnected', error),
]);
const phishingSafelistStream = mux.createStream('metamask-phishing-safelist');
Expand Down
1 change: 0 additions & 1 deletion types/obj-multiplex.d.ts

This file was deleted.

3 changes: 3 additions & 0 deletions types/readable-stream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'readable-stream' {
export { pipeline } from 'stream';
}
109 changes: 25 additions & 84 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,16 @@ __metadata:
languageName: node
linkType: hard

"@metamask/object-multiplex@npm:^2.0.0":
version: 2.0.0
resolution: "@metamask/object-multiplex@npm:2.0.0"
dependencies:
once: ^1.4.0
readable-stream: ^3.6.2
checksum: 54baea752a3ac7c2742c376512e00d4902d383e9da8787574d3b21eb0081523309e24e3915a98f3ae0341d65712b6832d2eb7eeb862f4ef0da1ead52dcde5387
languageName: node
linkType: hard

"@metamask/phishing-warning@workspace:.":
version: 0.0.0-use.local
resolution: "@metamask/phishing-warning@workspace:."
Expand All @@ -1566,14 +1576,13 @@ __metadata:
"@metamask/eslint-config": ^9.0.0
"@metamask/eslint-config-nodejs": ^9.0.0
"@metamask/eslint-config-typescript": ^9.0.1
"@metamask/object-multiplex": ^2.0.0
"@metamask/post-message-stream": ^7.0.0
"@playwright/test": ^1.30.0
"@testing-library/dom": ^8.13.0
"@testing-library/user-event": ^14.1.1
"@types/node": ^17.0.23
"@types/pump": ^1.1.1
"@types/punycode": ^2.1.0
"@types/readable-stream": ^2.3.13
"@typescript-eslint/eslint-plugin": ^4.33.0
"@typescript-eslint/parser": ^4.33.0
babelify: ^10.0.0
Expand All @@ -1590,12 +1599,11 @@ __metadata:
globalthis: 1.0.1
http-server: ^14.1.1
minify-stream: ^2.1.0
obj-multiplex: ^1.0.0
playwright: ^1.30.0
prettier: ^2.6.2
prettier-plugin-packagejson: ^2.2.17
pump: ^3.0.0
punycode: ^2.3.0
readable-stream: ^3.6.2
ses: ^0.18.8
terser: ^5.13.1
ts-node: ^10.7.0
Expand Down Expand Up @@ -1964,32 +1972,13 @@ __metadata:
languageName: node
linkType: hard

"@types/pump@npm:^1.1.1":
version: 1.1.1
resolution: "@types/pump@npm:1.1.1"
dependencies:
"@types/node": "*"
checksum: dd4a1485f2f6052cacb71a94b48d9f360e07a2fc3fac03782ae4caa9856e6df7017ee89515d70ecefcfe281553311cde4a3748219c9fcd757fdb77f3a47e0f29
languageName: node
linkType: hard

"@types/punycode@npm:^2.1.0":
version: 2.1.0
resolution: "@types/punycode@npm:2.1.0"
checksum: 6835698becab395eb9ac186970fd7879aeb522ea72d516ef9d681d787989653fcc2439ecc07d48280e1ca11862773b806efeec3fdbd1207528829a83b65d4275
languageName: node
linkType: hard

"@types/readable-stream@npm:^2.3.13":
version: 2.3.13
resolution: "@types/readable-stream@npm:2.3.13"
dependencies:
"@types/node": "*"
safe-buffer: "*"
checksum: 70ccd78e67c6f2b9a66c2329004f394bf62e0a72c973f3c75effe16b9b23d0a982a6eaf1cbe1bd32d16a279b712efca5a8c8715afe696d0edd5511742bea8e49
languageName: node
linkType: hard

"@types/resolve@npm:1.17.1":
version: 1.17.1
resolution: "@types/resolve@npm:1.17.1"
Expand Down Expand Up @@ -2567,14 +2556,7 @@ __metadata:
languageName: node
linkType: hard

"bn.js@npm:^5.0.0":
version: 5.2.0
resolution: "bn.js@npm:5.2.0"
checksum: 6117170393200f68b35a061ecbf55d01dd989302e7b3c798a3012354fa638d124f0b2f79e63f77be5556be80322a09c40339eda6413ba7468524c0b6d4b4cb7a
languageName: node
linkType: hard

"bn.js@npm:^5.2.1":
"bn.js@npm:^5.0.0, bn.js@npm:^5.2.1":
version: 5.2.1
resolution: "bn.js@npm:5.2.1"
checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3
Expand Down Expand Up @@ -3527,7 +3509,7 @@ __metadata:
languageName: node
linkType: hard

"end-of-stream@npm:^1.1.0, end-of-stream@npm:^1.4.0, end-of-stream@npm:^1.4.1":
"end-of-stream@npm:^1.4.1":
version: 1.4.4
resolution: "end-of-stream@npm:1.4.4"
dependencies:
Expand Down Expand Up @@ -5890,17 +5872,6 @@ __metadata:
languageName: node
linkType: hard

"obj-multiplex@npm:^1.0.0":
version: 1.0.0
resolution: "obj-multiplex@npm:1.0.0"
dependencies:
end-of-stream: ^1.4.0
once: ^1.4.0
readable-stream: ^2.3.3
checksum: 6bdcb7d48a1cd4458a7ff0be0b3c1dc58e8e9e6504f937c10b1eac096a3d459b85d7ba32bdd9a45382bb238e245eb42ebcd91430c72f04b0a57c97f846f2d06f
languageName: node
linkType: hard

"object-assign@npm:^4.1.0, object-assign@npm:^4.1.1":
version: 4.1.1
resolution: "object-assign@npm:4.1.1"
Expand Down Expand Up @@ -5946,7 +5917,7 @@ __metadata:
languageName: node
linkType: hard

"once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0":
"once@npm:^1.3.0, once@npm:^1.4.0":
version: 1.4.0
resolution: "once@npm:1.4.0"
dependencies:
Expand Down Expand Up @@ -6241,16 +6212,7 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^2.6.2":
version: 2.6.2
resolution: "prettier@npm:2.6.2"
bin:
prettier: bin-prettier.js
checksum: 48d08dde8e9fb1f5bccdd205baa7f192e9fc8bc98f86e1b97d919de804e28c806b0e6cc685e4a88211aa7987fa9668f30baae19580d87ced3ed0f2ec6572106f
languageName: node
linkType: hard

"prettier@npm:^2.8.8":
"prettier@npm:^2.6.2, prettier@npm:^2.8.8":
version: 2.8.8
resolution: "prettier@npm:2.8.8"
bin:
Expand Down Expand Up @@ -6336,16 +6298,6 @@ __metadata:
languageName: node
linkType: hard

"pump@npm:^3.0.0":
version: 3.0.0
resolution: "pump@npm:3.0.0"
dependencies:
end-of-stream: ^1.1.0
once: ^1.3.1
checksum: e42e9229fba14732593a718b04cb5e1cfef8254544870997e0ecd9732b189a48e1256e4e5478148ecb47c8511dca2b09eae56b4d0aad8009e6fac8072923cfc9
languageName: node
linkType: hard

"punycode@npm:1.3.2":
version: 1.3.2
resolution: "punycode@npm:1.3.2"
Expand Down Expand Up @@ -6477,7 +6429,7 @@ __metadata:
languageName: node
linkType: hard

"readable-stream@npm:3.6.2, readable-stream@npm:^3.6.2":
"readable-stream@npm:3.6.2, readable-stream@npm:^3.0.2, readable-stream@npm:^3.1.1, readable-stream@npm:^3.5.0, readable-stream@npm:^3.6.0, readable-stream@npm:^3.6.2":
version: 3.6.2
resolution: "readable-stream@npm:3.6.2"
dependencies:
Expand All @@ -6488,7 +6440,7 @@ __metadata:
languageName: node
linkType: hard

"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.6, readable-stream@npm:^2.2.2, readable-stream@npm:^2.3.3, readable-stream@npm:~2.3.6":
"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.6, readable-stream@npm:^2.2.2, readable-stream@npm:~2.3.6":
version: 2.3.7
resolution: "readable-stream@npm:2.3.7"
dependencies:
Expand All @@ -6503,17 +6455,6 @@ __metadata:
languageName: node
linkType: hard

"readable-stream@npm:^3.0.2, readable-stream@npm:^3.1.1, readable-stream@npm:^3.5.0, readable-stream@npm:^3.6.0":
version: 3.6.0
resolution: "readable-stream@npm:3.6.0"
dependencies:
inherits: ^2.0.3
string_decoder: ^1.1.1
util-deprecate: ^1.0.1
checksum: d4ea81502d3799439bb955a3a5d1d808592cf3133350ed352aeaa499647858b27b1c4013984900238b0873ec8d0d8defce72469fb7a83e61d53f5ad61cb80dc8
languageName: node
linkType: hard

"regenerate-unicode-properties@npm:^10.0.1":
version: 10.0.1
resolution: "regenerate-unicode-properties@npm:10.0.1"
Expand Down Expand Up @@ -6757,20 +6698,20 @@ __metadata:
languageName: node
linkType: hard

"safe-buffer@npm:*, safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:^5.1.1, safe-buffer@npm:^5.1.2, safe-buffer@npm:^5.2.0, safe-buffer@npm:^5.2.1, safe-buffer@npm:~5.2.0":
version: 5.2.1
resolution: "safe-buffer@npm:5.2.1"
checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491
languageName: node
linkType: hard

"safe-buffer@npm:5.1.2, safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1":
version: 5.1.2
resolution: "safe-buffer@npm:5.1.2"
checksum: f2f1f7943ca44a594893a852894055cf619c1fbcb611237fc39e461ae751187e7baf4dc391a72125e0ac4fb2d8c5c0b3c71529622e6a58f46b960211e704903c
languageName: node
linkType: hard

"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:^5.1.1, safe-buffer@npm:^5.1.2, safe-buffer@npm:^5.2.0, safe-buffer@npm:^5.2.1, safe-buffer@npm:~5.2.0":
version: 5.2.1
resolution: "safe-buffer@npm:5.2.1"
checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491
languageName: node
linkType: hard

"safer-buffer@npm:>= 2.1.2 < 3.0.0, safer-buffer@npm:^2.0.2, safer-buffer@npm:^2.1.0, safer-buffer@npm:~2.1.0":
version: 2.1.2
resolution: "safer-buffer@npm:2.1.2"
Expand Down