Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade dependencies to latest #183

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- '10'
- '12'
- '10'
- '12'
- '14'
sudo: false
script:
- if [[ $DEPLOY_DOCS ]]; then bash ./scripts/docs.sh; fi
Expand All @@ -23,4 +24,4 @@ notifications:
on_success: never
on_failure: always
rooms:
- secure: "YoSSxftifz8V8BIGXQSAJTg+mkKs+QVYrnSJ7U4r1M4oP8QUgzBhgv8oBoA35uUA9YqLUi5kYqF7ClRiGg/UAzECEb9svH3Y1ipCvTr/Sz7DEOA960ZgqiEduP8YZARPxJo6aGUR1t8ZF9t1mVK9lFiNchuvZ6+GqKhxpvCkojE3bFZj+0QIw1OuTFdApR7j+ZTazCB9iE6Wx92Jfad0KS47C9jr7+7IF03eSN7VOsLUNQlP659TTeUMbHZ0IcmhalazTtgDiSRuUjYfBTzhKB/gYAVFfccNNx7fQGUHUu29Qm6JKenyZq1BxNNw/CAMvwFePmBukdVaVTdn5YVLe1v3uERnzYd/vbGHdTW8t1Dh13zXtZA4mERRDpSOeyp1MSmJDBg7iKG4UmtpcpuTHQr/1n12BV2wjMLw3VYdQym8t/uYFsnaKcJf9CSR2Rz9B1laLDIxAgzcyjksupKSmMuT1FQiKDAGQCov5UBxvGpSz7MP4fgSe7/de2ypxnLZvrmgWsuriLXgKgXjtGhhr/BKhXkwZc7rmxjJ0ZJodmLIbePG7ylFH/e4B2rBwApMTr518/Zh6uQIXExxmUq9fNb5c9ObReU04DVded6uqy2bnIQMdjZ3oevuXCdwZiIjAyKpLx3WSsYs3pTfLgLkyGhNkwoqO/NTew7bt6T9l40="
- secure: 'YoSSxftifz8V8BIGXQSAJTg+mkKs+QVYrnSJ7U4r1M4oP8QUgzBhgv8oBoA35uUA9YqLUi5kYqF7ClRiGg/UAzECEb9svH3Y1ipCvTr/Sz7DEOA960ZgqiEduP8YZARPxJo6aGUR1t8ZF9t1mVK9lFiNchuvZ6+GqKhxpvCkojE3bFZj+0QIw1OuTFdApR7j+ZTazCB9iE6Wx92Jfad0KS47C9jr7+7IF03eSN7VOsLUNQlP659TTeUMbHZ0IcmhalazTtgDiSRuUjYfBTzhKB/gYAVFfccNNx7fQGUHUu29Qm6JKenyZq1BxNNw/CAMvwFePmBukdVaVTdn5YVLe1v3uERnzYd/vbGHdTW8t1Dh13zXtZA4mERRDpSOeyp1MSmJDBg7iKG4UmtpcpuTHQr/1n12BV2wjMLw3VYdQym8t/uYFsnaKcJf9CSR2Rz9B1laLDIxAgzcyjksupKSmMuT1FQiKDAGQCov5UBxvGpSz7MP4fgSe7/de2ypxnLZvrmgWsuriLXgKgXjtGhhr/BKhXkwZc7rmxjJ0ZJodmLIbePG7ylFH/e4B2rBwApMTr518/Zh6uQIXExxmUq9fNb5c9ObReU04DVded6uqy2bnIQMdjZ3oevuXCdwZiIjAyKpLx3WSsYs3pTfLgLkyGhNkwoqO/NTew7bt6T9l40='
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@
"repository": "https://github.com/okta/okta-sdk-nodejs",
"dependencies": {
"deep-copy": "^1.4.2",
"flat": "^2.0.1",
"flat": "^5.0.0",
"isomorphic-fetch": "2.2.1",
"js-yaml": "^3.13.0",
"lodash": "^4.17.14",
"js-yaml": "^3.14.0",
"lodash": "^4.17.19",
"njwt": "^1.0.0",
"parse-link-header": "1.0.0",
"parse-link-header": "^1.0.1",
"rasha": "^1.2.5"
},
"devDependencies": {
"@okta/openapi": "^2.0.0",
"chai": "^3.5.0",
"eslint": "^3.19.0",
"eslint-plugin-jest": "^21.17.0",
"chai": "^4.2.0",
"eslint": "^7.5.0",
"eslint-plugin-jest": "^23.19.0",
"fake-fs": "^0.5.0",
"faker": "^4.1.0",
"globby": "^6.1.0",
"ink-docstrap": "^1.3.0",
"jest": "^23.1.0",
"globby": "^11.0.1",
"ink-docstrap": "^1.3.2",
"jest": "^26.1.0",
"jest-date-mock": "^1.0.8",
"jsdoc": "^3.4.0",
"mocha": "^3.4.1",
"nyc": "^10.3.2",
"jsdoc": "^3.6.5",
"mocha": "^8.0.1",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"sinon": "^7.3.1",
"sinon": "^9.0.2",
"speakeasy": "^2.0.0"
},
"jest": {
Expand Down
132 changes: 66 additions & 66 deletions src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class Collection {
}

self.getNextPage()
.then(collection => {
self.currentItems = collection;
return nextItem();
})
.catch(reject);
.then(collection => {
self.currentItems = collection;
return nextItem();
})
.catch(reject);
});
}

