-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(client, network): Browser streams/resends working correctly.
- Loading branch information
Showing
20 changed files
with
162 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface PersistentStore<K, V> { | ||
get(key: K): Promise<V | undefined> | ||
set(key: K, value: V): Promise<boolean> | ||
has(key: K): Promise<boolean> | ||
delete(key: K): Promise<boolean> | ||
clear(): Promise<boolean> | ||
size(): Promise<number> | ||
close(): Promise<void> | ||
destroy(): Promise<void> | ||
exists(): Promise<boolean> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Crypto as WebCrypto } from 'node-webcrypto-ossl' | ||
|
||
export function getCryptoInstance(): Crypto { | ||
return new WebCrypto() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface WebCrypto { | ||
new (): Crypto | ||
(): Crypto | ||
} | ||
|
||
const WebCryptoFn: WebCrypto = function WebCrypto() { | ||
return window.crypto | ||
} as WebCrypto | ||
|
||
export { WebCryptoFn as Crypto } |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type FetchResponse = Response | ||
// In browsers, the node-fetch package is replaced with this to use native fetch | ||
export default ( | ||
((typeof fetch !== 'undefined' && fetch) || (typeof window !== 'undefined' && window.fetch) || undefined)! | ||
) | ||
|
||
export { FetchResponse as Response } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { PassThrough, Readable } from 'stream' | ||
|
||
export function ConvertBrowserStream(browserStream: ReadableStream | Readable) { | ||
if ('pipe' in browserStream) { | ||
return browserStream as Readable | ||
} | ||
|
||
const reader = browserStream.getReader() | ||
const stream = new PassThrough() | ||
// eslint-disable-next-line no-inner-declarations | ||
async function pull() { | ||
try { | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { done, value } = await reader.read() | ||
if (done) { | ||
return | ||
} | ||
|
||
if (!stream.writable) { | ||
return | ||
} | ||
|
||
stream.write(value) | ||
} | ||
} catch (err) { | ||
stream.destroy(err) | ||
reader.cancel() | ||
} finally { | ||
stream.end() | ||
} | ||
} | ||
pull() | ||
return stream | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"extends": "@streamr/dev-config/ts/tsconfig.browser.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"noEmit": true, | ||
"declarationDir": "dist/types", | ||
"outDir": "dist", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"strictBindCallApply": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"stream": ["readable-stream"], | ||
"util": ["util"], | ||
"http": ["./src/shim/http-https.js"], | ||
"@ethersproject/wordlists": ["./node_modules/@ethersproject/wordlists/lib.esm/browser-wordlists.js"], | ||
"https": ["./src/shim/http-https.js"], | ||
"crypto": ["./node_modules/crypto-browserify"], | ||
"buffer": ["./node_modules/buffer"], | ||
"node-fetch": ["./src/shim/node-fetch.ts"], | ||
"node-webcrypto-ossl": ["./src/shim/crypto.ts"], | ||
"streamr-client-protocol/dist/contracts/NodeRegistry.json": ["./node_modules/streamr-client-protocol/dist/contracts/NodeRegistry.json"], | ||
"streamr-client-protocol/*": ["./node_modules/streamr-client-protocol/src/*"], | ||
"streamr-client-protocol": ["./node_modules/streamr-client-protocol/src/index.ts"], | ||
"streamr-network": ["./node_modules/streamr-network/src/browser.ts"], | ||
"./node_modules/streamr-network/src/connection/NodeWebRtcConnection.ts": ["./node_modules/streamr-network/src/connection/BrowserWebRtcConnection.ts"], | ||
"./node_modules/streamr-network/src/connection/ws/NodeClientWsEndpoint.ts": ["./node_modules/streamr-network/src/connection/ws/BrowserClientWsEndpoint.ts"], | ||
"./node_modules/streamr-network/src/connection/ws/NodeClientWsConnection.ts": ["./node_modules/streamr-network/src/connection/ws/BrowserClientWsConnection.ts"], | ||
"./node_modules/streamr-network/src/helpers/logger/LoggerNode.ts": ["./node_modules/streamr-network/src/helpers/logger/LoggerBrowser.ts"] | ||
} | ||
}, | ||
"include": [ | ||
"package.json", | ||
"src/**/*", | ||
"vendor/**/*", | ||
"contracts/**/*.json" | ||
], | ||
"references": [ | ||
{ "path": "node_modules/streamr-client-protocol/tsconfig.node.json" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters