Skip to content

Commit 312c0b0

Browse files
authored
API-2239 / API-2184 Vulnerabilities in the Javascript SDK (#134)
* API-2239 update simple-oauth2 and @hapi/hoek, use node 12 * API-2239 update elliptic, simple oauth * API-2239 update jest * API-2239 update eslint * API-2239 update gulp js doc deps * API-2239 update babel/gulp * API-2239 update simple oauth 2 3.4.0 * API-2239 sample files using client credentials * API-2239 add tag and metaproperties samples * API-2239 add node 12 for tests, github action * API-2239 update node versions tests, github action * API-2239 update node versions publish, github action * API-2239 update Dockerfile, README/package version
1 parent b7e2c4d commit 312c0b0

14 files changed

+5085
-4509
lines changed

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
node-version: [ 8.x, 10.x, 11.x ]
20+
node-version: [ 12.x, 14.x, 16.x, 17.x, 18.x ]
2121

2222
steps:
2323
- uses: actions/checkout@v4

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [ 8.x, 10.x, 11.x ]
19+
node-version: [ 12.x, 14.x, 16.x, 17.x, 18.x ]
2020

2121
steps:
2222
- uses: actions/checkout@v4

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:11
1+
FROM node:12
22

33
RUN mkdir /app
44
WORKDIR /app

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface to communicate with
1212

1313
To use this SDK, you will need:
1414

15-
- [Node.js **v6.3.0 or above**](https://nodejs.org/)
15+
- [Node.js **v12 or above**](https://nodejs.org/) (SDK Version 2.5.0 and above)
1616

1717
Node installation will include [NPM](https://www.npmjs.com/), which is
1818
responsible for dependency management.

gulpfile.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ gulp.task("lint", () => {
1717
.pipe(eslint.format());
1818
});
1919

20-
gulp.task("babel", () => {
20+
gulp.task("babel", async () => {
2121
gulp
2222
.src("src/*.js")
2323
.pipe(
2424
babel({
25-
presets: ["env"],
26-
plugins: ["transform-object-rest-spread",
27-
["transform-runtime", {
28-
"polyfill": false,
25+
presets: ["@babel/preset-env"],
26+
plugins: ["@babel/plugin-proposal-object-rest-spread",
27+
// polyfill skipped by default
28+
["@babel/plugin-transform-runtime", {
2929
"regenerator": true
3030
}
3131
]
@@ -35,9 +35,9 @@ gulp.task("babel", () => {
3535
.pipe(gulp.dest("dist"));
3636
});
3737

38-
gulp.task("build", () => {
38+
gulp.task("build", async () => {
3939
webpack({
40-
entry: ["babel-polyfill", path.join(__dirname, "./src/bynder-js-sdk")],
40+
entry: ["@babel/polyfill", path.join(__dirname, "./src/bynder-js-sdk")],
4141
output: {
4242
path: path.join(__dirname, "/dist/"),
4343
filename: "bundle.js",
@@ -52,17 +52,17 @@ gulp.task("build", () => {
5252
test: /\.js$/,
5353
exclude: /node_modules/,
5454
loader: "babel-loader",
55-
query: {
56-
presets: ["env"],
57-
plugins: ["transform-object-rest-spread"],
55+
options: {
56+
presets: ["@babel/preset-env"],
57+
plugins: ["@babel/plugin-proposal-object-rest-spread"],
5858
}
5959
},
6060
{
6161
test: /\.js$/,
6262
include: /node_modules\/proper-url-join/,
6363
loader: "babel-loader",
64-
query: {
65-
presets: [["env", { "modules": 'commonjs' }]],
64+
options: {
65+
presets: [["@babel/preset-env", { "modules": 'commonjs' }]],
6666
plugins: ["add-module-exports"]
6767
}
6868
}

package.json

+27-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bynder/bynder-js-sdk",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"description": "Bynder Javascript SDK",
55
"main": "./dist/bynder-js-sdk.js",
66
"scripts": {
@@ -14,48 +14,57 @@
1414
"dist/bynder-js-sdk.js"
1515
],
1616
"devDependencies": {
17-
"babel": "^6.23.0",
18-
"babel-core": "^6.26.3",
19-
"babel-loader": "^7.1.5",
17+
"@babel/core": "^7.26.9",
18+
"@babel/plugin-transform-object-rest-spread": "^7.25.9",
19+
"@babel/polyfill": "^7.0.0",
20+
"@babel/preset-env": "^7.0.0",
21+
"babel-core": "^7.0.0-bridge.0",
22+
"babel-jest": "^24.0.0",
23+
"babel-loader": "^8.0.0",
2024
"babel-plugin-add-module-exports": "^1.0.4",
21-
"babel-polyfill": "^6.26.0",
22-
"babel-preset-env": "^1.7.0",
23-
"eslint": "~3.7.1",
25+
"eslint": "^5.0.0",
2426
"eslint-config-airbnb": "^18.0.1",
2527
"eslint-plugin-import": "^2.18.2",
2628
"eslint-plugin-jsx-a11y": "^6.2.3",
2729
"eslint-plugin-react": "^7.15.1",
28-
"gulp": "^3.9.1",
29-
"gulp-babel": "^7.0.1",
30+
"gulp": "^4.0.0",
31+
"gulp-babel": "^8.0.0",
3032
"gulp-connect": "^5.7.0",
3133
"gulp-eslint": "^6.0.0",
32-
"gulp-jsdoc3": "^2.0.0",
33-
"jest": "^24.9.0",
34+
"gulp-jsdoc3": "^3.0.0",
35+
"jest": "^28.1.3",
3436
"json-loader": "^0.5.7",
3537
"path": "^0.12.7",
36-
"webpack": "^4.41.0"
38+
"webpack": "^4.44.2"
3739
},
3840
"dependencies": {
39-
"axios": "^0.27.2",
40-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
41-
"babel-plugin-transform-runtime": "^6.23.0",
42-
"elliptic": "6.5.4",
41+
"@babel/core": "^7.26.9",
42+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
43+
"@babel/plugin-transform-runtime": "^7.0.0",
44+
"axios": "^0.28.0",
45+
"elliptic": "6.6.1",
4346
"handlebars": "4.7.7",
4447
"ini": "1.3.8",
4548
"is-url": "^1.2.4",
4649
"isomorphic-form-data": "^1.0.0",
4750
"proper-url-join": "^1.2.0",
4851
"query-string": "6.14.1",
49-
"simple-oauth2": "^2.5.1",
52+
"simple-oauth2": "^3.4.0",
5053
"ssri": "6.0.2",
5154
"websocket-extensions": "0.1.4",
5255
"y18n": "4.0.3",
5356
"yargs-parser": "13.1.2"
5457
},
5558
"resolutions": {
59+
"braces": "^3.0.3",
5660
"graceful-fs": "^4.2.4",
5761
"lodash": "^4.17.21",
58-
"@hapi/hoek": "8.5.0"
62+
"json5": "2.2.3",
63+
"micromatch": "4.0.8",
64+
"postcss": "8.4.31",
65+
"sanitize-html": "2.12.1",
66+
"send": "0.19.0",
67+
"serialize-javascript": "6.0.2"
5968
},
6069
"repository": "[email protected]:Bynder/bynder-js-sdk.git"
6170
}

samples/brands_client_credentials.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
5+
const brandsSample = async () => {
6+
const bynder = new Bynder(configs);
7+
const token = await bynder.getTokenClientCredentials();
8+
9+
bynder.getBrands()
10+
.then((data) => {
11+
console.log(data);
12+
})
13+
.catch((error) => {
14+
console.error(error);
15+
});
16+
}
17+
18+
brandsSample();
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
5+
const collectionsSample = async () => {
6+
const bynder = new Bynder(configs);
7+
const token = await bynder.getTokenClientCredentials();
8+
9+
bynder.getCollections()
10+
.then((data) => {
11+
console.log(data);
12+
})
13+
.catch((error) => {
14+
console.error(error);
15+
});
16+
}
17+
18+
collectionsSample();

samples/media_client_credentials.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
5+
const mediaSample = async () => {
6+
const bynder = new Bynder(configs);
7+
const token = await bynder.getTokenClientCredentials();
8+
9+
bynder.getMediaList({
10+
type: 'image',
11+
limit: 9,
12+
page: 1
13+
})
14+
.then((data) => {
15+
console.log('getAssets with parameters', data, '\n\n');
16+
return bynder.getMediaList();
17+
})
18+
.then((data) => {
19+
console.log('getAssetsTotal', data, '\n\n');
20+
return bynder.getMediaList({
21+
page: 1,
22+
limit: 9
23+
});
24+
})
25+
}
26+
27+
mediaSample();
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
5+
const metapropertySample = async () => {
6+
const bynder = new Bynder(configs);
7+
const token = await bynder.getTokenClientCredentials();
8+
9+
bynder.getMetaproperties()
10+
.then((data) => {
11+
console.log('getMetaproperties', data, '\n\n');
12+
})
13+
}
14+
15+
metapropertySample();
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
const smartFiltersSample = async () => {
5+
const bynder = new Bynder(configs);
6+
const token = await bynder.getTokenClientCredentials();
7+
8+
bynder.getSmartfilters()
9+
.then((data) => {
10+
console.log(data);
11+
})
12+
.catch((error) => {
13+
console.error(error);
14+
});
15+
}
16+
17+
smartFiltersSample();

samples/tags_client_credentials.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Bynder = require('../dist/bynder-js-sdk.js');
2+
const configs = require('../secret.json');
3+
4+
const tagSample = async () => {
5+
const bynder = new Bynder(configs);
6+
const token = await bynder.getTokenClientCredentials();
7+
8+
bynder.getTags()
9+
.then((data) => {
10+
console.log(data);
11+
})
12+
.catch((error) => {
13+
console.log(error);
14+
});
15+
}
16+
17+
tagSample();
18+

samples/upload_client_credentials.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const Bynder = require('../dist/bynder-js-sdk.js');
4+
const configs = require('../secret.json');
5+
6+
const uploadSample = async () => {
7+
const bynder = new Bynder(configs);
8+
const token = await bynder.getTokenClientCredentials();
9+
10+
bynder.getBrands()
11+
.then((data) => {
12+
const brand = data[0];
13+
const file = `${__dirname}/testasset.png`;
14+
return bynder.uploadFile({
15+
filename: path.basename(file),
16+
body: fs.readFileSync(file),
17+
data: {
18+
brandId: brand.id,
19+
name: 'test asset'
20+
}
21+
}, console.log);
22+
})
23+
.then(console.log)
24+
.catch((error) => {
25+
console.error(error);
26+
});
27+
}
28+
29+
uploadSample()

0 commit comments

Comments
 (0)