-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fc3b84
commit 98e2c07
Showing
4 changed files
with
135 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
|
||
<html> | ||
<head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import { LoggingLevel } from "./bitwarden_client/logging_level"; | ||
import { DeviceType } from "./bitwarden_client/schemas"; | ||
|
||
import("./bitwarden_client").then(async (module) => { | ||
const client = new module.BitwardenClient({ | ||
apiUrl: "http://localhost:8081/api", | ||
identityUrl: "http://localhost:8081/identity", | ||
deviceType: DeviceType.SDK, | ||
userAgent: "Bitwarden JS SDK", | ||
}, LoggingLevel.Debug); | ||
const result = await client.login("[email protected]", "asdfasdf"); | ||
console.log(`auth result success: ${result.success}`); | ||
const client = new module.BitwardenClient( | ||
{ | ||
apiUrl: "http://localhost:8081/api", | ||
identityUrl: "http://localhost:8081/identity", | ||
deviceType: DeviceType.SDK, | ||
userAgent: "Bitwarden JS SDK", | ||
}, | ||
module.LogLevel.Debug, | ||
); | ||
|
||
const apikeyResponse = await client.getUserApiKey("asdfasdf"); | ||
console.log(`user API key: ${apikeyResponse.data.apiKey}`); | ||
const accessToken = "insert your access token here"; | ||
const organizationId = "insert your organization id here"; | ||
|
||
const sync = await client.sync(); | ||
console.log("Sync result", sync); | ||
await client.accessTokenLogin(accessToken); | ||
|
||
const org_id = sync.data.profile.organizations[0].id; | ||
const secret = await client | ||
.secrets() | ||
.create("TEST_KEY", "Secret1234!", "This is a test secret", organizationId); | ||
console.log("New secret: ", secret); | ||
|
||
const secret = await client.secrets().create("TEST_KEY", "This is a test secret", org_id, "Secret1234!"); | ||
console.log("New secret: ", secret.data); | ||
|
||
await client.secrets().delete([secret.data.id]); | ||
await client.secrets().delete([secret.id]); | ||
}); |