service-call-script-helpers-develop
v1.0.0
Published
Runtime-injected helpers for sandboxed service-call scripts
Maintainers
Readme
service-call-script-helpers
Runtime-injected helpers for sandboxed service-call scripts. The package does not connect to Redis or expose Node.js internals directly. Cache operations are forwarded through a runtime adapter supplied by the host application.
Installation
npm install service-call-script-helpersHost usage
const {
SCRIPT_HELPER_NAMES,
createHelperRegistry,
} = require('service-call-script-helpers');
const helpers = createHelperRegistry({
callParentHelper(helper, args) {
// Forward privileged operations to the parent process.
return sendRequestToParent(helper, args);
},
safeFetch(url, options) {
// Apply the host application's network policy here.
return restrictedFetch(url, options);
},
});The resulting frozen registry exposes:
environmentCirclecallServicecacheSetValue,cacheGetValue, andcacheDeleteValue- record cache helpers (
cachePutScriptRecord,cacheGetScriptRecord, index queries, count, and delete) xmlToJson
The host remains responsible for allowlisting helpers before exposing them to untrusted scripts.
Script usage
Once the host injects the registry as serviceCall, scripts keep the same API:
async function main() {
return serviceCall.cacheGetValue('customer:42');
}
main();Test
npm test