Expand All @@ -67,18 +67,18 @@ class Collection {

getNextPage() {
return this.client.http.http(this.nextUri, this.request, {isCollection: true})
.then(res => {
const link = res.headers.get('link');
if (link) {
const parsed = parseLinkHeader(link);
if (parsed.next) {
this.nextUri = parsed.next.url;
return res.json();
.then(res => {
const link = res.headers.get('link');
if (link) {
const parsed = parseLinkHeader(link);
if (parsed.next) {
this.nextUri = parsed.next.url;
return res.json();
}
}
}
this.nextUri = undefined;
return res.json();
});
this.nextUri = undefined;
return res.json();
});
}

/**
Expand All @@ -90,32 +90,32 @@ class Collection {
const self = this;
function nextItem() {
return self.next()
.then(nextResult => {
if (!nextResult.value) {
return;
}
const result = iterator(nextResult.value);

// if it's a Promise
if (result && result.then) {
return result.then(shouldContinue => {
if (shouldContinue !== false && !nextResult.done) {
return nextItem();
}
});

// if they want to short-circuit
} else if (result === false) {
return;

// if there are no more items
} else if (nextResult.done) {
return;
}

// if it's synchronous and not short-circuited
return nextItem();
});
.then(nextResult => {
if (!nextResult.value) {
return;
}
const result = iterator(nextResult.value);

// if it's a Promise
if (result && result.then) {
return result.then(shouldContinue => {
if (shouldContinue !== false && !nextResult.done) {
return nextItem();
}
});

// if they want to short-circuit
} else if (result === false) {
return;

// if there are no more items
} else if (nextResult.done) {
return;
}

// if it's synchronous and not short-circuited
return nextItem();
});
}

return nextItem();
Expand Down Expand Up @@ -148,30 +148,30 @@ class Collection {
return;
}
return self.next()
.then(nextResult => {
if (closed) {
return;
}

if (!nextResult.value) {
return setTimeout(nextItem, interval);
}
const result = config.next(nextResult.value);

// if it's a Promise
if (result && result.then) {
return result.then(() => nextItem());
} else {
nextItem();
}
})
.catch(err => {
const errResult = config.error(err);
if (errResult && errResult.then) {
return errResult.then(() => nextItem());
}
return nextItem();
});
.then(nextResult => {
if (closed) {
return;
}

if (!nextResult.value) {
return setTimeout(nextItem, interval);
}
const result = config.next(nextResult.value);

// if it's a Promise
if (result && result.then) {
return result.then(() => nextItem());
} else {
nextItem();
}
})
.catch(err => {
const errResult = config.error(err);
if (errResult && errResult.then) {
return errResult.then(() => nextItem());
}
return nextItem();
});
}

nextItem();
Expand Down
72 changes: 36 additions & 36 deletions src/default-cache-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,45 @@ module.exports = function defaultCacheMiddleware(ctx, next) {
if (ctx.req.method.toLowerCase() === 'get' && !ctx.isCollection) {
// TODO: use ctx.req.url as cache key and add json() method to cached result: https://oktainc.atlassian.net/browse/OKTA-280090
cacheCheck = ctx.cacheStore.get(ctx.req.uri)
.then(body => {
if (body) {
cacheHit = true;
ctx.res = {
status: 200,
text() {
return Promise.resolve(body);
}
};
}
});
.then(body => {
if (body) {
cacheHit = true;
ctx.res = {
status: 200,
text() {
return Promise.resolve(body);
}
};
}
});
}
return Promise.resolve(cacheCheck)
.then(() => next())
.then(() => {
if (cacheHit || ctx.isCollection) {
return;
}
if (ctx.req.method.toLowerCase() === 'get') {
.then(() => next())
.then(() => {
if (cacheHit || ctx.isCollection) {
return;
}
if (ctx.req.method.toLowerCase() === 'get') {
// store response in cache
return ctx.res.clone().text()
.then(text => {
try {
const selfHref = _.get(JSON.parse(text), '_links.self.href');
if (selfHref) {
ctx.cacheStore.set(selfHref, text);
}
} catch (e) {
// TODO: add custom logger
}
});
} else {
return ctx.res.clone().text()
.then(text => {
try {
const selfHref = _.get(JSON.parse(text), '_links.self.href');
if (selfHref) {
ctx.cacheStore.set(selfHref, text);
}
} catch (e) {
// TODO: add custom logger
}
});
} else {
// clear cache for affected resources
const affected = [];
const resources = ctx.resources || [];
for (let resource of resources) {
affected.push(ctx.cacheStore.delete(resource));
const affected = [];
const resources = ctx.resources || [];
for (let resource of resources) {
affected.push(ctx.cacheStore.delete(resource));
}
return Promise.all(affected);
}
return Promise.all(affected);
}
});
});
};
2 changes: 1 addition & 1 deletion src/default-request-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DefaultRequestExecutor extends RequestExecutor {
}
newRequest.headers[this.retryCountHeader] =
newRequest.headers[this.retryCountHeader] ?
newRequest.headers[this.retryCountHeader] + 1 : 1;
newRequest.headers[this.retryCountHeader] + 1 : 1;
return newRequest;
}

Expand Down
10 changes: 5 additions & 5 deletions src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Http {
}

return this.oauth.getAccessToken()
.then(accessToken => {
request.headers.Authorization = `Bearer ${accessToken.access_token}`;
});
.then(accessToken => {
request.headers.Authorization = `Bearer ${accessToken.access_token}`;
});
}

http(uri, request, context) {
Expand Down Expand Up @@ -103,7 +103,7 @@ class Http {

return promise.then(res => ctx.res = res);
})
.then(() => ctx.res);
.then(() => ctx.res);
};

return execute();
Expand All @@ -120,7 +120,7 @@ class Http {
'Accept': 'application/json'
}, request.headers);
return this.http(uri, request, context)
.then(res => res.json());
.then(res => res.json());
}

getJson(uri, request, context) {
Expand Down
1 change: 1 addition & 0 deletions src/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function formatParams(obj) {
var str = [];
if (obj !== null) {
for (var key in obj) {
// eslint-disable-next-line no-prototype-builtins
if (obj.hasOwnProperty(key) &&
obj[key] !== undefined &&
obj[key] !== null) {
Expand Down
38 changes: 19 additions & 19 deletions src/okta-response-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@

function OktaResponseHeaders(responseHeadersMap) {
return Object.entries(responseHeadersMap)
.reduce((acc, arr) => {
const key = arr[0];
const value = arr[1][0];
switch (key) {
case 'x-okta-request-id':
acc[key] = value;
break;
case 'x-rate-limit-limit':
acc[key] = parseInt(value, 10);
break;
case 'x-rate-limit-remaining':
acc[key] = parseInt(value, 10);
break;
case 'x-rate-limit-reset':
acc[key] = parseInt(value, 10);
break;
}
return acc;
}, {});
.reduce((acc, arr) => {
const key = arr[0];
const value = arr[1][0];
switch (key) {
case 'x-okta-request-id':
acc[key] = value;
break;
case 'x-rate-limit-limit':
acc[key] = parseInt(value, 10);
break;
case 'x-rate-limit-remaining':
acc[key] = parseInt(value, 10);
break;
case 'x-rate-limit-reset':
acc[key] = parseInt(value, 10);
break;
}
return acc;
}, {});
}

module.exports = OktaResponseHeaders;
Loading