sdk
sdk copied to clipboard
Can't update secret through JS SDK: 404 Not Found
Steps To Reproduce
Here is an example using the JS SDK to update a secret:
import {
BitwardenClient,
type ClientSettings,
DeviceType,
LogLevel,
} from "@bitwarden/sdk-napi";
const BITWARDEN_ACCESS_TOKEN = "**redacted**";
const settings: ClientSettings = {
apiUrl: "https://api.bitwarden.com",
identityUrl: "https://identity.bitwarden.com",
userAgent: "Bitwarden SDK",
deviceType: DeviceType.SDK,
};
// Can't use LogLevel.Info here, due to:
// SyntaxError: Export named 'LogLevel' not found in module '/**redacted**/node_modules/@bitwarden/sdk-napi/dist/index.js'.
const client = new BitwardenClient(settings, 2);
const result = await client.loginWithAccessToken(BITWARDEN_ACCESS_TOKEN);
if (!result.success) {
throw Error("Authentication failed");
}
const secret = (
await client.secrets().get("45036529-9d5c-4dc5-9662-b1f800fd82d9")
).data;
if (!secret) {
throw Error("Secret not found");
}
const secretUpdateResponse = await client
.secrets()
.update(
secret.id,
secret.key,
secret.note,
secret.organizationId,
"foo",
);
console.log(secretUpdateResponse);
Sadly, the current SDK seems to be unusable for now.
Expected Result
I would expect this to update the given secret.
Actual Result
The response is:
{
data: null,
errorMessage: "Received error message from server: [404 Not Found] {\"message\":\"Resource not found.\",\"validationErrors\":null,\"exceptionMessage\":null,\"exceptionStackTrace\":null,\"innerExceptionMessage\":null,\"object\":\"error\"}",
success: false,
}
Aside from that, it's also not possible to use LogLevel.Info as described on the npm package: https://www.npmjs.com/package/@bitwarden/sdk-napi
Since using that causes a syntax error:
SyntaxError: Export named 'LogLevel' not found in module '/**redacted**/node_modules/@bitwarden/sdk-napi/dist/index.js'.
Screenshots or Videos
No response
Additional Context
No response
Operating System
Linux
Operating System Version
No response
Build Version
"@bitwarden/sdk-napi": "^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.