
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
xcfunctions
Advanced tools
XComponent REST triggered methods JavaScript client library
Since version 5.0, XComponent allows one to implement microservices in any programming language. This is done by means of the new REST triggered methods, in opposition to the standard Native ones, generated automatically by XComponent's build tool chain and implemented in C#.
The present library abstracts away from XComponent's REST API and allows developers to write code that reads and behaves very close to the way native triggered methods are written.
This library implements an event queue that periodically polls the REST server looking for triggered methods to execute.
As a developer, you must register a set of triggered methods implementation functions associating them to the component's state machines and then start the event queue. The associated functions will then ben called when a triggered method needs to be executed server side. Functions can update state machine's public and internal member and trigger senders.
With npm do:
npm install xcfunctions
Registers a set of triggered method implementation functions and associate them to triggered methods in the provided component/state machine pair.
triggeredMethod is a dictionary whose keys are the names of the triggered methods and values are triggered method implementation functions.
Triggered methods are named following this pattern (special cases will be listed on next section):
ExecuteOn_ToStateName_From_FromStateName_Through_TransitionName
For a transition named TransitioName, from state FromStateName to ToStateName.
If the code of the trigger method is asynchronous, add done parameter and call it back at the end of the execution.
The following code snippet illustrates a call to the registerTriggeredMethods(...) method:
xcfunctions.registerTriggeredMethods('Component', 'StateMachine', {
ExecuteOn_EntryPoint: (event, publicMember, internalMember, context, sender, stringResources) => {
...
},
ExecuteOn_S0_From_S1_Through_T: (event, publicMember, internalMember, context, sender, stringResources) => {
...
},
ExecuteOn_S2_From_S1_Through_T2: (event, publicMember, internalMember, context, sender, stringResources, done) => {
done();
},
...
});
Starts the event queue that polls the REST service for triggered methods to execute.
The configuration parameter is optional and it has the following structure:
configuration = {
port:, number,
host: string,
timeoutInMillis: number,
}
Where:
timeoutInMillis: is the timeout for the execution of triggered methods defined in milliseconds; its default value is 1000ms.port: is the port where the state machine is exposed on the server; its default value is 9676.host: is the host name where the state machine is exposed on the server; its default value is 127.0.0.1.The callback parameter is optional and allows one to detect initialization errors, and to be notified when polling started.
It has the following signature:
function callback(error, success) {
if (error) {
// erro contains the error message
} else if (success) {
// event queue ready and polling started
}
}
A triggered method implementation function has the following signature:
(event, publicMember, internalMember, context, sender, stringResources) => {
...
}
Where:
event is the event object that triggered the transition;publicMember and internalMember are respectively the public and internal members of the state machine when the transition was triggered. NOTE: These objects may be modified by the function code, modifications will be transferred to state machine.context represents the execution context of the state machine, with the following structure:{
PublishNotification: boolean,
StateMachineId: number
WorkerId: number
StateCode: number
StateMachineCode: number,
ComponentCode: number,
PrivateTopic: string,
MessageType: string,
ErrorMessage: string,
SessionData: string
}
sender is the object used to trigger sender calls, use it as follows:sender.transitionName(sentEvent, useContext);
Where transitionName is the name of the transition to trigger, sentEvent represents the event to be sent to trigger the transition and useContext is a boolean indicating if the event should be forwarded only to the current state machine (true) or to all state machines of the same type (false).
stringResources is an object that contains the string resources configured for the component. Strings resources are a per component key value store that store the configuration of each XComponent component. It is read on the runtime startup and is immutable.Entry point triggered methods: these transitions are executed once per component, when its entry point state machine is instantiated. The triggered method should be called ExecuteOn_EntryPoint and its triggering event is an empty object, and should therefore be ignored.
Public member initializers: these transitions are executed when a forked state machine is created. The triggered method should be called InitializePublicMember. This method should initialize the child state machine's public and internal members from its parent's. The received event has the following structure:
{
ParentPublicMember: {
...
},
ParentInternalMember: {
...
}
}
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-featureApache 2.0
FAQs
XComponent.Functions JS client library
The npm package xcfunctions receives a total of 6 weekly downloads. As such, xcfunctions popularity was classified as not popular.
We found that xcfunctions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.