Git Product home page Git Product logo

Comments (6)

idimov-keeper avatar idimov-keeper commented on July 30, 2024

Hello ivankustera
Example code should work with both localConfigStorage and loadJsonConfig.

What is your Node version?
What is the version of Keeper Secrets Manager JavaScript SDK?
"@keeper-security/secrets-manager-core": "^16.3.1",

A few suggestions that may help in resolving the issue:

  1. Try using absolute path for the config file.
  2. Debug print the JSON text before loading it into loadJsonConfig to make sure appKey is present - you should see a line like this: "appKey": "xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx=",
...
	const configJson = require('fs').readFileSync('./ksm-config.json').toString()
	console.log(configJson)
	const storage = loadJsonConfig(configJson)
...

Please do not post actual config file contents in this thread.

from secrets-manager.

ivankustera avatar ivankustera commented on July 30, 2024

Hi,

I have verified that config file and string I am passing to loadJsonConfig have all needed keys. This config was produced by the following CLI command:

secrets-manager client add --app MyApp --config-init json --unlock-ip

Also, I added some logging into storage's getValue and getBytes methods and I can see that at some point it gets value for appKey but later it fails. So the storage is at least initialised with it.

My node version is v16.13.0 and the sdk is "@keeper-security/secrets-manager-core": "^16.3.1".

from secrets-manager.

idimov-keeper avatar idimov-keeper commented on July 30, 2024

from secrets-manager.

ivankustera avatar ivankustera commented on July 30, 2024

Thanks for your reply, but I am still having troubles to make it work. Here are all the details:

node v16.13.0
@keeper-security/secrets-manager-core: "^16.3.1"
Keeper Commander v16.6.6 (Current version)
Python Version: 3.9.13

Here's the helper code:

const oneTimeToken = 'xxx'
module.exports.getKeeperRecords2 = async () => {
  const storage = localConfigStorage("ksm-config-2.json")

  await initializeStorage(storage, oneTimeToken)

  const { records } = await getSecrets({ storage: storage })
  console.log({records})
}

The initial run is fine, I get empty array as expected. But the next run fails with the error:

/Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:266
        throw new Error(`Unable to load the key ${keyId}`);
              ^

Error: Unable to load the key appKey
    at /Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:266:15
    at Generator.next (<anonymous>)
    at /Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:54:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:50:12)
    at loadKey (/Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:257:37)
    at /Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:360:23
    at Generator.next (<anonymous>)
    at /Users/ivan/keeper-poc/node_modules/@keeper-security/secrets-manager-core/dist/index.cjs.js:54:71
    at new Promise (<anonymous>)

I verified that the config generated using one time token was identical as the one that was initialised from the commander.

from secrets-manager.

ivankustera avatar ivankustera commented on July 30, 2024

After a short consultation with Max we figured out the the issue is an empty vault. When I added an empty secret it worked immediately. I am renaming this issue to be more clear what the problem is.

from secrets-manager.

maksimu avatar maksimu commented on July 30, 2024

@ivankustera thank you working with us and trying to get to bottom of this issue. We will try to fix this issue soon and also will add a better error messaging.

from secrets-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.