Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThirdPartyRequest.createBlock fails with a null pointer error #41

Open
ishmam-mahmud opened this issue Aug 31, 2023 · 1 comment
Open

Comments

@ishmam-mahmud
Copy link

Running the following code:

// run.js
import { KeyPair, ThirdPartyRequest, block } from '@biscuit-auth/biscuit-wasm';

const third = new KeyPair()
const thirdBuilder = block`
 user(123);
`;

const thirdRequest = new ThirdPartyRequest();
const thirdBlock = thirdRequest.createBlock(third.getPrivateKey(), thirdBuilder)

returns the following error message:

(node:31428) ExperimentalWarning: Importing WebAssembly modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
biscuit-wasm loading
~/node_modules/@biscuit-auth/biscuit-wasm/module/biscuit_bg.js:2504
    throw new Error(getStringFromWasm0(arg0, arg1));
          ^

Error: null pointer passed to rust
    at __wbindgen_throw (~/node_modules/@biscuit-auth/biscuit-wasm/module/biscuit_bg.js:2504:11)
    at wasm://wasm/006425f6:wasm-function[1430]:0x122550
    at wasm://wasm/006425f6:wasm-function[1431]:0x12255d
    at wasm://wasm/006425f6:wasm-function[537]:0xd8538
    at ThirdPartyRequest.createBlock (~/node_modules/@biscuit-auth/biscuit-wasm/module/biscuit_bg.js:2104:18)
    at ~/run.js:10:33
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

Line 2104:18 on biscuit_bg.js is

wasm.thirdpartyrequest_createBlock(retptr, ptr, private_key.ptr, block_builder.ptr);

and after adding some console.logs before that line, I found that ptr is undefined.

@divarvel
Copy link
Collaborator

The third-party request has to be created from a token. I'll check why the constructor is exposed, but it should not be used directly.

https://github.com/biscuit-auth/biscuit-wasm/blob/main/examples/node/index.js#L33-L41 shows how to append a third-party block to an existing token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants