Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
fix(deps): update dependency @google-cloud/secret-manager to v3 (#345)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency @google-cloud/secret-manager to v3

* fix: use public api of secret-manager dependency

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Markus Maga <[email protected]>
  • Loading branch information
3 people authored Sep 28, 2020
1 parent 4c2ae7b commit 2bf42db
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 158 deletions.
8 changes: 4 additions & 4 deletions lib/backends/gcp-secrets-manager-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GCPSecretsManagerBackend extends KVBackend {
* Gets the project id from auth object from the GCP Secret Manager Client
*/
_getProjectId () {
return this._client.auth._cachedProjectId
return this._client.auth.getProjectId()
}

/**
Expand All @@ -31,7 +31,7 @@ class GCPSecretsManagerBackend extends KVBackend {
async _get ({ key, keyOptions, specOptions: { projectId } }) {
if (!projectId) {
// get the project id from client
projectId = this._getProjectId()
projectId = await this._getProjectId()
}

let secretVersion = 'latest'
Expand All @@ -41,10 +41,10 @@ class GCPSecretsManagerBackend extends KVBackend {

this._logger.info(`fetching secret ${key} from GCP Secret for project ${projectId} with version ${secretVersion}`)

const version = await this._client.accessSecretVersion({
const [version] = await this._client.accessSecretVersion({
name: 'projects/' + projectId + '/secrets/' + key + '/versions/' + secretVersion
})
const secret = version[0].payload.data.toString('utf8')
const secret = version.payload.data.toString('utf8')
// Handle binary files - this is useful when you've stored a base64 encoded string
if (keyOptions && keyOptions.isBinary) {
return Buffer.from(secret, 'base64')
Expand Down
Loading

0 comments on commit 2bf42db

Please sign in to comment.