mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[PM-8280] email forwarders (#11563)
* forwarder lookup and generation support * localize algorithm names and descriptions in the credential generator service * add encryption support to UserStateSubject * move generic rx utilities to common * move icon button labels to generator configurations
This commit is contained in:
29
libs/common/src/tools/public-classifier.ts
Normal file
29
libs/common/src/tools/public-classifier.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
import { Classifier } from "@bitwarden/common/tools/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>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user