]> git.codecow.com Git - libnemo.git/commitdiff
Add rolodex to type definition file.
authorChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 17:33:06 +0000 (10:33 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 17:33:06 +0000 (10:33 -0700)
src/types.d.ts

index 95210eed8972eabb1bd5ef89e128b0de7c1c53c9..4f5f371742b98cbd10c3f0bc357f381f03fab5f4 100644 (file)
@@ -290,6 +290,69 @@ export type KeyPair = {
        publicKey?: Key
 }
 
+/**
+* Represents a basic address book of Nano accounts. Multiple addresses can be
+* saved under one nickname.
+*/
+export declare class Rolodex {
+       /**
+       * Adds an address to the rolodex under a specific nickname.
+       *
+       * If the name exists, add the address as a new association to that name. If
+       * the account exists under a different name, update the name. If no matches
+       * are found at all, add a new entry.
+       *
+       * @param {string} name - Contact alias for the address
+       * @param {string} address - Nano account address
+       * @returns {Promise<boolean>} Promise for true if name and address are added to the rolodex, else false
+       */
+       static add (name: string, address: string): Promise<boolean>
+       /**
+       * Removes a Nano address from its related contact in the rolodex.
+       *
+       * @param {string} address - Nano account address
+       * @returns {Promise<boolean>} Promise for true if address successfully removed, else false
+       */
+       static deleteAddress (address: string): Promise<boolean>
+       /**
+       * Removes a contact and its related Nano addresses from the rolodex.
+       *
+       * @param {string} name - Contact name to delete
+       * @returns {Promise<boolean>} Promise for true if name and related addresses successfully removed, else false
+       */
+       static deleteName (name: string): Promise<boolean>
+       /**
+       * Gets all Nano account addresses associated with a name from the rolodex.
+       *
+       * @param {string} name - Alias to look up
+       * @returns {Promise<string[]>} Promise for a list of Nano addresses associated with the name
+       */
+       static getAddresses (name: string): Promise<string[]>
+       /**
+       * Gets all names stored in the rolodex.
+       *
+       * @returns {Promise<string[]>} Promise for a list of all names stored in the rolodex
+       */
+       static getAllNames (): Promise<string[]>
+       /**
+       * Gets the name associated with a specific Nano address from the rolodex.
+       *
+       * @param {string} address - Nano account address
+       * @returns {Promise<string|null>} Promise for the name associated with the address, or null if not found
+       */
+       static getName (address: string): Promise<string | null>
+       /**
+       * Verifies whether the public key of any Nano address saved under a specific
+       * name in the rolodex was used to sign a specific set of data.
+       *
+       * @param {string} name - Alias to look up
+       * @param {string} signature - Signature to use for verification
+       * @param {...string} data - Signed data to verify
+       * @returns {Promise<boolean>} True if the signature was used to sign the data, else false
+       */
+       static verify (name: string, signature: string, ...data: string[]): Promise<boolean>
+}
+
 /**
 * Processes a queue of tasks using Web Workers.
 */