@fluidframework/debugger 2.0.0-internal.1.2.0.93071 → 2.0.0-internal.1.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebugger.d.ts","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAyB,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAIpG,yBAAiB,aAAa,CAAC;IAC3B;;;;;OAKG;IACH,SAAsB,iBAAiB,CACnC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMhE;IAED,SAAsB,wBAAwB,CAC1C,sBAAsB,EAAE,uBAAuB,mEASlD;CAOJ"}
1
+ {"version":3,"file":"fluidDebugger.d.ts","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAyB,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAKpG,yBAAiB,aAAa,CAAC;IAC3B;;;;;OAKG;IACH,SAAsB,iBAAiB,CACnC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMhE;IAED,SAAsB,wBAAwB,CAC1C,sBAAsB,EAAE,uBAAuB,mEASlD;CAOJ"}
@@ -8,6 +8,7 @@ exports.FluidDebugger = void 0;
8
8
  const replay_driver_1 = require("@fluidframework/replay-driver");
9
9
  const fluidDebuggerController_1 = require("./fluidDebuggerController");
10
10
  const fluidDebuggerUi_1 = require("./fluidDebuggerUi");
11
+ // eslint-disable-next-line @typescript-eslint/no-namespace
11
12
  var FluidDebugger;
12
13
  (function (FluidDebugger) {
13
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebugger.js","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAoG;AACpG,uEAAkE;AAClE,uDAA+C;AAE/C,IAAiB,aAAa,CAiC7B;AAjCD,WAAiB,aAAa;IAC1B;;;;;OAKG;IACI,KAAK,UAAU,iBAAiB,CACnC,eAAiC;QACjC,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,eAAe,CAAC;SAC1B;QACD,OAAO,qCAAqB,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAPqB,+BAAiB,oBAOtC,CAAA;IAEM,KAAK,UAAU,wBAAwB,CAC1C,sBAA+C;QAC/C,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,sBAAsB,CAAC;SACjC;QACD,OAAO,IAAI,4CAA4B,CACnC,sBAAsB,EACtB,UAAU,CACb,CAAC;IACN,CAAC;IAVqB,sCAAwB,2BAU7C,CAAA;IAED;;;OAGG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,+CAAqB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,4BAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAClH,CAAC,EAjCgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAiC7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport { ReplayDocumentService, ReplayDocumentServiceFactory } from \"@fluidframework/replay-driver\";\nimport { DebugReplayController } from \"./fluidDebuggerController\";\nimport { DebuggerUI } from \"./fluidDebuggerUi\";\n\nexport namespace FluidDebugger {\n /**\n * Creates document service wrapper that pops up Debugger window and allows user to play ops one by one.\n * User can chose to start with any snapshot\n * If pop-ups are disabled, we continue without debugger.\n * @param documentService - original document service to use to fetch ops / snapshots.\n */\n export async function createFromService(\n documentService: IDocumentService): Promise<IDocumentService> {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentService;\n }\n return ReplayDocumentService.create(documentService, controller);\n }\n\n export async function createFromServiceFactory(\n documentServiceFactory: IDocumentServiceFactory) {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentServiceFactory;\n }\n return new ReplayDocumentServiceFactory(\n documentServiceFactory,\n controller,\n );\n }\n\n /**\n * Binds DebuggerUI & DebugReplayController together\n * These classes do not know each other and talk through interfaces\n */\n const createFluidDebugger = () => DebugReplayController.create((controller) => DebuggerUI.create(controller));\n}\n"]}
1
+ {"version":3,"file":"fluidDebugger.js","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAoG;AACpG,uEAAkE;AAClE,uDAA+C;AAE/C,2DAA2D;AAC3D,IAAiB,aAAa,CAiC7B;AAjCD,WAAiB,aAAa;IAC1B;;;;;OAKG;IACI,KAAK,UAAU,iBAAiB,CACnC,eAAiC;QACjC,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,eAAe,CAAC;SAC1B;QACD,OAAO,qCAAqB,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAPqB,+BAAiB,oBAOtC,CAAA;IAEM,KAAK,UAAU,wBAAwB,CAC1C,sBAA+C;QAC/C,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,sBAAsB,CAAC;SACjC;QACD,OAAO,IAAI,4CAA4B,CACnC,sBAAsB,EACtB,UAAU,CACb,CAAC;IACN,CAAC;IAVqB,sCAAwB,2BAU7C,CAAA;IAED;;;OAGG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,+CAAqB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,4BAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAClH,CAAC,EAjCgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAiC7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport { ReplayDocumentService, ReplayDocumentServiceFactory } from \"@fluidframework/replay-driver\";\nimport { DebugReplayController } from \"./fluidDebuggerController\";\nimport { DebuggerUI } from \"./fluidDebuggerUi\";\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace FluidDebugger {\n /**\n * Creates document service wrapper that pops up Debugger window and allows user to play ops one by one.\n * User can chose to start with any snapshot\n * If pop-ups are disabled, we continue without debugger.\n * @param documentService - original document service to use to fetch ops / snapshots.\n */\n export async function createFromService(\n documentService: IDocumentService): Promise<IDocumentService> {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentService;\n }\n return ReplayDocumentService.create(documentService, controller);\n }\n\n export async function createFromServiceFactory(\n documentServiceFactory: IDocumentServiceFactory) {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentServiceFactory;\n }\n return new ReplayDocumentServiceFactory(\n documentServiceFactory,\n controller,\n );\n }\n\n /**\n * Binds DebuggerUI & DebugReplayController together\n * These classes do not know each other and talk through interfaces\n */\n const createFluidDebugger = () => DebugReplayController.create((controller) => DebuggerUI.create(controller));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebuggerUi.d.ts","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAE3F,MAAM,WAAW,WAAW;IACxB;;;OAGG;IACH,WAAW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AQ,CAAC,EAAE,iBAAiB,CAAC;IACvC,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC;IAEtC,SAAS,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IACxC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IACtC,SAAS,CAAC,kBAAkB,UAAS;IACrC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAEpC,SAAS,CAAC,cAAc,UAAS;IAEjC,SAAS,aAA8B,UAAU,EAAE,mBAAmB,EAAmB,cAAc,EAAE,MAAM;IAyC/G,OAAO,CAAC,yBAAyB;IAQ1B,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE;IAahC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM;IAQjE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM;IAiC7D,mBAAmB,CAAC,OAAO,EAAE,OAAO;IAKpC,gBAAgB,CAAC,GAAG,EAAE,yBAAyB,EAAE;IAejD,iBAAiB,CAAC,YAAY,EAAE,MAAM;IAOtC,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO;IAOlE,OAAO,CAAC,QAAQ;CAYnB"}
@@ -111,12 +111,9 @@ class DebuggerUI {
111
111
  this.versions = versions;
112
112
  for (const version of versions) {
113
113
  const option = document.createElement("option");
114
- if (version.date !== undefined) {
115
- option.text = `id = ${version.id}, time = ${version.date}`;
116
- }
117
- else {
118
- option.text = `id = ${version.id}`;
119
- }
114
+ option.text = version.date !== undefined
115
+ ? `id = ${version.id}, time = ${version.date}`
116
+ : `id = ${version.id}`;
120
117
  this.selector.add(option);
121
118
  }
122
119
  }
@@ -129,13 +126,9 @@ class DebuggerUI {
129
126
  }
130
127
  }
131
128
  versionSelected(seqNumber, version) {
132
- let text;
133
- if (typeof version === "string") {
134
- text = `Playing ${version} file`;
135
- }
136
- else {
137
- text = `Playing from ${version.id}, seq# ${seqNumber}`;
138
- }
129
+ const text = typeof version === "string"
130
+ ? `Playing ${version} file`
131
+ : `Playing from ${version.id}, seq# ${seqNumber}`;
139
132
  this.wasVersionSelected = true;
140
133
  this.selector = undefined;
141
134
  const doc = this.debuggerWindow.document;
@@ -184,16 +177,9 @@ class DebuggerUI {
184
177
  }
185
178
  }
186
179
  updateLastOpText(lastKnownOp, stillLoading) {
187
- let text;
188
- if (lastKnownOp < 0) {
189
- text = `FluidDebugger can't play ops in this mode`;
190
- }
191
- if (stillLoading) {
192
- text = `Last op (still loading): ${lastKnownOp}`;
193
- }
194
- else {
195
- text = `Document's last op seq#: ${lastKnownOp}`;
196
- }
180
+ const text = stillLoading
181
+ ? `Last op (still loading): ${lastKnownOp}`
182
+ : `Document's last op seq#: ${lastKnownOp}`;
197
183
  this.lastOpText.textContent = text;
198
184
  }
