From 7dd28a5941e37e13e5d6899e3214bb53e5b7267a Mon Sep 17 00:00:00 2001 From: ha-sante <90225652+ha-sante@users.noreply.github.com> Date: Tue, 28 Feb 2023 13:03:32 +0000 Subject: [PATCH] Update create-secrets.mdx I am making this change to draw your attention to this as it seems that some variables are used wrong. - Specifically this section: util.decodeBase64(encryptedProjectKey), util.decodeBase64(encryptedProjectKey.nonce), util.decodeBase64(encryptedProjectKey.sender.publicKey), util.decodeBase64(PSWD) - Imported tweetnacl as well so it's easier to understand and for the code to make sense from the get go. --- docs/api-reference/overview/examples/create-secrets.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/api-reference/overview/examples/create-secrets.mdx b/docs/api-reference/overview/examples/create-secrets.mdx index 319bd9d46..0cd731f5f 100644 --- a/docs/api-reference/overview/examples/create-secrets.mdx +++ b/docs/api-reference/overview/examples/create-secrets.mdx @@ -23,6 +23,7 @@ Prerequisites: ```js const crypto = require('crypto'); const axios = require('axios'); +const nacl = require('tweetnacl'); const ALGORITHM = 'aes-256-gcm'; const BLOCK_SIZE_BYTES = 16; @@ -94,9 +95,9 @@ const createSecrets = async () => { // 4. decrypt the project key with your private key const projectKey = nacl.box.open( util.decodeBase64(encryptedProjectKey), - util.decodeBase64(projectKey.nonce), - util.decodeBase64(projectKey.sender.publicKey), - util.decodeBase64(privateKey) + util.decodeBase64(encryptedProjectKey.nonce), + util.decodeBase64(encryptedProjectKey.sender.publicKey), + util.decodeBase64(PSWD) ); // 5. encrypt your secret(s) with the project key