Socket
Socket
Sign inDemoInstall

@availity/api-core

Package Overview
Dependencies
5
Maintainers
18
Versions
118
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.3 to 7.0.4

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## 7.0.4 (2021-09-30)
### Bug Fixes
* **api-core:** fix organizations resources check ([28644b6](https://github.com/Availity/sdk-js/commit/28644b6431ba22df265225386e09aaec53f5a9e1))
## 7.0.3 (2021-09-16)

@@ -8,0 +19,0 @@

2

lib/resources/organizations.js

@@ -355,2 +355,4 @@ "use strict";

accum[orgId].match = false;
} else {
accum[orgId].resources = [].concat((0, _toConsumableArray2["default"])(accum[orgId].resources), (0, _toConsumableArray2["default"])(matchedOrgs[orgId].resources));
}

@@ -357,0 +359,0 @@ }

4

package.json
{
"name": "@availity/api-core",
"version": "7.0.3",
"version": "7.0.4",
"description": "Base API definitions for the Availity REST API",

@@ -30,3 +30,3 @@ "keywords": [

},
"gitHead": "e74d19e307f522cd164d32fa70cda7bbcf90a61d"
"gitHead": "c11abb5548bd3dc3ba37f4ee3e2214e4d5526f09"
}

@@ -44,5 +44,3 @@ /* eslint-disable unicorn/consistent-destructuring */

return this.avUsers
.me()
.then((user) => this.queryOrganizations(user, config));
return this.avUsers.me().then((user) => this.queryOrganizations(user, config));
}

@@ -79,6 +77,3 @@

const authorizedOrgs = await this.getFilteredOrganizations(
additionalPostGetArgs,
data
);
const authorizedOrgs = await this.getFilteredOrganizations(additionalPostGetArgs, data);

@@ -120,14 +115,7 @@ // avUserPermissions call doesn't return much useful organization data

// resourceIds is passed as readOnly, convert so that we can use Array methods on it
const resourceIdsArray = Array.isArray(resourceIdsToUse)
? resourceIdsToUse
: [resourceIdsToUse];
const resourceIdsArray = Array.isArray(resourceIdsToUse) ? resourceIdsToUse : [resourceIdsToUse];
const permissionIdsOR = Array.isArray(permissionIdsToUse)
? permissionIdsToUse
: [permissionIdsToUse];
const permissionIdsOR = Array.isArray(permissionIdsToUse) ? permissionIdsToUse : [permissionIdsToUse];
if (
region !== this.previousRegionId ||
!this.arePermissionsEqual(permissionIdsOR)
) {
if (region !== this.previousRegionId || !this.arePermissionsEqual(permissionIdsOR)) {
// avUserPermissions will return a list of user organizations that match given permission and region

@@ -158,38 +146,29 @@ // This call does not need to be paginated and

if (Array.isArray(permissionIdOR)) {
const matchedOrgs = permissionIdOR.reduce(
(matchedANDOrgsByPerm, permissionIdAND, index) => {
if (this.userPermissions[permissionIdAND]) {
for (const org of this.userPermissions[permissionIdAND]
.organizations) {
if (index === 0) {
// add the orgs for the first permission
matchedANDOrgsByPerm[org.id] = org;
} else if (matchedANDOrgsByPerm[org.id]) {
// if duplicate, add resources
matchedANDOrgsByPerm[org.id].resources = [
...matchedANDOrgsByPerm[org.id].resources,
...org.resources,
];
}
const matchedOrgs = permissionIdOR.reduce((matchedANDOrgsByPerm, permissionIdAND, index) => {
if (this.userPermissions[permissionIdAND]) {
for (const org of this.userPermissions[permissionIdAND].organizations) {
if (index === 0) {
// add the orgs for the first permission
matchedANDOrgsByPerm[org.id] = org;
} else if (matchedANDOrgsByPerm[org.id]) {
// if duplicate, add resources
matchedANDOrgsByPerm[org.id].resources = [...matchedANDOrgsByPerm[org.id].resources, ...org.resources];
}
}
// filter unmatched orgs out
matchedANDOrgsByPerm = Object.keys(matchedANDOrgsByPerm)
.filter((orgId) => {
if (this.userPermissions[permissionIdAND]) {
return this.userPermissions[
permissionIdAND
].organizations.some((org) => org.id === orgId);
}
return false;
})
.reduce((obj, orgId) => {
obj[orgId] = matchedANDOrgsByPerm[orgId];
return obj;
}, {});
}
// filter unmatched orgs out
matchedANDOrgsByPerm = Object.keys(matchedANDOrgsByPerm)
.filter((orgId) => {
if (this.userPermissions[permissionIdAND]) {
return this.userPermissions[permissionIdAND].organizations.some((org) => org.id === orgId);
}
return false;
})
.reduce((obj, orgId) => {
obj[orgId] = matchedANDOrgsByPerm[orgId];
return obj;
}, {});
return matchedANDOrgsByPerm;
},
{}
);
return matchedANDOrgsByPerm;
}, {});
for (const orgId of Object.keys(matchedOrgs)) {

@@ -199,2 +178,4 @@ if (!accum[orgId]) {

accum[orgId].match = false;
} else {
accum[orgId].resources = [...accum[orgId].resources, ...matchedOrgs[orgId].resources];
}

@@ -209,6 +190,3 @@ }

// add the resources
accum[org.id].resources = [
...accum[org.id].resources,
...org.resources,
];
accum[org.id].resources = [...accum[org.id].resources, ...org.resources];
}

@@ -243,5 +221,3 @@ }

for (const orgId of Object.keys(authorizedOrgs)) {
const isMatch = authorizedOrgs[orgId].resources.some(
(res) => res.id === resourceIdOR
);
const isMatch = authorizedOrgs[orgId].resources.some((res) => res.id === resourceIdOR);
if (isMatch || !resourceIdOR) {

@@ -281,6 +257,3 @@ authorizedOrgs[orgId].match = true;

const prevPermissionArray = [];
if (
typeof this.previousPermissionIds === 'string' ||
typeof this.previousPermissionIds === 'number'
) {
if (typeof this.previousPermissionIds === 'string' || typeof this.previousPermissionIds === 'number') {
prevPermissionArray.push(this.previousPermissionIds);

@@ -316,6 +289,4 @@ } else if (Array.isArray(this.previousPermissionIds)) {

}
throw new TypeError(
'permission/resourcesId(s) must be either an array of ids, a string, or a number'
);
throw new TypeError('permission/resourcesId(s) must be either an array of ids, a string, or a number');
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc