Skip to main content

Interface.ClientShareProvider

Represents a storage provider for the client share.

The purpose of ClientShareProvider is to provide an interface that allows integrators to save and restore the client share of their customers. The integrator has the responsibility to securely store the client share.

Remarks​

The client share is not considered sensitive data because only the client can use it, and its usage is secured by strong authentication between the client and the Keyban services.

Example Implementation​

Below is a basic implementation of a CustomClientShareProvider using a fetch-based provider:

class CustomClientShareProvider implements ClientShareProvider {
// Retrieves the client share data.
async get(): Promise<string | null> {
try {
const response = await fetch("/api/clientShare", {
method: "GET",
headers: { "Content-Type": "application/json" },
});

if (!response.ok) {
console.error("Failed to fetch client share:", response.statusText);
return null;
}

return response.text();
} catch (error) {
console.error("Error retrieving client share:", error);
return null;
}
}

// Saves the client share data.
async set(clientShare: string): Promise<void> {
try {
const response = await fetch("/api/clientShare", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ clientShare }),
});

if (!response.ok) {
throw new Error(`Failed to save client share: ${response.statusText}`);
}
} catch (error) {
console.error("Error saving client share:", error);
throw error;
}
}
}

This implementation assumes the existence of an API endpoint /api/clientShare to manage the client share on the server side. The integrator should ensure that the endpoint is appropriately secured.

Methods​

get()​

get(key: string): Promise<string | null>;

Retrieves the client share information.

Parameters​

ParameterTypeDescription
keystringThe key associated with the client share.

Returns​

Promise<string | null>

  • A promise that resolves to a string containing the client share, or null if not available.

set()​

set(key: string, clientShare: string): Promise<unknown>;

Sets the client share information.

Parameters​

ParameterTypeDescription
keystringThe key associated with the client share.
clientSharestringThe client share string to set.

Returns​

Promise<unknown>

  • A promise that resolves when the client share has been set.