New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

google-cloud-bucket

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-cloud-bucket - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="0.1.4"></a>
## [0.1.4](https://github.com/nicolasdao/google-cloud-bucket/compare/v0.1.3...v0.1.4) (2018-11-25)
### Features
* Add support for updating a bucket's config as well as gettnig that config ([8de1577](https://github.com/nicolasdao/google-cloud-bucket/commit/8de1577))
<a name="0.1.3"></a>

@@ -7,0 +17,0 @@ ## [0.1.3](https://github.com/nicolasdao/google-cloud-bucket/compare/v0.1.2...v0.1.3) (2018-11-25)

12

index.js

@@ -62,2 +62,4 @@ /**

const getObject = (bucket, filePath) => getToken(auth).then(token => gcp.get(bucket, filePath, token))
const getBucket = (bucket) => getToken(auth).then(token => gcp.config.get(bucket, token))
const updateConfig = (bucket, config={}) => getToken(auth).then(token => gcp.config.update(bucket, config, token))
const makePublic = filePath => getToken(auth).then(token => {

@@ -86,3 +88,11 @@ const { bucket, file } = _getBucketAndPathname(filePath, { ignoreMissingFile: true })

'get': retryGetObject,
makePublic
makePublic,
config: (bucket) => Promise.resolve(null).then(() => {
if(!bucket)
throw new Error('Missing required \'bucket\' argument')
return {
'get': () => getBucket(bucket),
update: (config={}) => updateConfig(bucket, config)
}
})
}

@@ -89,0 +99,0 @@ }

2

package.json
{
"name": "google-cloud-bucket",
"version": "0.1.3",
"version": "0.1.4",
"description": "Nodejs package to add objects to a Google Cloud Bucket.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,4 +43,13 @@ /**

const getBucket = (bucket, token) => Promise.resolve(null).then(() => {
_validateRequiredParams({ bucket, token })
return fetch.get(BUCKET_URL(bucket), {
Accept: 'application/json',
Authorization: `Bearer ${token}`
})
})
const getBucketFile = (bucket, filepath, token) => Promise.resolve(null).then(() => {
_validateRequiredParams({ filepath, token })
_validateRequiredParams({ bucket, filepath, token })

@@ -116,7 +125,34 @@ const { contentType } = urlHelper.getInfo(filepath)

const updateConfig = (bucket, config={}, token) => Promise.resolve(null).then(() => {
_validateRequiredParams({ bucket, token })
if (!Object.keys(config).some(x => x))
return { status: 200, data: { message: 'Empty config. Nothing to update.' } }
const payload = JSON.stringify(config)
return fetch.patch(`${BUCKET_URL(bucket)}`, {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}, payload).then(({ status, data }) => {
if (status < 400) {
data = data || {}
data.uri = `https://storage.googleapis.com/${encodeURIComponent(bucket)}`
return { status, data }
}
let e = new Error(status == 404 ? 'Object not found' : status == 401 ? 'Access denied' : 'Internal Server Error')
e.code = status
e.data = data
throw e
})
})
module.exports = {
insert: putObject,
'get': getBucketFile,
makePublic
makePublic,
config: {
'get': getBucket,
update: updateConfig
}
}

@@ -123,0 +159,0 @@

@@ -20,2 +20,5 @@ /**

const patchData = (url, headers={}, body) =>
fetch(url, { method: 'PATCH', headers, body }).then(_processResponse)
const getData = (url, headers={}) =>

@@ -27,3 +30,4 @@ fetch(url, { method: 'GET', headers }).then(_processResponse)

'get': getData,
put: putData
put: putData,
patch: patchData
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc