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

@koopjs/koop-core

Package Overview
Dependencies
Maintainers
7
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koopjs/koop-core - npm Package Compare versions

Comparing version 9.2.10 to 10.0.0

8

package.json
{
"name": "@koopjs/koop-core",
"description": "Serve, transform, and query geospatial data on the web",
"version": "9.2.10",
"version": "10.0.0",
"contributors": [

@@ -24,3 +24,3 @@ {

"@koopjs/logger": "5.0.0",
"@koopjs/output-geoservices": "7.1.9",
"@koopjs/output-geoservices": "8.0.0",
"@sindresorhus/fnv1a": "^2.0.1",

@@ -34,3 +34,3 @@ "body-parser": "^1.19.0",

"express": "^4.17.1",
"joi": "^17.10.2",
"joi": "^17.11.0",
"lodash": "^4.17.15"

@@ -43,3 +43,3 @@ },

"should-sinon": "0.0.6",
"sinon": "^16.0.0",
"sinon": "^17.0.1",
"supertest": "^6.3.1"

@@ -46,0 +46,0 @@ },

@@ -97,2 +97,12 @@ # Koop

#### skipGeoservicesRegistration
By default, Koop will register the GeoServices output-plugin (a.k.a. FeatureServer). If you do not want this plugin registered or want to register a specific version, you can skip the default registration by setting the option to `true`:
```js
const options = {
skipGeoservicesRegistration: true
}
```
#### geoservicesDefaults

@@ -99,0 +109,0 @@ Koop registers the Geoservices output plugin (FeatureServer) by default. This plugin takes its own options including those to set server and layer metadata (e.g., FeatureServer version, copyrightText, maxRecordCount, etc). These are useful for overriding defaults set in the FeatureServer codebase. You can have Koop set these options at start-up by passing the `geoservicesDefaults` option. It should be a JSON object with the specification described in the [FeatureServer documentation](packages/featureserver#featureserver.setdefaults).

@@ -38,2 +38,7 @@ const { promisify } = require('util');

async pull (req, callback) {
const { error } = await this.#authorizeRequest(req);
if (error) {
return callback(error);
}
const key = this.#createCacheKey(req);

@@ -67,2 +72,7 @@

async pullLayer (req, callback) {
const { error } = await this.#authorizeRequest(req);
if (error) {
return callback(error);
}
if (!this.#getLayer) {

@@ -96,2 +106,7 @@ callback(new Error(`getLayer() method is not implemented in the ${this.namespace} provider.`));

async pullCatalog (req, callback) {
const { error } = await this.#authorizeRequest(req);
if (error) {
return callback(error);
}
if (!this.#getCatalog) {

@@ -125,2 +140,8 @@ callback(new Error(`getCatalog() method is not implemented in the ${this.namespace} provider.`));

async pullStream (req) {
const { error } = await this.#authorizeRequest(req);
if (error) {
throw error;
}
if (this.getStream) {

@@ -142,16 +163,44 @@ await this.#before(req);

}
async #authorizeRequest (req) {
try {
await this.authorize(req);
} catch (error) {
error.code = 401;
return { error };
}
return { error: null };
}
}
// If provider does not have auth-methods,
// check for global auth-module. if exists, use it,
// otherwise use dummy methods
if (typeof ProviderModel.prototype.authorize !== 'function') {
Model.prototype.authorize = typeof authModule?.authorize === 'function' ? authModule.authorize : async () => {};
}
if (typeof ProviderModel.prototype.authenticate !== 'function') {
Model.prototype.authenticate = typeof authModule?.authenticate === 'function' ? authModule?.authenticate : async () => { return {}; };
}
if(typeof authModule?.authenticationSpecification === 'function') {
logger.warn('Use of "authenticationSpecification" is deprecated. It will be removed in a future release.');
Model.prototype.authenticationSpecification = authModule?.authenticationSpecification;
}
// Add auth methods if auth plugin registered with Koop
if (authModule) {
const {
authenticationSpecification,
authenticate,
authorize
} = authModule;
// if (authModule) {
// const {
// authenticationSpecification,
// authenticate,
// authorize
// } = authModule;
Model.prototype.authenticationSpecification = Object.assign({}, authenticationSpecification(namespace), { provider: namespace });
Model.prototype.authenticate = authenticate;
Model.prototype.authorize = authorize;
}
// Model.prototype.authenticationSpecification = Object.assign({}, authenticationSpecification(namespace), { provider: namespace });
// Model.prototype.authenticate = authenticate;
// Model.prototype.authorize = authorize;
// }
return new Model({ logger, cache }, options);

@@ -158,0 +207,0 @@ };

@@ -15,2 +15,4 @@ const Events = require('events');

class Koop extends Events {
#authModule;
constructor(options) {

@@ -20,3 +22,2 @@ super();

// TODO: remove usage of "config" module
this.config = { ...options, ...config };

@@ -34,7 +35,9 @@ this.server = initServer(this.config);

this.register(geoservices, {
logger: this.log,
authInfo: this.config.authInfo,
defaults: geoservicesDefaults
});
if (this.config.skipGeoservicesRegistration !== true) {
this.register(geoservices, {
logger: this.log,
authInfo: this.config.authInfo,
defaults: geoservicesDefaults
});
}

@@ -52,3 +55,3 @@ this.server

register(plugin = {}, options) {
register(plugin, options) {
if (!plugin) {

@@ -70,6 +73,2 @@ throw new Error('Plugin registration failed: plugin undefined');

if (plugin.type === 'filesystem') {
return this.#registerFilesystem(plugin, options);
}
if (plugin.type === 'auth') {

@@ -79,6 +78,2 @@ return this.#registerAuth(plugin, options);

if (plugin.type === 'plugin') {
return this.#registerPlugin(plugin, options);
}
this.log.warn(

@@ -96,3 +91,3 @@ 'Unrecognized plugin type: "' +

cache: this.cache,
authModule: this._authModule,
authModule: this.#authModule,
pluginDefinition,

@@ -122,29 +117,5 @@ outputPlugins: this.outputs,

#registerAuth (auth) {
this._authModule = auth;
this.#authModule = auth;
this.log.info(`registered auth module: ${auth.name} v${auth.version}`);
}
#registerFilesystem (Filesystem) {
this.fs = new Filesystem();
this.log.info(
`registered filesystem: ${Filesystem.pluginName || Filesystem.plugin_name || Filesystem.name} v${Filesystem.version}`
);
}
#registerPlugin (Plugin) {
const name = Plugin.pluginName || Plugin.plugin_name || Plugin.name;
if (!name) {
throw new Error('Plugin is missing name');
}
let dependencies;
if (Array.isArray(Plugin.dependencies) && Plugin.dependencies.length) {
dependencies = Plugin.dependencies.reduce((deps, dep) => {
deps[dep] = this[dep];
return deps;
}, {});
}
this[name] = new Plugin(dependencies);
this.log.info('registered plugin:', name, Plugin.version);
}
}

@@ -167,3 +138,3 @@

// Use CORS unless explicitly disabled in the config
if (!options.disableCors) {
if (options.disableCors !== true) {
app.use(cors());

@@ -173,3 +144,3 @@ }

// Use compression unless explicitly disable in the config
if (!options.disableCompression) {
if (options.disableCompression !== true) {
app.use(compression());

@@ -176,0 +147,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