videomail-client 16.0.0 → 16.0.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/dist/esm/index.js CHANGED
@@ -3620,7 +3620,7 @@ const constants = {
3620
3620
  }
3621
3621
  };
3622
3622
  var package_namespaceObject = {
3623
- rE: "16.0.0"
3623
+ rE: "16.0.2"
3624
3624
  };
3625
3625
  function isAudioEnabled(options) {
3626
3626
  return Boolean(options.audio.enabled);
@@ -3835,7 +3835,7 @@ class VideomailError extends error_HTTPVideomailError {
3835
3835
  return this.classList;
3836
3836
  }
3837
3837
  constructor(message, options, classList, errData){
3838
- super(message, errData), VideomailError_define_property(this, "title", "Error from videomail-client npm package"), VideomailError_define_property(this, "location", window.location.href), VideomailError_define_property(this, "logLines", void 0), VideomailError_define_property(this, "whitelistKey", void 0), VideomailError_define_property(this, "cookie", void 0), VideomailError_define_property(this, "err", void 0), VideomailError_define_property(this, "promise", void 0), VideomailError_define_property(this, "reason", void 0), VideomailError_define_property(this, "browser", void 0), VideomailError_define_property(this, "cpu", void 0), VideomailError_define_property(this, "device", void 0), VideomailError_define_property(this, "engine", void 0), VideomailError_define_property(this, "os", void 0), VideomailError_define_property(this, "screen", void 0), VideomailError_define_property(this, "orientation", void 0), VideomailError_define_property(this, "versions", void 0), VideomailError_define_property(this, "classList", void 0);
3838
+ super(message, errData), VideomailError_define_property(this, "title", "Error from videomail-client npm package"), VideomailError_define_property(this, "location", window.location.href), VideomailError_define_property(this, "logLines", void 0), VideomailError_define_property(this, "whitelistKey", void 0), VideomailError_define_property(this, "err", void 0), VideomailError_define_property(this, "promise", void 0), VideomailError_define_property(this, "reason", void 0), VideomailError_define_property(this, "browser", void 0), VideomailError_define_property(this, "cpu", void 0), VideomailError_define_property(this, "device", void 0), VideomailError_define_property(this, "engine", void 0), VideomailError_define_property(this, "os", void 0), VideomailError_define_property(this, "screen", void 0), VideomailError_define_property(this, "orientation", void 0), VideomailError_define_property(this, "versions", void 0), VideomailError_define_property(this, "classList", void 0);
3839
3839
  this.explanation = errData?.explanation;
3840
3840
  this.logLines = errData?.logLines;
3841
3841
  this.whitelistKey = options.whitelistKey;
@@ -3847,9 +3847,6 @@ class VideomailError extends error_HTTPVideomailError {
3847
3847
  this.device = usefulClientData.device.type ? usefulClientData.device : void 0;
3848
3848
  this.engine = usefulClientData.engine;
3849
3849
  this.os = usefulClientData.os;
3850
- let cookie;
3851
- if (__webpack_require__.g.document.cookie.length > 0) cookie = __webpack_require__.g.document.cookie.split(",").map((c)=>c.trim());
3852
- this.cookie = cookie && cookie.length > 0 ? cookie : void 0;
3853
3850
  this.screen = [
3854
3851
  screen.width,
3855
3852
  screen.height,
@@ -4037,6 +4034,51 @@ function findOriginalExc(exc) {
4037
4034
  return exc;
4038
4035
  }
4039
4036
  const error_findOriginalExc = findOriginalExc;
4037
+ const REDACTED = "[redacted]";
4038
+ const PRIVATE_FIELDS = "cookies?|set[-_]?cookie|(?:proxy[-_]?)?authorization|pass(?:word|phrase|wd)|(?:client[-_]?)?secret|(?:x[-_]?)?api[-_]?key|(?:access|refresh|id|auth|session)[-_]?token|token|(?:x[-_]?)?(?:csrf|xsrf)(?:[-_]?token)?|session(?:[-_]?id)?|e[-_]?mail|from|to|cc|bcc|recipients?|sender";
4039
+ const PRIVATE_FIELD = new RegExp(`^(?:${PRIVATE_FIELDS})$`, "iu");
4040
+ const PRIVATE_CONTENT_FIELD = /^(?:subject|body)$/iu;
4041
+ const URL_FIELD = /^(?:url|uri|href|location|recordLocation|blockedURI|responseURL)$/iu;
4042
+ const LOG_ASSIGNMENT = String.raw`(["']?\b(?:${PRIVATE_FIELDS}|subject|body)["']?\s*[:=]\s*)`;
4043
+ const LOG_VALUES = [
4044
+ /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/u.source,
4045
+ /(?:Bearer|Basic)\s+[^\s,;}]+/u.source,
4046
+ /[^\s,;{}[\]]+/u.source
4047
+ ].join("|");
4048
+ const PRIVATE_LOG_VALUE = new RegExp(`${LOG_ASSIGNMENT}(?:${LOG_VALUES})`, "giu");
4049
+ function sanitizeUrl(value, base) {
4050
+ try {
4051
+ const url = new URL(value, base);
4052
+ url.username = "";
4053
+ url.password = "";
4054
+ url.search = "";
4055
+ url.hash = "";
4056
+ return url.href;
4057
+ } catch {
4058
+ return REDACTED;
4059
+ }
4060
+ }
4061
+ function sanitizeText(text) {
4062
+ return text.replace(/\b(?:https?|wss?):\/\/[^\s"'<>(){}]+/giu, (value)=>{
4063
+ const position = /:\d+:\d+$/u.exec(value)?.[0] ?? "";
4064
+ const address = position ? value.slice(0, -position.length) : value;
4065
+ return `${sanitizeUrl(address)}${position}`;
4066
+ }).replace(PRIVATE_LOG_VALUE, `$1${REDACTED}`).replace(/\b(Bearer|Basic)\s+[\w.+/~=-]+/giu, `$1 ${REDACTED}`).replace(/\b[\w.%+-]+@[\w.-]+\.[a-z]{2,}\b/giu, REDACTED);
4067
+ }
4068
+ function sanitizeErrorReport(report) {
4069
+ function redactField(key, value) {
4070
+ if (PRIVATE_FIELD.test(key)) return REDACTED;
4071
+ if ("string" != typeof value) return value;
4072
+ if (PRIVATE_CONTENT_FIELD.test(key)) return REDACTED;
4073
+ const text = URL_FIELD.test(key) ? sanitizeUrl(value, report.location) : value;
4074
+ return sanitizeText(text);
4075
+ }
4076
+ const json = JSON.stringify(serializeError(report), redactField);
4077
+ const sanitized = JSON.parse(json);
4078
+ if (null === sanitized || "object" != typeof sanitized) throw new TypeError("An error report must serialize to an object.");
4079
+ return sanitized;
4080
+ }
4081
+ const error_sanitizeErrorReport = sanitizeErrorReport;
4040
4082
  function Despot_define_property(obj, key, value) {
4041
4083
  if (key in obj) Object.defineProperty(obj, key, {
4042
4084
  value: value,
@@ -4500,7 +4542,6 @@ class Resource {
4500
4542
  },
4501
4543
  browser: err.browser,
4502
4544
  code: err.code,
4503
- cookie: err.cookie,
4504
4545
  cause: err.cause instanceof Error ? serializeError(err.cause) : err.cause,
4505
4546
  cpu: err.cpu,
4506
4547
  device: err.device,
@@ -4521,7 +4562,7 @@ class Resource {
4521
4562
  enumerateDevices,
4522
4563
  usedConstraints: err.usedConstraints
4523
4564
  };
4524
- await superagent(FormMethod.POST, url).query(queryParams).set("Timezone-Id", this.timezoneId).withCredentials().send(fullVideomailErrorData).timeout(this.options.timeouts.connection);
4565
+ await superagent(FormMethod.POST, url).query(queryParams).set("Timezone-Id", this.timezoneId).withCredentials().send(error_sanitizeErrorReport(fullVideomailErrorData)).timeout(this.options.timeouts.connection);
4525
4566
  }
4526
4567
  async post(videomail) {
4527
4568
  const newVideomail = this.applyDefaultValues(videomail);
@@ -6834,6 +6875,7 @@ class Recorder extends util_Despot {
6834
6875
  this.options.logger.debug(debugLine);
6835
6876
  const canReconnect = this.canReconnectAfterStreamClose();
6836
6877
  this.connected = false;
6878
+ this.stopPings();
6837
6879
  if (this.shouldIgnoreStreamClose()) return;
6838
6880
  if (this.mediaTransmissionStarted) this.failInterruptedRecording();
6839
6881
  else if (canReconnect) {
@@ -6850,7 +6892,37 @@ class Recorder extends util_Despot {
6850
6892
  }, 0);
6851
6893
  }
6852
6894
  shouldIgnoreStreamClose() {
6853
- return this.recordingTransportFailed || Boolean(this.unloaded);
6895
+ return this.recordingTransportFailed || Boolean(this.unloaded) || this.validate();
6896
+ }
6897
+ handleStreamError(url2Connect, err) {
6898
+ if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
6899
+ else this.lastSocketError = serializeError(err);
6900
+ const debugLine = string_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
6901
+ error: serializeError(err)
6902
+ });
6903
+ this.options.logger.debug(debugLine);
6904
+ if (this.validate()) {
6905
+ this.connected = false;
6906
+ this.stopPings();
6907
+ this.discardSocket();
6908
+ return;
6909
+ }
6910
+ if (!this.connected) return void this.handleConnectionFailure({
6911
+ url2Connect,
6912
+ cause: "error"
6913
+ });
6914
+ const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
6915
+ cause: this.lastSocketError ?? err
6916
+ });
6917
+ if (this.mediaTransmissionStarted) return void this.failInterruptedRecording();
6918
+ this.emit("ERROR", {
6919
+ err: error_createError({
6920
+ message: "WebSocket stream error",
6921
+ explanation: `The WebSocket stream emitted an error event. Details: ${string_pretty(err)}`,
6922
+ options: this.options,
6923
+ exc: streamError
6924
+ })
6925
+ });
6854
6926
  }
6855
6927
  sendPings() {
6856
6928
  this.stopPings();
@@ -6861,6 +6933,7 @@ class Recorder extends util_Despot {
6861
6933
  }
6862
6934
  stopPings() {
6863
6935
  if (void 0 === this.pingInterval) return;
6936
+ this.options.logger.debug("Recorder: stopping pings...");
6864
6937
  window.clearInterval(this.pingInterval);
6865
6938
  this.pingInterval = void 0;
6866
6939
  }
@@ -7012,7 +7085,7 @@ class Recorder extends util_Despot {
7012
7085
  });
7013
7086
  }
7014
7087
  shouldIgnoreConnectionFailure() {
7015
- return this.connectionFailed || this.connected || Boolean(this.unloaded);
7088
+ return this.connectionFailed || this.connected || Boolean(this.unloaded) || this.validate();
7016
7089
  }
7017
7090
  calculateFrameProgress() {
7018
7091
  return `${(this.confirmedFrameNumber / (this.framesCount || 1) * 100).toFixed(2)}%`;
@@ -7218,28 +7291,7 @@ class Recorder extends util_Despot {
7218
7291
  }
7219
7292
  });
