// Copyright © Aptos // SPDX-License-Identifier: Apache-2.0 // Adding or removing an account? This will be idempotent, but racy import { Account, AccountPublicKey, PublicKey as AptosPublicKey, Signature } from '@aptos-labs/ts-sdk'; import { Ed25519KeyPair, Ed25519PublicKey, Ed25519SecretKey } from './utils'; // ADD/REMOVE is used for account connections export declare enum AccountConnectionAction { ADD = "add", REMOVE = "remove" } /** * When a wallet wants to create a pairing, or add/remove an account from a wallet connection, it must prove that it * has the secret key for a given account. To do so it uses an `AccountConnectInfo` object. * 1. Once the `AccountConnectInfo` is assembled, it’s JSON serialized to get a `accountInfoSerialized` string. * 2. We then domain separate and hash the `accountInfoSerialized` to get the `accountInfoHash`: * `SHA3-256(SHA3-256('APTOS::IDENTITY_CONNECT::') | SHA3-256(accountInfoSerialized))` * 3. To obtain the `signature`, we sign the `accountInfoHash` with the Ed25519 private key of the sender, and hex * encode it. * 4. These are assembled into an `AccountConnectInfoSerialized`, ready to be sent in an HTTP request. */ export type BaseAccountConnectInfo = { // The account address accountAddress: string; // either 'add' or 'remove' action: AccountConnectionAction; // A unique identifier for this connection: it is either the walletId or the pairingId // Prevents replay attacks across wallets intentId: string; // Prevents replay attacks across time- these are only valid for 5 minutes timestampMillis: number; // The public key for the encrypted e2e channel, base64 transportEd25519PublicKeyB64: string; }; export type Ed25519AccountConnectInfo = BaseAccountConnectInfo & { // The account ed25519 public key, base64 ed25519PublicKeyB64: string; publicKeyB64?: undefined; }; export type AnyAccountConnectInfo = BaseAccountConnectInfo & { ed25519PublicKeyB64?: undefined; // The account public key, bcs-serialized and base64-encoded publicKeyB64: string; }; // Ensuring compatibility with previous wallet-sdk versions export type AccountConnectInfo = Ed25519AccountConnectInfo | AnyAccountConnectInfo; export type Ed25519AccountConnectInfoSerialized = { accountInfoSerialized: string; signature: string; signatureB64?: undefined; }; export type AnyAccountConnectInfoSerialized = { accountInfoSerialized: string; signature?: undefined; signatureB64: string; }; export type AccountConnectInfoSerialized = Ed25519AccountConnectInfoSerialized | AnyAccountConnectInfoSerialized; export type SyncSignCallback = (message: Uint8Array) => Signature; export type AsyncSignCallback = (message: Uint8Array) => Promise; export type AnySignCallback = SyncSignCallback | AsyncSignCallback; export declare function deriveAccountTransportEd25519Keypair(ed25519SecretKey: Ed25519SecretKey, publicKey: Ed25519PublicKey | AptosPublicKey): Ed25519KeyPair; export declare function deriveAccountTransportEd25519Keypair(signCallback: SyncSignCallback, publicKey: Ed25519PublicKey | AptosPublicKey): Ed25519KeyPair; export declare function deriveAccountTransportEd25519Keypair(signCallback: AsyncSignCallback, publicKey: Ed25519PublicKey | AptosPublicKey): Promise; export declare function deriveAccountTransportEd25519Keypair(signCallback: AnySignCallback, publicKey: Ed25519PublicKey | AptosPublicKey): Ed25519KeyPair | Promise; export type CreateSerializedAccountInfoArgs = [ signCallback: TSignCallback, publicKey: AccountPublicKey, transportEd25519PublicKey: Ed25519PublicKey, action: AccountConnectionAction, intentId: string, accountAddress?: string ]; export declare function createSerializedAccountInfo(...args: CreateSerializedAccountInfoArgs): AccountConnectInfoSerialized; export declare function createSerializedAccountInfo(...args: CreateSerializedAccountInfoArgs): Promise; export declare function createSerializedAccountInfo(...args: CreateSerializedAccountInfoArgs): AccountConnectInfoSerialized | Promise; export declare function aptosAccountToSerializedInfo(account: Account, intentId: string): Promise; //# sourceMappingURL=walletAccounts.d.ts.map