@biscuit-auth/biscuit-wasm
Advanced tools
Comparing version 0.4.0-alpha2 to 0.4.0-alpha3
@@ -91,2 +91,10 @@ /* tslint:disable */ | ||
/** | ||
* Creates a BlockBuilder | ||
* | ||
* the builder can be merged with a `BiscuitBuilder`, another `BlockBuilder`, | ||
* and used to append a block to a biscuit | ||
* @returns {BlockBuilder} | ||
*/ | ||
static block_builder(): BlockBuilder; | ||
/** | ||
* Creates an attenuated token by adding the block generated by the BlockBuilder | ||
@@ -93,0 +101,0 @@ * @param {BlockBuilder} block |
@@ -55,2 +55,38 @@ import * as wasm from "./biscuit_bg.wasm"; | ||
export function block(strings, ...values) { | ||
let code = ""; | ||
for (let i = 0; i < strings.length; i++) { | ||
code += strings[i]; | ||
if(i < values.length){ | ||
code += `{_param_${i}}` | ||
} | ||
} | ||
const termParameters = Object.fromEntries(values.map((v, i) => { | ||
return [ | ||
`_param_${i}`, | ||
prepareTerm(v) | ||
]; | ||
})); | ||
const isKeyParam = (v) => { | ||
return typeof v === "string" && v.startsWith("ed25519/") || v.toDatalogParameter; | ||
}; | ||
const keyParameters = Object.fromEntries( | ||
values.map((v,i) => [i,v]) | ||
.filter(([i,v]) => isKeyParam(v)) | ||
.map(([i,v]) => { | ||
return [ | ||
`_param_${i}`, | ||
prepareTerm(v) | ||
]; | ||
}) | ||
); | ||
const builder = Biscuit.block_builder(); | ||
builder.addCodeWithParameters(code, termParameters, keyParameters); | ||
return builder; | ||
} | ||
export function authorizer(strings, ...values) { | ||
@@ -57,0 +93,0 @@ let code = ""; |
{ | ||
"name": "@biscuit-auth/biscuit-wasm", | ||
"description": "WebAssembly wrapper for Biscuit authorization tokens", | ||
"version": "0.4.0-alpha2", | ||
"version": "0.4.0-alpha3", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1712364
2755
0