Socket
Socket
Sign inDemoInstall

@vonage/js-onewebrtc-telemetry

Package Overview
Dependencies
Maintainers
42
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.1.2 to 1.1.3

.github/actions/deploy-documentation/action.yml

6

CHANGELOG.md
# CHANGELOG.md
## 1.1.3 (2023-05-30)
Changes:
- Allow to specify id for reporter
## 1.1.2 (2023-03-28)

@@ -5,0 +11,0 @@

2

dist/js-onewebrtc-telemetry.umd.js

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

(function(r,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(r=typeof globalThis<"u"?globalThis:r||self,s(r["js-onewebrtc-telemetry"]={}))})(this,function(r){"use strict";var H=Object.defineProperty;var J=(r,s,l)=>s in r?H(r,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):r[s]=l;var k=(r,s,l)=>(J(r,typeof s!="symbol"?s+"":s,l),l);var s=(e=>(e.automation="automation",e.test="test",e.vbc="vbc",e.video="video",e.voice="voice",e))(s||{});const l="hlg.tokbox.com/prod/logging/vcp_webrtc",A="https://",U=1e4;let f;const v=new Uint8Array(16);function M(){if(!f&&(f=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!f))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return f(v)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));function N(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}const w={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function O(e,t,n){if(w.randomUUID&&!t&&!e)return w.randomUUID();e=e||{};const i=e.random||(e.rng||M)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){n=n||0;for(let a=0;a<16;++a)t[n+a]=i[a];return t}return N(i)}function h(e,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let n=globalThis.vonage.workerizer;return n[e]||(n[e]=t),n[e]}const c=h("globals",{});var u=(e=>(e.INIT="INIT",e.FORWARD="FORWARD",e.TERMINATE="TERMINATE",e.GLOBALS_SYNC="GLOBALS_SYNC",e))(u||{});function m(e){return[ImageBitmap,ReadableStream,WritableStream].some(n=>e instanceof n)}let C=0;function E(e,t,n,i,a){const d=C++;return e.postMessage({id:d,type:t,functionName:n,args:i},i.filter(g=>m(g))),new Promise(g=>{a==null||a.set(d,g)})}function p(e,t){const{id:n,type:i}=e,a=Array.isArray(t)?t:[t];postMessage({id:n,type:i,result:t},a.filter(d=>m(d)))}const T=h("workerized",{});function I(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function L(){if(I())p({type:u.GLOBALS_SYNC},c);else{const e=[];for(const t in T){const{worker:n,resolvers:i}=T[t].workerContext;n&&e.push(E(n,u.GLOBALS_SYNC,"",[c],i))}await Promise.all(e)}}function y(e,t){if(Array.isArray(t))t.splice(0,t.length);else if(typeof t=="object")for(const n in t)delete t[n];for(const n in e)Array.isArray(e[n])?(t[n]=[],y(e[n],t[n])):typeof e[n]=="object"?(t[n]={},y(e[n],t[n])):t[n]=e[n]}async function V(e,t){const{functionName:n,args:i}=e;if(!t.instance)throw"instance not initialized";if(!n)throw"missing function name to call";if(!t.instance[n])throw`undefined function [${n}] in class ${t.instance.constructor.workerId}`;p(e,await t.instance[n](...i!=null?i:[]))}const G=h("registeredWorkers",{});function _(e,t){if(!e.args)throw"Missing className while initializing worker";const[n,i]=e.args,a=G[n];if(a)t.instance=new a(e.args.slice(1));else throw`unknown worker class ${n}`;y(i,c),p(e,typeof t.instance!==void 0)}async function D(e,t){const{args:n}=e;if(!t.instance)throw"instance not initialized";let i;t.instance.terminate&&(i=await t.instance.terminate(...n!=null?n:[])),p(e,i)}function W(e){if(!e.args)throw"Missing globals while syncing";y(e.args[0],c),p(e,{})}function z(){const e={};onmessage=async t=>{const n=t.data;switch(n.type){case u.INIT:_(n,e);break;case u.FORWARD:V(n,e);break;case u.TERMINATE:D(n,e);break;case u.GLOBALS_SYNC:W(n);break}}}I()&&z();function j(e,t){return c[e]||(c[e]=t),[()=>c[e],async n=>{c[e]=n,await L()}]}function x(e,t){return j(e,t)}const[B,P]=x("metadata");function Y(e){P(e)}function b(){return B()}class F{constructor(t){k(this,"uuid",O());this.config=t}async send(t){var g,R,S;const{appId:n,sourceType:i}=(g=b())!=null?g:{};if(!n||!i)return"metadata missing";const a=new AbortController,d=setTimeout(()=>a.abort(),U);return await((S=(R=this.config)==null?void 0:R.fetch)!=null?S:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(t)),signal:a.signal}),clearTimeout(d),"success"}getUrl(){var n;let t=(n=b().proxyUrl)!=null?n:A;return t+=(t.at(-1)==="/"?"":"/")+l,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(t){const n=b();return{guid:this.uuid,...t,applicationId:n.appId,timestamp:Date.now(),proxyUrl:n.proxyUrl,source:n.sourceType}}}r.Reporter=F,r.SourceType=s,r.getVonageMetadata=b,r.setVonageMetadata=Y,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
var __defProp=Object.defineProperty,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["js-onewebrtc-telemetry"]={})}(this,(function(e){"use strict";var t=(e=>(e.automation="automation",e.test="test",e.vbc="vbc",e.video="video",e.voice="voice",e))(t||{});let n;const o=new Uint8Array(16);function rng(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}const a=[];for(let p=0;p<256;++p)a.push((p+256).toString(16).slice(1));const r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function v4(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const o=(e=e||{}).random||(e.rng||rng)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function unsafeStringify(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}(o)}function createGlobalThisVariable(e,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let n=globalThis.vonage.workerizer;return n[e]||(n[e]=t),n[e]}const i=createGlobalThisVariable("globals",{});var s=(e=>(e.INIT="INIT",e.FORWARD="FORWARD",e.TERMINATE="TERMINATE",e.GLOBALS_SYNC="GLOBALS_SYNC",e))(s||{});function isTransferable(e){return[ImageBitmap,ReadableStream,WritableStream].some((t=>e instanceof t))}let c=0;function postCommand$1(e,t,n,o,a){const r=c++;e.postMessage({id:r,type:t,functionName:n,args:o},o.filter((e=>isTransferable(e))));return new Promise((e=>{null==a||a.set(r,e)}))}function postCommand(e,t){const{id:n,type:o}=e,a=Array.isArray(t)?t:[t];postMessage({id:n,type:o,result:t},a.filter((e=>isTransferable(e))))}const l=createGlobalThisVariable("workerized",{});function isWorker(){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope}function copy(e,t){if(Array.isArray(t))t.splice(0,t.length);else if("object"==typeof t)for(const n in t)delete t[n];for(const n in e)Array.isArray(e[n])?(t[n]=[],copy(e[n],t[n])):"object"==typeof e[n]?(t[n]={},copy(e[n],t[n])):t[n]=e[n]}const u=createGlobalThisVariable("registeredWorkers",{});function createGlobal(e,t){return i[e]||(i[e]=t),[()=>i[e],async t=>{i[e]=t,await async function globalsSync(){if(isWorker())postCommand({type:s.GLOBALS_SYNC},i);else{const e=[];for(const t in l){const{worker:n,resolvers:o}=l[t].workerContext;n&&e.push(postCommand$1(n,s.GLOBALS_SYNC,"",[i],o))}await Promise.all(e)}}()}]}isWorker()&&function initWorker(){const e={};onmessage=async t=>{const n=t.data;switch(n.type){case s.INIT:!function handleCommandInit(e,t){if(!e.args)throw"Missing className while initializing worker";const[n,o]=e.args,a=u[n];if(!a)throw`unknown worker class ${n}`;t.instance=new a(e.args.slice(1)),copy(o,i),postCommand(e,void 0!==typeof t.instance)}(n,e);break;case s.FORWARD:!async function handleCommandForward(e,t){const{functionName:n,args:o}=e;if(!t.instance)throw"instance not initialized";if(!n)throw"missing function name to call";if(!t.instance[n])throw`undefined function [${n}] in class ${t.instance.constructor.workerId}`;postCommand(e,await t.instance[n](...null!=o?o:[]))}(n,e);break;case s.TERMINATE:!async function handleCommandTerminate(e,t){const{args:n}=e;if(!t.instance)throw"instance not initialized";let o;t.instance.terminate&&(o=await t.instance.terminate(...null!=n?n:[])),postCommand(e,o)}(n,e);break;case s.GLOBALS_SYNC:!function handleCommandGlobalsSync(e){if(!e.args)throw"Missing globals while syncing";copy(e.args[0],i),postCommand(e,{})}(n)}}}();const[d,f]=function registerGlobal(e,t){return createGlobal(e,t)}("metadata");function getVonageMetadata(){return d()}e.Reporter=class Reporter{constructor(e,t){__publicField(this,"uuid"),this.config=e,this.uuid=null!=t?t:v4()}async send(e){var t,n,o;const{appId:a,sourceType:r}=null!=(t=getVonageMetadata())?t:{};if(!a||!r)return"metadata missing";const i=new AbortController,s=setTimeout((()=>i.abort()),1e4),c=null!=(o=null==(n=this.config)?void 0:n.fetch)?o:fetch;return await c(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:i.signal}),clearTimeout(s),"success"}getUrl(){var e;let t=null!=(e=getVonageMetadata().proxyUrl)?e:"https://";return t+=("/"===t.at(-1)?"":"/")+"hlg.tokbox.com/prod/logging/vcp_webrtc",t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=getVonageMetadata();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}},e.SourceType=t,e.getVonageMetadata=getVonageMetadata,e.setVonageMetadata=function setVonageMetadata(e){f(e)},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
{
"name": "@vonage/js-onewebrtc-telemetry",
"version": "1.1.2",
"version": "1.1.3",
"description": "Library providing telemetry logging capabilities to Vonage monitoring servers.",

@@ -9,7 +9,11 @@ "types": "./dist/index.d.ts",

"scripts": {
"build": "tsc && vite build",
"typedoc": "typedoc --theme github-wiki src/index.ts",
"build": "npm-run-all build:js build:static",
"build:js": "tsc && vite build",
"build:static": "vite-node .github/scripts/build-static.js",
"build:doc": "typedoc --excludeInternal --excludePrivate --excludeProtected --disableSources --out dist/doc src/index.ts",
"prettier": "prettier --write ./src ./tests",
"doc": "typedoc --excludeInternal --excludePrivate --excludeProtected --disableSources --out dist/docs src/index.ts",
"test": "karma start --single-run"
"test": "karma start --single-run",
"test:install": "",
"version:local": "node -pe 'require(\"./package.json\").version'",
"version:published": "npm show @vonage/js-onewebrtc-telemetry version"
},

@@ -43,3 +47,5 @@ "repository": {

"mocha": "^10.0.0",
"npm-run-all": "^4.1.5",
"sinon": "^14.0.1",
"terser": "^5.17.1",
"typedoc": "^0.23.16",

@@ -50,2 +56,3 @@ "typedoc-github-wiki-theme": "^1.0.1",

"vite": "^3.1.0",
"vite-node": "^0.31.0",
"vite-plugin-dts": "^1.4.1"

@@ -52,0 +59,0 @@ },

<a href="https://www.vonage.com/">
<img src="public/logo.png" alt="Vonage logo" title="Vonage" align="right" height="60" />
<img src="./logo.png" alt="Vonage logo" title="Vonage" align="right" height="60" />
</a>

@@ -4,0 +4,0 @@

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

export class Reporter {
private uuid: string = uuid();
private uuid: string;
constructor(public config?: ReporterConfig) {}
constructor(public config?: ReporterConfig, id?: string) {
this.uuid = id ?? uuid();
}

@@ -12,0 +14,0 @@ public async send(report: SendableReport): Promise<string> {

@@ -0,34 +1,24 @@

import * as path from "path";
import dts from "vite-plugin-dts";
import { defineConfig } from "vite";
import { resolve } from "path";
import { unlink } from "fs";
import dts from "vite-plugin-dts";
import * as packageJson from "./package.json";
const packageName = packageJson.name.split("/")[1];
function removeFromBuild(files = []) {
return {
name: "remove-from-build",
resolveId(source) {
return source === "virtual-module" ? source : null;
},
renderStart(outputOptions, inputOptions) {
const dir = outputOptions.dir;
files.forEach((file) => {
unlink(resolve(dir, file), () => console.log(`Deleted ${file}`));
});
},
};
}
export default defineConfig({
test: {
include: ["tests/**/*.test.ts"],
},
module.exports = defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "js-onewebrtc-telemetry",
fileName: "js-onewebrtc-telemetry",
emptyOutDir: true,
entry: path.resolve(__dirname, "src/index.ts"),
name: packageName,
fileName: (format) => `${packageName}.${format}.js`,
},
minify: "terser",
terserOptions: {
keep_fnames: true,
},
},
plugins: [dts(), removeFromBuild(["logo.png"])],
plugins: [
dts({
outputDir: "dist/types",
}),
],
});
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