Add automatic bas64 translation. Now I'll experiment with slicing the
objects into separate string entries
This commit is contained in:
parent
5768ac93d9
commit
c9f3876cf4
@ -1,11 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { getMemory } from "../memory";
|
import { getMemory } from "../memory";
|
||||||
import { RequestCluster } from "../request-cluster";
|
import { RequestCluster } from "../request-cluster";
|
||||||
import {
|
import { MergedStolenDataEntry, Sources } from "../stolen-data-entry";
|
||||||
MergedStolenDataEntry,
|
|
||||||
Sources,
|
|
||||||
StolenDataEntry,
|
|
||||||
} from "../stolen-data-entry";
|
|
||||||
|
|
||||||
import { hyphenate, useEmitter } from "../util";
|
import { hyphenate, useEmitter } from "../util";
|
||||||
|
|
||||||
@ -19,6 +15,14 @@ function StolenDataValueTable({
|
|||||||
prefixKey: string;
|
prefixKey: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
{entry.getDecodingsApplied().includes("base64") ? (
|
||||||
|
<span style={{ color: "white", backgroundColor: "green" }}>
|
||||||
|
"base64"
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{Object.keys(entry.getParsedValues(prefixKey)[0]).map((key) => {
|
{Object.keys(entry.getParsedValues(prefixKey)[0]).map((key) => {
|
||||||
@ -46,6 +50,7 @@ function StolenDataValueTable({
|
|||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@ import { TCModel } from "@iabtcf/core";
|
|||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
import ExtendedRequest, { HAREntry } from "./extended-request";
|
import ExtendedRequest, { HAREntry } from "./extended-request";
|
||||||
import Mark from "./mark";
|
import Mark from "./mark";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getshorthost,
|
getshorthost,
|
||||||
|
isBase64JSON,
|
||||||
isJSONObject,
|
isJSONObject,
|
||||||
isURL,
|
isURL,
|
||||||
parseToObject,
|
parseToObject,
|
||||||
@ -29,12 +31,15 @@ const id = (function* id() {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
export type DecodingSchema = "base64";
|
||||||
|
|
||||||
export class StolenDataEntry extends EventEmitter {
|
export class StolenDataEntry extends EventEmitter {
|
||||||
public isIAB = false;
|
public isIAB = false;
|
||||||
public iab: TCModel | null = null;
|
public iab: TCModel | null = null;
|
||||||
public id: number;
|
public id: number;
|
||||||
public marks: Mark[] = [];
|
public marks: Mark[] = [];
|
||||||
public classification: keyof typeof Classifications;
|
public classification: keyof typeof Classifications;
|
||||||
|
public decoding_applied: DecodingSchema = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public request: ExtendedRequest,
|
public request: ExtendedRequest,
|
||||||
@ -50,6 +55,10 @@ export class StolenDataEntry extends EventEmitter {
|
|||||||
super();
|
super();
|
||||||
this.id = id.next().value as number;
|
this.id = id.next().value as number;
|
||||||
this.classification = this.classify();
|
this.classification = this.classify();
|
||||||
|
if (isBase64JSON(value)) {
|
||||||
|
this.value = atob(value);
|
||||||
|
this.decoding_applied = "base64";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPriority() {
|
getPriority() {
|
||||||
@ -291,4 +300,8 @@ export class MergedStolenDataEntry extends EventEmitter {
|
|||||||
toggleMark(key: string): void {
|
toggleMark(key: string): void {
|
||||||
this.entries.forEach((entry) => entry.toggleMark(key));
|
this.entries.forEach((entry) => entry.toggleMark(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDecodingsApplied(): DecodingSchema[] {
|
||||||
|
return unique(this.entries.map((entry) => entry.decoding_applied));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
util.ts
12
util.ts
@ -171,3 +171,15 @@ export function isSameURL(url1: string, url2: string): boolean {
|
|||||||
url2 = url2.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
url2 = url2.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
||||||
return url1 === url2;
|
return url1 === url2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isBase64(s: string): boolean {
|
||||||
|
try {
|
||||||
|
atob(s);
|
||||||
|
return true;
|
||||||
|
} catch (e) {}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isBase64JSON(s: unknown): s is string {
|
||||||
|
return typeof s === "string" && isBase64(s) && isJSONObject(atob(s));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user