github / docs

The open-source repo for docs.github.com
https://docs.github.com
Creative Commons Attribution 4.0 International
16.15k stars 59.38k forks source link

Node.JS examples based on `tweetsodium` need to be replaced as it is deprecated #17814

Closed thispsj closed 2 years ago

thispsj commented 2 years ago

Code of Conduct

What article(s) on docs.github.com is/are affected?

Four articles :

1) * https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret

What part(s) of the article would you like to see updated?

Some points which I would like to highlight here :

Additional information

I am also providing the replacement script below:

// Written with ā¤ļø by PSJ and free to use under The Unlicense.
const sodium=require('libsodium-wrappers')
const secret = 'plain-text-secret' // replace with secret before running the script.
const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key.

//Check if libsodium is ready and then proceed.

sodium.ready.then( ()=>{

// Convert Secret & Base64 key to Uint8Array.
let binkey= sodium.from_base64(key, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(key, 'base64')
let binsec= sodium.from_string(secret) // Equivalent of Buffer.from(secret)

//Encrypt the secret using LibSodium
let encBytes= sodium.crypto_box_seal(binsec,binkey) // Similar to tweetsodium.seal(binsec,binkey)

// Convert encrypted Uint8Array to Base64
let output=sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(encBytes).toString('base64')

console.log(output)
});

async/await can also be used instead.


UPDATE

REST API reference for codespaces secrets (both user and repository) is also affected and hence added.

ramyaparimi commented 2 years ago

@thispsj Thanks so much for opening an issue! I'll triage this for the team to review :eyes:

thispsj commented 2 years ago

Someone please add the codespaces label also.

mchammer01 commented 2 years ago

Hi @thispsj šŸ‘‹šŸ» - thanks for creating this issue āœØ Just to let you know that I've asked the relevant team for a technical review on your observations and suggestions. Thanks for your patience šŸ˜ƒ

github-actions[bot] commented 2 years ago

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] commented 2 years ago

This is a gentle bump for the docs team that this issue is waiting for technical review.

lgarron commented 2 years ago

@thispsj Do you think you'll get around to this at some point? We'd love to see the docs updated to avoid recommending our deprecated library.

thispsj commented 2 years ago

@thispsj Do you think you'll get around to this at some point? We'd love to see the docs updated to avoid recommending our deprecated library.

@lgarron Ya sure I can implement this provided that I can edit REST docs. šŸ˜…

skedwards88 commented 2 years ago

Thanks for opening this issue and for writing a replacement script @thispsj šŸ’– As you noted, this needs to be fixed internally in the OpenAPI schema, so I will add a label to start that process.

docubot commented 2 years ago

Thank you for opening this issue! Updates to the REST/GraphQL API description must be made internally. I have copied your issue to an internal issue, so I will close this issue.