Skip to main content
This Node.js sample implements the complete two-party sequence against a Neuron:
  1. Alice creates an instance with explicit Owner and Reader parts and all eight fixture parameters.
  2. Alice signs the Owner role.
  3. Alice sends a contractProposal through POST /Agent/Xmpp/SendXmlMessage.
  4. Bob receives the proposal through POST /Agent/Xmpp/PopMessages and retrieves the exact contract.
  5. Bob signs the Reader role.
  6. The sample requires the final state to be Signed and checks both role signatures.

Files

  • template.xml reproduces the broker’s Template1.xml integration-test fixture. Its content schema is currently available from http://lab.tagroot.io/Test/Test1.xsd.
  • agreement.mjs runs the lifecycle.
  • signatures.mjs implements the exact HMAC messages.
  • signatures.test.mjs contains deterministic signature and XML checks.
  • .env.example lists the required configuration without secrets.

Before running

Both Alice and Bob need:
  • an Agent API account and JWT;
  • an approved Legal Identity;
  • a key associated with that identity;
  • the key’s caller-chosen id, algorithm local name, and algorithm namespace;
  • their account and key passwords available at runtime but not committed or logged.
Propose the included template with POST /Agent/Legal/ProposeTemplate. A trust-provider operator must approve it. Record the resulting deployment-specific template ID as NEURON_TEMPLATE_ID.
The integration-test fixture proves the contract shape and parameter mapping; it does not bypass the target deployment’s template-review policy. Do not copy a template ID between Neurons.

Run

Copy the sample directory, load the values from .env.example into your environment, and run:
A successful run prints the contract ID, Signed state, and both roles. PopMessages removes queued messages as it returns them, so use a dedicated development account when testing delivery.

What was verified

The current local IoTBroker suite passes its two-client role-signing test and its proposal-delivery test. The sample also runs deterministic tests over the exact CreateKey and SignContract message construction used by the server and maintained JavaScript client. Production readiness still requires operator approval of the template, credentials for two real accounts, and validation against the exact Neuron build you will deploy.