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

Projects support for npm @bitwarden/sdk-napi #914

Closed
1 task done
wmr-trevor opened this issue Jul 19, 2024 · 5 comments
Closed
1 task done

Projects support for npm @bitwarden/sdk-napi #914

wmr-trevor opened this issue Jul 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@wmr-trevor
Copy link

Steps To Reproduce

  1. Install the package npm i @bitwarden/sdk-napi
  2. Attempt to get project info

Expected Result

I would have expected the .project() property to be set in the BitwardenClient class similar to .secret()

I would also assume that a new ProjectsClient class will be needed similar to the SecretsClient class found in crates/bitwarden-napi/src-ts/bitwarden_client/index.ts

Actual Result

There is currently not a easy supported method to get project information like there is for secrets.

Screenshots or Videos

No response

Additional Context

The relavant information needed to successfully run the commands is in the schema file.
So the following works to list the projects.

const { BitwardenClient } = require("@bitwarden/sdk-napi");
const {
    Convert,
} = require("@bitwarden/sdk-napi/dist/bitwarden_client/schemas");

async function main() {
    const organizationId = process.env.BWS_ORG_ID;
    const accessToken = process.env.BWS_ACCESS_TOKEN;
    if (
        typeof organizationId !== "string" ||
        !organizationId ||
        typeof accessToken !== "string" ||
        !accessToken
    ) {
        throw new Error("Missing required environment variables");
    }

    // setup the bitwarden secrets manager
    const settings = {};
    const client = new BitwardenClient(settings);

    const result = await client.loginWithAccessToken(accessToken);
    if (!result.success) {
        throw new Error("Failed to login with access token");
    }

    const cmdResult = await client.client.runCommand(
        Convert.commandToJson({
            projects: {
                list: {
                    organizationId,
                },
            },
        })
    );

    const list = Convert.toResponseForProjectsResponse(cmdResult).data;

    console.log(list);
}
main();

More Detailed Version Info

└─┬ @bitwarden/[email protected]
  └── @bitwarden/[email protected]

Operating System

Linux

Operating System Version

Pop!_OS 22.04 LTS

Build Version

@0.3.1

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@wmr-trevor wmr-trevor added the bug Something isn't working label Jul 19, 2024
@dani-garcia
Copy link
Member

This should be fixed by #934 when it gets merged, I think

@Araxeus

This comment was marked as off-topic.

@Araxeus

This comment was marked as off-topic.

@Hinton
Copy link
Member

Hinton commented Sep 5, 2024

The team is working on publishing new versions of all the SDKs. I don't have a date but it should be soon.

@coltonhurst
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants