fabric-chaincode-node
fabric-chaincode-node copied to clipboard
KeyEndorsementPolicy class useful for working with State Based Endorsement is not documented in the node reference docs
I looked on https://hyperledger.github.io/fabric-chaincode-node/release-2.2/api/index.html
and cannot find this class documented yet it is important for users who want to use state based endorsement
Class: ProposalCreator (alias / legacy name, returned by getCreator())
Note: In the current Fabric chaincode-node API, getCreator() returns a SerializedIdentity. Some older or auto-generated JSDoc pages refer to ProposalCreator as a class, but that is misleading — you should treat this as a read-only structure provided by the runtime, and not something you normally instantiate.
Constructor
-
Although documented (in older JSDoc) as constructible, you should not use
new ProposalCreator(). The endorsing peer/runtime constructs and populates the instance, and returns it instub.getCreator()or equivalent. -
The constructor may exist for legacy JSDoc generation, but application/chaincode code should not rely on constructing it manually.
Properties
-
Note: In TypeScript the property is
idBytes(camelCase). Some older documentation usesid_bytes; that is incorrect or outdated and should be normalized toidBytes.
Methods / Behavior
-
There are no methods on this object (beyond what JavaScript gives you). It is purely a data container.
-
The runtime guarantees that the certificate and MSP ID are valid and correspond to the identity that submitted the proposal.
-
For verification or parsing, chaincode code can interpret
idBytes(e.g. converting to string, parsing as X.509, extracting subject, etc.).
Interaction with ChaincodeStub.getCreator() / ctx.stub.getCreator()
-
getCreator()returns the identity of the chaincode invocation’s submitter. -
This identity is used, for example, in verifying custom signatures, enforcing access control, or combining with state-based endorsement logic (e.g. ensuring that only certain identities can modify endorsement parameters, etc.).
Using in State-Based Endorsement Context
State-based endorsement allows per-key (or per-private-data-key) endorsement policies. The relevant APIs in the fabric-shim stub include:
-
stub.getStateValidationParameter(key) -
stub.setStateValidationParameter(key, endorsementPolicyBytes) -
(For private data)
stub.getPrivateDataValidationParameter(collection, key)andstub.setPrivateDataValidationParameter(...)
When your chaincode is operating under a state-based endorsement model, you may wish to check or enforce that the transaction submitter is allowed to modify the endorsement parameters of a given key. In that scenario:
-
Use
getCreator()to retrieve the submitter’s identity (mspid+idBytes). -
Parse their certificate (e.g. subject, attributes) if needed.
-
Compare against your access rules (e.g. only org
Org1MSPcertificate with certain OU or CN allowed). -
If allowed, call
setStateValidationParameter(...)(or private variant) to update endorsement policy for that particular key.
Thus, accurate documentation of the ProposalCreator / serialized identity is important for state-based endorsement workflows.
Suggested JSDoc / Markdown to Add to Fabric chaincode-node docs