199
185
  download(filename, data) {
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebuggerUi.js","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AA8FtD,MAAM,kBAAkB,GACpB;;;;;;;;;;;;;;;;QAgBI,CAAC;AAET,MAAM,mBAAmB,GACrB;;;;;;;;;;;;;;;QAeI,CAAC;AAET,MAAa,UAAU;IA4CnB,YAAuC,UAA+B,EAAmB,cAAsB;QAAxE,eAAU,GAAV,UAAU,CAAqB;QAAmB,mBAAc,GAAd,cAAc,CAAQ;QALrG,uBAAkB,GAAG,KAAK,CAAC;QAC3B,aAAQ,GAAe,EAAE,CAAC;QAE1B,mBAAc,GAAG,KAAK,CAAC;QAG7B,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,QA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;SACvC;IACL,CAAC;IAEM,gBAAgB,CAAC,WAAmB,EAAE,YAAqB;QAC9D,IAAI,IAAY,CAAC;QACjB,IAAI,WAAW,GAAG,CAAC,EAAE;YACjB,IAAI,GAAG,2CAA2C,CAAC;SACtD;QACD,IAAI,YAAY,EAAE;YACd,IAAI,GAAG,4BAA4B,WAAW,EAAE,CAAC;SACpD;aAAM;YACH,IAAI,GAAG,4BAA4B,WAAW,EAAE,CAAC;SACpD;QACD,IAAI,CAAC,UAAW,CAAC,WAAW,GAAG,IAAI,CAAC;IACxC,CAAC;IAEO,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,iCAAkC,kBAAkB,CAAC,IAAI,CAAE,EAAE,CAAC,CAAC;QAC5F,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AA5MD,gCA4MC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, IVersion } from \"@fluidframework/protocol-definitions\";\n\nexport interface IDebuggerUI {\n /**\n * Version information is provided.\n * Expect updates (information about seq#, timestamp) through updateVersion() calls\n */\n addVersions(version: IVersion[]): void;\n\n /**\n * Call when new version is downloaded from storage\n * Expect multiple callbacks.\n */\n updateVersion(index: number, version: IVersion, seqNumber: number): void;\n\n /**\n * Called in response to successful onVersionSelection() or onSnapshotFileSelection() call\n * and provides extra information about selection.\n * It expected that UI layer would change its mode as result of this call, i.e. switch to\n * displaying op playback controls (if this is supported)\n * Note: There maybe no call to versionSelected() in response to onSnapshotFileSelection() call\n * if file does not exist, has wrong name of wrong format.\n * @param version - version, file name, or undefined if playing ops.\n */\n versionSelected(seqNumber: number, version: IVersion | string): void;\n\n /**\n * Called by controller in response to new ops being downloaded\n * Called with disable = true if there are no (currently) ops to play\n */\n disableNextOpButton(disable: boolean): void;\n\n /**\n * Called by controller when new ops arrive (or we are done playing previous batch)\n * Indicates next batch of ops that would be played when UI calls controller's onOpButtonClick()\n * Called with ops=[] when there are no ops to play.\n */\n updateNextOpText(ops: ISequencedDocumentMessage[]): void;\n\n /**\n * Called periodically when new versions are downloaded from server\n */\n updateVersionText(versionsLeft: number): void;\n\n /**\n * Called periodically to notify about last known op\n * @param lastKnownOp - seq number of last known op. -1 if can't play ops in this mode (load from file)\n * @param stillLoading - true if we did not reach yet the end of the stream\n */\n updateLastOpText(lastKnownOp: number, stillLoading: boolean): void;\n}\n\nexport interface IDebuggerController {\n /**\n * Initialization. UI layers calls into controller to connect the two.\n * @param ui - UI layer\n */\n connectToUi(ui: IDebuggerUI);\n\n /**\n * Called by UI layer when debugger window is closed by user\n * If called before user makes selection of snapshot/file, original\n * document service is returned to loader (instead of debugger service) and normal document load continues.\n */\n onClose(): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - Snapshot version to start from.\n */\n onVersionSelection(version: IVersion): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - File to load snapshot from\n */\n onSnapshotFileSelection(file: File): void;\n\n /**\n * \"next op\" button is clicked in the UI\n * @param steps - number of ops to play.\n */\n onOpButtonClick(steps: number): void;\n\n /**\n * \"Download ops\" option is clicked in the UI. Returns JSON of the full opStream when available.\n * @param anonymize - anonymize the ops json using the sanitization tool\n */\n onDownloadOpsButtonClick(anonymize: boolean): Promise<string>;\n}\n\nconst debuggerWindowHtml =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\nPlease select snapshot or file to start with<br/>\nClose debugger window to proceed to live document<br/><br/>\n<select style='width:250px' id='selector'>\n</select>\n&nbsp; &nbsp; &nbsp;\n<button id='buttonVers' style='width:60px'>Go</button><br/>\n<input id='file' type='file' value='Load from file'/>\n<br/><br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n<br/><br/><div id='versionText'></div>\n</body>`;\n\nconst debuggerWindowHtml2 =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\n<div id='versionText'></div>\n<div id='lastOp'></div>\n<br/>\nStep to move: <input type='number' id='steps' value='1' min='1' style='width:50px'/>\n&nbsp; &nbsp; &nbsp;<button id='buttonOps' style='width:60px'>Go</button>\n<br/><br/>\n<div id='text1'></div><div id='text2'></div><div id='text3'></div>\n<br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n</body>`;\n\nexport class DebuggerUI {\n public static create(controller: IDebuggerController): DebuggerUI | null {\n if (\n typeof window !== \"object\" ||\n window === null ||\n typeof window.document !== \"object\" ||\n window.document == null) {\n console.log(\"Can't create debugger window - not running in browser!\");\n return null;\n }\n\n const debuggerWindow = window.open(\n \"\",\n \"\",\n \"width=400,height=400,resizable=yes,location=no,menubar=no,titlebar=no,status=no,toolbar=no\");\n if (!debuggerWindow) {\n console.error(\"Can't create debugger window - please enable pop-up windows in your browser!\");\n return null;\n }\n\n return new DebuggerUI(controller, debuggerWindow);\n }\n\n private static formatDate(date: number) {\n // Alternative - without timezone\n // new Date().toLocaleString('default', { timeZone: 'UTC'}));\n // new Date().toLocaleString('default', { year: 'numeric', month: 'short',\n // day: 'numeric', hour: '2-digit', minute: 'numeric', second: 'numeric' }));\n return new Date(date).toUTCString();\n }\n\n protected selector?: HTMLSelectElement;\n protected versionText: HTMLDivElement;\n\n protected buttonOps?: HTMLButtonElement;\n protected text1?: HTMLDivElement;\n protected text2?: HTMLDivElement;\n protected text3?: HTMLDivElement;\n protected lastOpText?: HTMLDivElement;\n protected wasVersionSelected = false;\n protected versions: IVersion[] = [];\n\n protected documentClosed = false;\n\n protected constructor(private readonly controller: IDebuggerController, private readonly debuggerWindow: Window) {\n const doc = this.debuggerWindow.document;\n doc.write(debuggerWindowHtml);\n\n window.addEventListener(\"beforeunload\", (e) => {\n this.documentClosed = true;\n this.debuggerWindow.close();\n }, false);\n\n this.debuggerWindow.addEventListener(\"beforeunload\", (e) => {\n if (!this.documentClosed) {\n this.controller.onClose();\n }\n }, false);\n\n this.selector = doc.getElementById(\"selector\") as HTMLSelectElement;\n\n const buttonVers = doc.getElementById(\"buttonVers\") as HTMLDivElement;\n buttonVers.onclick = () => {\n const index = this.selector!.selectedIndex;\n controller.onVersionSelection(this.versions[index]);\n };\n\n const fileSnapshot = doc.getElementById(\"file\") as HTMLInputElement;\n fileSnapshot.addEventListener(\"change\", () => {\n const files = fileSnapshot.files;\n if (files) {\n controller.onSnapshotFileSelection(files[0]);\n }\n }, false);\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = \"Fetching snapshots, please wait...\";\n\n controller.connectToUi(this);\n }\n\n private attachDownloadOpsListener(element: HTMLElement, anonymize: HTMLInputElement) {\n element.addEventListener(\"click\", () => {\n this.controller.onDownloadOpsButtonClick(anonymize.checked).then((opJson) => {\n this.download(\"opStream.json\", opJson);\n }).catch((error) => { console.log(`Error downloading ops: ${error}`); });\n });\n }\n\n public addVersions(versions: IVersion[]) {\n if (this.selector) {\n this.versions = versions;\n for (const version of versions) {\n const option = document.createElement(\"option\");\n if (version.date !== undefined) {\n option.text = `id = ${version.id}, time = ${version.date}`;\n } else {\n option.text = `id = ${version.id}`;\n }\n this.selector.add(option);\n }\n }\n }\n\n public updateVersion(index: number, version: IVersion, seqNumber: number) {\n if (this.selector) {\n const option = this.selector[index] as HTMLOptionElement;\n option.text = `${option.text}, seq = ${seqNumber}`;\n this.selector[index] = option;\n }\n }\n\n public versionSelected(seqNumber: number, version: IVersion | string) {\n let text: string;\n if (typeof version === \"string\") {\n text = `Playing ${version} file`;\n } else {\n text = `Playing from ${version.id}, seq# ${seqNumber}`;\n }\n\n this.wasVersionSelected = true;\n this.selector = undefined;\n\n const doc = this.debuggerWindow.document;\n doc.open();\n doc.write(debuggerWindowHtml2);\n doc.close();\n\n this.lastOpText = doc.getElementById(\"lastOp\") as HTMLDivElement;\n this.text1 = doc.getElementById(\"text1\") as HTMLDivElement;\n this.text2 = doc.getElementById(\"text2\") as HTMLDivElement;\n this.text3 = doc.getElementById(\"text3\") as HTMLDivElement;\n\n const steps = doc.getElementById(\"steps\") as HTMLInputElement;\n this.buttonOps = doc.getElementById(\"buttonOps\") as HTMLButtonElement;\n this.buttonOps.disabled = true;\n this.buttonOps.onclick = () => {\n this.controller.onOpButtonClick(Number(steps.value));\n };\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = text;\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n }\n\n public disableNextOpButton(disable: boolean) {\n assert(!!this.buttonOps, 0x088 /* \"Missing button ops button!\" */);\n this.buttonOps.disabled = disable;\n }\n\n public updateNextOpText(ops: ISequencedDocumentMessage[]) {\n if (ops.length === 0) {\n this.text1!.textContent = \"\";\n this.text2!.textContent = \"\";\n this.text3!.textContent = \"\";\n } else {\n const op = ops[0];\n const seq = op.sequenceNumber;\n const date = DebuggerUI.formatDate(op.timestamp);\n this.text1!.textContent = `Next op seq#: ${seq}`;\n this.text2!.textContent = `Type: ${op.type}`;\n this.text3!.textContent = `${date}`;\n }\n }\n\n public updateVersionText(versionCount: number) {\n if (!this.wasVersionSelected) {\n const text = versionCount === 0 ? \"\" : `Fetching information about ${versionCount} snapshots...`;\n this.versionText.textContent = text;\n }\n }\n\n public updateLastOpText(lastKnownOp: number, stillLoading: boolean) {\n let text: string;\n if (lastKnownOp < 0) {\n text = `FluidDebugger can't play ops in this mode`;\n }\n if (stillLoading) {\n text = `Last op (still loading): ${lastKnownOp}`;\n } else {\n text = `Document's last op seq#: ${lastKnownOp}`;\n }\n this.lastOpText!.textContent = text;\n }\n\n private download(filename: string, data: string): void {\n const element = document.createElement(\"a\");\n element.setAttribute(\"href\", `data:text/plain;charset=utf-8,${ encodeURIComponent(data) }`);\n element.setAttribute(\"download\", filename);\n\n element.style.display = \"none\";\n document.body.appendChild(element);\n\n element.click();\n\n document.body.removeChild(element);\n }\n}\n"]}
1
+ {"version":3,"file":"fluidDebuggerUi.js","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AA8FtD,MAAM,kBAAkB,GACpB;;;;;;;;;;;;;;;;QAgBI,CAAC;AAET,MAAM,mBAAmB,GACrB;;;;;;;;;;;;;;;QAeI,CAAC;AAET,MAAa,UAAU;IA4CnB,YAAuC,UAA+B,EAAmB,cAAsB;QAAxE,eAAU,GAAV,UAAU,CAAqB;QAAmB,mBAAc,GAAd,cAAc,CAAQ;QALrG,uBAAkB,GAAG,KAAK,CAAC;QAC3B,aAAQ,GAAe,EAAE,CAAC;QAE1B,mBAAc,GAAG,KAAK,CAAC;QAG7B,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC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WAAW,EAAE;YAC3C,CAAC,CAAC,4BAA4B,WAAW,EAAE,CAAC;QAChD,IAAI,CAAC,UAAW,CAAC,WAAW,GAAG,IAAI,CAAC;IACxC,CAAC;IAEO,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,iCAAkC,kBAAkB,CAAC,IAAI,CAAE,EAAE,CAAC,CAAC;QAC5F,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AAjMD,gCAiMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, IVersion } from \"@fluidframework/protocol-definitions\";\n\nexport interface IDebuggerUI {\n /**\n * Version information is provided.\n * Expect updates (information about seq#, timestamp) through updateVersion() calls\n */\n addVersions(version: IVersion[]): void;\n\n /**\n * Call when new version is downloaded from storage\n * Expect multiple callbacks.\n */\n updateVersion(index: number, version: IVersion, seqNumber: number): void;\n\n /**\n * Called in response to successful onVersionSelection() or onSnapshotFileSelection() call\n * and provides extra information about selection.\n * It expected that UI layer would change its mode as result of this call, i.e. switch to\n * displaying op playback controls (if this is supported)\n * Note: There maybe no call to versionSelected() in response to onSnapshotFileSelection() call\n * if file does not exist, has wrong name of wrong format.\n * @param version - version, file name, or undefined if playing ops.\n */\n versionSelected(seqNumber: number, version: IVersion | string): void;\n\n /**\n * Called by controller in response to new ops being downloaded\n * Called with disable = true if there are no (currently) ops to play\n */\n disableNextOpButton(disable: boolean): void;\n\n /**\n * Called by controller when new ops arrive (or we are done playing previous batch)\n * Indicates next batch of ops that would be played when UI calls controller's onOpButtonClick()\n * Called with ops=[] when there are no ops to play.\n */\n updateNextOpText(ops: ISequencedDocumentMessage[]): void;\n\n /**\n * Called periodically when new versions are downloaded from server\n */\n updateVersionText(versionsLeft: number): void;\n\n /**\n * Called periodically to notify about last known op\n * @param lastKnownOp - seq number of last known op. -1 if can't play ops in this mode (load from file)\n * @param stillLoading - true if we did not reach yet the end of the stream\n */\n updateLastOpText(lastKnownOp: number, stillLoading: boolean): void;\n}\n\nexport interface IDebuggerController {\n /**\n * Initialization. UI layers calls into controller to connect the two.\n * @param ui - UI layer\n */\n connectToUi(ui: IDebuggerUI);\n\n /**\n * Called by UI layer when debugger window is closed by user\n * If called before user makes selection of snapshot/file, original\n * document service is returned to loader (instead of debugger service) and normal document load continues.\n */\n onClose(): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - Snapshot version to start from.\n */\n onVersionSelection(version: IVersion): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - File to load snapshot from\n */\n onSnapshotFileSelection(file: File): void;\n\n /**\n * \"next op\" button is clicked in the UI\n * @param steps - number of ops to play.\n */\n onOpButtonClick(steps: number): void;\n\n /**\n * \"Download ops\" option is clicked in the UI. Returns JSON of the full opStream when available.\n * @param anonymize - anonymize the ops json using the sanitization tool\n */\n onDownloadOpsButtonClick(anonymize: boolean): Promise<string>;\n}\n\nconst debuggerWindowHtml =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\nPlease select snapshot or file to start with<br/>\nClose debugger window to proceed to live document<br/><br/>\n<select style='width:250px' id='selector'>\n</select>\n&nbsp; &nbsp; &nbsp;\n<button id='buttonVers' style='width:60px'>Go</button><br/>\n<input id='file' type='file' value='Load from file'/>\n<br/><br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n<br/><br/><div id='versionText'></div>\n</body>`;\n\nconst debuggerWindowHtml2 =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\n<div id='versionText'></div>\n<div id='lastOp'></div>\n<br/>\nStep to move: <input type='number' id='steps' value='1' min='1' style='width:50px'/>\n&nbsp; &nbsp; &nbsp;<button id='buttonOps' style='width:60px'>Go</button>\n<br/><br/>\n<div id='text1'></div><div id='text2'></div><div id='text3'></div>\n<br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n</body>`;\n\nexport class DebuggerUI {\n public static create(controller: IDebuggerController): DebuggerUI | null {\n if (\n typeof window !== \"object\" ||\n window === null ||\n typeof window.document !== \"object\" ||\n window.document == null) {\n console.log(\"Can't create debugger window - not running in browser!\");\n return null;\n }\n\n const debuggerWindow = window.open(\n \"\",\n \"\",\n \"width=400,height=400,resizable=yes,location=no,menubar=no,titlebar=no,status=no,toolbar=no\");\n if (!debuggerWindow) {\n console.error(\"Can't create debugger window - please enable pop-up windows in your browser!\");\n return null;\n }\n\n return new DebuggerUI(controller, debuggerWindow);\n }\n\n private static formatDate(date: number) {\n // Alternative - without timezone\n // new Date().toLocaleString('default', { timeZone: 'UTC'}));\n // new Date().toLocaleString('default', { year: 'numeric', month: 'short',\n // day: 'numeric', hour: '2-digit', minute: 'numeric', second: 'numeric' }));\n return new Date(date).toUTCString();\n }\n\n protected selector?: HTMLSelectElement;\n protected versionText: HTMLDivElement;\n\n protected buttonOps?: HTMLButtonElement;\n protected text1?: HTMLDivElement;\n protected text2?: HTMLDivElement;\n protected text3?: HTMLDivElement;\n protected lastOpText?: HTMLDivElement;\n protected wasVersionSelected = false;\n protected versions: IVersion[] = [];\n\n protected documentClosed = false;\n\n protected constructor(private readonly controller: IDebuggerController, private readonly debuggerWindow: Window) {\n const doc = this.debuggerWindow.document;\n doc.write(debuggerWindowHtml);\n\n window.addEventListener(\"beforeunload\", (e) => {\n this.documentClosed = true;\n this.debuggerWindow.close();\n }, false);\n\n this.debuggerWindow.addEventListener(\"beforeunload\", (e) => {\n if (!this.documentClosed) {\n this.controller.onClose();\n }\n }, false);\n\n this.selector = doc.getElementById(\"selector\") as HTMLSelectElement;\n\n const buttonVers = doc.getElementById(\"buttonVers\") as HTMLDivElement;\n buttonVers.onclick = () => {\n const index = this.selector!.selectedIndex;\n controller.onVersionSelection(this.versions[index]);\n };\n\n const fileSnapshot = doc.getElementById(\"file\") as HTMLInputElement;\n fileSnapshot.addEventListener(\"change\", () => {\n const files = fileSnapshot.files;\n if (files) {\n controller.onSnapshotFileSelection(files[0]);\n }\n }, false);\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = \"Fetching snapshots, please wait...\";\n\n controller.connectToUi(this);\n }\n\n private attachDownloadOpsListener(element: HTMLElement, anonymize: HTMLInputElement) {\n element.addEventListener(\"click\", () => {\n this.controller.onDownloadOpsButtonClick(anonymize.checked).then((opJson) => {\n this.download(\"opStream.json\", opJson);\n }).catch((error) => { console.log(`Error downloading ops: ${error}`); });\n });\n }\n\n public addVersions(versions: IVersion[]) {\n if (this.selector) {\n this.versions = versions;\n for (const version of versions) {\n const option = document.createElement(\"option\");\n option.text = version.date !== undefined\n ? `id = ${version.id}, time = ${version.date}`\n : `id = ${version.id}`;\n this.selector.add(option);\n }\n }\n }\n\n public updateVersion(index: number, version: IVersion, seqNumber: number) {\n if (this.selector) {\n const option = this.selector[index] as HTMLOptionElement;\n option.text = `${option.text}, seq = ${seqNumber}`;\n this.selector[index] = option;\n }\n }\n\n public versionSelected(seqNumber: number, version: IVersion | string) {\n const text = typeof version === \"string\"\n ? `Playing ${version} file`\n : `Playing from ${version.id}, seq# ${seqNumber}`;\n\n this.wasVersionSelected = true;\n this.selector = undefined;\n\n const doc = this.debuggerWindow.document;\n doc.open();\n doc.write(debuggerWindowHtml2);\n doc.close();\n\n this.lastOpText = doc.getElementById(\"lastOp\") as HTMLDivElement;\n this.text1 = doc.getElementById(\"text1\") as HTMLDivElement;\n this.text2 = doc.getElementById(\"text2\") as HTMLDivElement;\n this.text3 = doc.getElementById(\"text3\") as HTMLDivElement;\n\n const steps = doc.getElementById(\"steps\") as HTMLInputElement;\n this.buttonOps = doc.getElementById(\"buttonOps\") as HTMLButtonElement;\n this.buttonOps.disabled = true;\n this.buttonOps.onclick = () => {\n this.controller.onOpButtonClick(Number(steps.value));\n };\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = text;\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n }\n\n public disableNextOpButton(disable: boolean) {\n assert(!!this.buttonOps, 0x088 /* \"Missing button ops button!\" */);\n this.buttonOps.disabled = disable;\n }\n\n public updateNextOpText(ops: ISequencedDocumentMessage[]) {\n if (ops.length === 0) {\n this.text1!.textContent = \"\";\n this.text2!.textContent = \"\";\n this.text3!.textContent = \"\";\n } else {\n const op = ops[0];\n const seq = op.sequenceNumber;\n const date = DebuggerUI.formatDate(op.timestamp);\n this.text1!.textContent = `Next op seq#: ${seq}`;\n this.text2!.textContent = `Type: ${op.type}`;\n this.text3!.textContent = `${date}`;\n }\n }\n\n public updateVersionText(versionCount: number) {\n if (!this.wasVersionSelected) {\n const text = versionCount === 0 ? \"\" : `Fetching information about ${versionCount} snapshots...`;\n this.versionText.textContent = text;\n }\n }\n\n public updateLastOpText(lastKnownOp: number, stillLoading: boolean) {\n const text = stillLoading\n ? `Last op (still loading): ${lastKnownOp}`\n : `Document's last op seq#: ${lastKnownOp}`;\n this.lastOpText!.textContent = text;\n }\n\n private download(filename: string, data: string): void {\n const element = document.createElement(\"a\");\n element.setAttribute(\"href\", `data:text/plain;charset=utf-8,${ encodeURIComponent(data) }`);\n element.setAttribute(\"download\", filename);\n\n element.style.display = \"none\";\n document.body.appendChild(element);\n\n element.click();\n\n document.body.removeChild(element);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EACH,yBAAyB,EAC5B,MAAM,sCAAsC,CAAC;AAc9C,aAAK,QAAQ;IACT,OAAO,IAAA;IACP,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,WAAW,IAAA;IACX,MAAM,IAAA;CACT;AASD;;;;;GAKG;AACH,cAAM,kBAAkB;IAqBhB,QAAQ,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO;IArB3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAoB;IACpC;;;OAGG;IACH,OAAO,CAAC,qBAAqB,CAAoB;IACjD,OAAO,CAAC,WAAW,CAAS;IAC5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAAK;gBAGlB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO,EACvD,KAAK,EAAE,OAAO;IAG3B,QAAQ,CAAC,GAAG,EAAE,GAAG;IAMjB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAm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AW,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,QAA2B,GAAG,MAAM,GAAG,SAAS;IAmBlF,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE;IAejC;;;;;OAKG;IAEH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,YAAY,GAAE,GAAG,CAAC,MAAM,CAA4B,GAAG,MAAM,GAAG,IAAI;IAyBxG;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,GAAE,GAAG,CAAC,MAAM,CAA4B,GAAG,GAAG;IAoBjF,OAAO,CAAC,OAAO,EAAE,GAAG;IAsBpB,UAAU,CAAC,OAAO,EAAE,GAAG;IA2BvB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;IAoB/B;;;OAGG;IACH,iBAAiB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;IAcrC;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,GAAG;IAgBtB,UAAU,CAAC,OAAO,EAAE,GAAG;IAMvB;;;;;;OAMG;IACH,mBAAmB,CAAC,QAAQ,EAAE,GAAG;IAgEjC,KAAK,CAAC,OAAO,EAAE,GAAG;IA2DlB;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,GAAG;IAazB,QAAQ,IAAI,yBAAyB,EAAE;CAiD1C"}
package/dist/sanitizer.js CHANGED
@@ -265,13 +265,7 @@ class Sanitizer {
265
265
  if (this.replacementMap.has(input)) {
266
266
  return this.replacementMap.get(input);
267
267
  }
268
- let replacement;
269
- if (this.fullScrub) {
270
- replacement = this.getRandomText(input.length);
271
- }
272
- else {
273
- replacement = input;
274
- }
268
+ const replacement = this.fullScrub ? this.getRandomText(input.length) : input;
275
269
  this.replacementMap.set(input, replacement);
276
270
  return replacement;
277
271
  }
@@ -464,12 +458,9 @@ class Sanitizer {
464
458
  }
465
459
  }
466
460
  fixDeltaOp(deltaOp) {
467
- if (typeof deltaOp.seg === "string") {
468
- deltaOp.seg = this.replaceText(deltaOp.seg);
469
- }
470
- else {
471
- deltaOp.seg = this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
472
- }
461
+ deltaOp.seg = typeof deltaOp.seg === "string"
462
+ ? this.replaceText(deltaOp.seg)
463
+ : this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
473
464
  }
