@libp2p/webrtc 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +16 -16
- package/dist/src/error.d.ts +12 -12
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +23 -24
- package/dist/src/error.js.map +1 -1
- package/dist/src/maconn.d.ts.map +1 -1
- package/dist/src/maconn.js.map +1 -1
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js.map +1 -1
- package/dist/src/sdp.d.ts +3 -2
- package/dist/src/sdp.d.ts.map +1 -1
- package/dist/src/sdp.js.map +1 -1
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +1 -1
- package/dist/src/stream.js.map +1 -1
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js.map +1 -1
- package/package.json +5 -4
- package/src/error.ts +32 -33
- package/src/maconn.ts +4 -4
- package/src/muxer.ts +2 -2
- package/src/sdp.ts +2 -1
- package/src/stream.ts +11 -11
- package/src/util.ts +1 -1
package/src/sdp.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { logger } from '@libp2p/logger'
|
|
|
2
2
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
3
3
|
import { bases } from 'multiformats/basics'
|
|
4
4
|
import * as multihashes from 'multihashes'
|
|
5
|
+
import type { HashCode, HashName } from 'multihashes'
|
|
5
6
|
|
|
6
7
|
import { inappropriateMultiaddr, invalidArgument, invalidFingerprint, unsupportedHashAlgorithm } from './error.js'
|
|
7
8
|
import { CERTHASH_CODE } from './transport.js'
|
|
@@ -44,7 +45,7 @@ export function certhash (ma: Multiaddr): string {
|
|
|
44
45
|
/**
|
|
45
46
|
* Convert a certhash into a multihash
|
|
46
47
|
*/
|
|
47
|
-
export function decodeCerthash (certhash: string) {
|
|
48
|
+
export function decodeCerthash (certhash: string): { code: HashCode, name: HashName, length: number, digest: Uint8Array } {
|
|
48
49
|
const mbdecoded = mbdecoder.decode(certhash)
|
|
49
50
|
return multihashes.decode(mbdecoded)
|
|
50
51
|
}
|
package/src/stream.ts
CHANGED
|
@@ -156,55 +156,55 @@ export class WebRTCStream implements Stream {
|
|
|
156
156
|
/**
|
|
157
157
|
* Unique identifier for a stream
|
|
158
158
|
*/
|
|
159
|
-
id: string
|
|
159
|
+
id: string
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Stats about this stream
|
|
163
163
|
*/
|
|
164
|
-
stat: StreamStat
|
|
164
|
+
stat: StreamStat
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* User defined stream metadata
|
|
168
168
|
*/
|
|
169
|
-
metadata: Record<string, any
|
|
169
|
+
metadata: Record<string, any>
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* The data channel used to send and receive data
|
|
173
173
|
*/
|
|
174
|
-
private readonly channel: RTCDataChannel
|
|
174
|
+
private readonly channel: RTCDataChannel
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
177
|
* The current state of the stream
|
|
178
178
|
*/
|
|
179
|
-
streamState = new StreamState()
|
|
179
|
+
streamState = new StreamState()
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
182
|
* Read unwrapped protobuf data from the underlying datachannel.
|
|
183
183
|
* _src is exposed to the user via the `source` getter to .
|
|
184
184
|
*/
|
|
185
|
-
private readonly _src: Source<Uint8ArrayList
|
|
185
|
+
private readonly _src: Source<Uint8ArrayList>
|
|
186
186
|
|
|
187
187
|
/**
|
|
188
188
|
* push data from the underlying datachannel to the length prefix decoder
|
|
189
189
|
* and then the protobuf decoder.
|
|
190
190
|
*/
|
|
191
|
-
private readonly _innersrc = pushable()
|
|
191
|
+
private readonly _innersrc = pushable()
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Deferred promise that resolves when the underlying datachannel is in the
|
|
195
195
|
* open state.
|
|
196
196
|
*/
|
|
197
|
-
opened: DeferredPromise<void> = defer()
|
|
197
|
+
opened: DeferredPromise<void> = defer()
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
200
|
* sinkCreated is set to true once the sinkFunction is invoked
|
|
201
201
|
*/
|
|
202
|
-
_sinkCalled: boolean = false
|
|
202
|
+
_sinkCalled: boolean = false
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Triggers a generator which can be used to close the sink.
|
|
206
206
|
*/
|
|
207
|
-
closeWritePromise: DeferredPromise<void> = defer()
|
|
207
|
+
closeWritePromise: DeferredPromise<void> = defer()
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
210
|
* Callback to invoke when the stream is closed.
|
|
@@ -436,7 +436,7 @@ export class WebRTCStream implements Stream {
|
|
|
436
436
|
private _sendFlag (flag: pb.Message_Flag): void {
|
|
437
437
|
try {
|
|
438
438
|
log.trace('Sending flag: %s', flag.toString())
|
|
439
|
-
const msgbuf = pb.Message.toBinary({ flag
|
|
439
|
+
const msgbuf = pb.Message.toBinary({ flag })
|
|
440
440
|
this.channel.send(lengthPrefixed.encode.single(msgbuf).subarray())
|
|
441
441
|
} catch (err) {
|
|
442
442
|
if (err instanceof Error) {
|
package/src/util.ts
CHANGED
|
@@ -2,7 +2,7 @@ export const nopSource = {
|
|
|
2
2
|
async * [Symbol.asyncIterator] () {}
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export const nopSink = async (_: any) => {}
|
|
5
|
+
export const nopSink = async (_: any): Promise<void> => {}
|
|
6
6
|
|
|
7
7
|
const charset = Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/')
|
|
8
8
|
export const genUfrag = (len: number): string => [...Array(len)].map(() => charset.at(Math.floor(Math.random() * charset.length))).join('')
|