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

planet-client

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

planet-client - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

14

api/mosaics.js

@@ -9,3 +9,2 @@ /**

var urls = require('./urls');
var util = require('./util');

@@ -16,4 +15,2 @@ /**

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -33,5 +30,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
util.augmentMosaicLinks(res.body);
}
return res.body;

@@ -45,4 +39,2 @@ });

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -63,8 +55,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
var mosaics = res.body.mosaics;
for (var i = 0, ii = mosaics.length; i < ii; ++i) {
util.augmentMosaicLinks(mosaics[i]);
}
}
return new Page(res.body, search);

@@ -71,0 +57,0 @@ });

@@ -9,3 +9,2 @@ /**

var urls = require('./urls');
var util = require('./util');

@@ -17,4 +16,2 @@ /**

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -34,5 +31,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
util.augmentQuadLinks(res.body);
}
return res.body;

@@ -47,4 +41,2 @@ });

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -65,8 +57,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
var quads = res.body.features;
for (var i = 0, ii = quads.length; i < ii; ++i) {
util.augmentQuadLinks(quads[i]);
}
}
return new Page(res.body, search.bind(null, mosaicId));

@@ -81,4 +67,2 @@ });

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -98,8 +82,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
var features = res.body.features;
for (var i = 0, ii = features.length; i < ii; ++i) {
util.augmentSceneLinks(features[i]);
}
}
return res.body;

@@ -106,0 +84,0 @@ });

@@ -9,3 +9,2 @@ /**

var urls = require('./urls');
var util = require('./util');

@@ -18,4 +17,2 @@ /**

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -41,5 +38,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
util.augmentSceneLinks(res.body);
}
return res.body;

@@ -53,4 +47,2 @@ });

* @param {Object} options Options.
* @param {boolean} options.augmentLinks Add API key to links for image
* resources in the response. True by default.
* @param {function(function())} options.terminator A function that is called

@@ -79,8 +71,2 @@ * with a function that can be called back to terminate the request.

return request.get(config).then(function(res) {
if (options.augmentLinks !== false) {
var scenes = res.body.features;
for (var i = 0, ii = scenes.length; i < ii; ++i) {
util.augmentSceneLinks(scenes[i]);
}
}
return new Page(res.body, search);

@@ -87,0 +73,0 @@ });

@@ -9,4 +9,2 @@ /**

var authStore = require('./auth-store');
function addQueryParams(link, params) {

@@ -27,57 +25,2 @@ var baseHash = link.split('#');

function augmentSceneLinks(scene) {
var properties = scene.properties;
var key = authStore.getKey();
if (key) {
var links = properties.links;
links.full = addQueryParams(links.full, {'api_key': key});
links.thumbnail = addQueryParams(links.thumbnail, {'api_key': key});
links['square_thumbnail'] = addQueryParams(
links['square_thumbnail'], {'api_key': key});
var products = properties.data.products;
for (var type in products) {
var product = products[type];
for (var format in product) {
product[format] = addQueryParams(product[format], {'api_key': key});
}
}
}
return scene;
}
function augmentQuadLinks(quad) {
var key = authStore.getKey();
if (key) {
var links = quad.properties.links;
if (links.full) {
links.full = addQueryParams(links.full, {'api_key': key});
}
if (links.thumbnail) {
links.thumbnail = addQueryParams(links.thumbnail, {'api_key': key});
}
}
return quad;
}
function augmentMosaicLinks(mosaic) {
var key = authStore.getKey();
if (key) {
var links = mosaic.links;
if (links.tiles) {
links.tiles = addQueryParams(links.tiles, {'api_key': key});
}
if (links.quadmap) {
links.quadmap = addQueryParams(links.quadmap, {'api_key': key});
}
}
return mosaic;
}
/**

@@ -101,5 +44,2 @@ * Simplified polyfill for ES6 Object.assign.

exports.addQueryParams = addQueryParams;
exports.augmentMosaicLinks = augmentMosaicLinks;
exports.augmentQuadLinks = augmentQuadLinks;
exports.augmentSceneLinks = augmentSceneLinks;
exports.assign = assign;

2

cli/find-scenes.js

@@ -166,3 +166,3 @@ var path = require('path');

log.debug('query: %j', query);
return fetch(scenes.search(query, {augmentLinks: false}), [], opts.limit);
return fetch(scenes.search(query), [], opts.limit);
}).then(function(features) {

@@ -169,0 +169,0 @@ return JSON.stringify({

{
"name": "planet-client",
"version": "0.10.0",
"version": "0.11.0",
"description": "A client for Planet's imagery API",

@@ -5,0 +5,0 @@ "repository": {

@@ -74,39 +74,2 @@ /* eslint-env mocha */

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: mosaic
});
};
var promise = mosaics.get('one');
promise.then(function(got) {
assert.equal(got.links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png' +
'?api_key=my-key');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: mosaic
});
};
var promise = mosaics.get('one', {augmentLinks: false});
promise.then(function(got) {
assert.equal(got.links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png');
done();
}).catch(done);
});
});

