werift 0.22.1 → 0.22.2
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/lib/common/src/binary.d.ts +6 -6
- package/lib/common/src/event.d.ts +1 -0
- package/lib/common/src/event.js +5 -0
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/log.d.ts +1 -2
- package/lib/common/src/transport.d.ts +2 -1
- package/lib/common/src/transport.js +28 -14
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +12 -12
- package/lib/dtls/src/cipher/suites/aead.d.ts +3 -2
- package/lib/dtls/src/cipher/suites/aead.js +31 -38
- package/lib/dtls/src/cipher/suites/aead.js.map +1 -1
- package/lib/dtls/src/context/cipher.d.ts +4 -4
- package/lib/dtls/src/context/cipher.js +21 -10
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/srtp.d.ts +3 -3
- package/lib/dtls/src/context/srtp.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/ellipticCurves.d.ts +1 -1
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.d.ts +2 -2
- package/lib/dtls/src/handshake/extensions/signature.d.ts +2 -2
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +1 -1
- package/lib/dtls/src/handshake/message/alert.d.ts +1 -1
- package/lib/dtls/src/handshake/message/certificate.d.ts +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/hello.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.d.ts +1 -1
- package/lib/dtls/src/handshake/message/finished.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
- package/lib/dtls/src/handshake/random.d.ts +3 -3
- package/lib/dtls/src/record/message/fragment.d.ts +1 -1
- package/lib/dtls/src/record/message/header.d.ts +2 -19
- package/lib/dtls/src/record/message/header.js +1 -60
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.d.ts +6 -27
- package/lib/dtls/src/record/message/plaintext.js +34 -16
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +4 -4
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/util/binary.d.ts +1 -1
- package/lib/ice/src/helper.d.ts +1 -1
- package/lib/ice/src/ice.d.ts +4 -3
- package/lib/ice/src/ice.js +89 -68
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +20 -1
- package/lib/ice/src/iceBase.js +46 -0
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/stun/attributes.d.ts +2 -2
- package/lib/ice/src/stun/attributes.js +47 -27
- package/lib/ice/src/stun/attributes.js.map +1 -1
- package/lib/ice/src/stun/message.d.ts +2 -2
- package/lib/ice/src/stun/message.js +21 -23
- package/lib/ice/src/stun/message.js.map +1 -1
- package/lib/ice/src/stun/protocol.d.ts +2 -2
- package/lib/ice/src/turn/protocol.d.ts +2 -2
- package/lib/index.mjs +2252 -1474
- package/lib/nonstandard/index.mjs +308 -351
- package/lib/rtp/src/codec/av1.d.ts +2 -2
- package/lib/rtp/src/codec/opus.d.ts +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +18 -8
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +2 -2
- package/lib/rtp/src/extra/container/mp4/sps-parser.d.ts +1 -1
- package/lib/rtp/src/extra/container/ogg/parser.d.ts +1 -1
- package/lib/rtp/src/extra/container/webm/container.d.ts +7 -7
- package/lib/rtp/src/extra/container/webm/container.js +17 -7
- package/lib/rtp/src/extra/container/webm/container.js.map +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/id.d.ts +222 -222
- package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +6 -1
- package/lib/rtp/src/extra/processor/dtxCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/interface.d.ts +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/mp4.js +3 -0
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtpTimeCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/webm.d.ts +1 -1
- package/lib/rtp/src/helper.d.ts +1 -1
- package/lib/rtp/src/rtcp/header.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/index.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/pictureLossIndication.d.ts +1 -1
- package/lib/rtp/src/rtcp/psfb/remb.d.ts +1 -1
- package/lib/rtp/src/rtcp/rr.d.ts +2 -2
- package/lib/rtp/src/rtcp/rtcp.d.ts +1 -1
- package/lib/rtp/src/rtcp/rtpfb/index.d.ts +1 -1
- package/lib/rtp/src/rtcp/rtpfb/nack.d.ts +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +4 -4
- package/lib/rtp/src/rtcp/sdes.d.ts +3 -3
- package/lib/rtp/src/rtcp/sr.d.ts +2 -2
- package/lib/rtp/src/rtp/headerExtension.d.ts +6 -6
- package/lib/rtp/src/rtp/red/packet.d.ts +2 -2
- package/lib/rtp/src/rtp/rtp.d.ts +2 -2
- package/lib/rtp/src/srtp/cipher/ctr.d.ts +4 -4
- package/lib/rtp/src/srtp/cipher/gcm.d.ts +4 -4
- package/lib/rtp/src/srtp/const.d.ts +3 -3
- package/lib/rtp/src/srtp/const.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.d.ts +7 -7
- package/lib/rtp/src/srtp/context/context.js +10 -4
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +3 -3
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +3 -3
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.d.ts +2 -2
- package/lib/rtp/src/srtp/srtp.d.ts +2 -2
- package/lib/sctp/src/chunk.d.ts +12 -12
- package/lib/sctp/src/chunk.js +87 -66
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/param.d.ts +3 -3
- package/lib/sctp/src/sctp.d.ts +3 -1
- package/lib/sctp/src/sctp.js +36 -1
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +15 -4
- package/lib/webrtc/src/dataChannel.js +42 -7
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/index.d.ts +1 -0
- package/lib/webrtc/src/index.js +1 -0
- package/lib/webrtc/src/index.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +1 -0
- package/lib/webrtc/src/media/index.js +1 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +2 -2
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/router.js +2 -1
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +3 -3
- package/lib/webrtc/src/media/rtpReceiver.js +51 -2
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +6 -0
- package/lib/webrtc/src/media/rtpSender.js +78 -7
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +12 -9
- package/lib/webrtc/src/media/rtpTransceiver.js +45 -8
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/stats.d.ts +279 -0
- package/lib/webrtc/src/media/stats.js +35 -1
- package/lib/webrtc/src/media/stats.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +34 -64
- package/lib/webrtc/src/peerConnection.js +319 -986
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +27 -0
- package/lib/webrtc/src/sctpManager.js +147 -0
- package/lib/webrtc/src/sctpManager.js.map +1 -0
- package/lib/webrtc/src/sdp.d.ts +3 -2
- package/lib/webrtc/src/sdp.js +17 -7
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +78 -0
- package/lib/webrtc/src/sdpManager.js +391 -0
- package/lib/webrtc/src/sdpManager.js.map +1 -0
- package/lib/webrtc/src/secureTransportManager.d.ts +56 -0
- package/lib/webrtc/src/secureTransportManager.js +345 -0
- package/lib/webrtc/src/secureTransportManager.js.map +1 -0
- package/lib/webrtc/src/transceiverManager.d.ts +40 -0
- package/lib/webrtc/src/transceiverManager.js +355 -0
- package/lib/webrtc/src/transceiverManager.js.map +1 -0
- package/lib/webrtc/src/transport/dtls.d.ts +18 -6
- package/lib/webrtc/src/transport/dtls.js +119 -11
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +24 -0
- package/lib/webrtc/src/transport/ice.js +86 -0
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.js +22 -7
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +3 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +15 -21
|
@@ -438,6 +438,11 @@ var Event = class {
|
|
|
438
438
|
};
|
|
439
439
|
return { unSubscribe, disposer };
|
|
440
440
|
};
|
|
441
|
+
pipe(e) {
|
|
442
|
+
this.subscribe((...args) => {
|
|
443
|
+
e.execute(...args);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
441
446
|
queuingSubscribe = (execute, complete, error) => {
|
|
442
447
|
if (this.ended) throw new Error("event completed");
|
|
443
448
|
const id = this.event.eventId;
|
|
@@ -522,6 +527,7 @@ var EventDisposer = class {
|
|
|
522
527
|
import {
|
|
523
528
|
createSocket as createSocket2
|
|
524
529
|
} from "dgram";
|
|
530
|
+
import net from "net";
|
|
525
531
|
import { connect } from "net";
|
|
526
532
|
var log = debug("werift-ice:packages/ice/src/transport.ts");
|
|
527
533
|
var UdpTransport = class _UdpTransport {
|
|
@@ -571,17 +577,23 @@ var UdpTransport = class _UdpTransport {
|
|
|
571
577
|
}
|
|
572
578
|
await new Promise((r) => this.socket.once("listening", r));
|
|
573
579
|
}
|
|
574
|
-
send = (data, addr) =>
|
|
575
|
-
addr
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
580
|
+
send = async (data, addr) => {
|
|
581
|
+
if (addr && !net.isIP(addr[0])) {
|
|
582
|
+
return new Promise((r, f) => {
|
|
583
|
+
this.socket.send(data, addr[1], addr[0], (error) => {
|
|
584
|
+
if (error) {
|
|
585
|
+
log("send error", addr, data);
|
|
586
|
+
f(error);
|
|
587
|
+
} else {
|
|
588
|
+
r();
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
} else {
|
|
593
|
+
addr = addr ?? [this.rinfo?.address, this.rinfo?.port];
|
|
594
|
+
this.socket.send(data, addr[1], addr[0]);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
585
597
|
get address() {
|
|
586
598
|
return this.socket.address();
|
|
587
599
|
}
|
|
@@ -818,7 +830,7 @@ var Mp4Container = class {
|
|
|
818
830
|
throw new Error("bufferFrame missing");
|
|
819
831
|
}
|
|
820
832
|
const duration = frame.timestamp - bufferFrame.timestamp;
|
|
821
|
-
const buffer2 = new
|
|
833
|
+
const buffer2 = new ArrayBuffer(bufferFrame.byteLength);
|
|
822
834
|
bufferFrame.copyTo(buffer2);
|
|
823
835
|
this.#mp4.addSample(track, buffer2, {
|
|
824
836
|
duration,
|
|
@@ -4022,6 +4034,7 @@ var RtpHeader = class _RtpHeader {
|
|
|
4022
4034
|
h.extensionLength = extensionLength;
|
|
4023
4035
|
currOffset += 2;
|
|
4024
4036
|
switch (h.extensionProfile) {
|
|
4037
|
+
// RFC 8285 RTP One Byte Header Extension
|
|
4025
4038
|
case ExtensionProfiles.OneByte:
|
|
4026
4039
|
{
|
|
4027
4040
|
const end = currOffset + extensionLength;
|
|
@@ -4045,6 +4058,7 @@ var RtpHeader = class _RtpHeader {
|
|
|
4045
4058
|
}
|
|
4046
4059
|
}
|
|
4047
4060
|
break;
|
|
4061
|
+
// RFC 8285 RTP Two Byte Header Extension
|
|
4048
4062
|
case ExtensionProfiles.TwoByte:
|
|
4049
4063
|
{
|
|
4050
4064
|
const end = currOffset + extensionLength;
|
|
@@ -4589,7 +4603,7 @@ var Context = class {
|
|
|
4589
4603
|
sessionSalt = Buffer.concat([sessionSalt, Buffer.from([0, 0])]);
|
|
4590
4604
|
const block = new AES.AES(this.masterKey);
|
|
4591
4605
|
sessionSalt = Buffer.from(block.encrypt(sessionSalt));
|
|
4592
|
-
return sessionSalt.
|
|
4606
|
+
return sessionSalt.subarray(0, 14);
|
|
4593
4607
|
}
|
|
4594
4608
|
generateSessionAuthTag(label) {
|
|
4595
4609
|
const sessionAuthTag = Buffer.from(this.masterSalt);
|
|
@@ -4605,12 +4619,18 @@ var Context = class {
|
|
|
4605
4619
|
for (let i = labelAndIndexOverKdr.length - 1, j = sessionAuthTag.length - 1; i >= 0; i--, j--) {
|
|
4606
4620
|
sessionAuthTag[j] = sessionAuthTag[j] ^ labelAndIndexOverKdr[i];
|
|
4607
4621
|
}
|
|
4608
|
-
let firstRun = Buffer.concat([
|
|
4609
|
-
|
|
4622
|
+
let firstRun = Buffer.concat([
|
|
4623
|
+
sessionAuthTag,
|
|
4624
|
+
Buffer.from([0, 0])
|
|
4625
|
+
]);
|
|
4626
|
+
let secondRun = Buffer.concat([
|
|
4627
|
+
sessionAuthTag,
|
|
4628
|
+
Buffer.from([0, 1])
|
|
4629
|
+
]);
|
|
4610
4630
|
const block = new AES.AES(this.masterKey);
|
|
4611
4631
|
firstRun = Buffer.from(block.encrypt(firstRun));
|
|
4612
4632
|
secondRun = Buffer.from(block.encrypt(secondRun));
|
|
4613
|
-
return Buffer.concat([firstRun, secondRun.
|
|
4633
|
+
return Buffer.concat([firstRun, secondRun.subarray(0, 4)]);
|
|
4614
4634
|
}
|
|
4615
4635
|
getSrtpSsrcState(ssrc) {
|
|
4616
4636
|
let s = this.srtpSSRCStates[ssrc];
|
|
@@ -5508,7 +5528,9 @@ var MP4Base = class {
|
|
|
5508
5528
|
if (!this.container.audioTrack) {
|
|
5509
5529
|
this.container.write({
|
|
5510
5530
|
codec: track.codec,
|
|
5511
|
-
description: buffer2ArrayBuffer(
|
|
5531
|
+
description: buffer2ArrayBuffer(
|
|
5532
|
+
OpusRtpPayload.createCodecPrivate()
|
|
5533
|
+
),
|
|
5512
5534
|
numberOfChannels: 2,
|
|
5513
5535
|
sampleRate: track.clockRate,
|
|
5514
5536
|
track: "audio"
|
|
@@ -6603,13 +6625,13 @@ var WebmStream = class extends WebmBase {
|
|
|
6603
6625
|
// src/nonstandard/navigator.ts
|
|
6604
6626
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
6605
6627
|
import { createSocket as createSocket3 } from "dgram";
|
|
6606
|
-
import { jspack as
|
|
6628
|
+
import { jspack as jspack8 } from "@shinyoshiaki/jspack";
|
|
6607
6629
|
|
|
6608
6630
|
// ../dtls/src/context/cipher.ts
|
|
6609
6631
|
import nodeCrypto, { createSign } from "crypto";
|
|
6610
6632
|
import { Certificate, PrivateKey } from "@fidm/x509";
|
|
6611
6633
|
import * as x509 from "@peculiar/x509";
|
|
6612
|
-
import {
|
|
6634
|
+
import { encode, types } from "@shinyoshiaki/binary-data";
|
|
6613
6635
|
import { addYears } from "date-fns";
|
|
6614
6636
|
|
|
6615
6637
|
// ../dtls/src/cipher/const.ts
|
|
@@ -6789,20 +6811,6 @@ var AbstractCipher = class {
|
|
|
6789
6811
|
}
|
|
6790
6812
|
};
|
|
6791
6813
|
|
|
6792
|
-
// ../dtls/src/handshake/binary.ts
|
|
6793
|
-
import { types } from "@shinyoshiaki/binary-data";
|
|
6794
|
-
var { uint16be, uint24be, buffer, array, uint8, string: string2 } = types;
|
|
6795
|
-
var Extension = {
|
|
6796
|
-
type: uint16be,
|
|
6797
|
-
data: buffer(uint16be)
|
|
6798
|
-
};
|
|
6799
|
-
var ExtensionList = array(Extension, uint16be, "bytes");
|
|
6800
|
-
var ASN11Cert = buffer(uint24be);
|
|
6801
|
-
var ClientCertificateType = uint8;
|
|
6802
|
-
var DistinguishedName = string2(uint16be);
|
|
6803
|
-
var SignatureHashAlgorithm = { hash: uint8, signature: uint8 };
|
|
6804
|
-
var ProtocolVersion = { major: uint8, minor: uint8 };
|
|
6805
|
-
|
|
6806
6814
|
// ../dtls/src/context/cipher.ts
|
|
6807
6815
|
var crypto = nodeCrypto.webcrypto;
|
|
6808
6816
|
x509.cryptoProvider.set(crypto);
|
|
@@ -6896,12 +6904,10 @@ var CipherContext = class {
|
|
|
6896
6904
|
};
|
|
6897
6905
|
encryptPacket(pkt) {
|
|
6898
6906
|
const header = pkt.recordLayerHeader;
|
|
6907
|
+
const version = header.protocolVersion.major << 8 | header.protocolVersion.minor;
|
|
6899
6908
|
const enc = this.cipher.encrypt(this.sessionType, pkt.fragment, {
|
|
6900
6909
|
type: header.contentType,
|
|
6901
|
-
version
|
|
6902
|
-
Buffer.from(encode(header.protocolVersion, ProtocolVersion).slice()),
|
|
6903
|
-
{ version: types2.uint16be }
|
|
6904
|
-
).version,
|
|
6910
|
+
version,
|
|
6905
6911
|
epoch: header.epoch,
|
|
6906
6912
|
sequenceNumber: header.sequenceNumber
|
|
6907
6913
|
});
|
|
@@ -6911,12 +6917,10 @@ var CipherContext = class {
|
|
|
6911
6917
|
}
|
|
6912
6918
|
decryptPacket(pkt) {
|
|
6913
6919
|
const header = pkt.recordLayerHeader;
|
|
6920
|
+
const version = header.protocolVersion.major << 8 | header.protocolVersion.minor;
|
|
6914
6921
|
const dec = this.cipher.decrypt(this.sessionType, pkt.fragment, {
|
|
6915
6922
|
type: header.contentType,
|
|
6916
|
-
version
|
|
6917
|
-
Buffer.from(encode(header.protocolVersion, ProtocolVersion).slice()),
|
|
6918
|
-
{ version: types2.uint16be }
|
|
6919
|
-
).version,
|
|
6923
|
+
version,
|
|
6920
6924
|
epoch: header.epoch,
|
|
6921
6925
|
sequenceNumber: header.sequenceNumber
|
|
6922
6926
|
});
|
|
@@ -6960,7 +6964,7 @@ var CipherContext = class {
|
|
|
6960
6964
|
curve: namedCurve,
|
|
6961
6965
|
len: publicKey.length
|
|
6962
6966
|
},
|
|
6963
|
-
{ type:
|
|
6967
|
+
{ type: types.uint8, curve: types.uint16be, len: types.uint8 }
|
|
6964
6968
|
).slice()
|
|
6965
6969
|
);
|
|
6966
6970
|
return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);
|
|
@@ -6978,10 +6982,10 @@ var SrtpContext2 = class {
|
|
|
6978
6982
|
};
|
|
6979
6983
|
|
|
6980
6984
|
// ../dtls/src/handshake/message/client/hello.ts
|
|
6981
|
-
import { decode as
|
|
6985
|
+
import { decode as decode3, encode as encode4, types as types5 } from "@shinyoshiaki/binary-data";
|
|
6982
6986
|
|
|
6983
6987
|
// ../dtls/src/record/message/fragment.ts
|
|
6984
|
-
import { decode
|
|
6988
|
+
import { decode, encode as encode2, types as types2 } from "@shinyoshiaki/binary-data";
|
|
6985
6989
|
|
|
6986
6990
|
// ../dtls/src/helper.ts
|
|
6987
6991
|
var dumpBuffer2 = (data) => "0x" + data.toString("hex").replace(/(.)(.)/g, "$1$2 ").split(" ").filter((s) => s != void 0 && s.length > 0).join(",0x");
|
|
@@ -7006,12 +7010,12 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
7006
7010
|
this.fragment = fragment;
|
|
7007
7011
|
}
|
|
7008
7012
|
static spec = {
|
|
7009
|
-
msg_type:
|
|
7010
|
-
length:
|
|
7011
|
-
message_seq:
|
|
7012
|
-
fragment_offset:
|
|
7013
|
-
fragment_length:
|
|
7014
|
-
fragment:
|
|
7013
|
+
msg_type: types2.uint8,
|
|
7014
|
+
length: types2.uint24be,
|
|
7015
|
+
message_seq: types2.uint16be,
|
|
7016
|
+
fragment_offset: types2.uint24be,
|
|
7017
|
+
fragment_length: types2.uint24be,
|
|
7018
|
+
fragment: types2.buffer((context) => context.current.fragment_length)
|
|
7015
7019
|
};
|
|
7016
7020
|
get summary() {
|
|
7017
7021
|
return getObjectSummary(this);
|
|
@@ -7028,7 +7032,7 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
7028
7032
|
}
|
|
7029
7033
|
static deSerialize(buf) {
|
|
7030
7034
|
return new _FragmentedHandshake(
|
|
7031
|
-
...Object.values(
|
|
7035
|
+
...Object.values(decode(buf, _FragmentedHandshake.spec))
|
|
7032
7036
|
);
|
|
7033
7037
|
}
|
|
7034
7038
|
serialize() {
|
|
@@ -7105,9 +7109,23 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
7105
7109
|
}
|
|
7106
7110
|
};
|
|
7107
7111
|
|
|
7112
|
+
// ../dtls/src/handshake/binary.ts
|
|
7113
|
+
import { types as types3 } from "@shinyoshiaki/binary-data";
|
|
7114
|
+
var { uint16be, uint24be, buffer, array, uint8, string: string2 } = types3;
|
|
7115
|
+
var Extension = {
|
|
7116
|
+
type: uint16be,
|
|
7117
|
+
data: buffer(uint16be)
|
|
7118
|
+
};
|
|
7119
|
+
var ExtensionList = array(Extension, uint16be, "bytes");
|
|
7120
|
+
var ASN11Cert = buffer(uint24be);
|
|
7121
|
+
var ClientCertificateType = uint8;
|
|
7122
|
+
var DistinguishedName = string2(uint16be);
|
|
7123
|
+
var SignatureHashAlgorithm = { hash: uint8, signature: uint8 };
|
|
7124
|
+
var ProtocolVersion = { major: uint8, minor: uint8 };
|
|
7125
|
+
|
|
7108
7126
|
// ../dtls/src/handshake/random.ts
|
|
7109
7127
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
7110
|
-
import { decode as
|
|
7128
|
+
import { decode as decode2, encode as encode3, types as types4 } from "@shinyoshiaki/binary-data";
|
|
7111
7129
|
var DtlsRandom = class _DtlsRandom {
|
|
7112
7130
|
constructor(gmt_unix_time = Math.floor(Date.now() / 1e3), random_bytes = randomBytes3(28)) {
|
|
7113
7131
|
this.gmt_unix_time = gmt_unix_time;
|
|
@@ -7119,7 +7137,7 @@ var DtlsRandom = class _DtlsRandom {
|
|
|
7119
7137
|
};
|
|
7120
7138
|
static deSerialize(buf) {
|
|
7121
7139
|
return new _DtlsRandom(
|
|
7122
|
-
...Object.values(
|
|
7140
|
+
...Object.values(decode2(buf, _DtlsRandom.spec))
|
|
7123
7141
|
);
|
|
7124
7142
|
}
|
|
7125
7143
|
static from(spec) {
|
|
@@ -7166,7 +7184,7 @@ var ClientHello = class _ClientHello {
|
|
|
7166
7184
|
}
|
|
7167
7185
|
static deSerialize(buf) {
|
|
7168
7186
|
return new _ClientHello(
|
|
7169
|
-
...Object.values(
|
|
7187
|
+
...Object.values(decode3(buf, _ClientHello.spec))
|
|
7170
7188
|
);
|
|
7171
7189
|
}
|
|
7172
7190
|
serialize() {
|
|
@@ -7186,45 +7204,8 @@ var ClientHello = class _ClientHello {
|
|
|
7186
7204
|
}
|
|
7187
7205
|
};
|
|
7188
7206
|
|
|
7189
|
-
// ../dtls/src/record/message/plaintext.ts
|
|
7190
|
-
import { decode as decode6, encode as encode6, types as types7 } from "@shinyoshiaki/binary-data";
|
|
7191
|
-
|
|
7192
7207
|
// ../dtls/src/record/message/header.ts
|
|
7193
|
-
import { decode as
|
|
7194
|
-
var DtlsPlaintextHeader = class _DtlsPlaintextHeader {
|
|
7195
|
-
constructor(contentType, protocolVersion, epoch, sequenceNumber, contentLen) {
|
|
7196
|
-
this.contentType = contentType;
|
|
7197
|
-
this.protocolVersion = protocolVersion;
|
|
7198
|
-
this.epoch = epoch;
|
|
7199
|
-
this.sequenceNumber = sequenceNumber;
|
|
7200
|
-
this.contentLen = contentLen;
|
|
7201
|
-
}
|
|
7202
|
-
static spec = {
|
|
7203
|
-
contentType: types6.uint8,
|
|
7204
|
-
protocolVersion: ProtocolVersion,
|
|
7205
|
-
epoch: types6.uint16be,
|
|
7206
|
-
sequenceNumber: types6.uint48be,
|
|
7207
|
-
contentLen: types6.uint16be
|
|
7208
|
-
};
|
|
7209
|
-
static createEmpty() {
|
|
7210
|
-
return new _DtlsPlaintextHeader(
|
|
7211
|
-
void 0,
|
|
7212
|
-
void 0,
|
|
7213
|
-
void 0,
|
|
7214
|
-
void 0,
|
|
7215
|
-
void 0
|
|
7216
|
-
);
|
|
7217
|
-
}
|
|
7218
|
-
static deSerialize(buf) {
|
|
7219
|
-
return new _DtlsPlaintextHeader(
|
|
7220
|
-
...Object.values(decode5(buf, _DtlsPlaintextHeader.spec))
|
|
7221
|
-
);
|
|
7222
|
-
}
|
|
7223
|
-
serialize() {
|
|
7224
|
-
const res = encode5(this, _DtlsPlaintextHeader.spec).slice();
|
|
7225
|
-
return Buffer.from(res);
|
|
7226
|
-
}
|
|
7227
|
-
};
|
|
7208
|
+
import { decode as decode4, encode as encode5, types as types6 } from "@shinyoshiaki/binary-data";
|
|
7228
7209
|
var MACHeader = class _MACHeader {
|
|
7229
7210
|
constructor(epoch, sequenceNumber, contentType, protocolVersion, contentLen) {
|
|
7230
7211
|
this.epoch = epoch;
|
|
@@ -7251,7 +7232,7 @@ var MACHeader = class _MACHeader {
|
|
|
7251
7232
|
}
|
|
7252
7233
|
static deSerialize(buf) {
|
|
7253
7234
|
return new _MACHeader(
|
|
7254
|
-
...Object.values(
|
|
7235
|
+
...Object.values(decode4(buf, _MACHeader.spec))
|
|
7255
7236
|
);
|
|
7256
7237
|
}
|
|
7257
7238
|
serialize() {
|
|
@@ -7260,48 +7241,6 @@ var MACHeader = class _MACHeader {
|
|
|
7260
7241
|
}
|
|
7261
7242
|
};
|
|
7262
7243
|
|
|
7263
|
-
// ../dtls/src/record/message/plaintext.ts
|
|
7264
|
-
var DtlsPlaintext = class _DtlsPlaintext {
|
|
7265
|
-
constructor(recordLayerHeader, fragment) {
|
|
7266
|
-
this.recordLayerHeader = recordLayerHeader;
|
|
7267
|
-
this.fragment = fragment;
|
|
7268
|
-
}
|
|
7269
|
-
static spec = {
|
|
7270
|
-
recordLayerHeader: DtlsPlaintextHeader.spec,
|
|
7271
|
-
fragment: types7.buffer(
|
|
7272
|
-
(context) => context.current.recordLayerHeader.contentLen
|
|
7273
|
-
)
|
|
7274
|
-
};
|
|
7275
|
-
get summary() {
|
|
7276
|
-
return {
|
|
7277
|
-
header: this.recordLayerHeader,
|
|
7278
|
-
fragment: dumpBuffer2(this.fragment)
|
|
7279
|
-
};
|
|
7280
|
-
}
|
|
7281
|
-
static createEmpty() {
|
|
7282
|
-
return new _DtlsPlaintext(void 0, void 0);
|
|
7283
|
-
}
|
|
7284
|
-
static deSerialize(buf) {
|
|
7285
|
-
const r = new _DtlsPlaintext(
|
|
7286
|
-
...Object.values(decode6(buf, _DtlsPlaintext.spec))
|
|
7287
|
-
);
|
|
7288
|
-
return r;
|
|
7289
|
-
}
|
|
7290
|
-
serialize() {
|
|
7291
|
-
const res = encode6(this, _DtlsPlaintext.spec).slice();
|
|
7292
|
-
return Buffer.from(res);
|
|
7293
|
-
}
|
|
7294
|
-
computeMACHeader() {
|
|
7295
|
-
return new MACHeader(
|
|
7296
|
-
this.recordLayerHeader.epoch,
|
|
7297
|
-
this.recordLayerHeader.sequenceNumber,
|
|
7298
|
-
this.recordLayerHeader.contentType,
|
|
7299
|
-
this.recordLayerHeader.protocolVersion,
|
|
7300
|
-
this.recordLayerHeader.contentLen
|
|
7301
|
-
).serialize();
|
|
7302
|
-
}
|
|
7303
|
-
};
|
|
7304
|
-
|
|
7305
7244
|
// ../dtls/src/flight/flight.ts
|
|
7306
7245
|
var warn = debug("werift-dtls : packages/dtls/src/flight/flight.ts : warn");
|
|
7307
7246
|
var err = debug("werift-dtls : packages/dtls/src/flight/flight.ts : err");
|
|
@@ -7384,17 +7323,6 @@ function createECDHEPSKKeyExchange() {
|
|
|
7384
7323
|
|
|
7385
7324
|
// ../dtls/src/cipher/suites/aead.ts
|
|
7386
7325
|
import * as crypto2 from "crypto";
|
|
7387
|
-
import { createDecode as createDecode2, encode as encode7, types as types8 } from "@shinyoshiaki/binary-data";
|
|
7388
|
-
var { uint8: uint82, uint16be: uint16be2, uint48be } = types8;
|
|
7389
|
-
var ContentType2 = uint82;
|
|
7390
|
-
var ProtocolVersion2 = uint16be2;
|
|
7391
|
-
var AEADAdditionalData = {
|
|
7392
|
-
epoch: uint16be2,
|
|
7393
|
-
sequence: uint48be,
|
|
7394
|
-
type: ContentType2,
|
|
7395
|
-
version: ProtocolVersion2,
|
|
7396
|
-
length: uint16be2
|
|
7397
|
-
};
|
|
7398
7326
|
var err2 = debug(
|
|
7399
7327
|
"werift-dtls : packages/dtls/src/cipher/suites/aead.ts : err"
|
|
7400
7328
|
);
|
|
@@ -7441,14 +7369,7 @@ var AEADCipher = class extends AbstractCipher {
|
|
|
7441
7369
|
iv.writeUInt16BE(header.epoch, this.nonceImplicitLength);
|
|
7442
7370
|
iv.writeUIntBE(header.sequenceNumber, this.nonceImplicitLength + 2, 6);
|
|
7443
7371
|
const explicitNonce = iv.slice(this.nonceImplicitLength);
|
|
7444
|
-
const
|
|
7445
|
-
epoch: header.epoch,
|
|
7446
|
-
sequence: header.sequenceNumber,
|
|
7447
|
-
type: header.type,
|
|
7448
|
-
version: header.version,
|
|
7449
|
-
length: data.length
|
|
7450
|
-
};
|
|
7451
|
-
const additionalBuffer = encode7(additionalData, AEADAdditionalData).slice();
|
|
7372
|
+
const additionalBuffer = this.encodeAdditionalBuffer(header, data.length);
|
|
7452
7373
|
const cipher = crypto2.createCipheriv(
|
|
7453
7374
|
this.blockAlgorithm,
|
|
7454
7375
|
writeKey,
|
|
@@ -7465,6 +7386,15 @@ var AEADCipher = class extends AbstractCipher {
|
|
|
7465
7386
|
const authTag = cipher.getAuthTag();
|
|
7466
7387
|
return Buffer.concat([explicitNonce, headPart, finalPart, authTag]);
|
|
7467
7388
|
}
|
|
7389
|
+
encodeAdditionalBuffer(header, dataLength) {
|
|
7390
|
+
const additionalBuffer = Buffer.alloc(13);
|
|
7391
|
+
additionalBuffer.writeUInt16BE(header.epoch, 0);
|
|
7392
|
+
additionalBuffer.writeUintBE(header.sequenceNumber, 2, 6);
|
|
7393
|
+
additionalBuffer.writeUInt8(header.type, 8);
|
|
7394
|
+
additionalBuffer.writeUInt16BE(header.version, 9);
|
|
7395
|
+
additionalBuffer.writeUInt16BE(dataLength, 11);
|
|
7396
|
+
return additionalBuffer;
|
|
7397
|
+
}
|
|
7468
7398
|
/**
|
|
7469
7399
|
* Decrypt message.
|
|
7470
7400
|
*/
|
|
@@ -7473,19 +7403,17 @@ var AEADCipher = class extends AbstractCipher {
|
|
|
7473
7403
|
const iv = isClient ? this.serverNonce : this.clientNonce;
|
|
7474
7404
|
const writeKey = isClient ? this.serverWriteKey : this.clientWriteKey;
|
|
7475
7405
|
if (!iv || !writeKey) throw new Error();
|
|
7476
|
-
const
|
|
7477
|
-
const explicitNonce = final.readBuffer(this.nonceExplicitLength);
|
|
7406
|
+
const explicitNonce = data.subarray(0, this.nonceExplicitLength);
|
|
7478
7407
|
explicitNonce.copy(iv, this.nonceImplicitLength);
|
|
7479
|
-
const encrypted =
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
const additionalBuffer = encode7(additionalData, AEADAdditionalData).slice();
|
|
7408
|
+
const encrypted = data.subarray(
|
|
7409
|
+
this.nonceExplicitLength,
|
|
7410
|
+
data.length - this.authTagLength
|
|
7411
|
+
);
|
|
7412
|
+
const authTag = data.subarray(data.length - this.authTagLength);
|
|
7413
|
+
const additionalBuffer = this.encodeAdditionalBuffer(
|
|
7414
|
+
header,
|
|
7415
|
+
encrypted.length
|
|
7416
|
+
);
|
|
7489
7417
|
const decipher = crypto2.createDecipheriv(
|
|
7490
7418
|
this.blockAlgorithm,
|
|
7491
7419
|
writeKey,
|
|
@@ -7710,12 +7638,12 @@ var ExtendedMasterSecret = class {
|
|
|
7710
7638
|
};
|
|
7711
7639
|
|
|
7712
7640
|
// ../dtls/src/handshake/extensions/renegotiationIndication.ts
|
|
7713
|
-
import { decode as
|
|
7641
|
+
import { decode as decode5, encode as encode6, types as types7 } from "@shinyoshiaki/binary-data";
|
|
7714
7642
|
var RenegotiationIndication = class _RenegotiationIndication {
|
|
7715
7643
|
static type = 65281;
|
|
7716
7644
|
static spec = {
|
|
7717
|
-
type:
|
|
7718
|
-
data:
|
|
7645
|
+
type: types7.uint16be,
|
|
7646
|
+
data: types7.uint8
|
|
7719
7647
|
};
|
|
7720
7648
|
type = _RenegotiationIndication.type;
|
|
7721
7649
|
data = 0;
|
|
@@ -7728,11 +7656,11 @@ var RenegotiationIndication = class _RenegotiationIndication {
|
|
|
7728
7656
|
}
|
|
7729
7657
|
static deSerialize(buf) {
|
|
7730
7658
|
return new _RenegotiationIndication(
|
|
7731
|
-
|
|
7659
|
+
decode5(buf, _RenegotiationIndication.spec)
|
|
7732
7660
|
);
|
|
7733
7661
|
}
|
|
7734
7662
|
serialize() {
|
|
7735
|
-
const res =
|
|
7663
|
+
const res = encode6(this, _RenegotiationIndication.spec).slice();
|
|
7736
7664
|
return Buffer.from(res);
|
|
7737
7665
|
}
|
|
7738
7666
|
get extension() {
|
|
@@ -7744,14 +7672,14 @@ var RenegotiationIndication = class _RenegotiationIndication {
|
|
|
7744
7672
|
};
|
|
7745
7673
|
|
|
7746
7674
|
// ../dtls/src/handshake/extensions/useSrtp.ts
|
|
7747
|
-
import { decode as
|
|
7675
|
+
import { decode as decode6, encode as encode7, types as types8 } from "@shinyoshiaki/binary-data";
|
|
7748
7676
|
import times from "lodash/times.js";
|
|
7749
7677
|
var UseSRTP = class _UseSRTP {
|
|
7750
7678
|
static type = 14;
|
|
7751
7679
|
// 9. IANA Considerations
|
|
7752
7680
|
static spec = {
|
|
7753
|
-
type:
|
|
7754
|
-
data:
|
|
7681
|
+
type: types8.uint16be,
|
|
7682
|
+
data: types8.buffer(types8.uint16be)
|
|
7755
7683
|
};
|
|
7756
7684
|
type = _UseSRTP.type;
|
|
7757
7685
|
data = Buffer.from([]);
|
|
@@ -7768,7 +7696,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
7768
7696
|
return v;
|
|
7769
7697
|
}
|
|
7770
7698
|
static deSerialize(buf) {
|
|
7771
|
-
const useSrtp = new _UseSRTP(
|
|
7699
|
+
const useSrtp = new _UseSRTP(decode6(buf, _UseSRTP.spec));
|
|
7772
7700
|
const profileLength = useSrtp.data.readUInt16BE();
|
|
7773
7701
|
const profiles = times(profileLength / 2).map((i) => {
|
|
7774
7702
|
return useSrtp.data.readUInt16BE(i * 2 + 2);
|
|
@@ -7790,7 +7718,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
7790
7718
|
this.mki
|
|
7791
7719
|
]);
|
|
7792
7720
|
this.data = data;
|
|
7793
|
-
const res =
|
|
7721
|
+
const res = encode7(this, _UseSRTP.spec).slice();
|
|
7794
7722
|
return Buffer.from(res);
|
|
7795
7723
|
}
|
|
7796
7724
|
static fromData(buf) {
|
|
@@ -7808,7 +7736,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
7808
7736
|
};
|
|
7809
7737
|
|
|
7810
7738
|
// ../dtls/src/handshake/message/certificate.ts
|
|
7811
|
-
import { decode as
|
|
7739
|
+
import { decode as decode7, encode as encode8, types as types9 } from "@shinyoshiaki/binary-data";
|
|
7812
7740
|
var Certificate2 = class _Certificate {
|
|
7813
7741
|
constructor(certificateList) {
|
|
7814
7742
|
this.certificateList = certificateList;
|
|
@@ -7816,18 +7744,18 @@ var Certificate2 = class _Certificate {
|
|
|
7816
7744
|
msgType = 11 /* certificate_11 */;
|
|
7817
7745
|
messageSeq;
|
|
7818
7746
|
static spec = {
|
|
7819
|
-
certificateList:
|
|
7747
|
+
certificateList: types9.array(ASN11Cert, types9.uint24be, "bytes")
|
|
7820
7748
|
};
|
|
7821
7749
|
static createEmpty() {
|
|
7822
7750
|
return new _Certificate(void 0);
|
|
7823
7751
|
}
|
|
7824
7752
|
static deSerialize(buf) {
|
|
7825
7753
|
return new _Certificate(
|
|
7826
|
-
...Object.values(
|
|
7754
|
+
...Object.values(decode7(buf, _Certificate.spec))
|
|
7827
7755
|
);
|
|
7828
7756
|
}
|
|
7829
7757
|
serialize() {
|
|
7830
|
-
const res =
|
|
7758
|
+
const res = encode8(this, _Certificate.spec).slice();
|
|
7831
7759
|
return Buffer.from(res);
|
|
7832
7760
|
}
|
|
7833
7761
|
toFragment() {
|
|
@@ -7844,30 +7772,30 @@ var Certificate2 = class _Certificate {
|
|
|
7844
7772
|
};
|
|
7845
7773
|
|
|
7846
7774
|
// ../dtls/src/handshake/message/changeCipherSpec.ts
|
|
7847
|
-
import { decode as
|
|
7775
|
+
import { decode as decode8, encode as encode9, types as types10 } from "@shinyoshiaki/binary-data";
|
|
7848
7776
|
var ChangeCipherSpec = class _ChangeCipherSpec {
|
|
7849
7777
|
constructor(type = 1) {
|
|
7850
7778
|
this.type = type;
|
|
7851
7779
|
}
|
|
7852
7780
|
static spec = {
|
|
7853
|
-
type:
|
|
7781
|
+
type: types10.uint8
|
|
7854
7782
|
};
|
|
7855
7783
|
static createEmpty() {
|
|
7856
7784
|
return new _ChangeCipherSpec();
|
|
7857
7785
|
}
|
|
7858
7786
|
static deSerialize(buf) {
|
|
7859
7787
|
return new _ChangeCipherSpec(
|
|
7860
|
-
...Object.values(
|
|
7788
|
+
...Object.values(decode8(buf, _ChangeCipherSpec.spec))
|
|
7861
7789
|
);
|
|
7862
7790
|
}
|
|
7863
7791
|
serialize() {
|
|
7864
|
-
const res =
|
|
7792
|
+
const res = encode9(this, _ChangeCipherSpec.spec).slice();
|
|
7865
7793
|
return Buffer.from(res);
|
|
7866
7794
|
}
|
|
7867
7795
|
};
|
|
7868
7796
|
|
|
7869
7797
|
// ../dtls/src/handshake/message/client/certificateVerify.ts
|
|
7870
|
-
import { decode as
|
|
7798
|
+
import { decode as decode9, encode as encode10, types as types11 } from "@shinyoshiaki/binary-data";
|
|
7871
7799
|
var CertificateVerify = class _CertificateVerify {
|
|
7872
7800
|
constructor(algorithm, signature) {
|
|
7873
7801
|
this.algorithm = algorithm;
|
|
@@ -7876,20 +7804,20 @@ var CertificateVerify = class _CertificateVerify {
|
|
|
7876
7804
|
msgType = 15 /* certificate_verify_15 */;
|
|
7877
7805
|
messageSeq;
|
|
7878
7806
|
static spec = {
|
|
7879
|
-
algorithm:
|
|
7880
|
-
signature:
|
|
7807
|
+
algorithm: types11.uint16be,
|
|
7808
|
+
signature: types11.buffer(types11.uint16be)
|
|
7881
7809
|
};
|
|
7882
7810
|
static createEmpty() {
|
|
7883
7811
|
return new _CertificateVerify(void 0, void 0);
|
|
7884
7812
|
}
|
|
7885
7813
|
static deSerialize(buf) {
|
|
7886
|
-
const res =
|
|
7814
|
+
const res = decode9(buf, _CertificateVerify.spec);
|
|
7887
7815
|
return new _CertificateVerify(
|
|
7888
7816
|
...Object.values(res)
|
|
7889
7817
|
);
|
|
7890
7818
|
}
|
|
7891
7819
|
serialize() {
|
|
7892
|
-
const res =
|
|
7820
|
+
const res = encode10(this, _CertificateVerify.spec).slice();
|
|
7893
7821
|
return Buffer.from(res);
|
|
7894
7822
|
}
|
|
7895
7823
|
toFragment() {
|
|
@@ -7906,7 +7834,7 @@ var CertificateVerify = class _CertificateVerify {
|
|
|
7906
7834
|
};
|
|
7907
7835
|
|
|
7908
7836
|
// ../dtls/src/handshake/message/client/keyExchange.ts
|
|
7909
|
-
import { decode as
|
|
7837
|
+
import { decode as decode10, encode as encode11, types as types12 } from "@shinyoshiaki/binary-data";
|
|
7910
7838
|
var ClientKeyExchange = class _ClientKeyExchange {
|
|
7911
7839
|
constructor(publicKey) {
|
|
7912
7840
|
this.publicKey = publicKey;
|
|
@@ -7914,19 +7842,19 @@ var ClientKeyExchange = class _ClientKeyExchange {
|
|
|
7914
7842
|
msgType = 16 /* client_key_exchange_16 */;
|
|
7915
7843
|
messageSeq;
|
|
7916
7844
|
static spec = {
|
|
7917
|
-
publicKey:
|
|
7845
|
+
publicKey: types12.buffer(types12.uint8)
|
|
7918
7846
|
};
|
|
7919
7847
|
static createEmpty() {
|
|
7920
7848
|
return new _ClientKeyExchange(void 0);
|
|
7921
7849
|
}
|
|
7922
7850
|
static deSerialize(buf) {
|
|
7923
|
-
const res =
|
|
7851
|
+
const res = decode10(buf, _ClientKeyExchange.spec);
|
|
7924
7852
|
return new _ClientKeyExchange(
|
|
7925
7853
|
...Object.values(res)
|
|
7926
7854
|
);
|
|
7927
7855
|
}
|
|
7928
7856
|
serialize() {
|
|
7929
|
-
const res =
|
|
7857
|
+
const res = encode11(this, _ClientKeyExchange.spec).slice();
|
|
7930
7858
|
return Buffer.from(res);
|
|
7931
7859
|
}
|
|
7932
7860
|
toFragment() {
|
|
@@ -7943,7 +7871,7 @@ var ClientKeyExchange = class _ClientKeyExchange {
|
|
|
7943
7871
|
};
|
|
7944
7872
|
|
|
7945
7873
|
// ../dtls/src/handshake/message/server/certificateRequest.ts
|
|
7946
|
-
import { decode as
|
|
7874
|
+
import { decode as decode11, encode as encode12, types as types13 } from "@shinyoshiaki/binary-data";
|
|
7947
7875
|
var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
7948
7876
|
constructor(certificateTypes2, signatures2, authorities) {
|
|
7949
7877
|
this.certificateTypes = certificateTypes2;
|
|
@@ -7953,9 +7881,9 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
7953
7881
|
msgType = 13 /* certificate_request_13 */;
|
|
7954
7882
|
messageSeq;
|
|
7955
7883
|
static spec = {
|
|
7956
|
-
certificateTypes:
|
|
7957
|
-
signatures:
|
|
7958
|
-
authorities:
|
|
7884
|
+
certificateTypes: types13.array(ClientCertificateType, types13.uint8, "bytes"),
|
|
7885
|
+
signatures: types13.array(SignatureHashAlgorithm, types13.uint16be, "bytes"),
|
|
7886
|
+
authorities: types13.array(DistinguishedName, types13.uint16be, "bytes")
|
|
7959
7887
|
};
|
|
7960
7888
|
static createEmpty() {
|
|
7961
7889
|
return new _ServerCertificateRequest(
|
|
@@ -7966,11 +7894,11 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
7966
7894
|
}
|
|
7967
7895
|
static deSerialize(buf) {
|
|
7968
7896
|
return new _ServerCertificateRequest(
|
|
7969
|
-
...Object.values(
|
|
7897
|
+
...Object.values(decode11(buf, _ServerCertificateRequest.spec))
|
|
7970
7898
|
);
|
|
7971
7899
|
}
|
|
7972
7900
|
serialize() {
|
|
7973
|
-
const res =
|
|
7901
|
+
const res = encode12(this, _ServerCertificateRequest.spec).slice();
|
|
7974
7902
|
return Buffer.from(res);
|
|
7975
7903
|
}
|
|
7976
7904
|
toFragment() {
|
|
@@ -7987,7 +7915,7 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
7987
7915
|
};
|
|
7988
7916
|
|
|
7989
7917
|
// ../dtls/src/handshake/message/server/hello.ts
|
|
7990
|
-
import { decode as
|
|
7918
|
+
import { decode as decode12, encode as encode13, types as types14 } from "@shinyoshiaki/binary-data";
|
|
7991
7919
|
var ServerHello = class _ServerHello {
|
|
7992
7920
|
constructor(serverVersion, random, sessionId, cipherSuite, compressionMethod, extensions) {
|
|
7993
7921
|
this.serverVersion = serverVersion;
|
|
@@ -8002,9 +7930,9 @@ var ServerHello = class _ServerHello {
|
|
|
8002
7930
|
static spec = {
|
|
8003
7931
|
serverVersion: ProtocolVersion,
|
|
8004
7932
|
random: DtlsRandom.spec,
|
|
8005
|
-
sessionId:
|
|
8006
|
-
cipherSuite:
|
|
8007
|
-
compressionMethod:
|
|
7933
|
+
sessionId: types14.buffer(types14.uint8),
|
|
7934
|
+
cipherSuite: types14.uint16be,
|
|
7935
|
+
compressionMethod: types14.uint8
|
|
8008
7936
|
};
|
|
8009
7937
|
static createEmpty() {
|
|
8010
7938
|
return new _ServerHello(
|
|
@@ -8017,7 +7945,7 @@ var ServerHello = class _ServerHello {
|
|
|
8017
7945
|
);
|
|
8018
7946
|
}
|
|
8019
7947
|
static deSerialize(buf) {
|
|
8020
|
-
const res =
|
|
7948
|
+
const res = decode12(buf, _ServerHello.spec);
|
|
8021
7949
|
const cls = new _ServerHello(
|
|
8022
7950
|
...Object.values(res)
|
|
8023
7951
|
);
|
|
@@ -8025,14 +7953,14 @@ var ServerHello = class _ServerHello {
|
|
|
8025
7953
|
if (expect.length < buf.length) {
|
|
8026
7954
|
return new _ServerHello(
|
|
8027
7955
|
...Object.values(
|
|
8028
|
-
|
|
7956
|
+
decode12(buf, { ..._ServerHello.spec, extensions: ExtensionList })
|
|
8029
7957
|
)
|
|
8030
7958
|
);
|
|
8031
7959
|
}
|
|
8032
7960
|
return cls;
|
|
8033
7961
|
}
|
|
8034
7962
|
serialize() {
|
|
8035
|
-
const res = this.extensions === void 0 ?
|
|
7963
|
+
const res = this.extensions === void 0 ? encode13(this, _ServerHello.spec).slice() : encode13(this, {
|
|
8036
7964
|
..._ServerHello.spec,
|
|
8037
7965
|
extensions: ExtensionList
|
|
8038
7966
|
}).slice();
|
|
@@ -8052,15 +7980,15 @@ var ServerHello = class _ServerHello {
|
|
|
8052
7980
|
};
|
|
8053
7981
|
|
|
8054
7982
|
// ../dtls/src/handshake/message/server/helloDone.ts
|
|
8055
|
-
import { decode as
|
|
7983
|
+
import { decode as decode13, encode as encode14 } from "@shinyoshiaki/binary-data";
|
|
8056
7984
|
|
|
8057
7985
|
// ../dtls/src/handshake/message/server/keyExchange.ts
|
|
8058
|
-
import { decode as
|
|
7986
|
+
import { decode as decode14, types as types15 } from "@shinyoshiaki/binary-data";
|
|
8059
7987
|
|
|
8060
7988
|
// ../dtls/src/util/binary.ts
|
|
8061
|
-
import { encode as
|
|
7989
|
+
import { encode as encode15 } from "@shinyoshiaki/binary-data";
|
|
8062
7990
|
function encodeBuffer(obj, spec) {
|
|
8063
|
-
return Buffer.from(
|
|
7991
|
+
return Buffer.from(encode15(obj, spec).slice());
|
|
8064
7992
|
}
|
|
8065
7993
|
|
|
8066
7994
|
// ../dtls/src/handshake/message/server/keyExchange.ts
|
|
@@ -8078,14 +8006,14 @@ var ServerKeyExchange = class _ServerKeyExchange {
|
|
|
8078
8006
|
msgType = 12 /* server_key_exchange_12 */;
|
|
8079
8007
|
messageSeq;
|
|
8080
8008
|
static spec = {
|
|
8081
|
-
ellipticCurveType:
|
|
8082
|
-
namedCurve:
|
|
8083
|
-
publicKeyLength:
|
|
8084
|
-
publicKey:
|
|
8085
|
-
hashAlgorithm:
|
|
8086
|
-
signatureAlgorithm:
|
|
8087
|
-
signatureLength:
|
|
8088
|
-
signature:
|
|
8009
|
+
ellipticCurveType: types15.uint8,
|
|
8010
|
+
namedCurve: types15.uint16be,
|
|
8011
|
+
publicKeyLength: types15.uint8,
|
|
8012
|
+
publicKey: types15.buffer((ctx) => ctx.current.publicKeyLength),
|
|
8013
|
+
hashAlgorithm: types15.uint8,
|
|
8014
|
+
signatureAlgorithm: types15.uint8,
|
|
8015
|
+
signatureLength: types15.uint16be,
|
|
8016
|
+
signature: types15.buffer((ctx) => ctx.current.signatureLength)
|
|
8089
8017
|
};
|
|
8090
8018
|
static createEmpty() {
|
|
8091
8019
|
return new _ServerKeyExchange(
|
|
@@ -8100,7 +8028,7 @@ var ServerKeyExchange = class _ServerKeyExchange {
|
|
|
8100
8028
|
);
|
|
8101
8029
|
}
|
|
8102
8030
|
static deSerialize(buf) {
|
|
8103
|
-
const res =
|
|
8031
|
+
const res = decode14(buf, _ServerKeyExchange.spec);
|
|
8104
8032
|
return new _ServerKeyExchange(
|
|
8105
8033
|
...Object.values(res)
|
|
8106
8034
|
);
|
|
@@ -8181,7 +8109,7 @@ handlers[14 /* server_hello_done_14 */] = ({ dtls }) => (msg) => {
|
|
|
8181
8109
|
};
|
|
8182
8110
|
|
|
8183
8111
|
// ../dtls/src/handshake/message/server/helloVerifyRequest.ts
|
|
8184
|
-
import { decode as
|
|
8112
|
+
import { decode as decode15, encode as encode16, types as types16 } from "@shinyoshiaki/binary-data";
|
|
8185
8113
|
var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
8186
8114
|
constructor(serverVersion, cookie) {
|
|
8187
8115
|
this.serverVersion = serverVersion;
|
|
@@ -8191,18 +8119,18 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
|
8191
8119
|
messageSeq;
|
|
8192
8120
|
static spec = {
|
|
8193
8121
|
serverVersion: ProtocolVersion,
|
|
8194
|
-
cookie:
|
|
8122
|
+
cookie: types16.buffer(types16.uint8)
|
|
8195
8123
|
};
|
|
8196
8124
|
static createEmpty() {
|
|
8197
8125
|
return new _ServerHelloVerifyRequest(void 0, void 0);
|
|
8198
8126
|
}
|
|
8199
8127
|
static deSerialize(buf) {
|
|
8200
8128
|
return new _ServerHelloVerifyRequest(
|
|
8201
|
-
...Object.values(
|
|
8129
|
+
...Object.values(decode15(buf, _ServerHelloVerifyRequest.spec))
|
|
8202
8130
|
);
|
|
8203
8131
|
}
|
|
8204
8132
|
serialize() {
|
|
8205
|
-
const res =
|
|
8133
|
+
const res = encode16(this, _ServerHelloVerifyRequest.spec).slice();
|
|
8206
8134
|
return Buffer.from(res);
|
|
8207
8135
|
}
|
|
8208
8136
|
get version() {
|
|
@@ -8225,18 +8153,18 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
|
8225
8153
|
};
|
|
8226
8154
|
|
|
8227
8155
|
// ../dtls/src/socket.ts
|
|
8228
|
-
import { decode as
|
|
8156
|
+
import { decode as decode19, types as types20 } from "@shinyoshiaki/binary-data";
|
|
8229
8157
|
|
|
8230
8158
|
// ../dtls/src/context/dtls.ts
|
|
8231
8159
|
var log12 = debug("werift-dtls : packages/dtls/src/context/dtls.ts : log");
|
|
8232
8160
|
|
|
8233
8161
|
// ../dtls/src/handshake/extensions/ellipticCurves.ts
|
|
8234
|
-
import { decode as
|
|
8162
|
+
import { decode as decode16, encode as encode17, types as types17 } from "@shinyoshiaki/binary-data";
|
|
8235
8163
|
var EllipticCurves = class _EllipticCurves {
|
|
8236
8164
|
static type = 10;
|
|
8237
8165
|
static spec = {
|
|
8238
|
-
type:
|
|
8239
|
-
data:
|
|
8166
|
+
type: types17.uint16be,
|
|
8167
|
+
data: types17.array(types17.uint16be, types17.uint16be, "bytes")
|
|
8240
8168
|
};
|
|
8241
8169
|
type = _EllipticCurves.type;
|
|
8242
8170
|
data = [];
|
|
@@ -8249,14 +8177,14 @@ var EllipticCurves = class _EllipticCurves {
|
|
|
8249
8177
|
static fromData(buf) {
|
|
8250
8178
|
return new _EllipticCurves({
|
|
8251
8179
|
type: _EllipticCurves.type,
|
|
8252
|
-
data:
|
|
8180
|
+
data: decode16(buf, _EllipticCurves.spec.data)
|
|
8253
8181
|
});
|
|
8254
8182
|
}
|
|
8255
8183
|
static deSerialize(buf) {
|
|
8256
|
-
return new _EllipticCurves(
|
|
8184
|
+
return new _EllipticCurves(decode16(buf, _EllipticCurves.spec));
|
|
8257
8185
|
}
|
|
8258
8186
|
serialize() {
|
|
8259
|
-
return Buffer.from(
|
|
8187
|
+
return Buffer.from(encode17(this, _EllipticCurves.spec).slice());
|
|
8260
8188
|
}
|
|
8261
8189
|
get extension() {
|
|
8262
8190
|
return {
|
|
@@ -8267,14 +8195,14 @@ var EllipticCurves = class _EllipticCurves {
|
|
|
8267
8195
|
};
|
|
8268
8196
|
|
|
8269
8197
|
// ../dtls/src/handshake/extensions/signature.ts
|
|
8270
|
-
import { decode as
|
|
8198
|
+
import { decode as decode17, encode as encode18, types as types18 } from "@shinyoshiaki/binary-data";
|
|
8271
8199
|
var Signature = class _Signature {
|
|
8272
8200
|
static type = 13;
|
|
8273
8201
|
static spec = {
|
|
8274
|
-
type:
|
|
8275
|
-
data:
|
|
8276
|
-
{ hash:
|
|
8277
|
-
|
|
8202
|
+
type: types18.uint16be,
|
|
8203
|
+
data: types18.array(
|
|
8204
|
+
{ hash: types18.uint8, signature: types18.uint8 },
|
|
8205
|
+
types18.uint16be,
|
|
8278
8206
|
"bytes"
|
|
8279
8207
|
)
|
|
8280
8208
|
};
|
|
@@ -8288,10 +8216,10 @@ var Signature = class _Signature {
|
|
|
8288
8216
|
return v;
|
|
8289
8217
|
}
|
|
8290
8218
|
static deSerialize(buf) {
|
|
8291
|
-
return new _Signature(
|
|
8219
|
+
return new _Signature(decode17(buf, _Signature.spec));
|
|
8292
8220
|
}
|
|
8293
8221
|
serialize() {
|
|
8294
|
-
const res =
|
|
8222
|
+
const res = encode18(this, _Signature.spec).slice();
|
|
8295
8223
|
return Buffer.from(res);
|
|
8296
8224
|
}
|
|
8297
8225
|
static fromData(buf) {
|
|
@@ -8308,23 +8236,23 @@ var Signature = class _Signature {
|
|
|
8308
8236
|
};
|
|
8309
8237
|
|
|
8310
8238
|
// ../dtls/src/handshake/message/alert.ts
|
|
8311
|
-
import { decode as
|
|
8239
|
+
import { decode as decode18, encode as encode19, types as types19 } from "@shinyoshiaki/binary-data";
|
|
8312
8240
|
var Alert = class _Alert {
|
|
8313
8241
|
constructor(level, description) {
|
|
8314
8242
|
this.level = level;
|
|
8315
8243
|
this.description = description;
|
|
8316
8244
|
}
|
|
8317
8245
|
static spec = {
|
|
8318
|
-
level:
|
|
8319
|
-
description:
|
|
8246
|
+
level: types19.uint8,
|
|
8247
|
+
description: types19.uint8
|
|
8320
8248
|
};
|
|
8321
8249
|
static deSerialize(buf) {
|
|
8322
8250
|
return new _Alert(
|
|
8323
|
-
...Object.values(
|
|
8251
|
+
...Object.values(decode18(buf, _Alert.spec))
|
|
8324
8252
|
);
|
|
8325
8253
|
}
|
|
8326
8254
|
serialize() {
|
|
8327
|
-
const res =
|
|
8255
|
+
const res = encode19(this, _Alert.spec).slice();
|
|
8328
8256
|
return Buffer.from(res);
|
|
8329
8257
|
}
|
|
8330
8258
|
};
|
|
@@ -8396,32 +8324,33 @@ var IPV4_PROTOCOL = 1;
|
|
|
8396
8324
|
var IPV6_PROTOCOL = 2;
|
|
8397
8325
|
|
|
8398
8326
|
// ../ice/src/stun/message.ts
|
|
8399
|
-
import { jspack as jspack4 } from "@shinyoshiaki/jspack";
|
|
8400
8327
|
import crc32 from "buffer-crc32";
|
|
8401
8328
|
|
|
8402
8329
|
// ../ice/src/stun/attributes.ts
|
|
8403
|
-
import { jspack as jspack3 } from "@shinyoshiaki/jspack";
|
|
8404
8330
|
import * as Int64 from "int64-buffer";
|
|
8405
8331
|
import nodeIp from "ip";
|
|
8406
8332
|
import range from "lodash/range.js";
|
|
8407
8333
|
function packAddress(value) {
|
|
8408
8334
|
const [address] = value;
|
|
8409
8335
|
const protocol = nodeIp.isV4Format(address) ? IPV4_PROTOCOL : IPV6_PROTOCOL;
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
]);
|
|
8336
|
+
const buffer2 = Buffer.alloc(4);
|
|
8337
|
+
buffer2.writeUInt8(0, 0);
|
|
8338
|
+
buffer2.writeUInt8(protocol, 1);
|
|
8339
|
+
buffer2.writeUInt16BE(value[1], 2);
|
|
8340
|
+
return Buffer.concat([buffer2, nodeIp.toBuffer(address)]);
|
|
8414
8341
|
}
|
|
8415
8342
|
function unpackErrorCode(data) {
|
|
8416
8343
|
if (data.length < 4) throw new Error("STUN error code is less than 4 bytes");
|
|
8417
|
-
const
|
|
8344
|
+
const codeHigh = data.readUInt8(2);
|
|
8345
|
+
const codeLow = data.readUInt8(3);
|
|
8418
8346
|
const reason = data.slice(4).toString("utf8");
|
|
8419
8347
|
return [codeHigh * 100 + codeLow, reason];
|
|
8420
8348
|
}
|
|
8421
8349
|
function unpackAddress(data) {
|
|
8422
8350
|
if (data.length < 4)
|
|
8423
8351
|
throw new Error("STUN address length is less than 4 bytes");
|
|
8424
|
-
const
|
|
8352
|
+
const protocol = data.readUInt8(1);
|
|
8353
|
+
const port = data.readUInt16BE(2);
|
|
8425
8354
|
const address = data.slice(4);
|
|
8426
8355
|
switch (protocol) {
|
|
8427
8356
|
case IPV4_PROTOCOL:
|
|
@@ -8436,11 +8365,11 @@ function unpackAddress(data) {
|
|
|
8436
8365
|
throw new Error("STUN address has unknown protocol");
|
|
8437
8366
|
}
|
|
8438
8367
|
}
|
|
8368
|
+
var cookieBuffer = Buffer.alloc(6);
|
|
8369
|
+
cookieBuffer.writeUInt16BE(COOKIE >> 16, 0);
|
|
8370
|
+
cookieBuffer.writeUInt32BE(COOKIE, 2);
|
|
8439
8371
|
function xorAddress(data, transactionId) {
|
|
8440
|
-
const xPad = [
|
|
8441
|
-
...jspack3.Pack("!HI", [COOKIE >> 16, COOKIE]),
|
|
8442
|
-
...transactionId
|
|
8443
|
-
];
|
|
8372
|
+
const xPad = [...cookieBuffer, ...transactionId];
|
|
8444
8373
|
let xData = data.slice(0, 2);
|
|
8445
8374
|
for (const i of range(2, data.length)) {
|
|
8446
8375
|
const num = data[i] ^ xPad[i - 2];
|
|
@@ -8454,22 +8383,28 @@ function unpackXorAddress(data, transactionId) {
|
|
|
8454
8383
|
return unpackAddress(xorAddress(data, transactionId));
|
|
8455
8384
|
}
|
|
8456
8385
|
function packErrorCode(value) {
|
|
8457
|
-
const
|
|
8458
|
-
|
|
8459
|
-
);
|
|
8460
|
-
|
|
8461
|
-
|
|
8386
|
+
const buffer2 = Buffer.alloc(4);
|
|
8387
|
+
buffer2.writeUInt16BE(0, 0);
|
|
8388
|
+
buffer2.writeUInt8(Math.floor(value[0] / 100), 2);
|
|
8389
|
+
buffer2.writeUInt8(value[0] % 100, 3);
|
|
8390
|
+
const encode20 = Buffer.from(value[1], "utf8");
|
|
8391
|
+
return Buffer.concat([buffer2, encode20]);
|
|
8462
8392
|
}
|
|
8463
8393
|
function packXorAddress(value, transactionId) {
|
|
8464
8394
|
return xorAddress(packAddress(value), transactionId);
|
|
8465
8395
|
}
|
|
8466
|
-
var packUnsigned = (value) =>
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
var
|
|
8396
|
+
var packUnsigned = (value) => {
|
|
8397
|
+
const buffer2 = Buffer.alloc(4);
|
|
8398
|
+
buffer2.writeUInt32BE(value, 0);
|
|
8399
|
+
return buffer2;
|
|
8400
|
+
};
|
|
8401
|
+
var unpackUnsigned = (data) => data.readUInt32BE(0);
|
|
8402
|
+
var packUnsignedShort = (value) => {
|
|
8403
|
+
const buffer2 = Buffer.alloc(4);
|
|
8404
|
+
buffer2.writeUInt16BE(value, 0);
|
|
8405
|
+
return buffer2;
|
|
8406
|
+
};
|
|
8407
|
+
var unpackUnsignedShort = (data) => data.readUInt16BE(0);
|
|
8473
8408
|
var packUnsigned64 = (value) => {
|
|
8474
8409
|
return new Int64.Int64BE(value.toString()).toBuffer();
|
|
8475
8410
|
};
|
|
@@ -8531,7 +8466,7 @@ var log20 = debug("werift-ice:packages/ice/src/stun/transaction.ts");
|
|
|
8531
8466
|
var log21 = debug("werift-ice : packages/ice/src/stun/protocol.ts");
|
|
8532
8467
|
|
|
8533
8468
|
// ../ice/src/turn/protocol.ts
|
|
8534
|
-
import { jspack as
|
|
8469
|
+
import { jspack as jspack3 } from "@shinyoshiaki/jspack";
|
|
8535
8470
|
var log22 = debug("werift-ice:packages/ice/src/turn/protocol.ts");
|
|
8536
8471
|
|
|
8537
8472
|
// ../ice/src/candidate.ts
|
|
@@ -8679,6 +8614,10 @@ var DTLS_SETUP_ROLE = Object.keys(
|
|
|
8679
8614
|
acc[key] = cur;
|
|
8680
8615
|
return acc;
|
|
8681
8616
|
}, {});
|
|
8617
|
+
var SRTP_PROFILE = {
|
|
8618
|
+
SRTP_AES128_CM_HMAC_SHA1_80: ProtectionProfileAes128CmHmacSha1_80,
|
|
8619
|
+
SRTP_AEAD_AES_128_GCM: ProtectionProfileAeadAes128Gcm
|
|
8620
|
+
};
|
|
8682
8621
|
|
|
8683
8622
|
// src/media/track.ts
|
|
8684
8623
|
import { v4 as v42 } from "uuid";
|
|
@@ -8780,15 +8719,14 @@ import { v4 as v44 } from "uuid";
|
|
|
8780
8719
|
var log30 = debug("werift:packages/webrtc/src/transport/ice.ts");
|
|
8781
8720
|
|
|
8782
8721
|
// src/transport/sctp.ts
|
|
8783
|
-
import { jspack as
|
|
8722
|
+
import { jspack as jspack6 } from "@shinyoshiaki/jspack";
|
|
8784
8723
|
import * as uuid2 from "uuid";
|
|
8785
8724
|
|
|
8786
8725
|
// ../sctp/src/sctp.ts
|
|
8787
|
-
import { jspack as
|
|
8726
|
+
import { jspack as jspack5 } from "@shinyoshiaki/jspack";
|
|
8788
8727
|
import range5 from "lodash/range.js";
|
|
8789
8728
|
|
|
8790
8729
|
// ../sctp/src/chunk.ts
|
|
8791
|
-
import { jspack as jspack6 } from "@shinyoshiaki/jspack";
|
|
8792
8730
|
import crc32c from "turbo-crc32/crc32c.js";
|
|
8793
8731
|
var Chunk = class _Chunk {
|
|
8794
8732
|
constructor(flags = 0, _body = Buffer.from("")) {
|
|
@@ -8807,10 +8745,12 @@ var Chunk = class _Chunk {
|
|
|
8807
8745
|
}
|
|
8808
8746
|
get bytes() {
|
|
8809
8747
|
if (!this.body) throw new Error();
|
|
8748
|
+
const header = Buffer.alloc(4);
|
|
8749
|
+
header.writeUInt8(this.type, 0);
|
|
8750
|
+
header.writeUInt8(this.flags, 1);
|
|
8751
|
+
header.writeUInt16BE(this.body.length + 4, 2);
|
|
8810
8752
|
const data = Buffer.concat([
|
|
8811
|
-
|
|
8812
|
-
jspack6.Pack("!BBH", [this.type, this.flags, this.body.length + 4])
|
|
8813
|
-
),
|
|
8753
|
+
header,
|
|
8814
8754
|
this.body,
|
|
8815
8755
|
...[...Array(padL(this.body.length))].map(() => Buffer.from("\0"))
|
|
8816
8756
|
]);
|
|
@@ -8822,13 +8762,11 @@ var BaseInitChunk = class extends Chunk {
|
|
|
8822
8762
|
super(flags, body);
|
|
8823
8763
|
this.flags = flags;
|
|
8824
8764
|
if (body) {
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
this.initialTsn
|
|
8831
|
-
] = jspack6.Unpack("!LLHHL", body);
|
|
8765
|
+
this.initiateTag = body.readUInt32BE(0);
|
|
8766
|
+
this.advertisedRwnd = body.readUInt32BE(4);
|
|
8767
|
+
this.outboundStreams = body.readUInt16BE(8);
|
|
8768
|
+
this.inboundStreams = body.readUInt16BE(10);
|
|
8769
|
+
this.initialTsn = body.readUInt32BE(12);
|
|
8832
8770
|
this.params = decodeParams(body.slice(16));
|
|
8833
8771
|
} else {
|
|
8834
8772
|
this.initiateTag = 0;
|
|
@@ -8846,17 +8784,13 @@ var BaseInitChunk = class extends Chunk {
|
|
|
8846
8784
|
initialTsn;
|
|
8847
8785
|
params;
|
|
8848
8786
|
get body() {
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
])
|
|
8857
|
-
);
|
|
8858
|
-
body = Buffer.concat([body, encodeParams(this.params)]);
|
|
8859
|
-
return body;
|
|
8787
|
+
const body = Buffer.alloc(16);
|
|
8788
|
+
body.writeUInt32BE(this.initiateTag, 0);
|
|
8789
|
+
body.writeUInt32BE(this.advertisedRwnd, 4);
|
|
8790
|
+
body.writeUInt16BE(this.outboundStreams, 8);
|
|
8791
|
+
body.writeUInt16BE(this.inboundStreams, 10);
|
|
8792
|
+
body.writeUInt32BE(this.initialTsn, 12);
|
|
8793
|
+
return Buffer.concat([body, encodeParams(this.params)]);
|
|
8860
8794
|
}
|
|
8861
8795
|
};
|
|
8862
8796
|
var InitChunk = class _InitChunk extends BaseInitChunk {
|
|
@@ -8876,12 +8810,10 @@ var ForwardTsnChunk = class _ForwardTsnChunk extends Chunk {
|
|
|
8876
8810
|
super(flags, body);
|
|
8877
8811
|
this.flags = flags;
|
|
8878
8812
|
if (body) {
|
|
8879
|
-
this.cumulativeTsn =
|
|
8813
|
+
this.cumulativeTsn = body.readUInt32BE(0);
|
|
8880
8814
|
let pos = 4;
|
|
8881
8815
|
while (pos < body.length) {
|
|
8882
|
-
this.streams.push(
|
|
8883
|
-
jspack6.Unpack("!HH", body.slice(pos))
|
|
8884
|
-
);
|
|
8816
|
+
this.streams.push([body.readUInt16BE(pos), body.readUInt16BE(pos + 2)]);
|
|
8885
8817
|
pos += 4;
|
|
8886
8818
|
}
|
|
8887
8819
|
} else {
|
|
@@ -8897,12 +8829,16 @@ var ForwardTsnChunk = class _ForwardTsnChunk extends Chunk {
|
|
|
8897
8829
|
set body(_) {
|
|
8898
8830
|
}
|
|
8899
8831
|
get body() {
|
|
8900
|
-
const body = Buffer.
|
|
8832
|
+
const body = Buffer.alloc(4);
|
|
8833
|
+
body.writeUInt32BE(this.cumulativeTsn, 0);
|
|
8901
8834
|
return Buffer.concat([
|
|
8902
8835
|
body,
|
|
8903
|
-
...this.streams.map(
|
|
8904
|
-
|
|
8905
|
-
|
|
8836
|
+
...this.streams.map(([id, seq]) => {
|
|
8837
|
+
const streamBuffer = Buffer.alloc(4);
|
|
8838
|
+
streamBuffer.writeUInt16BE(id, 0);
|
|
8839
|
+
streamBuffer.writeUInt16BE(seq, 2);
|
|
8840
|
+
return streamBuffer;
|
|
8841
|
+
})
|
|
8906
8842
|
]);
|
|
8907
8843
|
}
|
|
8908
8844
|
};
|
|
@@ -8911,7 +8847,10 @@ var DataChunk = class _DataChunk extends Chunk {
|
|
|
8911
8847
|
super(flags, body);
|
|
8912
8848
|
this.flags = flags;
|
|
8913
8849
|
if (body) {
|
|
8914
|
-
|
|
8850
|
+
this.tsn = body.readUInt32BE(0);
|
|
8851
|
+
this.streamId = body.readUInt16BE(4);
|
|
8852
|
+
this.streamSeqNum = body.readUInt16BE(6);
|
|
8853
|
+
this.protocol = body.readUInt32BE(8);
|
|
8915
8854
|
this.userData = body.slice(12);
|
|
8916
8855
|
}
|
|
8917
8856
|
}
|
|
@@ -8935,20 +8874,15 @@ var DataChunk = class _DataChunk extends Chunk {
|
|
|
8935
8874
|
sentTime;
|
|
8936
8875
|
get bytes() {
|
|
8937
8876
|
const length = 16 + this.userData.length;
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
this.protocol
|
|
8948
|
-
])
|
|
8949
|
-
),
|
|
8950
|
-
this.userData
|
|
8951
|
-
]);
|
|
8877
|
+
const header = Buffer.alloc(16);
|
|
8878
|
+
header.writeUInt8(this.type, 0);
|
|
8879
|
+
header.writeUInt8(this.flags, 1);
|
|
8880
|
+
header.writeUInt16BE(length, 2);
|
|
8881
|
+
header.writeUInt32BE(this.tsn, 4);
|
|
8882
|
+
header.writeUInt16BE(this.streamId, 8);
|
|
8883
|
+
header.writeUInt16BE(this.streamSeqNum, 10);
|
|
8884
|
+
header.writeUInt32BE(this.protocol, 12);
|
|
8885
|
+
let data = Buffer.concat([header, this.userData]);
|
|
8952
8886
|
if (length % 4) {
|
|
8953
8887
|
data = Buffer.concat([
|
|
8954
8888
|
data,
|
|
@@ -9041,18 +8975,17 @@ var SackChunk = class _SackChunk extends Chunk {
|
|
|
9041
8975
|
super(flags, body);
|
|
9042
8976
|
this.flags = flags;
|
|
9043
8977
|
if (body) {
|
|
9044
|
-
|
|
9045
|
-
this.
|
|
9046
|
-
|
|
8978
|
+
this.cumulativeTsn = body.readUInt32BE(0);
|
|
8979
|
+
this.advertisedRwnd = body.readUInt32BE(4);
|
|
8980
|
+
const nbGaps = body.readUInt16BE(8);
|
|
8981
|
+
const nbDuplicates = body.readUInt16BE(10);
|
|
9047
8982
|
let pos = 12;
|
|
9048
8983
|
[...Array(nbGaps)].forEach(() => {
|
|
9049
|
-
this.gaps.push(
|
|
9050
|
-
jspack6.Unpack("!HH", body.slice(pos))
|
|
9051
|
-
);
|
|
8984
|
+
this.gaps.push([body.readUInt16BE(pos), body.readUInt16BE(pos + 2)]);
|
|
9052
8985
|
pos += 4;
|
|
9053
8986
|
});
|
|
9054
8987
|
[...Array(nbDuplicates)].forEach(() => {
|
|
9055
|
-
this.duplicates.push(
|
|
8988
|
+
this.duplicates.push(body.readUInt32BE(pos));
|
|
9056
8989
|
pos += 4;
|
|
9057
8990
|
});
|
|
9058
8991
|
}
|
|
@@ -9067,24 +9000,30 @@ var SackChunk = class _SackChunk extends Chunk {
|
|
|
9067
9000
|
advertisedRwnd = 0;
|
|
9068
9001
|
get bytes() {
|
|
9069
9002
|
const length = 16 + 4 * (this.gaps.length + this.duplicates.length);
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9003
|
+
const header = Buffer.alloc(16);
|
|
9004
|
+
header.writeUInt8(this.type, 0);
|
|
9005
|
+
header.writeUInt8(this.flags, 1);
|
|
9006
|
+
header.writeUInt16BE(length, 2);
|
|
9007
|
+
header.writeUInt32BE(this.cumulativeTsn, 4);
|
|
9008
|
+
header.writeUInt32BE(this.advertisedRwnd, 8);
|
|
9009
|
+
header.writeUInt16BE(this.gaps.length, 12);
|
|
9010
|
+
header.writeUInt16BE(this.duplicates.length, 14);
|
|
9011
|
+
let data = Buffer.concat([
|
|
9012
|
+
header,
|
|
9013
|
+
...this.gaps.map((gap) => {
|
|
9014
|
+
const gapBuffer = Buffer.alloc(4);
|
|
9015
|
+
gapBuffer.writeUInt16BE(gap[0], 0);
|
|
9016
|
+
gapBuffer.writeUInt16BE(gap[1], 2);
|
|
9017
|
+
return gapBuffer;
|
|
9018
|
+
})
|
|
9084
9019
|
]);
|
|
9085
9020
|
data = Buffer.concat([
|
|
9086
9021
|
data,
|
|
9087
|
-
...this.duplicates.map((tsn) =>
|
|
9022
|
+
...this.duplicates.map((tsn) => {
|
|
9023
|
+
const tsnBuffer = Buffer.alloc(4);
|
|
9024
|
+
tsnBuffer.writeUInt32BE(tsn, 0);
|
|
9025
|
+
return tsnBuffer;
|
|
9026
|
+
})
|
|
9088
9027
|
]);
|
|
9089
9028
|
return data;
|
|
9090
9029
|
}
|
|
@@ -9094,7 +9033,7 @@ var ShutdownChunk = class _ShutdownChunk extends Chunk {
|
|
|
9094
9033
|
super(flags, body);
|
|
9095
9034
|
this.flags = flags;
|
|
9096
9035
|
if (body) {
|
|
9097
|
-
this.cumulativeTsn =
|
|
9036
|
+
this.cumulativeTsn = body.readUInt32BE(0);
|
|
9098
9037
|
}
|
|
9099
9038
|
}
|
|
9100
9039
|
static type = 7;
|
|
@@ -9103,7 +9042,9 @@ var ShutdownChunk = class _ShutdownChunk extends Chunk {
|
|
|
9103
9042
|
}
|
|
9104
9043
|
cumulativeTsn = 0;
|
|
9105
9044
|
get body() {
|
|
9106
|
-
|
|
9045
|
+
const body = Buffer.alloc(4);
|
|
9046
|
+
body.writeUInt32BE(this.cumulativeTsn, 0);
|
|
9047
|
+
return body;
|
|
9107
9048
|
}
|
|
9108
9049
|
};
|
|
9109
9050
|
var ShutdownAckChunk = class _ShutdownAckChunk extends Chunk {
|
|
@@ -9151,12 +9092,10 @@ function encodeParams(params) {
|
|
|
9151
9092
|
let padding = Buffer.from("");
|
|
9152
9093
|
params.forEach(([type, value]) => {
|
|
9153
9094
|
const length = value.length + 4;
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
value
|
|
9159
|
-
]);
|
|
9095
|
+
const paramHeader = Buffer.alloc(4);
|
|
9096
|
+
paramHeader.writeUInt16BE(type, 0);
|
|
9097
|
+
paramHeader.writeUInt16BE(length, 2);
|
|
9098
|
+
body = Buffer.concat([body, padding, paramHeader, value]);
|
|
9160
9099
|
padding = Buffer.concat(
|
|
9161
9100
|
[...Array(padL(length))].map(() => Buffer.from("\0"))
|
|
9162
9101
|
);
|
|
@@ -9167,7 +9106,8 @@ function decodeParams(body) {
|
|
|
9167
9106
|
const params = [];
|
|
9168
9107
|
let pos = 0;
|
|
9169
9108
|
while (pos <= body.length - 4) {
|
|
9170
|
-
const
|
|
9109
|
+
const type = body.readUInt16BE(pos);
|
|
9110
|
+
const length = body.readUInt16BE(pos + 2);
|
|
9171
9111
|
params.push([type, body.slice(pos + 4, pos + length)]);
|
|
9172
9112
|
pos += length + padL(length);
|
|
9173
9113
|
}
|
|
@@ -9175,7 +9115,7 @@ function decodeParams(body) {
|
|
|
9175
9115
|
}
|
|
9176
9116
|
|
|
9177
9117
|
// ../sctp/src/param.ts
|
|
9178
|
-
import { jspack as
|
|
9118
|
+
import { jspack as jspack4 } from "@shinyoshiaki/jspack";
|
|
9179
9119
|
import range4 from "lodash/range.js";
|
|
9180
9120
|
|
|
9181
9121
|
// ../sctp/src/sctp.ts
|
|
@@ -9194,15 +9134,29 @@ var log33 = debug("werift:packages/webrtc/src/media/rtpReceiver.ts");
|
|
|
9194
9134
|
var log34 = debug("werift:packages/webrtc/src/media/router.ts");
|
|
9195
9135
|
|
|
9196
9136
|
// src/media/rtpSender.ts
|
|
9197
|
-
import { jspack as
|
|
9137
|
+
import { jspack as jspack7 } from "@shinyoshiaki/jspack";
|
|
9198
9138
|
import * as uuid4 from "uuid";
|
|
9199
9139
|
var log35 = debug("werift:packages/webrtc/src/media/rtpSender.ts");
|
|
9200
9140
|
|
|
9201
9141
|
// src/peerConnection.ts
|
|
9202
9142
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
9203
|
-
import isEqual2 from "lodash/isEqual.js";
|
|
9204
9143
|
import * as uuid5 from "uuid";
|
|
9205
|
-
|
|
9144
|
+
|
|
9145
|
+
// src/sctpManager.ts
|
|
9146
|
+
var log36 = debug("werift:packages/webrtc/src/transport/sctpManager.ts");
|
|
9147
|
+
|
|
9148
|
+
// src/secureTransportManager.ts
|
|
9149
|
+
var log37 = debug(
|
|
9150
|
+
"werift:packages/webrtc/src/transport/secureTransportManager.ts"
|
|
9151
|
+
);
|
|
9152
|
+
var srtpProfiles = [
|
|
9153
|
+
SRTP_PROFILE.SRTP_AEAD_AES_128_GCM,
|
|
9154
|
+
// prefer
|
|
9155
|
+
SRTP_PROFILE.SRTP_AES128_CM_HMAC_SHA1_80
|
|
9156
|
+
];
|
|
9157
|
+
|
|
9158
|
+
// src/peerConnection.ts
|
|
9159
|
+
var log38 = debug("werift:packages/webrtc/src/peerConnection.ts");
|
|
9206
9160
|
var defaultPeerConfig = {
|
|
9207
9161
|
codecs: {
|
|
9208
9162
|
audio: [useOPUS(), usePCMU()],
|
|
@@ -9230,6 +9184,9 @@ var defaultPeerConfig = {
|
|
|
9230
9184
|
forceTurnTCP: false
|
|
9231
9185
|
};
|
|
9232
9186
|
|
|
9187
|
+
// src/transceiverManager.ts
|
|
9188
|
+
var log39 = debug("werift:packages/webrtc/src/media/rtpTransceiverManager.ts");
|
|
9189
|
+
|
|
9233
9190
|
// src/nonstandard/navigator.ts
|
|
9234
9191
|
var Navigator = class {
|
|
9235
9192
|
mediaDevices;
|
|
@@ -9251,7 +9208,7 @@ var MediaDevices = class extends EventTarget {
|
|
|
9251
9208
|
if (video) {
|
|
9252
9209
|
this.video?.onReceiveRtp.subscribe((rtp) => {
|
|
9253
9210
|
const cloned = rtp.clone();
|
|
9254
|
-
cloned.header.ssrc =
|
|
9211
|
+
cloned.header.ssrc = jspack8.Unpack("!L", randomBytes4(4))[0];
|
|
9255
9212
|
video.onReceiveRtp.execute(cloned);
|
|
9256
9213
|
});
|
|
9257
9214
|
}
|
|
@@ -9259,7 +9216,7 @@ var MediaDevices = class extends EventTarget {
|
|
|
9259
9216
|
if (audio) {
|
|
9260
9217
|
this.audio?.onReceiveRtp.subscribe((rtp) => {
|
|
9261
9218
|
const cloned = rtp.clone();
|
|
9262
|
-
cloned.header.ssrc =
|
|
9219
|
+
cloned.header.ssrc = jspack8.Unpack("!L", randomBytes4(4))[0];
|
|
9263
9220
|
audio.onReceiveRtp.execute(cloned);
|
|
9264
9221
|
});
|
|
9265
9222
|
}
|