Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bynder/bynder-js-sdk

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bynder/bynder-js-sdk - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

secret.example.json

118

dist/bynder-js-sdk.js

@@ -186,3 +186,43 @@ 'use strict';

var bodyTypes = {
BUFFER: 'BUFFER',
BLOB: 'BLOB',
STREAM: 'STREAM',
/**
* @param {Object} body - The file body whose type we need to determine
* @return {string} One of bodyTypes.BUFFER, bodyTypes.BLOB, bodyTypes.STREAM
*/
get: function get(body) {
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(body)) {
return bodyTypes.BUFFER;
}
if (typeof window !== 'undefined' && window.Blob && body instanceof window.Blob) {
return bodyTypes.BLOB;
}
if (typeof body.read === 'function') {
return bodyTypes.STREAM;
}
return null;
}
};
/**
* @return {number} length - The amount of data that can be read from the file
*/
function getLength(file) {
var body = file.body,
length = file.length;
var bodyType = bodyTypes.get(body);
if (bodyType === bodyTypes.BUFFER) {
return body.length;
}
if (bodyType === bodyTypes.BLOB) {
return body.size;
}
return length;
}
/**
* @classdesc Represents the Bynder SDK. It allows the user to make every call to the API with a single function.

@@ -192,3 +232,2 @@ * @class

var Bynder = function () {

@@ -525,4 +564,4 @@ /**

}
var request = new APICall(this.baseURL, 'v4/metaproperties/', 'POST', this.consumerToken, this.accessToken, { data: JSON.stringify(object) } // The API requires an object with the query content stringified inside
);
var request = new APICall(this.baseURL, 'v4/metaproperties/', 'POST', this.consumerToken, this.accessToken, { data: JSON.stringify(object) // The API requires an object with the query content stringified inside
});
return request.send();

@@ -549,4 +588,4 @@ }

}
var request = new APICall(this.baseURL, 'v4/metaproperties/' + object.id + '/', 'POST', this.consumerToken, this.accessToken, { data: JSON.stringify(object) } // The API requires an object with the query content stringified inside
);
var request = new APICall(this.baseURL, 'v4/metaproperties/' + object.id + '/', 'POST', this.consumerToken, this.accessToken, { data: JSON.stringify(object) // The API requires an object with the query content stringified inside
});
return request.send();

@@ -762,2 +801,32 @@ }

/**
* Remove assets from desired collection.
* @see {@link http://docs.bynder.apiary.io/#reference/collections/specific-collection-operations/remove-asset-from-a-collection|API Call}
* @param {Object} queryObject={} - An object containing the id of the desired collection and deleteIds of assets.
* @param {String} queryObject.id - The id of the shared collection.
* @param {String} queryObject.deleteIds - Asset ids to remove from the collection
* @return {Promise} Response - Returns a Promise that, when fulfilled, will either return an Object with the
* response or an Error with the problem.
*/
}, {
key: 'deleteMediaFromCollection',
value: function deleteMediaFromCollection(queryObject) {
var parametersObject = queryObject;
if (!this.validURL()) {
return rejectURL();
}
if (!queryObject.id) {
return rejectValidation('collection', 'id');
}
if (!queryObject.deleteIds) {
return rejectValidation('collection', 'deleteIds');
}
if (Array.isArray(parametersObject.deleteIds)) {
parametersObject.deleteIds = parametersObject.deleteIds.join();
}
var request = new APICall(this.baseURL, 'v4/collections/' + queryObject.id + '/media/', 'DELETE', this.consumerToken, this.accessToken, parametersObject);
return request.send();
}
/**
* Share the collection to the recipients provided.

@@ -1000,4 +1069,4 @@ * @see {@link http://docs.bynder.apiary.io/#reference/collections/specific-collection-operations/share-collection|API Call}

var isBuffer = Buffer.isBuffer(body);
var length = isBuffer ? body.length : file.length;
var bodyType = bodyTypes.get(body);
var length = getLength(file);
var CHUNK_SIZE = 1024 * 1024 * 5;

@@ -1022,6 +1091,13 @@ var chunks = Math.ceil(length / CHUNK_SIZE);

form.append('file', chunkData);
var headers = Object.assign(form.getHeaders(), {
'content-length': form.getLengthSync()
});
return _axios2.default.post(endpoint, form, { headers: headers });
var opts = void 0;
if (typeof window !== 'undefined') {
opts = {}; // With browser based FormData headers are taken care of automatically
} else {
opts = {
headers: Object.assign(form.getHeaders(), {
'content-length': form.getLengthSync()
})
};
}
return _axios2.default.post(endpoint, form, opts);
};

@@ -1037,11 +1113,5 @@

}
// upload next chunk
var chunkData = void 0;
if (isBuffer) {
// handle buffer data
var start = chunkNumber * CHUNK_SIZE;
var end = Math.min(start + CHUNK_SIZE, length);
chunkData = body.slice(start, end);
} else {
if (bodyType === bodyTypes.STREAM) {
// handle stream data

@@ -1054,2 +1124,7 @@ chunkData = body.read(CHUNK_SIZE);

}
} else {
// handle buffer/blob data
var start = chunkNumber * CHUNK_SIZE;
var end = Math.min(start + CHUNK_SIZE, length);
chunkData = body.slice(start, end);
}

@@ -1083,5 +1158,4 @@ return uploadChunkToS3(chunkData, ++chunkNumber).then(function () {

var isBuffer = Buffer.isBuffer(body);
var isStream = typeof body.read === 'function';
var length = isBuffer ? body.length : file.length;
var bodyType = bodyTypes.get(body);
var length = getLength(file);

@@ -1097,3 +1171,3 @@ if (!this.validURL()) {

}
if (!body || !isStream && !isBuffer) {
if (!body || !bodyType) {
return rejectValidation('upload', 'body');

@@ -1100,0 +1174,0 @@ }

2

package.json
{
"name": "@bynder/bynder-js-sdk",
"version": "1.0.3",
"version": "1.0.4",
"description": "Bynder Javascript SDK",

@@ -5,0 +5,0 @@ "main": "./dist/bynder-js-sdk.js",

@@ -103,2 +103,3 @@ # Bynder JavaScript SDK

* `addMediaToCollection(queryObject)`
* `deleteMediaFromCollection(queryObject)`

@@ -105,0 +106,0 @@ ### Tags

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