Skip to main content

init_from_archive_bytes

Function init_from_archive_bytes 

Source
pub async fn init_from_archive_bytes(
    config: JsValue,
    archive_bytes: Uint8Array,
) -> Result<Cedarling, Error>
Expand description

Create a new instance of the Cedarling application from archive bytes.

This function allows loading a policy store from a Cedar Archive (.cjar) that was fetched with custom logic (e.g., with authentication headers).

§Arguments

  • config - Bootstrap configuration (Map or Object) without a policy-store source property. The archive bytes provide the policy store.
  • archive_bytes - The .cjar archive bytes (Uint8Array)

§Example

await initWasm();
const config = {
  CEDARLING_APPLICATION_NAME: "task-api",
  CEDARLING_LOG_TYPE: "memory",
  CEDARLING_LOG_TTL: 120,
};
const response = await fetch("https://example.com/policy-store.cjar", {
  headers: { Authorization: "Bearer <token>" },
});
if (!response.ok) throw new Error("Unable to fetch policy store");
const archiveBytes = new Uint8Array(await response.arrayBuffer());
const cedarling = await initFromArchiveBytes(config, archiveBytes);