Using 'createTritonApiClient' and setting profile.privKey throws error

Open
#192 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, node.js
Domain
api, cloud

Research direction

Start in TritonApi._setupProfile and compare its use of auth.KeyPair.fromPrivateKey with the exports in smartdc-auth's lib/index.js. Reproduce the failure by creating a TritonApi client with profile.privKey supplied from an environment variable, then verify that this setup no longer throws the reported TypeError.

Written by the indexing model from the issue text.

Description

First, some background on what I'm trying to do...

I'd like to be able to use this tool in a Node.js app which is deployed in a Docker container and be able to pass in the private key as an enviroment variable.

To do this, I'm using the 'createTritonApiClient' function to create an instance of TritonApi, passing in a profile object with the privKey property set from the env variable. So far, so good.

However, when I do this, I get the error "TypeError: Cannot read property 'fromPrivateKey' of undefined".

Doing a little digging, it looks like these are the relevant lines in 'TritonApi._setupProfile':

var auth = require('smartdc-auth');

...

 auth.KeyPair.fromPrivateKey(key)

The problem appears to be that KeyPair isn't listed as export in the 'smartdc-auth' module.

If I add KeyPair as an export in my local copy of the 'smartdc-auth' module, everything works as expected.

Dominant language
JavaScript
Stars
60
Forks
36
Avg merge
3d 8h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TritonDataCenter/node-triton

All issues in TritonDataCenter/node-triton

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.