474
465
  /**
475
466
  * Fix the contents object for an op message. Does not do extra type handling. Does
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,sDAAwC;AACxC,+DAAsD;AAItD,mDAWyB;AAEzB,IAAK,QAMJ;AAND,WAAK,QAAQ;IACT,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,qDAAW,CAAA;IACX,2CAAM,CAAA;AACV,CAAC,EANI,QAAQ,KAAR,QAAQ,QAMZ;AAED,sEAAsE;AACtE,uBAAuB;AACvB,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,kBAAkB;IAoBpB,YACa,gBAAuD,EACvD,KAAc;QADd,qBAAgB,GAAhB,gBAAgB,CAAuC;QACvD,UAAK,GAAL,KAAK,CAAS;QArB3B;;;;WAIG;QACK,aAAQ,GAAG,IAAI,KAAK,EAAO,CAAC;QACpC;;;WAGG;QACK,0BAAqB,GAAG,IAAI,KAAK,EAAO,CAAC;QACzC,gBAAW,GAAG,KAAK,CAAC;QAC5B;;;;WAIG;QACK,uBAAkB,GAAG,CAAC,CAAC;IAK3B,CAAC;IAEL,QAAQ,CAAC,GAAQ;QACb,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,OAA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oBAClB,KAAK,MAAM,CAAC,CAAC;wBACT,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBACtB,MAAM;qBACT;oBACD,KAAK,SAAS,CAAC,CAAC;wBACZ,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBACzB,MAAM;qBACT;oBACD,KAAK,QAAQ,CAAC,CAAC;wBACX,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;wBACxB,MAAM;qBACT;oBACD,KAAK,IAAI,CAAC,CAAC;wBACP,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;wBACpB,MAAM;qBACT;oBACD,KAAK,WAAW,CAAC,CAAC;wBACd,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;wBAC3B,MAAM;qBACT;oBACD,KAAK,MAAM,CAAC;oBACZ,KAAK,OAAO,CAAC;oBACb,KAAK,UAAU,CAAC;oBAChB,KAAK,WAAW,CAAC;oBACjB,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM;oBACV;wBACI,IAAI,CAAC,QAAQ,CAAC,sBAAsB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;iBAC3D;YACL,CAAC,CAAC,CAAC;YAEH,8DAA8D;YAC9D,IAAA,qBAAM,EAAC,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAC7G;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAjfD,8BAifC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This tool cleans up a message.json file downloaded through fluid-fetch to remove\n * user content and user identifying information. Enough information can be retained\n * to allow loading through Fluid Preview, or everything can be scrubbed so that only\n * replay-tool can read the result. Anonymous identifying information such as client\n * IDs are always retained. Object keys are NOT scrubbed, including those that are\n * nested within values (only leaf values are scrubbed).\n *\n * Note: While user content/information is scrubbed, it should not be assumed to be\n * fully anonymized because certain meta-information (such as word lengths and\n * consistent replacement) are preserved.\n *\n * Messages must match known structures when scrubbing for Fluid Preview.\n */\n\nimport * as Validator from \"jsonschema\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n attachContentsSchema,\n chunkedOpContentsSchema,\n joinContentsSchema,\n joinDataSchema,\n opContentsMapSchema,\n opContentsSchema,\n opContentsMergeTreeDeltaOpSchema,\n opContentsMergeTreeGroupOpSchema,\n opContentsRegisterCollectionSchema,\n proposeContentsSchema,\n} from \"./messageSchema\";\n\nenum TextType {\n Generic,\n Email,\n Name,\n FluidObject,\n MapKey,\n}\n\n// Workaround to jsonschema package not supporting \"false\" as a schema\n// that matches nothing\nconst falseResult = {\n valid: false,\n toString: () => { return \"Unmatched format\"; },\n};\n\n/**\n * Class that takes chunkedOp messages and can provide their concatenated\n * contents along with re-write sanitized content in-place back into the\n * messages. Assumes sanitized messages are always less than or equal in\n * size to the original message.\n */\nclass ChunkedOpProcessor {\n /**\n * Message references so we can replace their contents in-place. These can\n * be top-level chunkedOp messages, or top-level op messages with a chunkedOp\n * within the contents\n */\n private messages = new Array<any>();\n /**\n * The messages' parsed contents for processing. Should parallel the\n * messages member\n */\n private parsedMessageContents = new Array<any>();\n private writtenBack = false;\n /**\n * keep track of the total starting length to make sure we don't somehow end\n * up with more content than we started with (meaning we may not be able to\n * write it back)\n */\n private concatenatedLength = 0;\n\n constructor(\n readonly validateSchemaFn: (object: any, schema: any) => boolean,\n readonly debug: boolean,\n ) { }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n addMessage(message: any): void {\n this.messages.push(message);\n\n let parsed;\n try {\n parsed = JSON.parse(message.contents);\n if (message.type === \"op\") {\n // nested within a regular op\n // need to go deeper to get the desired contents\n parsed = parsed.contents;\n }\n } catch (e) {\n this.debugMsg(e);\n this.debugMsg(message.contents);\n }\n this.validateSchemaFn(parsed, chunkedOpContentsSchema);\n this.parsedMessageContents.push(parsed);\n }\n\n hasAllMessages(): boolean {\n const lastMsgContents = this.parsedMessageContents[this.parsedMessageContents.length - 1];\n return lastMsgContents.chunkId !== undefined && lastMsgContents.chunkId === lastMsgContents.totalChunks;\n }\n\n /**\n * @returns The concatenated contents of all the messages parsed as json\n */\n getConcatenatedContents(): any {\n const contentsString = this.parsedMessageContents.reduce((previousValue: string, currentValue: any) => {\n return previousValue + (currentValue.contents as string);\n }, \"\");\n\n this.concatenatedLength = contentsString.length;\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(contentsString);\n } catch (e) {\n this.debugMsg(contentsString);\n this.debugMsg(e);\n return undefined;\n }\n }\n\n /**\n * Write back sanitized contents into the messages. The contents are\n * stringified, split up, and written in place to the messages that\n * were added earlier. The number of messages is preserved.\n * @param contents - Sanitized contents to write back\n */\n writeSanitizedContents(contents: any): void {\n // Write back a chunk size equal to the original\n const chunkSize = this.parsedMessageContents[0].contents.length;\n\n let stringified: string;\n try {\n stringified = JSON.stringify(contents);\n assert(stringified.length <= this.concatenatedLength,\n 0x089 /* \"Stringified length of chunk contents > total starting length\" */);\n } catch (e) {\n this.debugMsg(e);\n throw e;\n }\n\n for (let i = 0; i < this.messages.length; i++) {\n const substring = stringified.substring(i * chunkSize, (i + 1) * chunkSize);\n\n const parsedContents = this.parsedMessageContents[i];\n parsedContents.contents = substring;\n const message = this.messages[i];\n\n let stringifiedParsedContents;\n try {\n // for nested chunkedOps, we need to recreate the extra nesting layer\n // we removed earlier when adding the message\n if (message.type === \"op\") {\n const nestingLayer = {\n type: \"chunkedOp\",\n contents: parsedContents,\n };\n stringifiedParsedContents = JSON.stringify(nestingLayer);\n } else {\n stringifiedParsedContents = JSON.stringify(parsedContents);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n\n message.contents = stringifiedParsedContents;\n }\n\n this.writtenBack = true;\n }\n\n reset(): void {\n assert(this.writtenBack, 0x08a /* \"resetting ChunkedOpProcessor that never wrote back its contents\" */);\n this.messages = new Array<any>();\n this.parsedMessageContents = new Array<any>();\n this.writtenBack = false;\n this.concatenatedLength = 0;\n }\n\n isPendingProcessing(): boolean {\n return this.messages.length !== 0;\n }\n}\n\nexport class Sanitizer {\n readonly validator = new Validator.Validator();\n // Represents the keys used to store Fluid object identifiers, snapshot info,\n // and other string fields that should not be replaced in contents blobs to\n // ensure the messages are still usable\n readonly defaultExcludedKeys = new Set<string>();\n // Represents the keys used by merge-tree ops their \"seg\" property, where other\n // keys represent user information\n readonly mergeTreeExcludedKeys = new Set<string>();\n // Map of user information to what it was replaced with. Used to ensure the same\n // data have the same replacements\n readonly replacementMap = new Map<string, string>();\n\n /**\n * Validate that the provided message matches the provided schema.\n * For a full scrub, warn and continue (scrubber should fully sanitize unexpected\n * fields for ops), otherwise throw an error because we cannot be sure user\n * information is being sufficiently sanitized.\n */\n objectMatchesSchema = (object: any, schema: any): boolean => {\n const result = schema === false ? falseResult : this.validator.validate(object, schema);\n if (!result.valid) {\n const errorMsg = `Bad msg fmt:\\n${result.toString()}\\n${JSON.stringify(object, undefined, 2)}`;\n\n if (this.fullScrub || this.noBail) {\n this.debugMsg(errorMsg);\n } else {\n throw new Error(errorMsg);\n }\n }\n return result.valid;\n };\n\n readonly chunkProcessor = new ChunkedOpProcessor(this.objectMatchesSchema, this.debug);\n\n constructor(\n readonly messages: ISequencedDocumentMessage[],\n readonly fullScrub: boolean,\n readonly noBail: boolean,\n readonly debug: boolean = false,\n ) {\n this.defaultExcludedKeys.add(\"type\");\n this.defaultExcludedKeys.add(\"id\");\n this.defaultExcludedKeys.add(\"pkg\");\n this.defaultExcludedKeys.add(\"snapshotFormatVersion\");\n this.defaultExcludedKeys.add(\"packageVersion\");\n this.mergeTreeExcludedKeys.add(\"nodeType\");\n }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n isFluidObjectKey(key: string): boolean {\n return key === \"type\" || key === \"id\";\n }\n\n getRandomText(len: number): string {\n let str = \"\";\n while (str.length < len) {\n str = str + Math.random().toString(36).substring(2);\n }\n return str.substr(0, len);\n }\n\n readonly wordTokenRegex = /\\S+/g;\n\n readonly replaceRandomTextFn = (match: string): string => {\n if (this.replacementMap.has(match)) {\n return this.replacementMap.get(match)!;\n }\n\n const replacement = this.getRandomText(match.length);\n this.replacementMap.set(match, replacement);\n return replacement;\n };\n\n /**\n * Replace text with garbage. FluidObject types are not replaced when not under\n * full scrub mode. All other text is replaced consistently.\n */\n replaceText(input?: string, type: TextType = TextType.Generic): string | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (type === TextType.FluidObject) {\n if (this.replacementMap.has(input)) {\n return this.replacementMap.get(input)!;\n }\n\n let replacement: string;\n if (this.fullScrub) {\n replacement = this.getRandomText(input.length);\n } else {\n replacement = input;\n }\n\n this.replacementMap.set(input, replacement);\n return replacement;\n }\n\n return input.replace(this.wordTokenRegex, this.replaceRandomTextFn);\n }\n\n replaceArray(input: any[]): any[] {\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n if (typeof value === \"string\") {\n input[i] = this.replaceText(value);\n } else if (Array.isArray(value)) {\n input[i] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[i] = this.replaceObject(value);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n /**\n * (sort of) recurses down the values of a JSON object to sanitize all its strings\n * (only checks strings, arrays, and objects)\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n replaceObject(input: object | null, excludedKeys: Set<string> = this.defaultExcludedKeys): object | null {\n // File might contain actual nulls\n if (input === null || input === undefined) {\n return input;\n }\n\n const keys = Object.keys(input);\n keys.forEach((key) => {\n if (this.fullScrub || !excludedKeys.has(key)) {\n const value = input[key];\n if (typeof value === \"string\") {\n input[key] = this.replaceText(\n value,\n this.isFluidObjectKey(key) ? TextType.FluidObject : TextType.Generic,\n );\n } else if (Array.isArray(value)) {\n input[key] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[key] = this.replaceObject(value, excludedKeys);\n }\n }\n });\n return input;\n }\n\n /**\n * Replacement on an unknown type or a parsed root level object\n * without a key\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n replaceAny(input: any, excludedKeys: Set<string> = this.defaultExcludedKeys): any {\n if (input === null || input === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n if (typeof input === \"string\") {\n return this.replaceText(input);\n } else if (Array.isArray(input)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.replaceArray(input);\n } else if (typeof input === \"object\") {\n return this.replaceObject(input, excludedKeys);\n }\n\n // Don't run replacement on any other types\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n fixJoin(message: any) {\n if (!this.objectMatchesSchema(message.contents, joinContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n }\n\n try {\n let data = JSON.parse(message.data);\n if (!this.objectMatchesSchema(data, joinDataSchema)) {\n data = this.replaceAny(data);\n } else {\n const user = data.detail.user;\n user.id = this.replaceText(user.id, TextType.Email);\n user.email = this.replaceText(user.email, TextType.Email);\n user.name = this.replaceText(user.name, TextType.Name);\n }\n\n message.data = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n }\n\n fixPropose(message: any) {\n if (!this.objectMatchesSchema(message.contents, proposeContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n } else {\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n if (this.fullScrub) {\n const pkg = data.value?.package;\n if (pkg?.name) {\n pkg.name = this.replaceText(pkg.name, TextType.FluidObject);\n }\n if (Array.isArray(pkg?.fluid?.browser?.umd?.files)) {\n pkg.fluid.browser.umd.files = this.replaceArray(pkg.fluid.browser.umd.files);\n }\n }\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n if (this.fullScrub) {\n message.contents.value = this.replaceText(message.contents.value, TextType.FluidObject);\n }\n }\n }\n }\n\n fixAttachEntries(entries: any[]) {\n entries.forEach((element) => {\n // Tree type\n if (element.value.entries) {\n this.fixAttachEntries(element.value.entries);\n } else {\n // Blob (leaf) type\n try {\n if (typeof element.value.contents === \"string\") {\n let data = JSON.parse(element.value.contents);\n data = this.replaceObject(data);\n element.value.contents = JSON.stringify(data);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n }\n });\n }\n\n /**\n * Fix the content of an attach in place\n * @param contents - contents object to fix\n */\n fixAttachContents(contents: any): any {\n assert(typeof contents === \"object\", 0x08b /* \"Unexpected type on contents for fix of an attach!\" */);\n if (!this.objectMatchesSchema(contents, attachContentsSchema)) {\n this.replaceObject(contents);\n } else {\n if (this.fullScrub) {\n contents.id = this.replaceText(contents.id, TextType.FluidObject);\n contents.type = this.replaceText(contents.type, TextType.FluidObject);\n }\n\n this.fixAttachEntries(contents.snapshot.entries);\n }\n }\n\n /**\n * Fix an attach message at the root level or a ContainerMessageType attach. Attach\n * messages found within an op message should instead have their contents parsed out\n * and sent to fixAttachContents.\n * @param message - The attach message to fix\n * @param withinOp - If the message is from within an op message (as opposed to being\n * an attach message at the root level). Root level attach messages have \"snapshot\"\n * under a \"contents\" key, whereas attach messages from within an op message have it\n * under a \"content\" key\n */\n fixAttach(message: any) {\n // Handle case where contents is stringified json\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n this.fixAttachContents(data);\n message.contents = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n this.fixAttachContents(message.contents);\n }\n }\n\n fixDeltaOp(deltaOp: any) {\n if (typeof deltaOp.seg === \"string\") {\n deltaOp.seg = this.replaceText(deltaOp.seg);\n } else {\n deltaOp.seg = this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);\n }\n }\n\n /**\n * Fix the contents object for an op message. Does not do extra type handling. Does\n * not handle special container message types like \"attach\", \"component\", and\n * \"chunkedOp\" (these should be handled by the caller)\n * @param contents - The contents object for an op message. If it was a string in the\n * message, it must have been converted to an object first\n */\n fixOpContentsObject(contents: any) {\n // do replacement\n if (!this.objectMatchesSchema(contents, opContentsSchema)) {\n this.replaceAny(contents);\n } else {\n if (this.fullScrub) {\n contents.address = this.replaceText(contents.address, TextType.FluidObject);\n }\n\n const innerContent = contents.contents.content;\n assert(innerContent !== undefined, 0x08c /* \"innerContent for fixing op contents is undefined!\" */);\n if (contents.contents.type === \"attach\") {\n // attach op\n // handle case where inner content is stringified json\n if (typeof contents.contents.content === \"string\") {\n try {\n const data = JSON.parse(contents.contents.content);\n this.fixAttachContents(data);\n contents.contents.content = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n this.fixAttachContents(contents.contents.content);\n }\n } else if (this.validator.validate(innerContent, opContentsMapSchema).valid) {\n // map op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else if (this.validator.validate(innerContent, opContentsMergeTreeGroupOpSchema).valid) {\n // merge tree group op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n innerContent.contents.ops.forEach((deltaOp) => {\n this.fixDeltaOp(deltaOp);\n });\n } else if (this.validator.validate(innerContent, opContentsMergeTreeDeltaOpSchema).valid) {\n // merge tree delta op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n this.fixDeltaOp(innerContent.contents);\n } else if (this.validator.validate(innerContent, opContentsRegisterCollectionSchema).valid) {\n // register collection op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else {\n // message contents don't match any known op format\n this.objectMatchesSchema(contents, false);\n }\n }\n }\n\n fixOp(message: any) {\n // handle case where contents is stringified json\n let msgContents;\n if (typeof message.contents === \"string\") {\n try {\n msgContents = JSON.parse(message.contents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n msgContents = message.contents;\n }\n\n // handle container message types\n switch (msgContents.type) {\n case \"attach\": {\n // this one is like a regular attach op, except its contents aren't nested as deep\n // run fixAttach directly and return\n this.fixAttach(msgContents);\n break;\n }\n case \"component\": {\n // this one functionally nests its contents one layer deeper\n // bring up the contents object and continue as usual\n this.fixOpContentsObject(msgContents.contents);\n break;\n }\n case \"chunkedOp\": {\n // this is a (regular?) op split into multiple parts due to size, e.g. because it\n // has an attached image, and where the chunkedOp is within the top-level op's contents\n // (as opposed to being at the top-level). The contents of the chunks need to be\n // concatenated to form the complete stringified json object\n // Early return here to skip re-stringify because no changes are made until the last\n // chunk, and the ChunkedOpProcessor will handle everything at that point\n return this.fixChunkedOp(message);\n }\n case \"blobAttach\": {\n // TODO: handle this properly once blob api is used\n this.debugMsg(\"TODO: blobAttach ops are skipped/unhandled\");\n return;\n }\n default: {\n // A regular op\n this.fixOpContentsObject(msgContents);\n }\n }\n\n // re-stringify the json if needed\n if (typeof message.contents === \"string\") {\n try {\n message.contents = JSON.stringify(msgContents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n }\n }\n\n /**\n * @param message - The top-level chunkedOp message or a top-level op message\n * with a chunkedOp inside its contents\n */\n fixChunkedOp(message: any) {\n this.chunkProcessor.addMessage(message);\n if (!this.chunkProcessor.hasAllMessages()) {\n return;\n }\n\n const contents = this.chunkProcessor.getConcatenatedContents();\n this.fixOpContentsObject(contents);\n\n this.chunkProcessor.writeSanitizedContents(contents);\n this.chunkProcessor.reset();\n }\n\n sanitize(): ISequencedDocumentMessage[] {\n let seq = 0;\n\n try {\n this.messages.map((message) => {\n seq = message.sequenceNumber;\n // message types from protocol-definitions' protocol.ts\n switch (message.type) {\n case \"join\": {\n this.fixJoin(message);\n break;\n }\n case \"propose\": {\n this.fixPropose(message);\n break;\n }\n case \"attach\": {\n this.fixAttach(message);\n break;\n }\n case \"op\": {\n this.fixOp(message);\n break;\n }\n case \"chunkedOp\": {\n this.fixChunkedOp(message);\n break;\n }\n case \"noop\":\n case \"leave\":\n case \"noClient\":\n case \"summarize\":\n case \"summaryAck\":\n case \"summaryNack\":\n break;\n default:\n this.debugMsg(`Unexpected op type ${message.type}`);\n }\n });\n\n // make sure we don't miss an incomplete chunked op at the end\n assert(!this.chunkProcessor.isPendingProcessing(), 0x08d /* \"After sanitize, pending incomplete ops!\" */);\n } catch (error) {\n this.debugMsg(`Error while processing sequenceNumber ${seq}`);\n throw error;\n }\n\n return this.messages;\n }\n}\n"]}
1
+ {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,sDAAwC;AACxC,+DAAsD;AAItD,mDAWyB;AAEzB,IAAK,QAMJ;AAND,WAAK,QAAQ;IACT,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,qDAAW,CAAA;IACX,2CAAM,CAAA;AACV,CAAC,EANI,QAAQ,KAAR,QAAQ,QAMZ;AAED,sEAAsE;AACtE,uBAAuB;AACvB,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,kBAAkB;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AC,QAAQ,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AA1eD,8BA0eC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This tool cleans up a message.json file downloaded through fluid-fetch to remove\n * user content and user identifying information. Enough information can be retained\n * to allow loading through Fluid Preview, or everything can be scrubbed so that only\n * replay-tool can read the result. Anonymous identifying information such as client\n * IDs are always retained. Object keys are NOT scrubbed, including those that are\n * nested within values (only leaf values are scrubbed).\n *\n * Note: While user content/information is scrubbed, it should not be assumed to be\n * fully anonymized because certain meta-information (such as word lengths and\n * consistent replacement) are preserved.\n *\n * Messages must match known structures when scrubbing for Fluid Preview.\n */\n\nimport * as Validator from \"jsonschema\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n attachContentsSchema,\n chunkedOpContentsSchema,\n joinContentsSchema,\n joinDataSchema,\n opContentsMapSchema,\n opContentsSchema,\n opContentsMergeTreeDeltaOpSchema,\n opContentsMergeTreeGroupOpSchema,\n opContentsRegisterCollectionSchema,\n proposeContentsSchema,\n} from \"./messageSchema\";\n\nenum TextType {\n Generic,\n Email,\n Name,\n FluidObject,\n MapKey,\n}\n\n// Workaround to jsonschema package not supporting \"false\" as a schema\n// that matches nothing\nconst falseResult = {\n valid: false,\n toString: () => { return \"Unmatched format\"; },\n};\n\n/**\n * Class that takes chunkedOp messages and can provide their concatenated\n * contents along with re-write sanitized content in-place back into the\n * messages. Assumes sanitized messages are always less than or equal in\n * size to the original message.\n */\nclass ChunkedOpProcessor {\n /**\n * Message references so we can replace their contents in-place. These can\n * be top-level chunkedOp messages, or top-level op messages with a chunkedOp\n * within the contents\n */\n private messages = new Array<any>();\n /**\n * The messages' parsed contents for processing. Should parallel the\n * messages member\n */\n private parsedMessageContents = new Array<any>();\n private writtenBack = false;\n /**\n * keep track of the total starting length to make sure we don't somehow end\n * up with more content than we started with (meaning we may not be able to\n * write it back)\n */\n private concatenatedLength = 0;\n\n constructor(\n readonly validateSchemaFn: (object: any, schema: any) => boolean,\n readonly debug: boolean,\n ) { }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n addMessage(message: any): void {\n this.messages.push(message);\n\n let parsed;\n try {\n parsed = JSON.parse(message.contents);\n if (message.type === \"op\") {\n // nested within a regular op\n // need to go deeper to get the desired contents\n parsed = parsed.contents;\n }\n } catch (e) {\n this.debugMsg(e);\n this.debugMsg(message.contents);\n }\n this.validateSchemaFn(parsed, chunkedOpContentsSchema);\n this.parsedMessageContents.push(parsed);\n }\n\n hasAllMessages(): boolean {\n const lastMsgContents = this.parsedMessageContents[this.parsedMessageContents.length - 1];\n return lastMsgContents.chunkId !== undefined && lastMsgContents.chunkId === lastMsgContents.totalChunks;\n }\n\n /**\n * @returns The concatenated contents of all the messages parsed as json\n */\n getConcatenatedContents(): any {\n const contentsString = this.parsedMessageContents.reduce((previousValue: string, currentValue: any) => {\n return previousValue + (currentValue.contents as string);\n }, \"\");\n\n this.concatenatedLength = contentsString.length;\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(contentsString);\n } catch (e) {\n this.debugMsg(contentsString);\n this.debugMsg(e);\n return undefined;\n }\n }\n\n /**\n * Write back sanitized contents into the messages. The contents are\n * stringified, split up, and written in place to the messages that\n * were added earlier. The number of messages is preserved.\n * @param contents - Sanitized contents to write back\n */\n writeSanitizedContents(contents: any): void {\n // Write back a chunk size equal to the original\n const chunkSize = this.parsedMessageContents[0].contents.length;\n\n let stringified: string;\n try {\n stringified = JSON.stringify(contents);\n assert(stringified.length <= this.concatenatedLength,\n 0x089 /* \"Stringified length of chunk contents > total starting length\" */);\n } catch (e) {\n this.debugMsg(e);\n throw e;\n }\n\n for (let i = 0; i < this.messages.length; i++) {\n const substring = stringified.substring(i * chunkSize, (i + 1) * chunkSize);\n\n const parsedContents = this.parsedMessageContents[i];\n parsedContents.contents = substring;\n const message = this.messages[i];\n\n let stringifiedParsedContents;\n try {\n // for nested chunkedOps, we need to recreate the extra nesting layer\n // we removed earlier when adding the message\n if (message.type === \"op\") {\n const nestingLayer = {\n type: \"chunkedOp\",\n contents: parsedContents,\n };\n stringifiedParsedContents = JSON.stringify(nestingLayer);\n } else {\n stringifiedParsedContents = JSON.stringify(parsedContents);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n\n message.contents = stringifiedParsedContents;\n }\n\n this.writtenBack = true;\n }\n\n reset(): void {\n assert(this.writtenBack, 0x08a /* \"resetting ChunkedOpProcessor that never wrote back its contents\" */);\n this.messages = new Array<any>();\n this.parsedMessageContents = new Array<any>();\n this.writtenBack = false;\n this.concatenatedLength = 0;\n }\n\n isPendingProcessing(): boolean {\n return this.messages.length !== 0;\n }\n}\n\nexport class Sanitizer {\n readonly validator = new Validator.Validator();\n // Represents the keys used to store Fluid object identifiers, snapshot info,\n // and other string fields that should not be replaced in contents blobs to\n // ensure the messages are still usable\n readonly defaultExcludedKeys = new Set<string>();\n // Represents the keys used by merge-tree ops their \"seg\" property, where other\n // keys represent user information\n readonly mergeTreeExcludedKeys = new Set<string>();\n // Map of user information to what it was replaced with. Used to ensure the same\n // data have the same replacements\n readonly replacementMap = new Map<string, string>();\n\n /**\n * Validate that the provided message matches the provided schema.\n * For a full scrub, warn and continue (scrubber should fully sanitize unexpected\n * fields for ops), otherwise throw an error because we cannot be sure user\n * information is being sufficiently sanitized.\n */\n objectMatchesSchema = (object: any, schema: any): boolean => {\n const result = schema === false ? falseResult : this.validator.validate(object, schema);\n if (!result.valid) {\n const errorMsg = `Bad msg fmt:\\n${result.toString()}\\n${JSON.stringify(object, undefined, 2)}`;\n\n if (this.fullScrub || this.noBail) {\n this.debugMsg(errorMsg);\n } else {\n throw new Error(errorMsg);\n }\n }\n return result.valid;\n };\n\n readonly chunkProcessor = new ChunkedOpProcessor(this.objectMatchesSchema, this.debug);\n\n constructor(\n readonly messages: ISequencedDocumentMessage[],\n readonly fullScrub: boolean,\n readonly noBail: boolean,\n readonly debug: boolean = false,\n ) {\n this.defaultExcludedKeys.add(\"type\");\n this.defaultExcludedKeys.add(\"id\");\n this.defaultExcludedKeys.add(\"pkg\");\n this.defaultExcludedKeys.add(\"snapshotFormatVersion\");\n this.defaultExcludedKeys.add(\"packageVersion\");\n this.mergeTreeExcludedKeys.add(\"nodeType\");\n }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n isFluidObjectKey(key: string): boolean {\n return key === \"type\" || key === \"id\";\n }\n\n getRandomText(len: number): string {\n let str = \"\";\n while (str.length < len) {\n str = str + Math.random().toString(36).substring(2);\n }\n return str.substr(0, len);\n }\n\n readonly wordTokenRegex = /\\S+/g;\n\n readonly replaceRandomTextFn = (match: string): string => {\n if (this.replacementMap.has(match)) {\n return this.replacementMap.get(match)!;\n }\n\n const replacement = this.getRandomText(match.length);\n this.replacementMap.set(match, replacement);\n return replacement;\n };\n\n /**\n * Replace text with garbage. FluidObject types are not replaced when not under\n * full scrub mode. All other text is replaced consistently.\n */\n replaceText(input?: string, type: TextType = TextType.Generic): string | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (type === TextType.FluidObject) {\n if (this.replacementMap.has(input)) {\n return this.replacementMap.get(input)!;\n }\n\n const replacement = this.fullScrub ? this.getRandomText(input.length) : input;\n\n this.replacementMap.set(input, replacement);\n return replacement;\n }\n\n return input.replace(this.wordTokenRegex, this.replaceRandomTextFn);\n }\n\n replaceArray(input: any[]): any[] {\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n if (typeof value === \"string\") {\n input[i] = this.replaceText(value);\n } else if (Array.isArray(value)) {\n input[i] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[i] = this.replaceObject(value);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n /**\n * (sort of) recurses down the values of a JSON object to sanitize all its strings\n * (only checks strings, arrays, and objects)\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n replaceObject(input: object | null, excludedKeys: Set<string> = this.defaultExcludedKeys): object | null {\n // File might contain actual nulls\n if (input === null || input === undefined) {\n return input;\n }\n\n const keys = Object.keys(input);\n keys.forEach((key) => {\n if (this.fullScrub || !excludedKeys.has(key)) {\n const value = input[key];\n if (typeof value === \"string\") {\n input[key] = this.replaceText(\n value,\n this.isFluidObjectKey(key) ? TextType.FluidObject : TextType.Generic,\n );\n } else if (Array.isArray(value)) {\n input[key] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[key] = this.replaceObject(value, excludedKeys);\n }\n }\n });\n return input;\n }\n\n /**\n * Replacement on an unknown type or a parsed root level object\n * without a key\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n replaceAny(input: any, excludedKeys: Set<string> = this.defaultExcludedKeys): any {\n if (input === null || input === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n if (typeof input === \"string\") {\n return this.replaceText(input);\n } else if (Array.isArray(input)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.replaceArray(input);\n } else if (typeof input === \"object\") {\n return this.replaceObject(input, excludedKeys);\n }\n\n // Don't run replacement on any other types\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n fixJoin(message: any) {\n if (!this.objectMatchesSchema(message.contents, joinContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n }\n\n try {\n let data = JSON.parse(message.data);\n if (!this.objectMatchesSchema(data, joinDataSchema)) {\n data = this.replaceAny(data);\n } else {\n const user = data.detail.user;\n user.id = this.replaceText(user.id, TextType.Email);\n user.email = this.replaceText(user.email, TextType.Email);\n user.name = this.replaceText(user.name, TextType.Name);\n }\n\n message.data = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n }\n\n fixPropose(message: any) {\n if (!this.objectMatchesSchema(message.contents, proposeContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n } else {\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n if (this.fullScrub) {\n const pkg = data.value?.package;\n if (pkg?.name) {\n pkg.name = this.replaceText(pkg.name, TextType.FluidObject);\n }\n if (Array.isArray(pkg?.fluid?.browser?.umd?.files)) {\n pkg.fluid.browser.umd.files = this.replaceArray(pkg.fluid.browser.umd.files);\n }\n }\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n if (this.fullScrub) {\n message.contents.value = this.replaceText(message.contents.value, TextType.FluidObject);\n }\n }\n }\n }\n\n fixAttachEntries(entries: any[]) {\n entries.forEach((element) => {\n // Tree type\n if (element.value.entries) {\n this.fixAttachEntries(element.value.entries);\n } else {\n // Blob (leaf) type\n try {\n if (typeof element.value.contents === \"string\") {\n let data = JSON.parse(element.value.contents);\n data = this.replaceObject(data);\n element.value.contents = JSON.stringify(data);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n }\n });\n }\n\n /**\n * Fix the content of an attach in place\n * @param contents - contents object to fix\n */\n fixAttachContents(contents: any): any {\n assert(typeof contents === \"object\", 0x08b /* \"Unexpected type on contents for fix of an attach!\" */);\n if (!this.objectMatchesSchema(contents, attachContentsSchema)) {\n this.replaceObject(contents);\n } else {\n if (this.fullScrub) {\n contents.id = this.replaceText(contents.id, TextType.FluidObject);\n contents.type = this.replaceText(contents.type, TextType.FluidObject);\n }\n\n this.fixAttachEntries(contents.snapshot.entries);\n }\n }\n\n /**\n * Fix an attach message at the root level or a ContainerMessageType attach. Attach\n * messages found within an op message should instead have their contents parsed out\n * and sent to fixAttachContents.\n * @param message - The attach message to fix\n * @param withinOp - If the message is from within an op message (as opposed to being\n * an attach message at the root level). Root level attach messages have \"snapshot\"\n * under a \"contents\" key, whereas attach messages from within an op message have it\n * under a \"content\" key\n */\n fixAttach(message: any) {\n // Handle case where contents is stringified json\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n this.fixAttachContents(data);\n message.contents = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n this.fixAttachContents(message.contents);\n }\n }\n\n fixDeltaOp(deltaOp: any) {\n deltaOp.seg = typeof deltaOp.seg === \"string\"\n ? this.replaceText(deltaOp.seg)\n : this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);\n }\n\n /**\n * Fix the contents object for an op message. Does not do extra type handling. Does\n * not handle special container message types like \"attach\", \"component\", and\n * \"chunkedOp\" (these should be handled by the caller)\n * @param contents - The contents object for an op message. If it was a string in the\n * message, it must have been converted to an object first\n */\n fixOpContentsObject(contents: any) {\n // do replacement\n if (!this.objectMatchesSchema(contents, opContentsSchema)) {\n this.replaceAny(contents);\n } else {\n if (this.fullScrub) {\n contents.address = this.replaceText(contents.address, TextType.FluidObject);\n }\n\n const innerContent = contents.contents.content;\n assert(innerContent !== undefined, 0x08c /* \"innerContent for fixing op contents is undefined!\" */);\n if (contents.contents.type === \"attach\") {\n // attach op\n // handle case where inner content is stringified json\n if (typeof contents.contents.content === \"string\") {\n try {\n const data = JSON.parse(contents.contents.content);\n this.fixAttachContents(data);\n contents.contents.content = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n this.fixAttachContents(contents.contents.content);\n }\n } else if (this.validator.validate(innerContent, opContentsMapSchema).valid) {\n // map op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else if (this.validator.validate(innerContent, opContentsMergeTreeGroupOpSchema).valid) {\n // merge tree group op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n innerContent.contents.ops.forEach((deltaOp) => {\n this.fixDeltaOp(deltaOp);\n });\n } else if (this.validator.validate(innerContent, opContentsMergeTreeDeltaOpSchema).valid) {\n // merge tree delta op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n this.fixDeltaOp(innerContent.contents);\n } else if (this.validator.validate(innerContent, opContentsRegisterCollectionSchema).valid) {\n // register collection op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else {\n // message contents don't match any known op format\n this.objectMatchesSchema(contents, false);\n }\n }\n }\n\n fixOp(message: any) {\n // handle case where contents is stringified json\n let msgContents;\n if (typeof message.contents === \"string\") {\n try {\n msgContents = JSON.parse(message.contents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n msgContents = message.contents;\n }\n\n // handle container message types\n switch (msgContents.type) {\n case \"attach\": {\n // this one is like a regular attach op, except its contents aren't nested as deep\n // run fixAttach directly and return\n this.fixAttach(msgContents);\n break;\n }\n case \"component\": {\n // this one functionally nests its contents one layer deeper\n // bring up the contents object and continue as usual\n this.fixOpContentsObject(msgContents.contents);\n break;\n }\n case \"chunkedOp\": {\n // this is a (regular?) op split into multiple parts due to size, e.g. because it\n // has an attached image, and where the chunkedOp is within the top-level op's contents\n // (as opposed to being at the top-level). The contents of the chunks need to be\n // concatenated to form the complete stringified json object\n // Early return here to skip re-stringify because no changes are made until the last\n // chunk, and the ChunkedOpProcessor will handle everything at that point\n return this.fixChunkedOp(message);\n }\n case \"blobAttach\": {\n // TODO: handle this properly once blob api is used\n this.debugMsg(\"TODO: blobAttach ops are skipped/unhandled\");\n return;\n }\n default: {\n // A regular op\n this.fixOpContentsObject(msgContents);\n }\n }\n\n // re-stringify the json if needed\n if (typeof message.contents === \"string\") {\n try {\n message.contents = JSON.stringify(msgContents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n }\n }\n\n /**\n * @param message - The top-level chunkedOp message or a top-level op message\n * with a chunkedOp inside its contents\n */\n fixChunkedOp(message: any) {\n this.chunkProcessor.addMessage(message);\n if (!this.chunkProcessor.hasAllMessages()) {\n return;\n }\n\n const contents = this.chunkProcessor.getConcatenatedContents();\n this.fixOpContentsObject(contents);\n\n this.chunkProcessor.writeSanitizedContents(contents);\n this.chunkProcessor.reset();\n }\n\n sanitize(): ISequencedDocumentMessage[] {\n let seq = 0;\n\n try {\n this.messages.map((message) => {\n seq = message.sequenceNumber;\n // message types from protocol-definitions' protocol.ts\n switch (message.type) {\n case \"join\": {\n this.fixJoin(message);\n break;\n }\n case \"propose\": {\n this.fixPropose(message);\n break;\n }\n case \"attach\": {\n this.fixAttach(message);\n break;\n }\n case \"op\": {\n this.fixOp(message);\n break;\n }\n case \"chunkedOp\": {\n this.fixChunkedOp(message);\n break;\n }\n case \"noop\":\n case \"leave\":\n case \"noClient\":\n case \"summarize\":\n case \"summaryAck\":\n case \"summaryNack\":\n break;\n default:\n this.debugMsg(`Unexpected op type ${message.type}`);\n }\n });\n\n // make sure we don't miss an incomplete chunked op at the end\n assert(!this.chunkProcessor.isPendingProcessing(), 0x08d /* \"After sanitize, pending incomplete ops!\" */);\n } catch (error) {\n this.debugMsg(`Error while processing sequenceNumber ${seq}`);\n throw error;\n }\n\n return this.messages;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebugger.d.ts","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAyB,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAIpG,yBAAiB,aAAa,CAAC;IAC3B;;;;;OAKG;IACH,SAAsB,iBAAiB,CACnC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMhE;IAED,SAAsB,wBAAwB,CAC1C,sBAAsB,EAAE,uBAAuB,mEASlD;CAOJ"}
1
+ {"version":3,"file":"fluidDebugger.d.ts","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAyB,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAKpG,yBAAiB,aAAa,CAAC;IAC3B;;;;;OAKG;IACH,SAAsB,iBAAiB,CACnC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMhE;IAED,SAAsB,wBAAwB,CAC1C,sBAAsB,EAAE,uBAAuB,mEASlD;CAOJ"}
@@ -5,6 +5,7 @@
5
5
  import { ReplayDocumentService, ReplayDocumentServiceFactory } from "@fluidframework/replay-driver";