7220
7293
  stream.on("error", (err)=>{
7221
- if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
7222
- else this.lastSocketError = serializeError(err);
7223
- const debugLine = string_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
7224
- error: serializeError(err)
7225
- });
7226
- this.options.logger.debug(debugLine);
7227
- if (!this.connected) return void this.handleConnectionFailure({
7228
- url2Connect,
7229
- cause: "error"
7230
- });
7231
- const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
7232
- cause: this.lastSocketError ?? err
7233
- });
7234
- if (this.mediaTransmissionStarted) return void this.failInterruptedRecording();
7235
- this.emit("ERROR", {
7236
- err: error_createError({
7237
- message: "WebSocket stream error",
7238
- explanation: `The WebSocket stream emitted an error event. Details: ${string_pretty(err)}`,
7239
- options: this.options,
7240
- exc: streamError
7241
- })
7242
- });
7294
+ this.handleStreamError(url2Connect, err);
7243
7295
  });
7244
7296
  stream.on("drain", ()=>{
7245
7297
  this.handleStreamDrain(stream);
@@ -7580,6 +7632,7 @@ class Recorder extends util_Despot {
7580
7632
  }
7581
7633
  back(cb) {
7582
7634
  this.emit("GOING_BACK");
7635
+ this.key = void 0;
7583
7636
  this.recordingDimensions = void 0;
7584
7637
  this.unloaded = false;
7585
7638
  this.show();
@@ -7644,7 +7697,7 @@ class Recorder extends util_Despot {
7644
7697
  this.stopTimeout = void 0;
7645
7698
  }
7646
7699
  validate() {
7647
- return this.connected && void 0 === this.canvas;
7700
+ return Boolean(this.key) && void 0 === this.canvas;
7648
7701
  }
7649
7702
  isReady() {
7650
7703
  return this.userMedia?.isReady();
@@ -29,7 +29,6 @@ export interface VideomailErrorData {
29
29
  }
30
30
  export interface FullVideomailErrorData extends VideomailErrorData {
31
31
  browser: IBrowser;
32
- cookie?: string[] | undefined;
33
32
  cpu?: ICPU | undefined;
34
33
  device?: IDevice | undefined;
35
34
  engine: IEngine;
@@ -12,7 +12,6 @@ declare class VideomailError extends HTTPVideomailError {
12
12
  readonly location: string;
13
13
  logLines?: string[] | undefined;
14
14
  whitelistKey: string | undefined;
15
- cookie: string[] | undefined;
16
15
  err?: Error | undefined;
17
16
  promise?: Promise<any> | undefined;
18
17
  reason?: any;
@@ -0,0 +1,3 @@
1
+ import type { FullVideomailErrorData } from "../../types/error.js";
2
+ declare function sanitizeErrorReport(report: FullVideomailErrorData): object;
3
+ export default sanitizeErrorReport;
@@ -83,6 +83,7 @@ declare class Recorder extends Despot {
83
83
  private shouldReportStreamClose;
84
84
  private handleStreamClose;
85
85
  private shouldIgnoreStreamClose;
86
+ private handleStreamError;
86
87
  private sendPings;
87
88
  private stopPings;
88
89
  private onAudioSample;