@magield/collectors 0.24.1 → 0.25.0

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.
@@ -36,7 +36,9 @@ import { hash } from '../hash.js';
36
36
  * obfuscated because a STUN server has to know it for the protocol to work.
37
37
  */
38
38
  /**
39
- * A public STUN server, used only to learn the reflexive address.
39
+ * A public STUN server, used only to learn the reflexive address, when the
40
+ * page names none of its own (`CollectorEnv.stunUrl`, set by the SDK from
41
+ * `turnUrl` so the edge collector answers instead).
40
42
  *
41
43
  * This is an outbound request from the visitor's browser to a third party, and
42
44
  * it is the reason this collector is opt-in even though it prompts for nothing.
@@ -51,7 +53,7 @@ export const webrtcCollector = {
51
53
  id: 'webrtc',
52
54
  wave: 'deep',
53
55
  optional: true,
54
- async collect({ window }) {
56
+ async collect({ window, stunUrl }) {
55
57
  const out = {};
56
58
  const Ctor = window.RTCPeerConnection ??
57
59
  window.webkitRTCPeerConnection;
@@ -65,7 +67,7 @@ export const webrtcCollector = {
65
67
  out['webrtc.supported'] = true;
66
68
  let connection;
67
69
  try {
68
- connection = new Ctor({ iceServers: [{ urls: STUN }] });
70
+ connection = new Ctor({ iceServers: [{ urls: stunUrl ?? STUN }] });
69
71
  // A data channel is what makes the browser gather at all. Nothing is
70
72
  // sent on it and no media device is touched.
71
73
  connection.createDataChannel('probe');
package/dist/types.d.ts CHANGED
@@ -24,6 +24,12 @@ export interface CollectorEnv {
24
24
  readonly document: Document;
25
25
  readonly screen: Screen;
26
26
  readonly performance: Performance;
27
+ /**
28
+ * The STUN server the `webrtc` collector asks, when the page has its own:
29
+ * the edge collector's TURN listener answers STUN too. Without it the
30
+ * collector uses Google's, a third party the visitor's browser then contacts.
31
+ */
32
+ readonly stunUrl?: string;
27
33
  }
28
34
  export type SignalValue = string | number | boolean | null;
29
35
  export interface Collector {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magield/collectors",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Browser signal collectors used by the Magic Shield web SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "files": [