-
Notifications
You must be signed in to change notification settings - Fork 50
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
840b01f
commit ddaf0f9
Showing
5 changed files
with
82 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
const { BitwardenClient: BitwardenClientWasm, LogLevel } = require('@bitwarden/sdk-wasm'); | ||
const sdk = require('@bitwarden/sdk-client'); | ||
|
||
|
||
async function main() { | ||
const settings = { | ||
apiUrl: process.env.API_URL, | ||
identityUrl: process.env.IDENTITY_URL | ||
}; | ||
|
||
const client = new sdk.BitwardenClient(new BitwardenClientWasm(JSON.stringify(settings), LogLevel.Debug)); | ||
|
||
const organization_id = process.env.ORGANIZATION_ID; | ||
await client.accessTokenLogin(process.env.ACCESS_TOKEN); | ||
|
||
|
||
const project = await client.projects().create('test', organization_id); | ||
const projects = await client.projects().list(organization_id); | ||
console.log(projects.data); | ||
|
||
const secret = await client.secrets().create('test-secret', "My secret!", "This is my secret", [project.id], organization_id); | ||
const secrets = await client.secrets().list(organization_id); | ||
console.log(secrets.data); | ||
|
||
console.log(project, secret); | ||
|
||
await client.projects().delete([project.id]); | ||
await client.secrets().delete([secret.id]); | ||
} | ||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "sdk-example", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"@bitwarden/sdk-client": "../sdk-client", | ||
"@bitwarden/sdk-wasm": "../wasm" | ||
} | ||
} | ||
|
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 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