Class: TrustBrowserManager
The BrowserRegistrationManager
(or TrustBrowserManager
as it's named in the code) is responsible for managing trusted browsers within an application. It allows the system to recognize, register, and manage browsers that are deemed secure and trusted for accessing the system. The manager supports operations such as retrieving a list of trusted browsers, adding a new trusted browser, enabling or disabling browser access, and removing browsers from the trusted list.
The core functionality revolves around creating and managing trusted browser instances, including decrypting browser fingerprints to ensure secure operations. This is useful for applications that need to track and manage which browsers can access sensitive information, improving security by allowing administrators to control browser access based on trust levels.
Method: getList
The getList()
method retrieves the list of all registered and trusted browsers associated with the user or the system.
-
Purpose: This method is used to fetch the list of browsers that a user has previously registered as trusted. This list allows the system to verify if a request is coming from one of the trusted browsers, providing an extra layer of security.
-
Parameters: This method does not accept any parameters.
-
Returns:
Promise<OperationDataResult<TrustBrowser[]>>
:- Success: Returns an
OperationDataResult
object containing an array of trusted browsers (TrustBrowser[]
). - Failure: Returns an
OperationDataResult
object with an error message indicating the failure reason, such as an unexpected error.
- Success: Returns an
Usage Example
const result = await agent.trustBrowserManager.getList();
if (result.isSuccessful) {
console.log('List of trusted browsers:', result.result);
} else {
console.error('Failed to fetch trusted browsers:', result.error);
}
Example Output (Success)
{
"isSuccessful": true,
"result": [
{
"id": "12345",
"fingerprint": "unique-fingerprint-1",
"createdAt": "2023-08-15T10:00:00.000Z",
"isEnabled": true
},
{
"id": "67890",
"fingerprint": "unique-fingerprint-2",
"createdAt": "2023-09-10T12:30:00.000Z",
"isEnabled": false
}
]
}
Common Use Cases
- Displaying Trusted Browsers: The result can be used to display a list of all browsers the user has registered as trusted in a user interface.
- Browser Validation: The system can use this list to check if the browser sending a request is in the trusted list, ensuring secure access.
Method: create
The create()
method is used to register a new browser as trusted by saving its fingerprint and a display name to the system.
-
Purpose: This method allows users to add a new trusted browser to their account by providing the browser’s fingerprint and a user-friendly display name. Once registered, the browser can be used for secure flows, and the system will be able to identify and trust requests coming from it.
-
Parameters:
model: CreateTrustBrowser
fingerprint: string
— The unique fingerprint identifier of the browser. This is typically a unique hash generated by the browser to identify it.displayName: string
— A user-friendly name for the browser (e.g., "My Home Laptop" or "Work PC").
-
Returns:
Promise<OperationResult>
- Success: Returns
true
in theOperationResult
object, indicating the browser was successfully registered. - Failure: Returns
false
in theOperationResult
object, along with an error message explaining why the registration failed (e.g., unexpected error or service failure).
- Success: Returns
Usage Example
const newBrowser = {
fingerprint: "unique-browser-fingerprint",
displayName: "My Work Laptop"
};
const result = await agent.trustBrowserManager.create(newBrowser);
if (result.isSuccessful) {
console.log("Browser successfully registered as trusted.");
} else {
console.error("Failed to register browser:", result.error);
}
Example Output (Success)
{
"isSuccessful": true
}
Common Use Cases
- Browser Registration: When a user wants to securely register a new browser as trusted, ensuring future interactions from this browser are recognized as safe.
- Enhanced Security: By adding the browser fingerprint to the system, the application can ensure that only trusted browsers are used for specific actions or flows.
Method: decrypt
The decrypt()
method is used to decrypt an encrypted browser fingerprint using a passphrase. This is useful in scenarios where the fingerprint has been encrypted for security purposes and needs to be decrypted for verification or processing.
-
Purpose: This method decrypts an encrypted fingerprint associated with a browser, allowing the application to compare or use the decrypted fingerprint for further operations.
-
Parameters:
cipherText: string
— The encrypted fingerprint that needs to be decrypted.passphrase: string
— The passphrase used to decrypt the fingerprint.
-
Returns:
Promise<OperationDataResult<string>>
- Success: Returns
true
in theOperationDataResult
object along with the decrypted fingerprint. - Failure: Returns
false
in theOperationDataResult
object, with an error message explaining why the decryption failed (e.g., incorrect passphrase, unexpected error).
- Success: Returns
Usage Example
const encryptedFingerprint = "someEncryptedFingerprintString";
const passphrase = "securePassphrase";
const result = await agent.trustBrowserManager.decrypt(encryptedFingerprint, passphrase);
if (result.isSuccessful) {
console.log("Decrypted fingerprint:", result.result);
} else {
console.error("Failed to decrypt fingerprint:", result.error);
}
Example Output (Success)
{
"isSuccessful": true,
"result": "decrypted-fingerprint-value"
}
Common Use Cases
- Fingerprint Verification: When the system stores encrypted fingerprints for security and needs to decrypt them for comparison or validation.
- Secure Data Handling: Ensuring that sensitive data, like browser fingerprints, can only be accessed by decrypting with a secure passphrase.
Method: enable
The enable()
method activates a trusted browser by its unique identifier, allowing it to be recognized and used in secure operations, such as proof requests or sensitive workflows.
-
Purpose: This method is used to enable a previously registered browser. Once enabled, the browser can participate in the secure flow of user interactions and be recognized as a trusted entity by the system.
-
Parameters:
id: string
— The unique identifier of the browser to be enabled.
-
Returns:
Promise<OperationResult>
- Success: Returns
true
in theOperationResult
object, indicating that the browser was successfully enabled. - Failure: Returns
false
in theOperationResult
object with an error message if the browser could not be enabled (e.g., due to an unexpected error or invalid ID).
- Success: Returns
Usage Example
const browserId = "some-unique-browser-id";
const result = await agent.trustBrowserManager.enable(browserId);
if (result.isSuccessful) {
console.log("Browser enabled successfully.");
} else {
console.error("Failed to enable browser:", result.error);
}
Example Output (Success)
{
"isSuccessful": true
}
Common Use Cases
- Enabling Trusted Browsers: Ensuring that only browsers explicitly trusted by the user are enabled and can participate in critical flows like logging in or performing proof requests.
- User Browser Management: When users manage their registered browsers, they may need to enable specific browsers to allow secure interaction with the system.
Method: disable
The disable()
method deactivates a trusted browser by its unique identifier, preventing it from being used in secure operations like proof requests or sensitive workflows.
-
Purpose: This method is used to disable a previously registered browser, which prevents it from participating in secure workflows or being recognized as a trusted browser.
-
Parameters:
id: string
— The unique identifier of the browser to be disabled.
-
Returns:
Promise<OperationResult>
- Success: Returns
true
in theOperationResult
object, indicating that the browser was successfully disabled. - Failure: Returns
false
in theOperationResult
object with an error message if the browser could not be disabled (e.g., due to an unexpected error or invalid ID).
- Success: Returns
Usage Example
const browserId = "some-unique-browser-id";
const result = await agent.trustBrowserManager.disable(browserId);
if (result.isSuccessful) {
console.log("Browser disabled successfully.");
} else {
console.error("Failed to disable browser:", result.error);
}
Example Output (Success)
{
"isSuccessful": true
}
Common Use Cases
- Disabling Unused Browsers: Ensuring that browsers no longer in use or untrusted are deactivated to maintain security in the application.
- User Browser Management: Users may disable specific browsers to limit their usage, for instance, if a device is no longer in use or has been compromised.
Method: delete
The delete()
method removes a trusted browser from the system by its unique identifier, ensuring it is no longer recognized or allowed for secure operations like proof requests or sensitive workflows.
-
Purpose: The purpose of this method is to permanently remove a browser from the list of trusted browsers, ensuring it cannot be used in future secure operations.
-
Parameters:
id: string
— The unique identifier of the browser to be deleted.
-
Returns:
Promise<OperationResult>
- Success: Returns
true
in theOperationResult
object, indicating that the browser was successfully deleted. - Failure: Returns
false
in theOperationResult
object with an error message if the browser could not be deleted (e.g., due to an unexpected error or invalid ID).
- Success: Returns
Usage Example
const browserId = "some-unique-browser-id";
const result = await agent.trustBrowserManager.delete(browserId);
if (result.isSuccessful) {
console.log("Browser deleted successfully.");
} else {
console.error("Failed to delete browser:", result.error);
}
Example Output (Success)
{
"isSuccessful": true
}
Common Use Cases
- Removing Untrusted Browsers: Deleting a browser that is no longer trusted due to security concerns or unauthorized access.
- Browser Management: Allowing users or administrators to clean up or manage the list of trusted browsers in the system.