Skip to main content

acceptPendingUserShares()

The acceptPendingUserShares() method in AeonSigner is responsible for checking for any user key shares that have been shared with the AeonSigner’s identity (derived from its EVM key) and subsequently integrating them into the signer’s operational key set after validation. This is a crucial step after an end-user approves sharing their key material with an API User/automated agent running an AeonSigner instance.

Conceptual Workflow

  1. Detection: The method queries a relevant Aeon backend service or a specific on-chain state to find if there are any pending key shares designated for the AeonSigner’s identifier.
  2. Validation & Integration: Before completing acceptance, the method performs a preliminary check to ensure the received share material is valid and can form a functional signature when combined with the AeonSigner’s existing local share. This involves a test signing operation. Upon successful validation, the AeonSigner integrates the new share material, making it ready for use.

Method Signature

class AeonSigner {
  /**
   * Detects if there are pending user shares shared with this signer,
   * validates them, and then integrates them to make the signer fully operational.
   * This is called after an end-user has approved sharing their key shares.
   *
   * @param workspaceId - The identifier of the workspace for which shares are being processed.
   * @returns A promise that resolves when the operation is complete, indicating success or failure.
   *          Returns details about the accepted shares or status.
   */
  async acceptPendingUserShares(workspaceId: string): Promise<AcceptanceResult>;
}

interface AcceptanceResult {
  success: boolean;
  message: string;
  acceptedSharesDetails?: any; // Information about the shares accepted
}

How It Works

  • The AeonSigner internally uses its configured connection to Aeon’s services.
  • It presents its EVM address as its identifier when checking for pending shares.
  • Successful validation leads to the direct integration of the shares into the AeonSigner instance.

Example Usage

const signer = new AeonSigner({
  /* signer configuration */
});
const workspaceId = "some-workspace-id";

async function finalizeApiUserSetup() {
  try {
    console.log("Checking for and accepting pending user shares...");
    const result = await signer.acceptPendingUserShares(workspaceId);
    if (result.success) {
      console.log(
        "User shares processed successfully!",
        result.acceptedSharesDetails || ""
      );
      // AeonSigner is now fully operational with the user's key share for this workspace
    } else {
      console.error("Failed to process user shares:", result.message);
    }
  } catch (error) {
    console.error("Error during acceptPendingUserShares:", error);
  }
}

// This function is called at an appropriate time,
// after the acceptWorkspaceInvite flow has completed and the user has approved
// sharing their key shares from their primary device.
finalizeApiUserSetup();
This method ensures that the AeonSigner only uses key shares after detection and validation, maintaining security and control over the key integration process.