{"version":3,"file":"with-abstract-public-keys.cjs","sources":["../../../../../src/modules/abstract/common/with-abstract-public-keys.js"],"sourcesContent":["import {\n  withExtendedPrototypeProperties,\n  withExtendedStaticProperties,\n} from '../../../utils';\n\n/**\n * Higher-order function that enhances a given class with abstract public key functionality.\n * @template C\n * @param {C} klass - The class to be enhanced.\n * @returns {C} A new class extended from the input class with added methods and properties.\n */\nexport default function withAbstractPublicKeys(klass) {\n  const name = `withAbstractPublicKeys(${klass.name})`;\n\n  /**\n   * An object containing a single property that references an anonymous subclass of the input class.\n   * This subclass includes methods for handling public keys and their parameters.\n   */\n  const obj = {\n    [name]: class extends klass {\n      /**\n       * Static method to prepare an object representing a new public key to be added on the chain.\n       * @param {...*} args - Variable list of arguments for creating a PublicKey instance, typically including bytes and curveType.\n       * @returns {PublicKey} The newly created PublicKey object.\n       */\n      static prepareAddPublicKey(...args) {\n        const { PublicKey } = this;\n\n        return new PublicKey(...args);\n      }\n\n      /**\n       * Asynchronously adds a public key to the blockchain.\n       * @param {*} id - The unique identifier for the public key.\n       * @param {PublicKey} publicKey - The public key to be added.\n       * @param {*} targetDid - The Distributed Identity (DID) of the entity to which the key is being added.\n       * @param {DidKeypair} didKeypair - A reference to the private key used for signing the transaction.\n       * @param {object} params - transcation parameters.\n       * @returns {Promise<*>} A Promise that resolves with the result of the addPublicKeyTx() method after being signed and sent.\n       */\n      async addPublicKey(id, publicKey, targetDid, didKeypair, params) {\n        return await this.signAndSend(\n          await this.addPublicKeyTx(id, publicKey, targetDid, didKeypair),\n          params,\n        );\n      }\n\n      /**\n       * Retrieves a single public key by its identifier and the DID of the entity it belongs to.\n       * @param {*} _did - The DID of the entity that owns or controls the requested key (currently unused in function body).\n       * @param {*} id - The unique identifier for the desired public key.\n       * @param {boolean} includeParams - Request params for the public key.\n       * @returns {Promise<Params>} A Promise that resolves with the parameters associated with the requested public key, if found. Otherwise, it rejects or returns null/undefined.\n       */\n      async getPublicKey(_did, _id, _includeParams = false) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieves all public keys associated with a given DID.\n       * @param {*} did - The DID of the entity whose public keys are being requested.\n       * @param {boolean} includeParams - Request params for the public key.\n       * @returns {Promise<Map<Id, Params>>} A Promise that resolves with a map containing all public key identifiers and their respective parameters for the specified DID. If no keys or an error occurs, it may return null/undefined or reject the promise.\n       */\n      async getAllPublicKeysByDid(_did, _includeParams = false) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieves the identifier of the most recently used public key for a given DID.\n       * @param {*} targetDid - The DID whose latest public key is being requested.\n       * @returns {Promise<Id>} A Promise that resolves with the ID of the latest public key associated with the provided DID, if available. Otherwise, it may reject or return null/undefined.\n       */\n      async lastPublicKeyId(_targetDid) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieves the identifier of the next unused public key for a given DID.\n       * @param {*} targetDid - The DID whose next available public key ID is being requested.\n       * @returns {Promise<Id>} A Promise that resolves with the ID of the next usable public key associated with the provided DID, if it exists. Otherwise, it may reject or return null/undefined.\n       */\n      async nextPublicKeyId(_targetDid) {\n        throw new Error('Unimplemented');\n      }\n    },\n  };\n\n  return withExtendedPrototypeProperties(\n    [\n      'addPublicKeyTx',\n      'getAllPublicKeysByDid',\n      'lastPublicKeyId',\n      'nextPublicKeyId',\n    ],\n    withExtendedStaticProperties(['PublicKey'], obj[name]),\n  );\n}\n"],"names":["withExtendedPrototypeProperties","withExtendedStaticProperties"],"mappings":";;;;;;;;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,sBAAsB,CAAC,KAAK,EAAE;AACtD,EAAE,MAAM,IAAI,GAAG,CAAC,uBAAuB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEtD;AACA;AACA;AACA;AACA,EAAE,MAAM,GAAG,GAAG;AACd,IAAI,CAAC,IAAI,GAAG,cAAc,KAAK,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA,MAAM,OAAO,mBAAmB,CAAC,GAAG,IAAI,E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