@@ -147,43 +110,4 @@

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
mosaics: [mosaic],
links: {}
}
});
};
mosaics.search({}).then(function(got) {
assert.equal(got.data.mosaics[0].links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png?' +
'api_key=my-key');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
mosaics: [mosaic],
links: {}
}
});
};
mosaics.search({}, {augmentLinks: false}).then(function(got) {
assert.equal(got.data.mosaics[0].links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png');
done();
}).catch(done);
});
});
});

@@ -79,39 +79,2 @@ /* eslint-env mocha */

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: quad
});
};
var promise = quads.get('my-mosaic', 'my-quad');
promise.then(function(got) {
assert.equal(got.properties.links.full,
'https://example.com/mosaics/one/quads/two/full' +
'?api_key=my-key');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: quad
});
};
var promise = quads.get('my-mosaic', 'my-quad', {augmentLinks: false});
promise.then(function(got) {
assert.equal(got.properties.links.full,
'https://example.com/mosaics/one/quads/two/full');
done();
}).catch(done);
});
});

@@ -152,41 +115,2 @@

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [quad],
links: {}
}
});
};
quads.search('my-mosaic', {}).then(function(got) {
assert.equal(got.data.features[0].properties.links.full,
'https://example.com/mosaics/one/quads/two/full' +
'?api_key=my-key');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [quad],
links: {}
}
});
};
quads.search('my-mosaic', {}, {augmentLinks: false}).then(function(got) {
assert.equal(got.data.features[0].properties.links.full,
'https://example.com/mosaics/one/quads/two/full');
done();
}).catch(done);
});
});

@@ -242,43 +166,4 @@

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [scene],
links: {}
}
});
};
quads.scenes('my-mosaic', 'my-quad').then(function(got) {
assert.equal(got.features[0].properties.links.full,
'http://example.com/?api_key=my-key#hash');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [scene],
links: {}
}
});
};
quads.scenes('my-mosaic', 'my-quad', {augmentLinks: false})
.then(function(got) {
assert.equal(got.features[0].properties.links.full,
'http://example.com/#hash');
done();
}).catch(done);
});
});
});

@@ -84,38 +84,2 @@ /* eslint-env mocha */

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: scene
});
};
var promise = scenes.get('bar');
promise.then(function(got) {
assert.equal(got.properties.links.full,
'http://example.com/?api_key=my-key#hash');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: scene
});
};
var promise = scenes.get('bar', {augmentLinks: false});
promise.then(function(got) {
assert.equal(got.properties.links.full,
'http://example.com/#hash');
done();
}).catch(done);
});
});

@@ -208,42 +172,4 @@

it('augments links if key is set', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [scene],
links: {}
}
});
};
scenes.search({foo: 'bar'}).then(function(got) {
assert.equal(got.data.features[0].properties.links.full,
'http://example.com/?api_key=my-key#hash');
done();
}).catch(done);
});
it('can be told not to augment links', function(done) {
auth.setKey('my-key');
request.get = function(config) {
return Promise.resolve({
body: {
features: [scene],
links: {}
}
});
};
scenes.search({foo: 'bar'}, {augmentLinks: false}).then(function(got) {
assert.equal(got.data.features[0].properties.links.full,
'http://example.com/#hash');
done();
}).catch(done);
});
});
});
/* eslint-env mocha */
var assert = require('chai').assert;
var authStore = require('../../api/auth-store');
var util = require('../../api/util');

@@ -61,192 +60,2 @@

