mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
* introduce extension service * deprecate legacy forwarder types * eliminate repeat algorithm emissions * extend logging to preference management * align forwarder ids with vendor ids * fix duplicate policy emissions; debugging required logger enhancements ----- Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
32 lines
953 B
TypeScript
32 lines
953 B
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { Jsonify } from "type-fest";
|
|
|
|
import { Classifier } from "./state/classifier";
|
|
|
|
export class PublicClassifier<Data> implements Classifier<Data, Data, Record<string, never>> {
|
|
constructor(private keys: (keyof Jsonify<Data>)[]) {}
|
|
|
|
classify(value: Data): { disclosed: Jsonify<Data>; secret: Jsonify<Record<string, never>> } {
|
|
const pickMe = JSON.parse(JSON.stringify(value));
|
|
|
|
const picked: Partial<Jsonify<Data>> = {};
|
|
for (const key of this.keys) {
|
|
picked[key] = pickMe[key];
|
|
}
|
|
const disclosed = picked as Jsonify<Data>;
|
|
|
|
return { disclosed, secret: null };
|
|
}
|
|
|
|
declassify(disclosed: Jsonify<Data>, _secret: Jsonify<Record<keyof Data, never>>) {
|
|
const result: Partial<Jsonify<Data>> = {};
|
|
|
|
for (const key of this.keys) {
|
|
result[key] = disclosed[key];
|
|
}
|
|
|
|
return result as Jsonify<Data>;
|
|
}
|
|
}
|