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

@cumulus/cmr-client

Package Overview
Dependencies
Maintainers
7
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cumulus/cmr-client - npm Package Compare versions

Comparing version 1.14.1 to 1.14.2

UmmUtils.js

54

CMR.js
'use strict';
const got = require('got');
const get = require('lodash.get');
const publicIp = require('public-ip');

@@ -12,3 +11,3 @@ const Logger = require('@cumulus/logger');

const getUrl = require('./getUrl');
const ValidationError = require('./ValidationError');
const { ummVersion, validateUMMG } = require('./UmmUtils');

@@ -24,53 +23,2 @@ const log = new Logger({ sender: 'cmr-client' });

/**
* Find the UMM version as a decimal string.
* If a version cannot be found on the input object
* version 1.4 is assumed and returned.
*
* @param {Object} umm - UMM metadata object
* @returns {string} UMM version for the given object
*
* @private
*/
function ummVersion(umm) {
return get(umm, 'MetadataSpecification.Version', '1.4');
}
/**
* Posts a given xml string to the validate endpoint of CMR
* and promises true if valid.
*
* @param {string} ummMetadata - the UMM object
* @param {string} identifier - the document identifier
* @param {string} provider - the CMR provider
* @returns {Promise<boolean>} returns true if the document is valid
*
* @private
*/
async function validateUMMG(ummMetadata, identifier, provider) {
const version = ummVersion(ummMetadata);
let result;
try {
result = await got.post(`${getUrl('validate', provider)}granule/${identifier}`, {
json: true,
body: ummMetadata,
headers: {
Accept: 'application/json',
'Content-type': `application/vnd.nasa.cmr.umm+json;version=${version}`
}
});
if (result.statusCode === 200) {
return true;
}
} catch (e) {
result = e.response;
}
throw new ValidationError(
`Validation was not successful. UMM metadata Object: ${JSON.stringify(ummMetadata)}`
);
}
/**
* Returns a valid a CMR token

@@ -77,0 +25,0 @@ *

{
"name": "@cumulus/cmr-client",
"version": "1.14.1",
"version": "1.14.2",
"engines": {

@@ -34,3 +34,3 @@ "node": ">=8.10.0"

"dependencies": {
"@cumulus/logger": "1.14.1",
"@cumulus/logger": "1.14.2",
"got": "^9.6.0",

@@ -49,3 +49,3 @@ "lodash.get": "^4.4.2",

},
"gitHead": "21573258d928168b03b04f4a8063236414506119"
"gitHead": "e76da51e3915b49e68861996be542efe40dbe3d4"
}
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