describe('augmentSceneLinks()', function() {
var scene;
beforeEach(function() {
scene = util.assign({}, {
properties: {
links: {
'full': 'http://example.com/#hash',
'square_thumbnail': 'http://example.com/?foo=bar',
'thumbnail': 'http://example.com/thumb'
},
data: {
products: {
foo: {
bar: 'http://example.com/foo/bar'
}
}
}
}
});
});
afterEach(function() {
authStore.clear();
});
it('adds a API key from stored token to data URLs', function() {
// {api_key: 'my-api-key'}
var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlfa2V5Ijoib' +
'XktYXBpLWtleSJ9.sYcuJzdUThIsvJGNymbobOh-nY6ZKFEqXTqwZS-4QvE';
authStore.setToken(token);
var key = authStore.getKey();
var augmented = util.augmentSceneLinks(scene);
assert.equal(augmented.properties.links.full,
'http://example.com/?api_key=' + key + '#hash');
assert.equal(augmented.properties.links['square_thumbnail'],
'http://example.com/?foo=bar&api_key=' + key);
assert.equal(augmented.properties.links.thumbnail,
'http://example.com/thumb?api_key=' + key);
assert.equal(augmented.properties.data.products.foo.bar,
'http://example.com/foo/bar?api_key=' + key);
});
it('adds a stored API key to data URLs', function() {
var key = 'my-key';
authStore.setKey(key);
var augmented = util.augmentSceneLinks(scene);
assert.equal(augmented.properties.links.full,
'http://example.com/?api_key=' + key + '#hash');
assert.equal(augmented.properties.links['square_thumbnail'],
'http://example.com/?foo=bar&api_key=' + key);
assert.equal(augmented.properties.links.thumbnail,
'http://example.com/thumb?api_key=' + key);
assert.equal(augmented.properties.data.products.foo.bar,
'http://example.com/foo/bar?api_key=' + key);
});
});
describe('augmentQuadLinks()', function() {
var quad;
beforeEach(function() {
quad = util.assign({}, {
geometry: {
type: 'Polygon',
coordinates: [
[
[-78.925781239, 39.0959629318],
[-78.925781239, 38.9594087879],
[-78.749999989, 38.9594087879],
[-78.749999989, 39.0959629318],
[-78.925781239, 39.0959629318]
]
]
},
type: 'Feature',
id: 'L15-0575E-1265N',
properties: {
updated: '2015-07-20T13:39:49.550576+00:00',
'num_input_scenes': 28,
links: {
self: 'https://example.com/mosaics/one/quads/two',
full: 'https://example.com/mosaics/one/quads/two/full',
thumbnail: 'https://example.com/mosaics/one/quads/two/thumb',
mosaic: 'https://example.com/mosaics/one',
scenes: 'https://example.com/mosaics/one/quads/two/scenes/'
},
'percent_covered': 100
}
});
});
afterEach(function() {
authStore.clear();
});
it('adds a API key from stored token to data URLs', function() {
// {api_key: 'my-api-key'}
var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlfa2V5Ijoib' +
'XktYXBpLWtleSJ9.sYcuJzdUThIsvJGNymbobOh-nY6ZKFEqXTqwZS-4QvE';
authStore.setToken(token);
var key = authStore.getKey();
var augmented = util.augmentQuadLinks(quad);
assert.equal(augmented.properties.links.full,
'https://example.com/mosaics/one/quads/two/full?api_key=' + key);
assert.equal(augmented.properties.links.thumbnail,
'https://example.com/mosaics/one/quads/two/thumb?api_key=' + key);
});
it('adds a stored API key to data URLs', function() {
var key = 'my-key';
authStore.setKey(key);
var augmented = util.augmentQuadLinks(quad);
assert.equal(augmented.properties.links.full,
'https://example.com/mosaics/one/quads/two/full?api_key=' + key);
assert.equal(augmented.properties.links.thumbnail,
'https://example.com/mosaics/one/quads/two/thumb?api_key=' + key);
});
});
describe('augmentMosaicLinks()', function() {
var mosaic;
beforeEach(function() {
mosaic = util.assign({}, {
name: 'one',
links: {
quads: 'https://example.com/mosaics/one/quads/',
self: 'https://example.com/mosaics/one',
tiles: 'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png',
quadmap: 'https://example.com/mosaics/one/quad-map.png'
},
'first_acquired': '2014-03-20T15:57:11+00:00',
datatype: 'byte',
'quad_size': 4096,
title: 'A Mosaic',
'coordinate_system': 'EPSG:3857',
geometry: {
type: 'Polygon',
coordinates: [
[[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]
]
},
'last_acquired': '2015-07-20T02:11:31.947579+00:00',
'scene_type': 'ortho',
'quad_pattern': 'L{glevel:d}-{tilex:04d}E-{tiley:04d}N',
level: 15,
resolution: 4.77731426716
});
});
afterEach(function() {
authStore.clear();
});
it('adds a API key from stored token to data URLs', function() {
// {api_key: 'my-api-key'}
var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlfa2V5Ijoib' +
'XktYXBpLWtleSJ9.sYcuJzdUThIsvJGNymbobOh-nY6ZKFEqXTqwZS-4QvE';
authStore.setToken(token);
var key = authStore.getKey();
var augmented = util.augmentMosaicLinks(mosaic);
assert.equal(augmented.links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png?api_key=' +
key);
assert.equal(augmented.links.quadmap,
'https://example.com/mosaics/one/quad-map.png?api_key=' + key);
});
it('adds a stored API key to data URLs', function() {
var key = 'my-key';
authStore.setKey(key);
var augmented = util.augmentMosaicLinks(mosaic);
assert.equal(augmented.links.tiles,
'https://s{0-3}.example.com/v0/mosaics/one/{z}/{x}/{y}.png?api_key=' +
key);
assert.equal(augmented.links.quadmap,
'https://example.com/mosaics/one/quad-map.png?api_key=' + key);
});
});
describe('assign()', function() {

@@ -253,0 +62,0 @@

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