Socket
Socket
Sign inDemoInstall

@vonage/js-onewebrtc-telemetry

Package Overview
Dependencies
Maintainers
36
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/js-onewebrtc-telemetry - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

1

dist/interfaces.d.ts

@@ -58,3 +58,4 @@ export declare enum SourceType {

proxyUrl?: string;
config?: string;
}
export declare type SendableReport = Omit<Report, "timestamp" | "applicationId" | "proxyUrl" | "proxyUrl">;

2

dist/js-onewebrtc-telemetry.umd.js

@@ -1,1 +0,1 @@

(function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["js-onewebrtc-telemetry"]={}))})(this,function(i){"use strict";var v=Object.defineProperty;var x=(i,o,d)=>o in i?v(i,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[o]=d;var a=(i,o,d)=>(x(i,typeof o!="symbol"?o+"":o,d),d);var o=(t=>(t.automation="automation",t.test="test",t.vbc="vbc",t.video="video",t.voice="voice",t))(o||{});const d="hlg.tokbox.com/prod/logging/vcp_webrtc",g="https://",h=1e4;let s;const m=new Uint8Array(16);function y(){if(!s&&(s=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!s))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return s(m)}const n=[];for(let t=0;t<256;++t)n.push((t+256).toString(16).slice(1));function U(t,e=0){return(n[t[e+0]]+n[t[e+1]]+n[t[e+2]]+n[t[e+3]]+"-"+n[t[e+4]]+n[t[e+5]]+"-"+n[t[e+6]]+n[t[e+7]]+"-"+n[t[e+8]]+n[t[e+9]]+"-"+n[t[e+10]]+n[t[e+11]]+n[t[e+12]]+n[t[e+13]]+n[t[e+14]]+n[t[e+15]]).toLowerCase()}const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function b(t,e,r){if(l.randomUUID&&!e&&!t)return l.randomUUID();t=t||{};const c=t.random||(t.rng||y)();if(c[6]=c[6]&15|64,c[8]=c[8]&63|128,e){r=r||0;for(let u=0;u<16;++u)e[r+u]=c[u];return e}return U(c)}class R{constructor(e){a(this,"uuid",b());this.config=e}async send(e){var p;const r=new AbortController,c=setTimeout(()=>r.abort(),h);return await((p=this.config.fetch)!=null?p:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:r.signal}),clearTimeout(c),"success"}getUrl(){var r;let e=(r=this.config.proxyUrl)!=null?r:g;return e+=(e.at(-1)==="/"?"":"/")+d,e}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){return{guid:this.uuid,...e,applicationId:this.config.appId,timestamp:Date.now(),proxyUrl:this.config.proxyUrl,source:this.config.sourceType}}}i.Reporter=R,i.SourceType=o,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r["js-onewebrtc-telemetry"]={}))})(this,function(r){"use strict";var x=Object.defineProperty;var I=(r,o,s)=>o in r?x(r,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[o]=s;var a=(r,o,s)=>(I(r,typeof o!="symbol"?o+"":o,s),s);var o=(t=>(t.automation="automation",t.test="test",t.vbc="vbc",t.video="video",t.voice="voice",t))(o||{});const s="hlg.tokbox.com/prod/logging/vcp_webrtc",h="https://",m=1e4;let p;const y=new Uint8Array(16);function U(){if(!p&&(p=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!p))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(y)}const n=[];for(let t=0;t<256;++t)n.push((t+256).toString(16).slice(1));function b(t,e=0){return(n[t[e+0]]+n[t[e+1]]+n[t[e+2]]+n[t[e+3]]+"-"+n[t[e+4]]+n[t[e+5]]+"-"+n[t[e+6]]+n[t[e+7]]+"-"+n[t[e+8]]+n[t[e+9]]+"-"+n[t[e+10]]+n[t[e+11]]+n[t[e+12]]+n[t[e+13]]+n[t[e+14]]+n[t[e+15]]).toLowerCase()}const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function R(t,e,c){if(l.randomUUID&&!e&&!t)return l.randomUUID();t=t||{};const i=t.random||(t.rng||U)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){c=c||0;for(let d=0;d<16;++d)e[c+d]=i[d];return e}return b(i)}class v{constructor(e){a(this,"uuid",R());this.config=e}async send(e){var u;if(!this.config||!this.config.appId||!this.config.sourceType)return"Missing config, report not sent";const c=new AbortController,i=setTimeout(()=>c.abort(),m);return await((u=this.config.fetch)!=null?u:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:c.signal}),clearTimeout(i),"success"}getUrl(){var c,i;let e=(i=(c=this.config)==null?void 0:c.proxyUrl)!=null?i:h;return e+=(e.at(-1)==="/"?"":"/")+s,e}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){var c,i,d,u,g;return{guid:this.uuid,...e,applicationId:(i=(c=this.config)==null?void 0:c.appId)!=null?i:"",source:(u=(d=this.config)==null?void 0:d.sourceType)!=null?u:"",timestamp:Date.now(),proxyUrl:(g=this.config)==null?void 0:g.proxyUrl}}}r.Reporter=v,r.SourceType=o,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
import { ReporterConfig, SendableReport } from "./interfaces";
export declare class Reporter {
config: ReporterConfig;
config?: ReporterConfig | undefined;
private uuid;
constructor(config: ReporterConfig);
constructor(config?: ReporterConfig | undefined);
send(report: SendableReport): Promise<string>;

@@ -7,0 +7,0 @@ private getUrl;

{
"name": "@vonage/js-onewebrtc-telemetry",
"version": "1.0.0",
"version": "1.0.2",
"description": "Library providing telemetry logging capabilities to Vonage monitoring servers.",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",

@@ -68,2 +68,3 @@ export enum SourceType {

proxyUrl?: string;
config?: string;
}

@@ -70,0 +71,0 @@

@@ -8,5 +8,8 @@ import { SERVER_PROTOCOL, SERVER_URI, TIMEOUT_MS } from "./constants";

constructor(public config: ReporterConfig) {}
constructor(public config?: ReporterConfig) {}
public async send(report: SendableReport): Promise<string> {
if (!this.config || !this.config.appId || !this.config.sourceType) {
return "Missing config, report not sent";
}
const controller = new AbortController();

@@ -28,3 +31,3 @@ const id = setTimeout(() => controller.abort(), TIMEOUT_MS);

private getUrl(): string {
let url = this.config.proxyUrl ?? SERVER_PROTOCOL;
let url = this.config?.proxyUrl ?? SERVER_PROTOCOL;
url += (url.at(-1) === "/" ? "" : "/") + SERVER_URI;

@@ -44,8 +47,8 @@ return url;

...report,
applicationId: this.config.appId,
applicationId: this.config?.appId ?? "",
source: this.config?.sourceType ?? "",
timestamp: Date.now(),
proxyUrl: this.config.proxyUrl,
source: this.config.sourceType,
proxyUrl: this.config?.proxyUrl,
};
}
}

@@ -29,2 +29,3 @@ import { describe, it, assert } from "vitest";

error: "error",
config: '{ "title": "this is a config" }',
};

@@ -31,0 +32,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc