From ea01a4d0c26ef8e7ca3fc76080a46c3b130fea6e Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 9 Dec 2023 11:55:16 +0000 Subject: [PATCH] implement set_root_key_id without error handling --- js-tests/index.js | 3 ++- src/builder.rs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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> {