6
6
  import { DebugReplayController } from "./fluidDebuggerController";
7
7
  import { DebuggerUI } from "./fluidDebuggerUi";
8
+ // eslint-disable-next-line @typescript-eslint/no-namespace
8
9
  export var FluidDebugger;
9
10
  (function (FluidDebugger) {
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebugger.js","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,KAAW,aAAa,CAiC7B;AAjCD,WAAiB,aAAa;IAC1B;;;;;OAKG;IACI,KAAK,UAAU,iBAAiB,CACnC,eAAiC;QACjC,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,eAAe,CAAC;SAC1B;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAPqB,+BAAiB,oBAOtC,CAAA;IAEM,KAAK,UAAU,wBAAwB,CAC1C,sBAA+C;QAC/C,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,sBAAsB,CAAC;SACjC;QACD,OAAO,IAAI,4BAA4B,CACnC,sBAAsB,EACtB,UAAU,CACb,CAAC;IACN,CAAC;IAVqB,sCAAwB,2BAU7C,CAAA;IAED;;;OAGG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAClH,CAAC,EAjCgB,aAAa,KAAb,aAAa,QAiC7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport { ReplayDocumentService, ReplayDocumentServiceFactory } from \"@fluidframework/replay-driver\";\nimport { DebugReplayController } from \"./fluidDebuggerController\";\nimport { DebuggerUI } from \"./fluidDebuggerUi\";\n\nexport namespace FluidDebugger {\n /**\n * Creates document service wrapper that pops up Debugger window and allows user to play ops one by one.\n * User can chose to start with any snapshot\n * If pop-ups are disabled, we continue without debugger.\n * @param documentService - original document service to use to fetch ops / snapshots.\n */\n export async function createFromService(\n documentService: IDocumentService): Promise<IDocumentService> {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentService;\n }\n return ReplayDocumentService.create(documentService, controller);\n }\n\n export async function createFromServiceFactory(\n documentServiceFactory: IDocumentServiceFactory) {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentServiceFactory;\n }\n return new ReplayDocumentServiceFactory(\n documentServiceFactory,\n controller,\n );\n }\n\n /**\n * Binds DebuggerUI & DebugReplayController together\n * These classes do not know each other and talk through interfaces\n */\n const createFluidDebugger = () => DebugReplayController.create((controller) => DebuggerUI.create(controller));\n}\n"]}
1
+ {"version":3,"file":"fluidDebugger.js","sourceRoot":"","sources":["../src/fluidDebugger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,2DAA2D;AAC3D,MAAM,KAAW,aAAa,CAiC7B;AAjCD,WAAiB,aAAa;IAC1B;;;;;OAKG;IACI,KAAK,UAAU,iBAAiB,CACnC,eAAiC;QACjC,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,eAAe,CAAC;SAC1B;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAPqB,+BAAiB,oBAOtC,CAAA;IAEM,KAAK,UAAU,wBAAwB,CAC1C,sBAA+C;QAC/C,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,sBAAsB,CAAC;SACjC;QACD,OAAO,IAAI,4BAA4B,CACnC,sBAAsB,EACtB,UAAU,CACb,CAAC;IACN,CAAC;IAVqB,sCAAwB,2BAU7C,CAAA;IAED;;;OAGG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAClH,CAAC,EAjCgB,aAAa,KAAb,aAAa,QAiC7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport { ReplayDocumentService, ReplayDocumentServiceFactory } from \"@fluidframework/replay-driver\";\nimport { DebugReplayController } from \"./fluidDebuggerController\";\nimport { DebuggerUI } from \"./fluidDebuggerUi\";\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace FluidDebugger {\n /**\n * Creates document service wrapper that pops up Debugger window and allows user to play ops one by one.\n * User can chose to start with any snapshot\n * If pop-ups are disabled, we continue without debugger.\n * @param documentService - original document service to use to fetch ops / snapshots.\n */\n export async function createFromService(\n documentService: IDocumentService): Promise<IDocumentService> {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentService;\n }\n return ReplayDocumentService.create(documentService, controller);\n }\n\n export async function createFromServiceFactory(\n documentServiceFactory: IDocumentServiceFactory) {\n const controller = createFluidDebugger();\n if (!controller) {\n return documentServiceFactory;\n }\n return new ReplayDocumentServiceFactory(\n documentServiceFactory,\n controller,\n );\n }\n\n /**\n * Binds DebuggerUI & DebugReplayController together\n * These classes do not know each other and talk through interfaces\n */\n const createFluidDebugger = () => DebugReplayController.create((controller) => DebuggerUI.create(controller));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebuggerUi.d.ts","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAE3F,MAAM,WAAW,WAAW;IACxB;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEvC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzE;;;;;;;;OAQG;IACH,eAAe,CAAC,SAAS,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c,CAAC;IACjC,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IACtC,SAAS,CAAC,kBAAkB,UAAS;IACrC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAEpC,SAAS,CAAC,cAAc,UAAS;IAEjC,SAAS,aAA8B,UAAU,EAAE,mBAAmB,EAAmB,cAAc,EAAE,MAAM;IAyC/G,OAAO,CAAC,yBAAyB;IAQ1B,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE;IAahC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM;IAQjE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM;IAiC7D,mBAAmB,CAAC,OAAO,EAAE,OAAO;IAKpC,gBAAgB,CAAC,GAAG,EAAE,yBAAyB,EAAE;IAejD,iBAAiB,CAAC,YAAY,EAAE,MAAM;IAOtC,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO;IAOlE,OAAO,CAAC,QAAQ;CAYnB"}
@@ -108,12 +108,9 @@ export class DebuggerUI {
108
108
  this.versions = versions;
109
109
  for (const version of versions) {
110
110
  const option = document.createElement("option");
111
- if (version.date !== undefined) {
112
- option.text = `id = ${version.id}, time = ${version.date}`;
113
- }
114
- else {
115
- option.text = `id = ${version.id}`;
116
- }
111
+ option.text = version.date !== undefined
112
+ ? `id = ${version.id}, time = ${version.date}`
113
+ : `id = ${version.id}`;
117
114
  this.selector.add(option);
118
115
  }
119
116
  }
@@ -126,13 +123,9 @@ export class DebuggerUI {
126
123
  }
127
124
  }
