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

[BUG]: Create or Update an Environment Secret OctoKit #324

Open
1 task done
cxs526 opened this issue Jun 20, 2023 · 2 comments
Open
1 task done

[BUG]: Create or Update an Environment Secret OctoKit #324

cxs526 opened this issue Jun 20, 2023 · 2 comments
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects

Comments

@cxs526
Copy link

cxs526 commented Jun 20, 2023

What happened?

Hi,
I am trying to create an environment secret using OctoKit with JavaScript. I have been following this documentation: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-environment-secret.
As per the example code from the above link, I am using the environment public key since we want to make an environment secret. I am using the "key" value from the return: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-public-key. I am getting an "invalid public key length" error. Has anyone else encountered this error?

Versions

Octokit.js v2.0.14
Node v18.16.0

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@cxs526 cxs526 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jun 20, 2023
@ghost ghost added this to Bugs in JS Jun 20, 2023
@wolfy1339
Copy link
Member

Can you share a code snippet that reproduces the error you are receiving?

Are you using @octokit/plugin-enterprise-cloud?

@cxs526
Copy link
Author

cxs526 commented Jun 20, 2023

Hi,
I am using octokit/rest. Here is the code I am using:

    const sodium = require('libsodium-wrappers')

    //Check if libsodium is ready and then proceed.
    sodium.ready.then(() => {
    
    // Convert Secret & Base64 key to Uint8Array.
    var encodedKey = sodium.to_base64(public_key, sodium.base64_variants.ORIGINAL)
    const binkey = sodium.from_base64(encodedKey, sodium.base64_variants.ORIGINAL)
    const binsec = sodium.from_string(secret)
    
    //Encrypt the secret using LibSodium
    let encBytes = sodium.crypto_box_seal(binkey, binsec)

    // Convert encrypted Uint8Array to Base64
    let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
JS
  
Bugs
Development

No branches or pull requests

2 participants