GraalJS and ZAP integration

GraalJS

Supply the verified classic bundle as a local script to a Java-enabled GraalJS context. Shell-style load and print must be available for this example.

load("decodebox.js");
DecodeBox.ready
  .then(() => DecodeBox.executeOperation("sha-256", "abc"))
  .then(print);

Java class lookup and access to the provider's JCA, time, encoding, byte-array and compression services must be permitted by the embedding host. Restrict host access to trusted scripts. Loading by URL requires host I/O and a GraalJS configuration permitting js.load-from-url. A locally verified bundle avoids granting remote-loading permission. Processing makes no outbound requests. Promises settle at the owning context's microtask checkpoints. Operations that sleep or call synchronous Java code occupy that thread. The provider checks its deadline after a blocking call returns. Hosts that require a hard deadline must enforce it externally.

The Java adapter keeps JCA keys and secret bytes in the provider instance that created them. Handles carry read-only metadata. Only an extractable key can be exported. For JWK conversion, the adapter accepts two-prime RSA private keys with complete CRT fields, and P-256, P-384 or P-521 EC keys. It checks declared uses, algorithm identifiers and public/private components. Choose the matching RSA hash in the JWK to PEM operation.

ZAP

The native add-on defaults to the extensionless /api in Hosted SDK mode. See the browser integration guide for the two classic SDK aliases.

To run a local SDK in the Script Console, select Stand Alone and ECMAScript : Graal.js. Set DECODEBOX_SDK to the absolute path of a verified classic bundle before starting ZAP. Run this script and check its output in the console.

const path = Java.type("java.lang.System").getenv("DECODEBOX_SDK");
if (!path) throw new Error("Set DECODEBOX_SDK to a verified local file");
load(String(path));
DecodeBox.ready.then(async () => {
  const output = await DecodeBox.executeOperation("from-base64", "SGVsbG8gWkFQ");
  if (output !== "Hello ZAP") throw new Error("Unexpected decoded text");
  print(output);
});

The separate native ZAP add-on has its own trust policy. It checks SDK size, API major and SHA-256. A changed bundle needs a separately trusted digest or the add-on's supported approval process. A plain checksum list does not satisfy its signed-manifest mode. Host permissions and trusted pins are managed by the consumer. See release verification.