From c592416430ff8fc773c110fae6d93ce82a3f65a1 Mon Sep 17 00:00:00 2001 From: Malcolm Still Date: Sun, 24 Sep 2023 11:32:01 +0100 Subject: [PATCH] Update imports + fix quote position --- docs/src/usage/nodejs.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/src/usage/nodejs.md b/docs/src/usage/nodejs.md index 9ec9e8d..f8948c2 100644 --- a/docs/src/usage/nodejs.md +++ b/docs/src/usage/nodejs.md @@ -42,7 +42,7 @@ const root = new KeyPair(); ## Create a token ```javascript -const { biscuit, KeyPair } = require('@biscuit-auth/biscuit-wasm'); +const { biscuit, PrivateKey } = require('@biscuit-auth/biscuit-wasm'); const userId = "1234"; // a token can be created from a datalog snippet @@ -56,7 +56,7 @@ for (let right of ["read", "write"]) { builder.addFact(fact`right(${right})`); } -const privateKey = PrivateKey.fromString("); +const privateKey = PrivateKey.fromString(""); const token = builder.build(privateKey); console.log(token.toBase64()); ``` @@ -64,9 +64,9 @@ console.log(token.toBase64()); ## Authorize a token ```javascript -const { authorizer, Biscuit } = require('@biscuit-auth/biscuit-wasm'); +const { authorizer, Biscuit, PublicKey } = require('@biscuit-auth/biscuit-wasm'); -const publicKey = PublicKey.fromString("); +const publicKey = PublicKey.fromString(""); const token = Biscuit.fromBase64("", publicKey); const userId = "1234"; @@ -92,9 +92,9 @@ const acceptedPolicyCustomLimits = authorizer.authorizeWithLimits({ ## Attenuate a token ```javascript -const { block, Biscuit } = require('@biscuit-auth/biscuit-wasm'); +const { block, Biscuit, PublicKey } = require('@biscuit-auth/biscuit-wasm'); -const publicKey = PublicKey.fromString("); +const publicKey = PublicKey.fromString(""); const token = Biscuit.fromBase64("", publicKey); // restrict to read only @@ -107,9 +107,9 @@ console.log(attenuatedToken.toBase64()); A sealed token cannot be attenuated further. ```javascript -const { Biscuit } = require('@biscuit-auth/biscuit-wasm'); +const { Biscuit, PublicKey } = require('@biscuit-auth/biscuit-wasm'); -const publicKey = PublicKey.fromString("); +const publicKey = PublicKey.fromString(""); const token = Biscuit.fromBase64("", publicKey); const sealedToken = token.sealToken(); @@ -119,9 +119,9 @@ const sealedToken = token.sealToken(); ```javascript -const { Biscuit } = require('@biscuit-auth/biscuit-wasm'); +const { Biscuit, PublicKey } = require('@biscuit-auth/biscuit-wasm'); -const publicKey = PublicKey.fromString("); +const publicKey = PublicKey.fromString(""); const token = Biscuit.fromBase64("", publicKey); // revocationIds is a list of hex-encoded revocation identifiers, @@ -137,9 +137,10 @@ if (containsRevokedIds(revocationIds)) { ## Query data from the authorizer ```javascript -const { authorizer, rule, Biscuit } = require('@biscuit-auth/biscuit-wasm'); +const { authorizer, rule, Biscuit, PublicKey } = require('@biscuit-auth/biscuit-wasm'); -const token = Biscuit.fromBase64(""); +const publicKey = PublicKey.fromString(""); +const token = Biscuit.fromBase64("", publicKey); const userId = "1234"; const auth = authorizer`