diff --git a/js-tests/index.js b/js-tests/index.js index 14cdb69..7e535f5 100644 --- a/js-tests/index.js +++ b/js-tests/index.js @@ -38,9 +38,10 @@ test("biscuit builder", function(t) { builder.addFact(fact`fact(${userId})`); builder.addRule(rule`u($id) <- user($id, ${userId})`); builder.addCheck(check`check if check(${userId})`); + builder.setRootKeyId(1234); t.equal( builder.toString(), - `// no root key id set + `// root key id: 1234 user("1234"); fact("1234"); u($id) <- user($id, "1234"); diff --git a/src/builder.rs b/src/builder.rs index 6f08264..15e8a72 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -36,6 +36,12 @@ impl BiscuitBuilder { self.0.merge(other.0.clone()) } + /// Sets the root key id + #[wasm_bindgen(js_name = setRootKeyId)] + pub fn set_root_key_id(&mut self, root_key_id: u32) { + self.0.set_root_key_id(root_key_id) + } + /// Adds a Datalog fact #[wasm_bindgen(js_name = addFact)] pub fn add_fact(&mut self, fact: &Fact) -> Result<(), JsValue> {