Skip to main content

signAcceptWorkspaceMessage(workspaceId: string): Promise<string>

Generates a cryptographic signature using the AeonSigner’s EVM private key. This signature serves as an authorization for the signer to accept an invitation to a specified Aeon workspace. The signature produced by this method is used in conjunction with the AeonClient.acceptWorkspaceInvite() method (see acceptWorkspaceInvite()).

Parameters

  • workspaceId: string - The unique identifier of the workspace for which the invitation is being accepted. This ID is typically provided through the Aeon platform when an invitation is issued.

Returns

  • Promise<string>: A promise that resolves with the hexadecimal string representation of the signature. This signature proves that the owner of the EVM private key associated with the AeonSigner authorizes joining the specified workspace.

Example

import { AeonSigner } from "@aeon-protocol/aeon-sdk";
import { Wallet } from "ethers";

// Assume 'signer' is an initialized AeonSigner instance
// const privateKeyHex = "your-private-key-hex-without-0x";
// const signer = new AeonSigner({ privateKey: Buffer.from(privateKeyHex, "hex") });

async function getWorkspaceInviteSignature(
  signer: AeonSigner,
  workspaceId: string
) {
  try {
    console.log(
      `Generating signature to accept invitation for workspace: ${workspaceId}...`
    );
    const signature = await signer.signAcceptWorkspaceMessage(workspaceId);
    console.log(`Signature obtained: ${signature}`);
    // This signature would then be used to call another function,
    // possibly via AeonClient or directly to a contract,
    // to complete the acceptWorkspaceInvite process.
    return signature;
  } catch (error) {
    console.error(
      `Failed to generate signature for workspace ${workspaceId}:`,
      error
    );
    throw error;
  }
}

// Example usage:
// const workspaceToJoin = "some-unique-workspace-id"; // Replace with actual workspace ID
// getWorkspaceInviteSignature(signer, workspaceToJoin)
//   .then(sig => {
//     console.log("Proceeding to accept invitation with signature:", sig);
//     // E.g., client.acceptWorkspaceInviteWithSignature(workspaceId, sig);
//   });