-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added honeypots support on UI in review mode
- Loading branch information
Showing
11 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2024 CVAT.ai Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { SerializedValidationLayout } from 'server-response-types'; | ||
import PluginRegistry from './plugins'; | ||
|
||
export default class ValidationLayout { | ||
#honeypotFrames: number[]; | ||
#honeypotRealFrames: number[]; | ||
|
||
public constructor(data: Required<SerializedValidationLayout>) { | ||
this.#honeypotFrames = [...data.honeypot_frames]; | ||
this.#honeypotRealFrames = [...data.honeypot_real_frames]; | ||
} | ||
|
||
public get honeypotFrames() { | ||
return [...this.#honeypotFrames]; | ||
} | ||
|
||
public get honeypotRealFrames() { | ||
return [...this.#honeypotRealFrames]; | ||
} | ||
|
||
async getRealFrame(frame: number): Promise<number | null> { | ||
const result = await PluginRegistry.apiWrapper.call(this, ValidationLayout.prototype.getRealFrame, frame); | ||
return result; | ||
} | ||
} | ||
|
||
Object.defineProperties(ValidationLayout.prototype.getRealFrame, { | ||
implementation: { | ||
writable: false, | ||
enumerable: false, | ||
value: function implementation(this: ValidationLayout, frame: number): number | null { | ||
const index = this.honeypotFrames.indexOf(frame); | ||
if (index !== -1) { | ||
return this.honeypotRealFrames[index]; | ||
} | ||
|
||
return null; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.