128
125
  versionSelected(seqNumber, version) {
129
- let text;
130
- if (typeof version === "string") {
131
- text = `Playing ${version} file`;
132
- }
133
- else {
134
- text = `Playing from ${version.id}, seq# ${seqNumber}`;
135
- }
126
+ const text = typeof version === "string"
127
+ ? `Playing ${version} file`
128
+ : `Playing from ${version.id}, seq# ${seqNumber}`;
136
129
  this.wasVersionSelected = true;
137
130
  this.selector = undefined;
138
131
  const doc = this.debuggerWindow.document;
@@ -181,16 +174,9 @@ export class DebuggerUI {
181
174
  }
182
175
  }
183
176
  updateLastOpText(lastKnownOp, stillLoading) {
184
- let text;
185
- if (lastKnownOp < 0) {
186
- text = `FluidDebugger can't play ops in this mode`;
187
- }
188
- if (stillLoading) {
189
- text = `Last op (still loading): ${lastKnownOp}`;
190
- }
191
- else {
192
- text = `Document's last op seq#: ${lastKnownOp}`;
193
- }
177
+ const text = stillLoading
178
+ ? `Last op (still loading): ${lastKnownOp}`
179
+ : `Document's last op seq#: ${lastKnownOp}`;
194
180
  this.lastOpText.textContent = text;
195
181
  }
196
182
  download(filename, data) {
@@ -1 +1 @@
1
- {"version":3,"file":"fluidDebuggerUi.js","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AA8FtD,MAAM,kBAAkB,GACpB;;;;;;;;;;;;;;;;QAgBI,CAAC;AAET,MAAM,mBAAmB,GACrB;;;;;;;;;;;;;;;QAeI,CAAC;AAET,MAAM,OAAO,UAAU;IA4CnB,YAAuC,UAA+B,EAAmB,cAAsB;QAAxE,eAAU,GAAV,UAAU,CAAqB;QAAmB,mBAAc,GAAd,cAAc,CAAQ;QALrG,uBAAkB,GAAG,KAAK,CAAC;QAC3B,aAAQ,GAAe,EAAE,CAAC;QAE1B,mBAAc,GAAG,KAAK,CAAC;QAG7B,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE9B,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,cAAc,GAAG,IAAI,C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AAE;YACd,IAAI,GAAG,4BAA4B,WAAW,EAAE,CAAC;SACpD;aAAM;YACH,IAAI,GAAG,4BAA4B,WAAW,EAAE,CAAC;SACpD;QACD,IAAI,CAAC,UAAW,CAAC,WAAW,GAAG,IAAI,CAAC;IACxC,CAAC;IAEO,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,iCAAkC,kBAAkB,CAAC,IAAI,CAAE,EAAE,CAAC,CAAC;QAC5F,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, IVersion } from \"@fluidframework/protocol-definitions\";\n\nexport interface IDebuggerUI {\n /**\n * Version information is provided.\n * Expect updates (information about seq#, timestamp) through updateVersion() calls\n */\n addVersions(version: IVersion[]): void;\n\n /**\n * Call when new version is downloaded from storage\n * Expect multiple callbacks.\n */\n updateVersion(index: number, version: IVersion, seqNumber: number): void;\n\n /**\n * Called in response to successful onVersionSelection() or onSnapshotFileSelection() call\n * and provides extra information about selection.\n * It expected that UI layer would change its mode as result of this call, i.e. switch to\n * displaying op playback controls (if this is supported)\n * Note: There maybe no call to versionSelected() in response to onSnapshotFileSelection() call\n * if file does not exist, has wrong name of wrong format.\n * @param version - version, file name, or undefined if playing ops.\n */\n versionSelected(seqNumber: number, version: IVersion | string): void;\n\n /**\n * Called by controller in response to new ops being downloaded\n * Called with disable = true if there are no (currently) ops to play\n */\n disableNextOpButton(disable: boolean): void;\n\n /**\n * Called by controller when new ops arrive (or we are done playing previous batch)\n * Indicates next batch of ops that would be played when UI calls controller's onOpButtonClick()\n * Called with ops=[] when there are no ops to play.\n */\n updateNextOpText(ops: ISequencedDocumentMessage[]): void;\n\n /**\n * Called periodically when new versions are downloaded from server\n */\n updateVersionText(versionsLeft: number): void;\n\n /**\n * Called periodically to notify about last known op\n * @param lastKnownOp - seq number of last known op. -1 if can't play ops in this mode (load from file)\n * @param stillLoading - true if we did not reach yet the end of the stream\n */\n updateLastOpText(lastKnownOp: number, stillLoading: boolean): void;\n}\n\nexport interface IDebuggerController {\n /**\n * Initialization. UI layers calls into controller to connect the two.\n * @param ui - UI layer\n */\n connectToUi(ui: IDebuggerUI);\n\n /**\n * Called by UI layer when debugger window is closed by user\n * If called before user makes selection of snapshot/file, original\n * document service is returned to loader (instead of debugger service) and normal document load continues.\n */\n onClose(): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - Snapshot version to start from.\n */\n onVersionSelection(version: IVersion): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - File to load snapshot from\n */\n onSnapshotFileSelection(file: File): void;\n\n /**\n * \"next op\" button is clicked in the UI\n * @param steps - number of ops to play.\n */\n onOpButtonClick(steps: number): void;\n\n /**\n * \"Download ops\" option is clicked in the UI. Returns JSON of the full opStream when available.\n * @param anonymize - anonymize the ops json using the sanitization tool\n */\n onDownloadOpsButtonClick(anonymize: boolean): Promise<string>;\n}\n\nconst debuggerWindowHtml =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\nPlease select snapshot or file to start with<br/>\nClose debugger window to proceed to live document<br/><br/>\n<select style='width:250px' id='selector'>\n</select>\n&nbsp; &nbsp; &nbsp;\n<button id='buttonVers' style='width:60px'>Go</button><br/>\n<input id='file' type='file' value='Load from file'/>\n<br/><br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n<br/><br/><div id='versionText'></div>\n</body>`;\n\nconst debuggerWindowHtml2 =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\n<div id='versionText'></div>\n<div id='lastOp'></div>\n<br/>\nStep to move: <input type='number' id='steps' value='1' min='1' style='width:50px'/>\n&nbsp; &nbsp; &nbsp;<button id='buttonOps' style='width:60px'>Go</button>\n<br/><br/>\n<div id='text1'></div><div id='text2'></div><div id='text3'></div>\n<br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n</body>`;\n\nexport class DebuggerUI {\n public static create(controller: IDebuggerController): DebuggerUI | null {\n if (\n typeof window !== \"object\" ||\n window === null ||\n typeof window.document !== \"object\" ||\n window.document == null) {\n console.log(\"Can't create debugger window - not running in browser!\");\n return null;\n }\n\n const debuggerWindow = window.open(\n \"\",\n \"\",\n \"width=400,height=400,resizable=yes,location=no,menubar=no,titlebar=no,status=no,toolbar=no\");\n if (!debuggerWindow) {\n console.error(\"Can't create debugger window - please enable pop-up windows in your browser!\");\n return null;\n }\n\n return new DebuggerUI(controller, debuggerWindow);\n }\n\n private static formatDate(date: number) {\n // Alternative - without timezone\n // new Date().toLocaleString('default', { timeZone: 'UTC'}));\n // new Date().toLocaleString('default', { year: 'numeric', month: 'short',\n // day: 'numeric', hour: '2-digit', minute: 'numeric', second: 'numeric' }));\n return new Date(date).toUTCString();\n }\n\n protected selector?: HTMLSelectElement;\n protected versionText: HTMLDivElement;\n\n protected buttonOps?: HTMLButtonElement;\n protected text1?: HTMLDivElement;\n protected text2?: HTMLDivElement;\n protected text3?: HTMLDivElement;\n protected lastOpText?: HTMLDivElement;\n protected wasVersionSelected = false;\n protected versions: IVersion[] = [];\n\n protected documentClosed = false;\n\n protected constructor(private readonly controller: IDebuggerController, private readonly debuggerWindow: Window) {\n const doc = this.debuggerWindow.document;\n doc.write(debuggerWindowHtml);\n\n window.addEventListener(\"beforeunload\", (e) => {\n this.documentClosed = true;\n this.debuggerWindow.close();\n }, false);\n\n this.debuggerWindow.addEventListener(\"beforeunload\", (e) => {\n if (!this.documentClosed) {\n this.controller.onClose();\n }\n }, false);\n\n this.selector = doc.getElementById(\"selector\") as HTMLSelectElement;\n\n const buttonVers = doc.getElementById(\"buttonVers\") as HTMLDivElement;\n buttonVers.onclick = () => {\n const index = this.selector!.selectedIndex;\n controller.onVersionSelection(this.versions[index]);\n };\n\n const fileSnapshot = doc.getElementById(\"file\") as HTMLInputElement;\n fileSnapshot.addEventListener(\"change\", () => {\n const files = fileSnapshot.files;\n if (files) {\n controller.onSnapshotFileSelection(files[0]);\n }\n }, false);\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = \"Fetching snapshots, please wait...\";\n\n controller.connectToUi(this);\n }\n\n private attachDownloadOpsListener(element: HTMLElement, anonymize: HTMLInputElement) {\n element.addEventListener(\"click\", () => {\n this.controller.onDownloadOpsButtonClick(anonymize.checked).then((opJson) => {\n this.download(\"opStream.json\", opJson);\n }).catch((error) => { console.log(`Error downloading ops: ${error}`); });\n });\n }\n\n public addVersions(versions: IVersion[]) {\n if (this.selector) {\n this.versions = versions;\n for (const version of versions) {\n const option = document.createElement(\"option\");\n if (version.date !== undefined) {\n option.text = `id = ${version.id}, time = ${version.date}`;\n } else {\n option.text = `id = ${version.id}`;\n }\n this.selector.add(option);\n }\n }\n }\n\n public updateVersion(index: number, version: IVersion, seqNumber: number) {\n if (this.selector) {\n const option = this.selector[index] as HTMLOptionElement;\n option.text = `${option.text}, seq = ${seqNumber}`;\n this.selector[index] = option;\n }\n }\n\n public versionSelected(seqNumber: number, version: IVersion | string) {\n let text: string;\n if (typeof version === \"string\") {\n text = `Playing ${version} file`;\n } else {\n text = `Playing from ${version.id}, seq# ${seqNumber}`;\n }\n\n this.wasVersionSelected = true;\n this.selector = undefined;\n\n const doc = this.debuggerWindow.document;\n doc.open();\n doc.write(debuggerWindowHtml2);\n doc.close();\n\n this.lastOpText = doc.getElementById(\"lastOp\") as HTMLDivElement;\n this.text1 = doc.getElementById(\"text1\") as HTMLDivElement;\n this.text2 = doc.getElementById(\"text2\") as HTMLDivElement;\n this.text3 = doc.getElementById(\"text3\") as HTMLDivElement;\n\n const steps = doc.getElementById(\"steps\") as HTMLInputElement;\n this.buttonOps = doc.getElementById(\"buttonOps\") as HTMLButtonElement;\n this.buttonOps.disabled = true;\n this.buttonOps.onclick = () => {\n this.controller.onOpButtonClick(Number(steps.value));\n };\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = text;\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n }\n\n public disableNextOpButton(disable: boolean) {\n assert(!!this.buttonOps, 0x088 /* \"Missing button ops button!\" */);\n this.buttonOps.disabled = disable;\n }\n\n public updateNextOpText(ops: ISequencedDocumentMessage[]) {\n if (ops.length === 0) {\n this.text1!.textContent = \"\";\n this.text2!.textContent = \"\";\n this.text3!.textContent = \"\";\n } else {\n const op = ops[0];\n const seq = op.sequenceNumber;\n const date = DebuggerUI.formatDate(op.timestamp);\n this.text1!.textContent = `Next op seq#: ${seq}`;\n this.text2!.textContent = `Type: ${op.type}`;\n this.text3!.textContent = `${date}`;\n }\n }\n\n public updateVersionText(versionCount: number) {\n if (!this.wasVersionSelected) {\n const text = versionCount === 0 ? \"\" : `Fetching information about ${versionCount} snapshots...`;\n this.versionText.textContent = text;\n }\n }\n\n public updateLastOpText(lastKnownOp: number, stillLoading: boolean) {\n let text: string;\n if (lastKnownOp < 0) {\n text = `FluidDebugger can't play ops in this mode`;\n }\n if (stillLoading) {\n text = `Last op (still loading): ${lastKnownOp}`;\n } else {\n text = `Document's last op seq#: ${lastKnownOp}`;\n }\n this.lastOpText!.textContent = text;\n }\n\n private download(filename: string, data: string): void {\n const element = document.createElement(\"a\");\n element.setAttribute(\"href\", `data:text/plain;charset=utf-8,${ encodeURIComponent(data) }`);\n element.setAttribute(\"download\", filename);\n\n element.style.display = \"none\";\n document.body.appendChild(element);\n\n element.click();\n\n document.body.removeChild(element);\n }\n}\n"]}
1
+ {"version":3,"file":"fluidDebuggerUi.js","sourceRoot":"","sources":["../src/fluidDebuggerUi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AA8FtD,MAAM,kBAAkB,GACpB;;;;;;;;;;;;;;;;QAgBI,CAAC;AAET,MAAM,mBAAmB,GACrB;;;;;;;;;;;;;;;QAeI,CAAC;AAET,MAAM,OAAO,UAAU;IA4CnB,YAAuC,UAA+B,EAAmB,cAAsB;QAAxE,eAAU,GAAV,UAAU,CAAqB;QAAmB,mBAAc,GAAd,cAAc,CAAQ;QALrG,uBAAkB,GAAG,KAAK,CAAC;QAC3B,aAAQ,GAAe,EAAE,CAAC;QAE1B,mBAAc,GAAG,KAAK,CAAC;QAG7B,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE9B,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC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Y;QAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,iCAAkC,kBAAkB,CAAC,IAAI,CAAE,EAAE,CAAC,CAAC;QAC5F,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, IVersion } from \"@fluidframework/protocol-definitions\";\n\nexport interface IDebuggerUI {\n /**\n * Version information is provided.\n * Expect updates (information about seq#, timestamp) through updateVersion() calls\n */\n addVersions(version: IVersion[]): void;\n\n /**\n * Call when new version is downloaded from storage\n * Expect multiple callbacks.\n */\n updateVersion(index: number, version: IVersion, seqNumber: number): void;\n\n /**\n * Called in response to successful onVersionSelection() or onSnapshotFileSelection() call\n * and provides extra information about selection.\n * It expected that UI layer would change its mode as result of this call, i.e. switch to\n * displaying op playback controls (if this is supported)\n * Note: There maybe no call to versionSelected() in response to onSnapshotFileSelection() call\n * if file does not exist, has wrong name of wrong format.\n * @param version - version, file name, or undefined if playing ops.\n */\n versionSelected(seqNumber: number, version: IVersion | string): void;\n\n /**\n * Called by controller in response to new ops being downloaded\n * Called with disable = true if there are no (currently) ops to play\n */\n disableNextOpButton(disable: boolean): void;\n\n /**\n * Called by controller when new ops arrive (or we are done playing previous batch)\n * Indicates next batch of ops that would be played when UI calls controller's onOpButtonClick()\n * Called with ops=[] when there are no ops to play.\n */\n updateNextOpText(ops: ISequencedDocumentMessage[]): void;\n\n /**\n * Called periodically when new versions are downloaded from server\n */\n updateVersionText(versionsLeft: number): void;\n\n /**\n * Called periodically to notify about last known op\n * @param lastKnownOp - seq number of last known op. -1 if can't play ops in this mode (load from file)\n * @param stillLoading - true if we did not reach yet the end of the stream\n */\n updateLastOpText(lastKnownOp: number, stillLoading: boolean): void;\n}\n\nexport interface IDebuggerController {\n /**\n * Initialization. UI layers calls into controller to connect the two.\n * @param ui - UI layer\n */\n connectToUi(ui: IDebuggerUI);\n\n /**\n * Called by UI layer when debugger window is closed by user\n * If called before user makes selection of snapshot/file, original\n * document service is returned to loader (instead of debugger service) and normal document load continues.\n */\n onClose(): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - Snapshot version to start from.\n */\n onVersionSelection(version: IVersion): void;\n\n /**\n * UI Layer notifies about selection of version to continue.\n * On successful load, versionSelected() is called.\n * @param version - File to load snapshot from\n */\n onSnapshotFileSelection(file: File): void;\n\n /**\n * \"next op\" button is clicked in the UI\n * @param steps - number of ops to play.\n */\n onOpButtonClick(steps: number): void;\n\n /**\n * \"Download ops\" option is clicked in the UI. Returns JSON of the full opStream when available.\n * @param anonymize - anonymize the ops json using the sanitization tool\n */\n onDownloadOpsButtonClick(anonymize: boolean): Promise<string>;\n}\n\nconst debuggerWindowHtml =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\nPlease select snapshot or file to start with<br/>\nClose debugger window to proceed to live document<br/><br/>\n<select style='width:250px' id='selector'>\n</select>\n&nbsp; &nbsp; &nbsp;\n<button id='buttonVers' style='width:60px'>Go</button><br/>\n<input id='file' type='file' value='Load from file'/>\n<br/><br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n<br/><br/><div id='versionText'></div>\n</body>`;\n\nconst debuggerWindowHtml2 =\n `<Title>Fluid Debugger</Title>\n<body>\n<h3>Fluid Debugger</h3>\n<div id='versionText'></div>\n<div id='lastOp'></div>\n<br/>\nStep to move: <input type='number' id='steps' value='1' min='1' style='width:50px'/>\n&nbsp; &nbsp; &nbsp;<button id='buttonOps' style='width:60px'>Go</button>\n<br/><br/>\n<div id='text1'></div><div id='text2'></div><div id='text3'></div>\n<br/>\n<h4>Download the current document's ops</h4>\n<input type='checkbox' id='anonymize' value='Anonymize'>\n<label for='anonymize'>Anonymize</label>\n<button type='button' id='downloadOps'>Download ops</button>\n</body>`;\n\nexport class DebuggerUI {\n public static create(controller: IDebuggerController): DebuggerUI | null {\n if (\n typeof window !== \"object\" ||\n window === null ||\n typeof window.document !== \"object\" ||\n window.document == null) {\n console.log(\"Can't create debugger window - not running in browser!\");\n return null;\n }\n\n const debuggerWindow = window.open(\n \"\",\n \"\",\n \"width=400,height=400,resizable=yes,location=no,menubar=no,titlebar=no,status=no,toolbar=no\");\n if (!debuggerWindow) {\n console.error(\"Can't create debugger window - please enable pop-up windows in your browser!\");\n return null;\n }\n\n return new DebuggerUI(controller, debuggerWindow);\n }\n\n private static formatDate(date: number) {\n // Alternative - without timezone\n // new Date().toLocaleString('default', { timeZone: 'UTC'}));\n // new Date().toLocaleString('default', { year: 'numeric', month: 'short',\n // day: 'numeric', hour: '2-digit', minute: 'numeric', second: 'numeric' }));\n return new Date(date).toUTCString();\n }\n\n protected selector?: HTMLSelectElement;\n protected versionText: HTMLDivElement;\n\n protected buttonOps?: HTMLButtonElement;\n protected text1?: HTMLDivElement;\n protected text2?: HTMLDivElement;\n protected text3?: HTMLDivElement;\n protected lastOpText?: HTMLDivElement;\n protected wasVersionSelected = false;\n protected versions: IVersion[] = [];\n\n protected documentClosed = false;\n\n protected constructor(private readonly controller: IDebuggerController, private readonly debuggerWindow: Window) {\n const doc = this.debuggerWindow.document;\n doc.write(debuggerWindowHtml);\n\n window.addEventListener(\"beforeunload\", (e) => {\n this.documentClosed = true;\n this.debuggerWindow.close();\n }, false);\n\n this.debuggerWindow.addEventListener(\"beforeunload\", (e) => {\n if (!this.documentClosed) {\n this.controller.onClose();\n }\n }, false);\n\n this.selector = doc.getElementById(\"selector\") as HTMLSelectElement;\n\n const buttonVers = doc.getElementById(\"buttonVers\") as HTMLDivElement;\n buttonVers.onclick = () => {\n const index = this.selector!.selectedIndex;\n controller.onVersionSelection(this.versions[index]);\n };\n\n const fileSnapshot = doc.getElementById(\"file\") as HTMLInputElement;\n fileSnapshot.addEventListener(\"change\", () => {\n const files = fileSnapshot.files;\n if (files) {\n controller.onSnapshotFileSelection(files[0]);\n }\n }, false);\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = \"Fetching snapshots, please wait...\";\n\n controller.connectToUi(this);\n }\n\n private attachDownloadOpsListener(element: HTMLElement, anonymize: HTMLInputElement) {\n element.addEventListener(\"click\", () => {\n this.controller.onDownloadOpsButtonClick(anonymize.checked).then((opJson) => {\n this.download(\"opStream.json\", opJson);\n }).catch((error) => { console.log(`Error downloading ops: ${error}`); });\n });\n }\n\n public addVersions(versions: IVersion[]) {\n if (this.selector) {\n this.versions = versions;\n for (const version of versions) {\n const option = document.createElement(\"option\");\n option.text = version.date !== undefined\n ? `id = ${version.id}, time = ${version.date}`\n : `id = ${version.id}`;\n this.selector.add(option);\n }\n }\n }\n\n public updateVersion(index: number, version: IVersion, seqNumber: number) {\n if (this.selector) {\n const option = this.selector[index] as HTMLOptionElement;\n option.text = `${option.text}, seq = ${seqNumber}`;\n this.selector[index] = option;\n }\n }\n\n public versionSelected(seqNumber: number, version: IVersion | string) {\n const text = typeof version === \"string\"\n ? `Playing ${version} file`\n : `Playing from ${version.id}, seq# ${seqNumber}`;\n\n this.wasVersionSelected = true;\n this.selector = undefined;\n\n const doc = this.debuggerWindow.document;\n doc.open();\n doc.write(debuggerWindowHtml2);\n doc.close();\n\n this.lastOpText = doc.getElementById(\"lastOp\") as HTMLDivElement;\n this.text1 = doc.getElementById(\"text1\") as HTMLDivElement;\n this.text2 = doc.getElementById(\"text2\") as HTMLDivElement;\n this.text3 = doc.getElementById(\"text3\") as HTMLDivElement;\n\n const steps = doc.getElementById(\"steps\") as HTMLInputElement;\n this.buttonOps = doc.getElementById(\"buttonOps\") as HTMLButtonElement;\n this.buttonOps.disabled = true;\n this.buttonOps.onclick = () => {\n this.controller.onOpButtonClick(Number(steps.value));\n };\n\n this.versionText = doc.getElementById(\"versionText\") as HTMLDivElement;\n this.versionText.textContent = text;\n\n const opDownloadButton = doc.getElementById(\"downloadOps\") as HTMLElement;\n const anonymizeCheckbox = doc.getElementById(\"anonymize\") as HTMLInputElement;\n this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);\n }\n\n public disableNextOpButton(disable: boolean) {\n assert(!!this.buttonOps, 0x088 /* \"Missing button ops button!\" */);\n this.buttonOps.disabled = disable;\n }\n\n public updateNextOpText(ops: ISequencedDocumentMessage[]) {\n if (ops.length === 0) {\n this.text1!.textContent = \"\";\n this.text2!.textContent = \"\";\n this.text3!.textContent = \"\";\n } else {\n const op = ops[0];\n const seq = op.sequenceNumber;\n const date = DebuggerUI.formatDate(op.timestamp);\n this.text1!.textContent = `Next op seq#: ${seq}`;\n this.text2!.textContent = `Type: ${op.type}`;\n this.text3!.textContent = `${date}`;\n }\n }\n\n public updateVersionText(versionCount: number) {\n if (!this.wasVersionSelected) {\n const text = versionCount === 0 ? \"\" : `Fetching information about ${versionCount} snapshots...`;\n this.versionText.textContent = text;\n }\n }\n\n public updateLastOpText(lastKnownOp: number, stillLoading: boolean) {\n const text = stillLoading\n ? `Last op (still loading): ${lastKnownOp}`\n : `Document's last op seq#: ${lastKnownOp}`;\n this.lastOpText!.textContent = text;\n }\n\n private download(filename: string, data: string): void {\n const element = document.createElement(\"a\");\n element.setAttribute(\"href\", `data:text/plain;charset=utf-8,${ encodeURIComponent(data) }`);\n element.setAttribute(\"download\", filename);\n\n element.style.display = \"none\";\n document.body.appendChild(element);\n\n element.click();\n\n document.body.removeChild(element);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EACH,yBAAyB,EAC5B,MAAM,sCAAsC,CAAC;AAc9C,aAAK,QAAQ;IACT,OAAO,IAAA;IACP,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,WAAW,IAAA;IACX,MAAM,IAAA;CACT;AASD;;;;;GAKG;AACH,cAAM,kBAAkB;IAqBhB,QAAQ,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO;IArB3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAoB;IACpC;;;OAGG;IACH,OAAO,CAAC,qBAAqB,CAAoB;IACjD,OAAO,CAAC,WAAW,CAAS;IAC5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAAK;gBAGlB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,OAAO,EACvD,KAAK,EAAE,OAAO;IAG3B,QAAQ,CAAC,GAAG,EAAE,GAAG;IAMjB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAmB9B,cAAc,IAAI,OAAO;IAKzB;;OAEG;IACH,uBAAuB,IAAI,GAAG;IAgB9B;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IA4C3C,KAAK,IAAI,IAAI;IAQb,mBAAmB,IA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AAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,YAAY,GAAE,GAAG,CAAC,MAAM,CAA4B,GAAG,MAAM,GAAG,IAAI;IAyBxG;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,GAAE,GAAG,CAAC,MAAM,CAA4B,GAAG,GAAG;IAoBjF,OAAO,CAAC,OAAO,EAAE,GAAG;IAsBpB,UAAU,CAAC,OAAO,EAAE,GAAG;IA2BvB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;IAoB/B;;;OAGG;IACH,iBAAiB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;IAcrC;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,GAAG;IAgBtB,UAAU,CAAC,OAAO,EAAE,GAAG;IAMvB;;;;;;OAMG;IACH,mBAAmB,CAAC,QAAQ,EAAE,GAAG;IAgEjC,KAAK,CAAC,OAAO,EAAE,GAAG;IA2DlB;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,GAAG;IAazB,QAAQ,IAAI,yBAAyB,EAAE;CAiD1C"}
package/lib/sanitizer.js CHANGED
@@ -243,13 +243,7 @@ export class Sanitizer {
243
243
  if (this.replacementMap.has(input)) {
244
244
  return this.replacementMap.get(input);
245
245
  }
246
- let replacement;
247
- if (this.fullScrub) {
248
- replacement = this.getRandomText(input.length);
249
- }
250
- else {
251
- replacement = input;
252
- }
246
+ const replacement = this.fullScrub ? this.getRandomText(input.length) : input;
253
247
  this.replacementMap.set(input, replacement);
254
248
  return replacement;
255
249
  }
@@ -442,12 +436,9 @@ export class Sanitizer {
442
436
  }
443
437
  }
444
438
  fixDeltaOp(deltaOp) {
445
- if (typeof deltaOp.seg === "string") {
446
- deltaOp.seg = this.replaceText(deltaOp.seg);
447
- }
448
- else {
449
- deltaOp.seg = this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
450
- }
439
+ deltaOp.seg = typeof deltaOp.seg === "string"
440
+ ? this.replaceText(deltaOp.seg)
441
+ : this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
451
442
  }
452
443
  /**
453
444
  * Fix the contents object for an op message. Does not do extra type handling. Does
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,qBAAqB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,IAAK,QAMJ;AAND,WAAK,QAAQ;IACT,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,qDAAW,CAAA;IACX,2CAAM,CAAA;AACV,CAAC,EANI,QAAQ,KAAR,QAAQ,QAMZ;AAED,sEAAsE;AACtE,uBAAuB;AACvB,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,kBAAkB;IAoBpB,YACa,gBAAuD,EACvD,KAAc;QADd,qBAAgB,GAAhB,gBAAgB,CAAuC;QACvD,UAAK,GAAL,KAAK,CAAS;QArB3B;;;;WAIG;QACK,aAAQ,GAAG,IAAI,KAAK,EAAO,CAAC;QACpC;;;WAGG;QACK,0BAAqB,GAAG,IAAI,KAAK,EAAO,CAAC;QACzC,gBAAW,GAAG,KAAK,CAAC;QAC5B;;;;WAIG;QACK,uBAAkB,GAAG,CAAC,CAAC;IAK3B,CAAC;IAEL,QAAQ,CAAC,GAAQ;QACb,IAAI,IAAI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AAE;oBAClB,KAAK,MAAM,CAAC,CAAC;wBACT,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBACtB,MAAM;qBACT;oBACD,KAAK,SAAS,CAAC,CAAC;wBACZ,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBACzB,MAAM;qBACT;oBACD,KAAK,QAAQ,CAAC,CAAC;wBACX,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;wBACxB,MAAM;qBACT;oBACD,KAAK,IAAI,CAAC,CAAC;wBACP,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;wBACpB,MAAM;qBACT;oBACD,KAAK,WAAW,CAAC,CAAC;wBACd,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;wBAC3B,MAAM;qBACT;oBACD,KAAK,MAAM,CAAC;oBACZ,KAAK,OAAO,CAAC;oBACb,KAAK,UAAU,CAAC;oBAChB,KAAK,WAAW,CAAC;oBACjB,KAAK,YAAY,CAAC;oBAClB,KAAK,aAAa;wBACd,MAAM;oBACV;wBACI,IAAI,CAAC,QAAQ,CAAC,sBAAsB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;iBAC3D;YACL,CAAC,CAAC,CAAC;YAEH,8DAA8D;YAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAC7G;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This tool cleans up a message.json file downloaded through fluid-fetch to remove\n * user content and user identifying information. Enough information can be retained\n * to allow loading through Fluid Preview, or everything can be scrubbed so that only\n * replay-tool can read the result. Anonymous identifying information such as client\n * IDs are always retained. Object keys are NOT scrubbed, including those that are\n * nested within values (only leaf values are scrubbed).\n *\n * Note: While user content/information is scrubbed, it should not be assumed to be\n * fully anonymized because certain meta-information (such as word lengths and\n * consistent replacement) are preserved.\n *\n * Messages must match known structures when scrubbing for Fluid Preview.\n */\n\nimport * as Validator from \"jsonschema\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n attachContentsSchema,\n chunkedOpContentsSchema,\n joinContentsSchema,\n joinDataSchema,\n opContentsMapSchema,\n opContentsSchema,\n opContentsMergeTreeDeltaOpSchema,\n opContentsMergeTreeGroupOpSchema,\n opContentsRegisterCollectionSchema,\n proposeContentsSchema,\n} from \"./messageSchema\";\n\nenum TextType {\n Generic,\n Email,\n Name,\n FluidObject,\n MapKey,\n}\n\n// Workaround to jsonschema package not supporting \"false\" as a schema\n// that matches nothing\nconst falseResult = {\n valid: false,\n toString: () => { return \"Unmatched format\"; },\n};\n\n/**\n * Class that takes chunkedOp messages and can provide their concatenated\n * contents along with re-write sanitized content in-place back into the\n * messages. Assumes sanitized messages are always less than or equal in\n * size to the original message.\n */\nclass ChunkedOpProcessor {\n /**\n * Message references so we can replace their contents in-place. These can\n * be top-level chunkedOp messages, or top-level op messages with a chunkedOp\n * within the contents\n */\n private messages = new Array<any>();\n /**\n * The messages' parsed contents for processing. Should parallel the\n * messages member\n */\n private parsedMessageContents = new Array<any>();\n private writtenBack = false;\n /**\n * keep track of the total starting length to make sure we don't somehow end\n * up with more content than we started with (meaning we may not be able to\n * write it back)\n */\n private concatenatedLength = 0;\n\n constructor(\n readonly validateSchemaFn: (object: any, schema: any) => boolean,\n readonly debug: boolean,\n ) { }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n addMessage(message: any): void {\n this.messages.push(message);\n\n let parsed;\n try {\n parsed = JSON.parse(message.contents);\n if (message.type === \"op\") {\n // nested within a regular op\n // need to go deeper to get the desired contents\n parsed = parsed.contents;\n }\n } catch (e) {\n this.debugMsg(e);\n this.debugMsg(message.contents);\n }\n this.validateSchemaFn(parsed, chunkedOpContentsSchema);\n this.parsedMessageContents.push(parsed);\n }\n\n hasAllMessages(): boolean {\n const lastMsgContents = this.parsedMessageContents[this.parsedMessageContents.length - 1];\n return lastMsgContents.chunkId !== undefined && lastMsgContents.chunkId === lastMsgContents.totalChunks;\n }\n\n /**\n * @returns The concatenated contents of all the messages parsed as json\n */\n getConcatenatedContents(): any {\n const contentsString = this.parsedMessageContents.reduce((previousValue: string, currentValue: any) => {\n return previousValue + (currentValue.contents as string);\n }, \"\");\n\n this.concatenatedLength = contentsString.length;\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(contentsString);\n } catch (e) {\n this.debugMsg(contentsString);\n this.debugMsg(e);\n return undefined;\n }\n }\n\n /**\n * Write back sanitized contents into the messages. The contents are\n * stringified, split up, and written in place to the messages that\n * were added earlier. The number of messages is preserved.\n * @param contents - Sanitized contents to write back\n */\n writeSanitizedContents(contents: any): void {\n // Write back a chunk size equal to the original\n const chunkSize = this.parsedMessageContents[0].contents.length;\n\n let stringified: string;\n try {\n stringified = JSON.stringify(contents);\n assert(stringified.length <= this.concatenatedLength,\n 0x089 /* \"Stringified length of chunk contents > total starting length\" */);\n } catch (e) {\n this.debugMsg(e);\n throw e;\n }\n\n for (let i = 0; i < this.messages.length; i++) {\n const substring = stringified.substring(i * chunkSize, (i + 1) * chunkSize);\n\n const parsedContents = this.parsedMessageContents[i];\n parsedContents.contents = substring;\n const message = this.messages[i];\n\n let stringifiedParsedContents;\n try {\n // for nested chunkedOps, we need to recreate the extra nesting layer\n // we removed earlier when adding the message\n if (message.type === \"op\") {\n const nestingLayer = {\n type: \"chunkedOp\",\n contents: parsedContents,\n };\n stringifiedParsedContents = JSON.stringify(nestingLayer);\n } else {\n stringifiedParsedContents = JSON.stringify(parsedContents);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n\n message.contents = stringifiedParsedContents;\n }\n\n this.writtenBack = true;\n }\n\n reset(): void {\n assert(this.writtenBack, 0x08a /* \"resetting ChunkedOpProcessor that never wrote back its contents\" */);\n this.messages = new Array<any>();\n this.parsedMessageContents = new Array<any>();\n this.writtenBack = false;\n this.concatenatedLength = 0;\n }\n\n isPendingProcessing(): boolean {\n return this.messages.length !== 0;\n }\n}\n\nexport class Sanitizer {\n readonly validator = new Validator.Validator();\n // Represents the keys used to store Fluid object identifiers, snapshot info,\n // and other string fields that should not be replaced in contents blobs to\n // ensure the messages are still usable\n readonly defaultExcludedKeys = new Set<string>();\n // Represents the keys used by merge-tree ops their \"seg\" property, where other\n // keys represent user information\n readonly mergeTreeExcludedKeys = new Set<string>();\n // Map of user information to what it was replaced with. Used to ensure the same\n // data have the same replacements\n readonly replacementMap = new Map<string, string>();\n\n /**\n * Validate that the provided message matches the provided schema.\n * For a full scrub, warn and continue (scrubber should fully sanitize unexpected\n * fields for ops), otherwise throw an error because we cannot be sure user\n * information is being sufficiently sanitized.\n */\n objectMatchesSchema = (object: any, schema: any): boolean => {\n const result = schema === false ? falseResult : this.validator.validate(object, schema);\n if (!result.valid) {\n const errorMsg = `Bad msg fmt:\\n${result.toString()}\\n${JSON.stringify(object, undefined, 2)}`;\n\n if (this.fullScrub || this.noBail) {\n this.debugMsg(errorMsg);\n } else {\n throw new Error(errorMsg);\n }\n }\n return result.valid;\n };\n\n readonly chunkProcessor = new ChunkedOpProcessor(this.objectMatchesSchema, this.debug);\n\n constructor(\n readonly messages: ISequencedDocumentMessage[],\n readonly fullScrub: boolean,\n readonly noBail: boolean,\n readonly debug: boolean = false,\n ) {\n this.defaultExcludedKeys.add(\"type\");\n this.defaultExcludedKeys.add(\"id\");\n this.defaultExcludedKeys.add(\"pkg\");\n this.defaultExcludedKeys.add(\"snapshotFormatVersion\");\n this.defaultExcludedKeys.add(\"packageVersion\");\n this.mergeTreeExcludedKeys.add(\"nodeType\");\n }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n isFluidObjectKey(key: string): boolean {\n return key === \"type\" || key === \"id\";\n }\n\n getRandomText(len: number): string {\n let str = \"\";\n while (str.length < len) {\n str = str + Math.random().toString(36).substring(2);\n }\n return str.substr(0, len);\n }\n\n readonly wordTokenRegex = /\\S+/g;\n\n readonly replaceRandomTextFn = (match: string): string => {\n if (this.replacementMap.has(match)) {\n return this.replacementMap.get(match)!;\n }\n\n const replacement = this.getRandomText(match.length);\n this.replacementMap.set(match, replacement);\n return replacement;\n };\n\n /**\n * Replace text with garbage. FluidObject types are not replaced when not under\n * full scrub mode. All other text is replaced consistently.\n */\n replaceText(input?: string, type: TextType = TextType.Generic): string | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (type === TextType.FluidObject) {\n if (this.replacementMap.has(input)) {\n return this.replacementMap.get(input)!;\n }\n\n let replacement: string;\n if (this.fullScrub) {\n replacement = this.getRandomText(input.length);\n } else {\n replacement = input;\n }\n\n this.replacementMap.set(input, replacement);\n return replacement;\n }\n\n return input.replace(this.wordTokenRegex, this.replaceRandomTextFn);\n }\n\n replaceArray(input: any[]): any[] {\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n if (typeof value === \"string\") {\n input[i] = this.replaceText(value);\n } else if (Array.isArray(value)) {\n input[i] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[i] = this.replaceObject(value);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n /**\n * (sort of) recurses down the values of a JSON object to sanitize all its strings\n * (only checks strings, arrays, and objects)\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n replaceObject(input: object | null, excludedKeys: Set<string> = this.defaultExcludedKeys): object | null {\n // File might contain actual nulls\n if (input === null || input === undefined) {\n return input;\n }\n\n const keys = Object.keys(input);\n keys.forEach((key) => {\n if (this.fullScrub || !excludedKeys.has(key)) {\n const value = input[key];\n if (typeof value === \"string\") {\n input[key] = this.replaceText(\n value,\n this.isFluidObjectKey(key) ? TextType.FluidObject : TextType.Generic,\n );\n } else if (Array.isArray(value)) {\n input[key] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[key] = this.replaceObject(value, excludedKeys);\n }\n }\n });\n return input;\n }\n\n /**\n * Replacement on an unknown type or a parsed root level object\n * without a key\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n replaceAny(input: any, excludedKeys: Set<string> = this.defaultExcludedKeys): any {\n if (input === null || input === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n if (typeof input === \"string\") {\n return this.replaceText(input);\n } else if (Array.isArray(input)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.replaceArray(input);\n } else if (typeof input === \"object\") {\n return this.replaceObject(input, excludedKeys);\n }\n\n // Don't run replacement on any other types\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n fixJoin(message: any) {\n if (!this.objectMatchesSchema(message.contents, joinContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n }\n\n try {\n let data = JSON.parse(message.data);\n if (!this.objectMatchesSchema(data, joinDataSchema)) {\n data = this.replaceAny(data);\n } else {\n const user = data.detail.user;\n user.id = this.replaceText(user.id, TextType.Email);\n user.email = this.replaceText(user.email, TextType.Email);\n user.name = this.replaceText(user.name, TextType.Name);\n }\n\n message.data = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n }\n\n fixPropose(message: any) {\n if (!this.objectMatchesSchema(message.contents, proposeContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n } else {\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n if (this.fullScrub) {\n const pkg = data.value?.package;\n if (pkg?.name) {\n pkg.name = this.replaceText(pkg.name, TextType.FluidObject);\n }\n if (Array.isArray(pkg?.fluid?.browser?.umd?.files)) {\n pkg.fluid.browser.umd.files = this.replaceArray(pkg.fluid.browser.umd.files);\n }\n }\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n if (this.fullScrub) {\n message.contents.value = this.replaceText(message.contents.value, TextType.FluidObject);\n }\n }\n }\n }\n\n fixAttachEntries(entries: any[]) {\n entries.forEach((element) => {\n // Tree type\n if (element.value.entries) {\n this.fixAttachEntries(element.value.entries);\n } else {\n // Blob (leaf) type\n try {\n if (typeof element.value.contents === \"string\") {\n let data = JSON.parse(element.value.contents);\n data = this.replaceObject(data);\n element.value.contents = JSON.stringify(data);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n }\n });\n }\n\n /**\n * Fix the content of an attach in place\n * @param contents - contents object to fix\n */\n fixAttachContents(contents: any): any {\n assert(typeof contents === \"object\", 0x08b /* \"Unexpected type on contents for fix of an attach!\" */);\n if (!this.objectMatchesSchema(contents, attachContentsSchema)) {\n this.replaceObject(contents);\n } else {\n if (this.fullScrub) {\n contents.id = this.replaceText(contents.id, TextType.FluidObject);\n contents.type = this.replaceText(contents.type, TextType.FluidObject);\n }\n\n this.fixAttachEntries(contents.snapshot.entries);\n }\n }\n\n /**\n * Fix an attach message at the root level or a ContainerMessageType attach. Attach\n * messages found within an op message should instead have their contents parsed out\n * and sent to fixAttachContents.\n * @param message - The attach message to fix\n * @param withinOp - If the message is from within an op message (as opposed to being\n * an attach message at the root level). Root level attach messages have \"snapshot\"\n * under a \"contents\" key, whereas attach messages from within an op message have it\n * under a \"content\" key\n */\n fixAttach(message: any) {\n // Handle case where contents is stringified json\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n this.fixAttachContents(data);\n message.contents = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n this.fixAttachContents(message.contents);\n }\n }\n\n fixDeltaOp(deltaOp: any) {\n if (typeof deltaOp.seg === \"string\") {\n deltaOp.seg = this.replaceText(deltaOp.seg);\n } else {\n deltaOp.seg = this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);\n }\n }\n\n /**\n * Fix the contents object for an op message. Does not do extra type handling. Does\n * not handle special container message types like \"attach\", \"component\", and\n * \"chunkedOp\" (these should be handled by the caller)\n * @param contents - The contents object for an op message. If it was a string in the\n * message, it must have been converted to an object first\n */\n fixOpContentsObject(contents: any) {\n // do replacement\n if (!this.objectMatchesSchema(contents, opContentsSchema)) {\n this.replaceAny(contents);\n } else {\n if (this.fullScrub) {\n contents.address = this.replaceText(contents.address, TextType.FluidObject);\n }\n\n const innerContent = contents.contents.content;\n assert(innerContent !== undefined, 0x08c /* \"innerContent for fixing op contents is undefined!\" */);\n if (contents.contents.type === \"attach\") {\n // attach op\n // handle case where inner content is stringified json\n if (typeof contents.contents.content === \"string\") {\n try {\n const data = JSON.parse(contents.contents.content);\n this.fixAttachContents(data);\n contents.contents.content = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n this.fixAttachContents(contents.contents.content);\n }\n } else if (this.validator.validate(innerContent, opContentsMapSchema).valid) {\n // map op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else if (this.validator.validate(innerContent, opContentsMergeTreeGroupOpSchema).valid) {\n // merge tree group op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n innerContent.contents.ops.forEach((deltaOp) => {\n this.fixDeltaOp(deltaOp);\n });\n } else if (this.validator.validate(innerContent, opContentsMergeTreeDeltaOpSchema).valid) {\n // merge tree delta op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n this.fixDeltaOp(innerContent.contents);\n } else if (this.validator.validate(innerContent, opContentsRegisterCollectionSchema).valid) {\n // register collection op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else {\n // message contents don't match any known op format\n this.objectMatchesSchema(contents, false);\n }\n }\n }\n\n fixOp(message: any) {\n // handle case where contents is stringified json\n let msgContents;\n if (typeof message.contents === \"string\") {\n try {\n msgContents = JSON.parse(message.contents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n msgContents = message.contents;\n }\n\n // handle container message types\n switch (msgContents.type) {\n case \"attach\": {\n // this one is like a regular attach op, except its contents aren't nested as deep\n // run fixAttach directly and return\n this.fixAttach(msgContents);\n break;\n }\n case \"component\": {\n // this one functionally nests its contents one layer deeper\n // bring up the contents object and continue as usual\n this.fixOpContentsObject(msgContents.contents);\n break;\n }\n case \"chunkedOp\": {\n // this is a (regular?) op split into multiple parts due to size, e.g. because it\n // has an attached image, and where the chunkedOp is within the top-level op's contents\n // (as opposed to being at the top-level). The contents of the chunks need to be\n // concatenated to form the complete stringified json object\n // Early return here to skip re-stringify because no changes are made until the last\n // chunk, and the ChunkedOpProcessor will handle everything at that point\n return this.fixChunkedOp(message);\n }\n case \"blobAttach\": {\n // TODO: handle this properly once blob api is used\n this.debugMsg(\"TODO: blobAttach ops are skipped/unhandled\");\n return;\n }\n default: {\n // A regular op\n this.fixOpContentsObject(msgContents);\n }\n }\n\n // re-stringify the json if needed\n if (typeof message.contents === \"string\") {\n try {\n message.contents = JSON.stringify(msgContents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n }\n }\n\n /**\n * @param message - The top-level chunkedOp message or a top-level op message\n * with a chunkedOp inside its contents\n */\n fixChunkedOp(message: any) {\n this.chunkProcessor.addMessage(message);\n if (!this.chunkProcessor.hasAllMessages()) {\n return;\n }\n\n const contents = this.chunkProcessor.getConcatenatedContents();\n this.fixOpContentsObject(contents);\n\n this.chunkProcessor.writeSanitizedContents(contents);\n this.chunkProcessor.reset();\n }\n\n sanitize(): ISequencedDocumentMessage[] {\n let seq = 0;\n\n try {\n this.messages.map((message) => {\n seq = message.sequenceNumber;\n // message types from protocol-definitions' protocol.ts\n switch (message.type) {\n case \"join\": {\n this.fixJoin(message);\n break;\n }\n case \"propose\": {\n this.fixPropose(message);\n break;\n }\n case \"attach\": {\n this.fixAttach(message);\n break;\n }\n case \"op\": {\n this.fixOp(message);\n break;\n }\n case \"chunkedOp\": {\n this.fixChunkedOp(message);\n break;\n }\n case \"noop\":\n case \"leave\":\n case \"noClient\":\n case \"summarize\":\n case \"summaryAck\":\n case \"summaryNack\":\n break;\n default:\n this.debugMsg(`Unexpected op type ${message.type}`);\n }\n });\n\n // make sure we don't miss an incomplete chunked op at the end\n assert(!this.chunkProcessor.isPendingProcessing(), 0x08d /* \"After sanitize, pending incomplete ops!\" */);\n } catch (error) {\n this.debugMsg(`Error while processing sequenceNumber ${seq}`);\n throw error;\n }\n\n return this.messages;\n }\n}\n"]}
1
+ {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gCAAgC,EAChC,gCAAgC,EAChC,kCAAkC,EAClC,qBAAqB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,IAAK,QAMJ;AAND,WAAK,QAAQ;IACT,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,qDAAW,CAAA;IACX,2CAAM,CAAA;AACV,CAAC,EANI,QAAQ,KAAR,QAAQ,QAMZ;AAED,sEA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AA8D;YAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAC7G;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This tool cleans up a message.json file downloaded through fluid-fetch to remove\n * user content and user identifying information. Enough information can be retained\n * to allow loading through Fluid Preview, or everything can be scrubbed so that only\n * replay-tool can read the result. Anonymous identifying information such as client\n * IDs are always retained. Object keys are NOT scrubbed, including those that are\n * nested within values (only leaf values are scrubbed).\n *\n * Note: While user content/information is scrubbed, it should not be assumed to be\n * fully anonymized because certain meta-information (such as word lengths and\n * consistent replacement) are preserved.\n *\n * Messages must match known structures when scrubbing for Fluid Preview.\n */\n\nimport * as Validator from \"jsonschema\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n attachContentsSchema,\n chunkedOpContentsSchema,\n joinContentsSchema,\n joinDataSchema,\n opContentsMapSchema,\n opContentsSchema,\n opContentsMergeTreeDeltaOpSchema,\n opContentsMergeTreeGroupOpSchema,\n opContentsRegisterCollectionSchema,\n proposeContentsSchema,\n} from \"./messageSchema\";\n\nenum TextType {\n Generic,\n Email,\n Name,\n FluidObject,\n MapKey,\n}\n\n// Workaround to jsonschema package not supporting \"false\" as a schema\n// that matches nothing\nconst falseResult = {\n valid: false,\n toString: () => { return \"Unmatched format\"; },\n};\n\n/**\n * Class that takes chunkedOp messages and can provide their concatenated\n * contents along with re-write sanitized content in-place back into the\n * messages. Assumes sanitized messages are always less than or equal in\n * size to the original message.\n */\nclass ChunkedOpProcessor {\n /**\n * Message references so we can replace their contents in-place. These can\n * be top-level chunkedOp messages, or top-level op messages with a chunkedOp\n * within the contents\n */\n private messages = new Array<any>();\n /**\n * The messages' parsed contents for processing. Should parallel the\n * messages member\n */\n private parsedMessageContents = new Array<any>();\n private writtenBack = false;\n /**\n * keep track of the total starting length to make sure we don't somehow end\n * up with more content than we started with (meaning we may not be able to\n * write it back)\n */\n private concatenatedLength = 0;\n\n constructor(\n readonly validateSchemaFn: (object: any, schema: any) => boolean,\n readonly debug: boolean,\n ) { }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n addMessage(message: any): void {\n this.messages.push(message);\n\n let parsed;\n try {\n parsed = JSON.parse(message.contents);\n if (message.type === \"op\") {\n // nested within a regular op\n // need to go deeper to get the desired contents\n parsed = parsed.contents;\n }\n } catch (e) {\n this.debugMsg(e);\n this.debugMsg(message.contents);\n }\n this.validateSchemaFn(parsed, chunkedOpContentsSchema);\n this.parsedMessageContents.push(parsed);\n }\n\n hasAllMessages(): boolean {\n const lastMsgContents = this.parsedMessageContents[this.parsedMessageContents.length - 1];\n return lastMsgContents.chunkId !== undefined && lastMsgContents.chunkId === lastMsgContents.totalChunks;\n }\n\n /**\n * @returns The concatenated contents of all the messages parsed as json\n */\n getConcatenatedContents(): any {\n const contentsString = this.parsedMessageContents.reduce((previousValue: string, currentValue: any) => {\n return previousValue + (currentValue.contents as string);\n }, \"\");\n\n this.concatenatedLength = contentsString.length;\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(contentsString);\n } catch (e) {\n this.debugMsg(contentsString);\n this.debugMsg(e);\n return undefined;\n }\n }\n\n /**\n * Write back sanitized contents into the messages. The contents are\n * stringified, split up, and written in place to the messages that\n * were added earlier. The number of messages is preserved.\n * @param contents - Sanitized contents to write back\n */\n writeSanitizedContents(contents: any): void {\n // Write back a chunk size equal to the original\n const chunkSize = this.parsedMessageContents[0].contents.length;\n\n let stringified: string;\n try {\n stringified = JSON.stringify(contents);\n assert(stringified.length <= this.concatenatedLength,\n 0x089 /* \"Stringified length of chunk contents > total starting length\" */);\n } catch (e) {\n this.debugMsg(e);\n throw e;\n }\n\n for (let i = 0; i < this.messages.length; i++) {\n const substring = stringified.substring(i * chunkSize, (i + 1) * chunkSize);\n\n const parsedContents = this.parsedMessageContents[i];\n parsedContents.contents = substring;\n const message = this.messages[i];\n\n let stringifiedParsedContents;\n try {\n // for nested chunkedOps, we need to recreate the extra nesting layer\n // we removed earlier when adding the message\n if (message.type === \"op\") {\n const nestingLayer = {\n type: \"chunkedOp\",\n contents: parsedContents,\n };\n stringifiedParsedContents = JSON.stringify(nestingLayer);\n } else {\n stringifiedParsedContents = JSON.stringify(parsedContents);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n\n message.contents = stringifiedParsedContents;\n }\n\n this.writtenBack = true;\n }\n\n reset(): void {\n assert(this.writtenBack, 0x08a /* \"resetting ChunkedOpProcessor that never wrote back its contents\" */);\n this.messages = new Array<any>();\n this.parsedMessageContents = new Array<any>();\n this.writtenBack = false;\n this.concatenatedLength = 0;\n }\n\n isPendingProcessing(): boolean {\n return this.messages.length !== 0;\n }\n}\n\nexport class Sanitizer {\n readonly validator = new Validator.Validator();\n // Represents the keys used to store Fluid object identifiers, snapshot info,\n // and other string fields that should not be replaced in contents blobs to\n // ensure the messages are still usable\n readonly defaultExcludedKeys = new Set<string>();\n // Represents the keys used by merge-tree ops their \"seg\" property, where other\n // keys represent user information\n readonly mergeTreeExcludedKeys = new Set<string>();\n // Map of user information to what it was replaced with. Used to ensure the same\n // data have the same replacements\n readonly replacementMap = new Map<string, string>();\n\n /**\n * Validate that the provided message matches the provided schema.\n * For a full scrub, warn and continue (scrubber should fully sanitize unexpected\n * fields for ops), otherwise throw an error because we cannot be sure user\n * information is being sufficiently sanitized.\n */\n objectMatchesSchema = (object: any, schema: any): boolean => {\n const result = schema === false ? falseResult : this.validator.validate(object, schema);\n if (!result.valid) {\n const errorMsg = `Bad msg fmt:\\n${result.toString()}\\n${JSON.stringify(object, undefined, 2)}`;\n\n if (this.fullScrub || this.noBail) {\n this.debugMsg(errorMsg);\n } else {\n throw new Error(errorMsg);\n }\n }\n return result.valid;\n };\n\n readonly chunkProcessor = new ChunkedOpProcessor(this.objectMatchesSchema, this.debug);\n\n constructor(\n readonly messages: ISequencedDocumentMessage[],\n readonly fullScrub: boolean,\n readonly noBail: boolean,\n readonly debug: boolean = false,\n ) {\n this.defaultExcludedKeys.add(\"type\");\n this.defaultExcludedKeys.add(\"id\");\n this.defaultExcludedKeys.add(\"pkg\");\n this.defaultExcludedKeys.add(\"snapshotFormatVersion\");\n this.defaultExcludedKeys.add(\"packageVersion\");\n this.mergeTreeExcludedKeys.add(\"nodeType\");\n }\n\n debugMsg(msg: any) {\n if (this.debug) {\n console.error(msg);\n }\n }\n\n isFluidObjectKey(key: string): boolean {\n return key === \"type\" || key === \"id\";\n }\n\n getRandomText(len: number): string {\n let str = \"\";\n while (str.length < len) {\n str = str + Math.random().toString(36).substring(2);\n }\n return str.substr(0, len);\n }\n\n readonly wordTokenRegex = /\\S+/g;\n\n readonly replaceRandomTextFn = (match: string): string => {\n if (this.replacementMap.has(match)) {\n return this.replacementMap.get(match)!;\n }\n\n const replacement = this.getRandomText(match.length);\n this.replacementMap.set(match, replacement);\n return replacement;\n };\n\n /**\n * Replace text with garbage. FluidObject types are not replaced when not under\n * full scrub mode. All other text is replaced consistently.\n */\n replaceText(input?: string, type: TextType = TextType.Generic): string | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (type === TextType.FluidObject) {\n if (this.replacementMap.has(input)) {\n return this.replacementMap.get(input)!;\n }\n\n const replacement = this.fullScrub ? this.getRandomText(input.length) : input;\n\n this.replacementMap.set(input, replacement);\n return replacement;\n }\n\n return input.replace(this.wordTokenRegex, this.replaceRandomTextFn);\n }\n\n replaceArray(input: any[]): any[] {\n for (let i = 0; i < input.length; i++) {\n const value = input[i];\n if (typeof value === \"string\") {\n input[i] = this.replaceText(value);\n } else if (Array.isArray(value)) {\n input[i] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[i] = this.replaceObject(value);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n /**\n * (sort of) recurses down the values of a JSON object to sanitize all its strings\n * (only checks strings, arrays, and objects)\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n replaceObject(input: object | null, excludedKeys: Set<string> = this.defaultExcludedKeys): object | null {\n // File might contain actual nulls\n if (input === null || input === undefined) {\n return input;\n }\n\n const keys = Object.keys(input);\n keys.forEach((key) => {\n if (this.fullScrub || !excludedKeys.has(key)) {\n const value = input[key];\n if (typeof value === \"string\") {\n input[key] = this.replaceText(\n value,\n this.isFluidObjectKey(key) ? TextType.FluidObject : TextType.Generic,\n );\n } else if (Array.isArray(value)) {\n input[key] = this.replaceArray(value);\n } else if (typeof value === \"object\") {\n input[key] = this.replaceObject(value, excludedKeys);\n }\n }\n });\n return input;\n }\n\n /**\n * Replacement on an unknown type or a parsed root level object\n * without a key\n * @param input - The object to sanitize\n * @param excludedKeys - object keys for which to skip replacement when not in fullScrub\n */\n replaceAny(input: any, excludedKeys: Set<string> = this.defaultExcludedKeys): any {\n if (input === null || input === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n if (typeof input === \"string\") {\n return this.replaceText(input);\n } else if (Array.isArray(input)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.replaceArray(input);\n } else if (typeof input === \"object\") {\n return this.replaceObject(input, excludedKeys);\n }\n\n // Don't run replacement on any other types\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return input;\n }\n\n fixJoin(message: any) {\n if (!this.objectMatchesSchema(message.contents, joinContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n }\n\n try {\n let data = JSON.parse(message.data);\n if (!this.objectMatchesSchema(data, joinDataSchema)) {\n data = this.replaceAny(data);\n } else {\n const user = data.detail.user;\n user.id = this.replaceText(user.id, TextType.Email);\n user.email = this.replaceText(user.email, TextType.Email);\n user.name = this.replaceText(user.name, TextType.Name);\n }\n\n message.data = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n }\n\n fixPropose(message: any) {\n if (!this.objectMatchesSchema(message.contents, proposeContentsSchema)) {\n message.contents = this.replaceAny(message.contents);\n } else {\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n if (this.fullScrub) {\n const pkg = data.value?.package;\n if (pkg?.name) {\n pkg.name = this.replaceText(pkg.name, TextType.FluidObject);\n }\n if (Array.isArray(pkg?.fluid?.browser?.umd?.files)) {\n pkg.fluid.browser.umd.files = this.replaceArray(pkg.fluid.browser.umd.files);\n }\n }\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n if (this.fullScrub) {\n message.contents.value = this.replaceText(message.contents.value, TextType.FluidObject);\n }\n }\n }\n }\n\n fixAttachEntries(entries: any[]) {\n entries.forEach((element) => {\n // Tree type\n if (element.value.entries) {\n this.fixAttachEntries(element.value.entries);\n } else {\n // Blob (leaf) type\n try {\n if (typeof element.value.contents === \"string\") {\n let data = JSON.parse(element.value.contents);\n data = this.replaceObject(data);\n element.value.contents = JSON.stringify(data);\n }\n } catch (e) {\n this.debugMsg(e);\n }\n }\n });\n }\n\n /**\n * Fix the content of an attach in place\n * @param contents - contents object to fix\n */\n fixAttachContents(contents: any): any {\n assert(typeof contents === \"object\", 0x08b /* \"Unexpected type on contents for fix of an attach!\" */);\n if (!this.objectMatchesSchema(contents, attachContentsSchema)) {\n this.replaceObject(contents);\n } else {\n if (this.fullScrub) {\n contents.id = this.replaceText(contents.id, TextType.FluidObject);\n contents.type = this.replaceText(contents.type, TextType.FluidObject);\n }\n\n this.fixAttachEntries(contents.snapshot.entries);\n }\n }\n\n /**\n * Fix an attach message at the root level or a ContainerMessageType attach. Attach\n * messages found within an op message should instead have their contents parsed out\n * and sent to fixAttachContents.\n * @param message - The attach message to fix\n * @param withinOp - If the message is from within an op message (as opposed to being\n * an attach message at the root level). Root level attach messages have \"snapshot\"\n * under a \"contents\" key, whereas attach messages from within an op message have it\n * under a \"content\" key\n */\n fixAttach(message: any) {\n // Handle case where contents is stringified json\n if (typeof message.contents === \"string\") {\n try {\n const data = JSON.parse(message.contents);\n this.fixAttachContents(data);\n message.contents = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n this.fixAttachContents(message.contents);\n }\n }\n\n fixDeltaOp(deltaOp: any) {\n deltaOp.seg = typeof deltaOp.seg === \"string\"\n ? this.replaceText(deltaOp.seg)\n : this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);\n }\n\n /**\n * Fix the contents object for an op message. Does not do extra type handling. Does\n * not handle special container message types like \"attach\", \"component\", and\n * \"chunkedOp\" (these should be handled by the caller)\n * @param contents - The contents object for an op message. If it was a string in the\n * message, it must have been converted to an object first\n */\n fixOpContentsObject(contents: any) {\n // do replacement\n if (!this.objectMatchesSchema(contents, opContentsSchema)) {\n this.replaceAny(contents);\n } else {\n if (this.fullScrub) {\n contents.address = this.replaceText(contents.address, TextType.FluidObject);\n }\n\n const innerContent = contents.contents.content;\n assert(innerContent !== undefined, 0x08c /* \"innerContent for fixing op contents is undefined!\" */);\n if (contents.contents.type === \"attach\") {\n // attach op\n // handle case where inner content is stringified json\n if (typeof contents.contents.content === \"string\") {\n try {\n const data = JSON.parse(contents.contents.content);\n this.fixAttachContents(data);\n contents.contents.content = JSON.stringify(data);\n } catch (e) {\n this.debugMsg(e);\n }\n } else {\n this.fixAttachContents(contents.contents.content);\n }\n } else if (this.validator.validate(innerContent, opContentsMapSchema).valid) {\n // map op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else if (this.validator.validate(innerContent, opContentsMergeTreeGroupOpSchema).valid) {\n // merge tree group op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n innerContent.contents.ops.forEach((deltaOp) => {\n this.fixDeltaOp(deltaOp);\n });\n } else if (this.validator.validate(innerContent, opContentsMergeTreeDeltaOpSchema).valid) {\n // merge tree delta op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n }\n this.fixDeltaOp(innerContent.contents);\n } else if (this.validator.validate(innerContent, opContentsRegisterCollectionSchema).valid) {\n // register collection op\n if (this.fullScrub) {\n innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);\n innerContent.contents.key = this.replaceText(innerContent.contents.key, TextType.MapKey);\n }\n if (innerContent.contents.value !== undefined) {\n innerContent.contents.value.value = this.replaceAny(innerContent.contents.value.value);\n }\n } else {\n // message contents don't match any known op format\n this.objectMatchesSchema(contents, false);\n }\n }\n }\n\n fixOp(message: any) {\n // handle case where contents is stringified json\n let msgContents;\n if (typeof message.contents === \"string\") {\n try {\n msgContents = JSON.parse(message.contents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n } else {\n msgContents = message.contents;\n }\n\n // handle container message types\n switch (msgContents.type) {\n case \"attach\": {\n // this one is like a regular attach op, except its contents aren't nested as deep\n // run fixAttach directly and return\n this.fixAttach(msgContents);\n break;\n }\n case \"component\": {\n // this one functionally nests its contents one layer deeper\n // bring up the contents object and continue as usual\n this.fixOpContentsObject(msgContents.contents);\n break;\n }\n case \"chunkedOp\": {\n // this is a (regular?) op split into multiple parts due to size, e.g. because it\n // has an attached image, and where the chunkedOp is within the top-level op's contents\n // (as opposed to being at the top-level). The contents of the chunks need to be\n // concatenated to form the complete stringified json object\n // Early return here to skip re-stringify because no changes are made until the last\n // chunk, and the ChunkedOpProcessor will handle everything at that point\n return this.fixChunkedOp(message);\n }\n case \"blobAttach\": {\n // TODO: handle this properly once blob api is used\n this.debugMsg(\"TODO: blobAttach ops are skipped/unhandled\");\n return;\n }\n default: {\n // A regular op\n this.fixOpContentsObject(msgContents);\n }\n }\n\n // re-stringify the json if needed\n if (typeof message.contents === \"string\") {\n try {\n message.contents = JSON.stringify(msgContents);\n } catch (e) {\n this.debugMsg(e);\n return;\n }\n }\n }\n\n /**\n * @param message - The top-level chunkedOp message or a top-level op message\n * with a chunkedOp inside its contents\n */\n fixChunkedOp(message: any) {\n this.chunkProcessor.addMessage(message);\n if (!this.chunkProcessor.hasAllMessages()) {\n return;\n }\n\n const contents = this.chunkProcessor.getConcatenatedContents();\n this.fixOpContentsObject(contents);\n\n this.chunkProcessor.writeSanitizedContents(contents);\n this.chunkProcessor.reset();\n }\n\n sanitize(): ISequencedDocumentMessage[] {\n let seq = 0;\n\n try {\n this.messages.map((message) => {\n seq = message.sequenceNumber;\n // message types from protocol-definitions' protocol.ts\n switch (message.type) {\n case \"join\": {\n this.fixJoin(message);\n break;\n }\n case \"propose\": {\n this.fixPropose(message);\n break;\n }\n case \"attach\": {\n this.fixAttach(message);\n break;\n }\n case \"op\": {\n this.fixOp(message);\n break;\n }\n case \"chunkedOp\": {\n this.fixChunkedOp(message);\n break;\n }\n case \"noop\":\n case \"leave\":\n case \"noClient\":\n case \"summarize\":\n case \"summaryAck\":\n case \"summaryNack\":\n break;\n default:\n this.debugMsg(`Unexpected op type ${message.type}`);\n }\n });\n\n // make sure we don't miss an incomplete chunked op at the end\n assert(!this.chunkProcessor.isPendingProcessing(), 0x08d /* \"After sanitize, pending incomplete ops!\" */);\n } catch (error) {\n this.debugMsg(`Error while processing sequenceNumber ${seq}`);\n throw error;\n }\n\n return this.messages;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/debugger",
3
- "version": "2.0.0-internal.1.2.0.93071",
3
+ "version": "2.0.0-internal.1.2.1",
4
4
  "description": "Fluid Debugger - a tool to play through history of a file",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -34,17 +34,17 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@fluidframework/common-utils": "^1.0.0",
37
- "@fluidframework/driver-definitions": "2.0.0-internal.1.2.0.93071",
38
- "@fluidframework/driver-utils": "2.0.0-internal.1.2.0.93071",
37
+ "@fluidframework/driver-definitions": "^2.0.0-internal.1.2.1",
38
+ "@fluidframework/driver-utils": "^2.0.0-internal.1.2.1",
39
39
  "@fluidframework/protocol-definitions": "^1.0.0",
40
- "@fluidframework/replay-driver": "2.0.0-internal.1.2.0.93071",
40
+ "@fluidframework/replay-driver": "^2.0.0-internal.1.2.1",
41
41
  "jsonschema": "^1.2.6"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@fluidframework/build-common": "^1.0.0",
45
45
  "@fluidframework/build-tools": "^0.4.4000",
46
46
  "@fluidframework/debugger-previous": "npm:@fluidframework/debugger@^1.1.0",
47
- "@fluidframework/eslint-config-fluid": "^0.28.2000",
47
+ "@fluidframework/eslint-config-fluid": "^1.0.0",
48
48
  "@microsoft/api-extractor": "^7.22.2",
49
49
  "@rushstack/eslint-config": "^2.5.1",
50
50
  "@types/mocha": "^9.1.1",
@@ -8,6 +8,7 @@ import { ReplayDocumentService, ReplayDocumentServiceFactory } from "@fluidframe
8
8
  import { DebugReplayController } from "./fluidDebuggerController";
9
9
  import { DebuggerUI } from "./fluidDebuggerUi";
10
10
 
11
+ // eslint-disable-next-line @typescript-eslint/no-namespace
11
12
  export namespace FluidDebugger {
12
13
  /**
13
14
  * Creates document service wrapper that pops up Debugger window and allows user to play ops one by one.
@@ -232,11 +232,9 @@ export class DebuggerUI {
232
232
  this.versions = versions;
233
233
  for (const version of versions) {
234
234
  const option = document.createElement("option");
235
- if (version.date !== undefined) {
236
- option.text = `id = ${version.id}, time = ${version.date}`;
237
- } else {
238
- option.text = `id = ${version.id}`;
239
- }
235
+ option.text = version.date !== undefined
236
+ ? `id = ${version.id}, time = ${version.date}`
237
+ : `id = ${version.id}`;
240
238
  this.selector.add(option);
241
239
  }
242
240
  }
@@ -251,12 +249,9 @@ export class DebuggerUI {
251
249
  }
252
250
 
253
251
  public versionSelected(seqNumber: number, version: IVersion | string) {
254
- let text: string;
255
- if (typeof version === "string") {
256
- text = `Playing ${version} file`;
257
- } else {
258
- text = `Playing from ${version.id}, seq# ${seqNumber}`;
259
- }
252
+ const text = typeof version === "string"
253
+ ? `Playing ${version} file`
254
+ : `Playing from ${version.id}, seq# ${seqNumber}`;
260
255
 
261
256
  this.wasVersionSelected = true;
262
257
  this.selector = undefined;
@@ -314,15 +309,9 @@ export class DebuggerUI {
314
309
  }
315
310
 
316
311
  public updateLastOpText(lastKnownOp: number, stillLoading: boolean) {
317
- let text: string;
318
- if (lastKnownOp < 0) {
319
- text = `FluidDebugger can't play ops in this mode`;
320
- }
321
- if (stillLoading) {
322
- text = `Last op (still loading): ${lastKnownOp}`;
323
- } else {
324
- text = `Document's last op seq#: ${lastKnownOp}`;
325
- }
312
+ const text = stillLoading
313
+ ? `Last op (still loading): ${lastKnownOp}`
314
+ : `Document's last op seq#: ${lastKnownOp}`;
326
315
  this.lastOpText!.textContent = text;
327
316
  }
328
317
 
package/src/sanitizer.ts CHANGED
@@ -287,12 +287,7 @@ export class Sanitizer {
287
287
  return this.replacementMap.get(input)!;
288
288
  }
289
289
 
290
- let replacement: string;
291
- if (this.fullScrub) {
292
- replacement = this.getRandomText(input.length);
293
- } else {
294
- replacement = input;
295
- }
290
+ const replacement = this.fullScrub ? this.getRandomText(input.length) : input;
296
291
 
297
292
  this.replacementMap.set(input, replacement);
298
293
  return replacement;
@@ -488,11 +483,9 @@ export class Sanitizer {
488
483
  }
489
484
 
490
485
  fixDeltaOp(deltaOp: any) {
491
- if (typeof deltaOp.seg === "string") {
492
- deltaOp.seg = this.replaceText(deltaOp.seg);
493
- } else {
494
- deltaOp.seg = this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
495
- }
486
+ deltaOp.seg = typeof deltaOp.seg === "string"
487
+ ? this.replaceText(deltaOp.seg)
488
+ : this.replaceObject(deltaOp.seg, this.mergeTreeExcludedKeys);
496
489
  }
497
490
 
498
491
  /**