From 4f9318f4d01770f3a63b054e2e160409771c9e1d Mon Sep 17 00:00:00 2001 From: Sourav Date: Wed, 11 Mar 2026 23:33:24 +0530 Subject: [PATCH 1/3] Document KeyEndorsementPolicy class for SBE #307 Signed-off-by: Sourav --- docs/_jsdoc.json | 1 + libraries/fabric-shim/index.js | 4 +++- libraries/fabric-shim/lib/utils/statebased.js | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/_jsdoc.json b/docs/_jsdoc.json index 5b2fccd8b..1b79c6a7a 100644 --- a/docs/_jsdoc.json +++ b/docs/_jsdoc.json @@ -5,6 +5,7 @@ "../libraries/fabric-shim/lib/chaincode.js", "../libraries/fabric-shim/lib/stub.js", "../libraries/fabric-shim/lib/iterators.js", + "../libraries/fabric-shim/lib/utils/statebased.js", "../apis/fabric-contract-api/lib" ] }, diff --git a/libraries/fabric-shim/index.js b/libraries/fabric-shim/index.js index eba64698d..73473c776 100644 --- a/libraries/fabric-shim/index.js +++ b/libraries/fabric-shim/index.js @@ -4,4 +4,6 @@ # SPDX-License-Identifier: Apache-2.0 */ -module.exports = require('./lib/chaincode.js'); +const shim = require('./lib/chaincode.js'); +module.exports = shim; +module.exports.KeyEndorsementPolicy = shim.KeyEndorsementPolicy; diff --git a/libraries/fabric-shim/lib/utils/statebased.js b/libraries/fabric-shim/lib/utils/statebased.js index c294ad5b1..598282a10 100644 --- a/libraries/fabric-shim/lib/utils/statebased.js +++ b/libraries/fabric-shim/lib/utils/statebased.js @@ -17,7 +17,8 @@ const ROLE_TYPE_PEER = 'PEER'; * of the MSP identifiers of organizations. * For more informations, please read the [documents]{@link https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#setting-key-level-endorsement-policies} * - * @class + * @class KeyEndorsementPolicy + * @memberof fabric-shim */ class KeyEndorsementPolicy { /** @@ -35,7 +36,7 @@ class KeyEndorsementPolicy { /** * returns the endorsement policy as bytes - * @returns {Buffer} the endorsement policy + * @returns {Uint8Array} the serialized signature policy envelope */ getPolicy() { const spe = this._getPolicyFromMspId(); @@ -45,7 +46,7 @@ class KeyEndorsementPolicy { /** * adds the specified orgs to the list of orgs that are required * to endorse - * @param {string} role the role of the new org(s). i.e., MEMBER or PEER + * @param {string} role the role of the new org(s). i.e., 'MEMBER' or 'PEER' * @param {...string} neworgs the new org(s) to be added to the endorsement policy */ addOrgs(role, ...neworgs) { From ed0f5b8ffd7ab43ff41ccf67a26adcd0e6b06c11 Mon Sep 17 00:00:00 2001 From: Sourav Jha Date: Tue, 2 Jun 2026 06:07:13 +0530 Subject: [PATCH 2/3] docs: remove class name and mark internal methods as private in KeyEndorsementPolicy Signed-off-by: Sourav Jha --- libraries/fabric-shim/lib/utils/statebased.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/fabric-shim/lib/utils/statebased.js b/libraries/fabric-shim/lib/utils/statebased.js index 598282a10..ecfeca3b4 100644 --- a/libraries/fabric-shim/lib/utils/statebased.js +++ b/libraries/fabric-shim/lib/utils/statebased.js @@ -17,7 +17,7 @@ const ROLE_TYPE_PEER = 'PEER'; * of the MSP identifiers of organizations. * For more informations, please read the [documents]{@link https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#setting-key-level-endorsement-policies} * - * @class KeyEndorsementPolicy + * @class * @memberof fabric-shim */ class KeyEndorsementPolicy { @@ -90,6 +90,7 @@ class KeyEndorsementPolicy { * Internal used only, set the orgs map from a signature policy envelope * @param {_policiesProto.SignaturePolicyEnvelope} signaturePolicyEnvelope the signaturePolicyEnvelope * decoded from the endorsement policy. + * @private */ _setMspIdsFromSPE(signaturePolicyEnvelope) { // iterate over the identities in this envelope @@ -107,6 +108,7 @@ class KeyEndorsementPolicy { * Internal used only. construct the policy from all orgs' mspIds. * the policy requires exactly 1 signature from all of the principals. * @returns {_policiesProto.SignaturePolicyEnvelope} return the SignaturePolicyEnvelope instance + * @private */ _getPolicyFromMspId() { From 1cb8d474d1142556dd691c13be3ea73f25bc2c20 Mon Sep 17 00:00:00 2001 From: Sourav Jha Date: Tue, 2 Jun 2026 15:50:31 +0530 Subject: [PATCH 3/3] refactor: simplify export logic in index.js to directly export the chaincode module Signed-off-by: Sourav Jha --- libraries/fabric-shim/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/fabric-shim/index.js b/libraries/fabric-shim/index.js index 73473c776..eba64698d 100644 --- a/libraries/fabric-shim/index.js +++ b/libraries/fabric-shim/index.js @@ -4,6 +4,4 @@ # SPDX-License-Identifier: Apache-2.0 */ -const shim = require('./lib/chaincode.js'); -module.exports = shim; -module.exports.KeyEndorsementPolicy = shim.KeyEndorsementPolicy; +module.exports = require('./lib/chaincode.js');