From 979931ece02a822b617fbffae31e0043ab97d415 Mon Sep 17 00:00:00 2001 From: hifibuild Date: Thu, 7 Oct 2021 16:24:45 +0000 Subject: [PATCH 1/9] Bump package version to 2.1.1-0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d4d74243..f6938d63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.0", + "version": "2.1.1-0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 390020eb..63e6f79c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.0", + "version": "2.1.1-0", "description": "The High Fidelity Audio Client Library allows developers to integrate High Fidelity's spatial audio technology into their projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts", From 38de425bc20b93e0c936bc92c3945124d7190204 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 7 Oct 2021 12:25:42 -0700 Subject: [PATCH 2/9] include event name and api version in diagnostics report --- src/classes/HiFiMixerSession.ts | 4 ++-- src/diagnostics/diagnostics.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/classes/HiFiMixerSession.ts b/src/classes/HiFiMixerSession.ts index 0fd48f72..02a6fc5b 100644 --- a/src/classes/HiFiMixerSession.ts +++ b/src/classes/HiFiMixerSession.ts @@ -1011,7 +1011,7 @@ export class HiFiMixerSession { this._hifiDiagnostics.prime(this.mixerInfo.visit_id_hash); this._copyAudioTracksFromRavi(); } else { - this._hifiDiagnostics.fire(); + this._hifiDiagnostics.fire(state.toString()); } } @@ -1070,7 +1070,7 @@ export class HiFiMixerSession { onRAVISessionStateChanged = (async function(event:any) : Promise { HiFiLogger.log(`New RAVI session state: \`${event.state}\``); let message = undefined; - this._raviDiagnostics.fire(); + this._raviDiagnostics.fire(event.state.toString()); switch (event.state) { case RaviSessionStates.CONNECTED: HiFiLogger.log(`RaviSession connected; waiting for results of audionet.init`); diff --git a/src/diagnostics/diagnostics.ts b/src/diagnostics/diagnostics.ts index 3f1cee5c..252e3d2f 100644 --- a/src/diagnostics/diagnostics.ts +++ b/src/diagnostics/diagnostics.ts @@ -1,5 +1,7 @@ import { HiFiMixerSession } from "../classes/HiFiMixerSession"; import { RaviSession, STATS_WATCHER_FILTER } from "../libravi/RaviSession"; +import { apiVersion } from "../index"; + const isBrowser = typeof window !== 'undefined'; const noop = (_:any):any => undefined; @@ -72,7 +74,7 @@ export class Diagnostics { Object.assign(this, {url, label, session, ravi, fireOn}); this.checkPersisted(); this.reset(); - this.fireListener = () => this.fire(); + this.fireListener = (event:any) => this.fire(event.type); this.onlineListener = () => this.checkPersisted(); } /** @@ -89,9 +91,9 @@ export class Diagnostics { /** * Call this when we get into a state that we want to know more about, e.g., when leaving the thing that caused us to prime(). */ - async fire() { + async fire(eventName:string) { if (!this.isPrimed()) return; - const reportString = this.toString(); + const reportString = this.toString(eventName); this.reset(); // When we fire on closing tab or browser, we sometimes don't have enough time to report, or // sometimes have enough time to report, but not enough to check the response. @@ -137,7 +139,7 @@ export class Diagnostics { /** * Answer a single (long) log line to report. */ - toString() { + toString(eventName:string) { return `${new Date().toISOString()} ${this.identifier} ` + this.s('logReason', 'sessionEND') + this.connectionStats('browserStats') + @@ -152,6 +154,8 @@ export class Diagnostics { this.visibilityInfo() + this.connectionInfo() + this.s('PERSISTENCE', directSendLabel) + + this.s('VERSION', apiVersion) + + this.s('EVENT', eventName) + (useDebugPrefixes ? '\n' : '') + ` [${xNavigator.userAgent}]`; } From 64abd91438a3819da640fafce651feaa14918fdc Mon Sep 17 00:00:00 2001 From: hifibuild Date: Tue, 12 Oct 2021 17:46:53 +0000 Subject: [PATCH 3/9] Bump package version to 2.1.1-1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f6938d63..8102d36a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-0", + "version": "2.1.1-1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 63e6f79c..b1c35010 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-0", + "version": "2.1.1-1", "description": "The High Fidelity Audio Client Library allows developers to integrate High Fidelity's spatial audio technology into their projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts", From 43b23a11f2a59ae85a2c619e2ef3d2c0204f2d1b Mon Sep 17 00:00:00 2001 From: RebeccaStankus Date: Tue, 12 Oct 2021 16:44:13 -0700 Subject: [PATCH 4/9] Use better UUID generation --- package.json | 1 + tests/testUtilities/testUtils.ts | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b1c35010..0ce82a4c 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "dependencies": { "esm": "^3.2.25", "pako": "^2.0.3", + "uuid": "^8.3.2", "wrtc": "^0.4.7", "ws": "^7.4.2" }, diff --git a/tests/testUtilities/testUtils.ts b/tests/testUtilities/testUtils.ts index c98c54ed..45b0253d 100644 --- a/tests/testUtilities/testUtils.ts +++ b/tests/testUtilities/testUtils.ts @@ -1,6 +1,7 @@ -const { default: SignedJWT } = require('jose/jwt/sign'); -const { default: UnsecuredJWT } = require('jose/jwt/unsecured'); -const crypto = require('crypto'); +const { default: SignedJWT } = require('jose/jwt/sign'), + { v4 } = require('uuid'), + { default: UnsecuredJWT } = require('jose/jwt/unsecured'), + crypto = require('crypto'); export let tokenTypes: any = {}; @@ -111,16 +112,7 @@ export async function generateJWT(tokenType: { [property: string]: any }, spaceI } export function generateUUID() { - let i = 0; - let generatedUUID = ""; - let baseString = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; - - while (i++ < 38) { - let c = baseString[i - 1], r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - generatedUUID += (c == '-' || c == '4') ? c : v.toString(16) - } - - return generatedUUID; + return v4(); } export function sleep(ms: number) { From f27a4625c56743b43f0d8bfcca6e246ad26177f7 Mon Sep 17 00:00:00 2001 From: hifibuild Date: Wed, 13 Oct 2021 17:11:45 +0000 Subject: [PATCH 5/9] Bump package version to 2.1.1-2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8102d36a..fe97f967 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-1", + "version": "2.1.1-2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0ce82a4c..74a7f3a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-1", + "version": "2.1.1-2", "description": "The High Fidelity Audio Client Library allows developers to integrate High Fidelity's spatial audio technology into their projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts", From ae7c245a039c5f7610b319dd4531c7ca93b11bad Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 13 Oct 2021 16:55:11 -0700 Subject: [PATCH 6/9] Catch exception when diagnostics report fails --- src/diagnostics/diagnostics.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diagnostics/diagnostics.ts b/src/diagnostics/diagnostics.ts index 3f1cee5c..9e4d7589 100644 --- a/src/diagnostics/diagnostics.ts +++ b/src/diagnostics/diagnostics.ts @@ -237,7 +237,8 @@ export class Diagnostics { method: 'POST', headers: { 'Content-Type': 'text/plain' }, body: reportString - }).then((response:Response) => response.ok); + }).then((response:Response) => response.ok) + .catch((err) => { console.log(`Could not send diagnostics report for ${this.label} to ${this.url}: ${err}`); return false; }); } /** * Add reportString to the set of data being saved for later reporting. From 87b5b054e46687d9f1764f489e902c0a3ffecb40 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 14 Oct 2021 10:08:29 -0700 Subject: [PATCH 7/9] Prevent web storage leak when diagnostics reports fail continuously --- src/diagnostics/diagnostics.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/diagnostics/diagnostics.ts b/src/diagnostics/diagnostics.ts index 9e4d7589..3e97ea01 100644 --- a/src/diagnostics/diagnostics.ts +++ b/src/diagnostics/diagnostics.ts @@ -17,6 +17,8 @@ if (!isBrowser) { } } +const MAX_DIAGNOSTICS_STORAGE_LENGTH = 5000; + const nonOperative = "non-operative"; STATS_WATCHER_FILTER.set('remote-inbound-rtp', @@ -249,7 +251,14 @@ export class Diagnostics { // there is a bug, or if the application site limits the connect-src (or default-src) // in its Content-Security-Policy header without allowing this.url. // If it is more than a line, we are accumulating stuff and really ought to phone home through the mixer when connected. - if (existing) existing += "\n"; + if (existing) { + if (existing.length > MAX_DIAGNOSTICS_STORAGE_LENGTH) { + // If it is many lines, we may be in a web context where we cannot send diagnostics lines, and are better off discarding them to conserve web storage + console.log(`Diagnostics for ${this.label} truncated`); + existing = ""; + } + existing += "\n"; + } // The reportString is generated as through it will be sent directly. Here we replace that label with a reason why we're persisting. reportString = reportString.replace(directSendLabel, reason); xStorage.setItem(this.label, existing + reportString); From 7916fd26d68670a6ae9a7d8e80a1adad44a6c444 Mon Sep 17 00:00:00 2001 From: hifibuild Date: Thu, 14 Oct 2021 18:21:39 +0000 Subject: [PATCH 8/9] Bump package version to 2.1.1-3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe97f967..79ac7d05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-2", + "version": "2.1.1-3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 74a7f3a5..1574735c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-2", + "version": "2.1.1-3", "description": "The High Fidelity Audio Client Library allows developers to integrate High Fidelity's spatial audio technology into their projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts", From 2975e6615952b28ffccd82afb851e470cf2d000c Mon Sep 17 00:00:00 2001 From: bridie-hifi Date: Thu, 14 Oct 2021 11:40:02 -0700 Subject: [PATCH 9/9] 2.1.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 79ac7d05..30ef129e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-3", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1574735c..4f585190 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "2.1.1-3", + "version": "2.1.1", "description": "The High Fidelity Audio Client Library allows developers to integrate High Fidelity's spatial audio technology into their projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts",