@@ -41,6 +41,7 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
41
41
InstanceMethod (" setRemoteDescription" , &PeerConnectionWrapper::setRemoteDescription),
42
42
InstanceMethod (" localDescription" , &PeerConnectionWrapper::localDescription),
43
43
InstanceMethod (" remoteDescription" , &PeerConnectionWrapper::remoteDescription),
44
+ InstanceMethod (" remoteFingerprint" , &PeerConnectionWrapper::remoteFingerprint),
44
45
InstanceMethod (" addRemoteCandidate" , &PeerConnectionWrapper::addRemoteCandidate),
45
46
InstanceMethod (" createDataChannel" , &PeerConnectionWrapper::createDataChannel),
46
47
InstanceMethod (" addTrack" , &PeerConnectionWrapper::addTrack),
@@ -202,6 +203,10 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
202
203
if (config.Get (" disableAutoNegotiation" ).IsBoolean ())
203
204
rtcConfig.disableAutoNegotiation = config.Get (" disableAutoNegotiation" ).As <Napi::Boolean >();
204
205
206
+ // disableAutoGathering option
207
+ if (config.Get (" disableAutoGathering" ).IsBoolean ())
208
+ rtcConfig.disableAutoGathering = config.Get (" disableAutoGathering" ).As <Napi::Boolean >();
209
+
205
210
// forceMediaTransport option
206
211
if (config.Get (" forceMediaTransport" ).IsBoolean ())
207
212
rtcConfig.forceMediaTransport = config.Get (" forceMediaTransport" ).As <Napi::Boolean >();
@@ -234,6 +239,22 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
234
239
}
235
240
}
236
241
242
+ // Allow skipping fingerprint validation
243
+ if (config.Get (" disableFingerprintVerification" ).IsBoolean ()) {
244
+ rtcConfig.disableFingerprintVerification = config.Get (" disableFingerprintVerification" ).As <Napi::Boolean >();
245
+ }
246
+
247
+ // Specify certificate to use if set
248
+ if (config.Get (" certificatePemFile" ).IsString ()) {
249
+ rtcConfig.certificatePemFile = config.Get (" certificatePemFile" ).As <Napi::String>().ToString ();
250
+ }
251
+ if (config.Get (" keyPemFile" ).IsString ()) {
252
+ rtcConfig.keyPemFile = config.Get (" keyPemFile" ).As <Napi::String>().ToString ();
253
+ }
254
+ if (config.Get (" keyPemPass" ).IsString ()) {
255
+ rtcConfig.keyPemPass = config.Get (" keyPemPass" ).As <Napi::String>().ToString ();
256
+ }
257
+
237
258
// Create peer-connection
238
259
try
239
260
{
@@ -314,6 +335,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
314
335
}
315
336
316
337
rtc::Description::Type type = rtc::Description::Type::Unspec;
338
+ rtc::LocalDescriptionInit init;
317
339
318
340
// optional
319
341
if (length > 0 )
@@ -339,7 +361,29 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
339
361
type = rtc::Description::Type::Rollback;
340
362
}
341
363
342
- mRtcPeerConnPtr ->setLocalDescription (type);
364
+ // optional
365
+ if (length > 1 )
366
+ {
367
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit" ;
368
+
369
+ if (info[1 ].IsObject ())
370
+ {
371
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit as object" ;
372
+ Napi::Object obj = info[1 ].As <Napi::Object>();
373
+
374
+ if (obj.Get (" iceUfrag" ).IsString ()) {
375
+ PLOG_DEBUG << " setLocalDescription() has ufrag" ;
376
+ init.iceUfrag = obj.Get (" iceUfrag" ).As <Napi::String>();
377
+ }
378
+
379
+ if (obj.Get (" icePwd" ).IsString ()) {
380
+ PLOG_DEBUG << " setLocalDescription() has password" ;
381
+ init.icePwd = obj.Get (" icePwd" ).As <Napi::String>();
382
+ }
383
+ }
384
+ }
385
+
386
+ mRtcPeerConnPtr ->setLocalDescription (type, init);
343
387
}
344
388
345
389
void PeerConnectionWrapper::setRemoteDescription (const Napi::CallbackInfo &info)
@@ -1049,7 +1093,34 @@ Napi::Value PeerConnectionWrapper::maxMessageSize(const Napi::CallbackInfo &info
1049
1093
1050
1094
try
1051
1095
{
1052
- return Napi::Number::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1096
+ return Napi::Array::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1097
+ }
1098
+ catch (std::exception &ex)
1099
+ {
1100
+ Napi::Error::New (env, std::string (" libdatachannel error: " ) + ex.what ()).ThrowAsJavaScriptException ();
1101
+ return Napi::Number::New (info.Env (), 0 );
1102
+ }
1103
+ }
1104
+
1105
+ Napi::Value PeerConnectionWrapper::remoteFingerprint (const Napi::CallbackInfo &info)
1106
+ {
1107
+ PLOG_DEBUG << " remoteFingerprints() called" ;
1108
+ Napi::Env env = info.Env ();
1109
+
1110
+ if (!mRtcPeerConnPtr )
1111
+ {
1112
+ return Napi::Number::New (info.Env (), 0 );
1113
+ }
1114
+
1115
+ try
1116
+ {
1117
+ auto fingerprint = mRtcPeerConnPtr ->remoteFingerprint ();
1118
+
1119
+ Napi::Object fingerprintObject = Napi::Object::New (env);
1120
+ fingerprintObject.Set (" value" , fingerprint.value );
1121
+ fingerprintObject.Set (" algorithm" , rtc::CertificateFingerprint::AlgorithmIdentifier (fingerprint.algorithm ));
1122
+
1123
+ return fingerprintObject;
1053
1124
}
1054
1125
catch (std::exception &ex)
1055
1126
{
0 commit comments