Projects support for npm @bitwarden/sdk-napi
Steps To Reproduce
- Install the package
npm i @bitwarden/sdk-napi - 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
- [X] 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.
This should be fixed by https://github.com/bitwarden/sdk/pull/934 when it gets merged, I think
It was merged last week but no new version was released?
Merged one month ago but the version didn't change in the PR and the package wasn't published on npm @dani-garcia @Hinton
https://github.com/bitwarden/sdk/blob/7ee604f9a01cb6d3c4ea18d7048151ff4ececfbe/crates/bitwarden-napi/package.json#L3
The team is working on publishing new versions of all the SDKs. I don't have a date but it should be soon.
The 1.0 release: https://github.com/bitwarden/sdk/releases/tag/napi-v1.0.0