@basemaps/lambda-tiler 7.16.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/build/util/__test__/validate.test.js +15 -0
- package/build/util/__test__/validate.test.js.map +1 -1
- package/build/util/validate.d.ts +2 -0
- package/build/util/validate.js +15 -1
- package/build/util/validate.js.map +1 -1
- package/dist/index.js +56091 -51564
- package/dist/node_modules/.package-lock.json +4 -4
- package/dist/node_modules/detect-libc/package.json +3 -2
- package/dist/package-lock.json +5 -5
- package/dist/package.json +1 -1
- package/package.json +10 -10
- package/src/util/__test__/validate.test.ts +18 -0
- package/src/util/validate.ts +18 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"node_modules/detect-libc": {
|
|
97
|
-
"version": "2.0.
|
|
98
|
-
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.
|
|
99
|
-
"integrity": "sha512-
|
|
97
|
+
"version": "2.0.4",
|
|
98
|
+
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
|
99
|
+
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
|
100
100
|
"license": "Apache-2.0",
|
|
101
101
|
"engines": {
|
|
102
102
|
"node": ">=8"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detect-libc",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Node.js module to detect the C standard library (libc) implementation family and version",
|
|
5
5
|
"main": "lib/detect-libc.js",
|
|
6
6
|
"files": [
|
|
@@ -36,5 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=8"
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"types": "index.d.ts"
|
|
40
41
|
}
|
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@basemaps/lambda-tiler",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "8.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lerc": "4.0.4",
|
|
@@ -518,9 +518,9 @@
|
|
|
518
518
|
}
|
|
519
519
|
},
|
|
520
520
|
"node_modules/detect-libc": {
|
|
521
|
-
"version": "2.0.
|
|
522
|
-
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.
|
|
523
|
-
"integrity": "sha512-
|
|
521
|
+
"version": "2.0.4",
|
|
522
|
+
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
|
523
|
+
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
|
524
524
|
"license": "Apache-2.0",
|
|
525
525
|
"engines": {
|
|
526
526
|
"node": ">=8"
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/lambda-tiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"types": "./build/index.d.ts",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@basemaps/config": "^
|
|
26
|
-
"@basemaps/config-loader": "^
|
|
27
|
-
"@basemaps/geo": "^
|
|
28
|
-
"@basemaps/shared": "^
|
|
29
|
-
"@basemaps/tiler": "^
|
|
30
|
-
"@basemaps/tiler-sharp": "^
|
|
31
|
-
"@linzjs/geojson": "^
|
|
25
|
+
"@basemaps/config": "^8.0.0",
|
|
26
|
+
"@basemaps/config-loader": "^8.0.0",
|
|
27
|
+
"@basemaps/geo": "^8.0.0",
|
|
28
|
+
"@basemaps/shared": "^8.0.0",
|
|
29
|
+
"@basemaps/tiler": "^8.0.0",
|
|
30
|
+
"@basemaps/tiler-sharp": "^8.0.0",
|
|
31
|
+
"@linzjs/geojson": "^8.0.0",
|
|
32
32
|
"@linzjs/lambda": "^4.0.0",
|
|
33
33
|
"@mapbox/vector-tile": "^2.0.3",
|
|
34
34
|
"p-limit": "^4.0.0",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"bundle": "./bundle.sh"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@basemaps/attribution": "^
|
|
53
|
+
"@basemaps/attribution": "^8.0.0",
|
|
54
54
|
"@chunkd/fs": "^11.2.0",
|
|
55
55
|
"@types/aws-lambda": "^8.10.75",
|
|
56
56
|
"@types/pixelmatch": "^5.0.0",
|
|
57
57
|
"pretty-json-log": "^1.0.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "852c7c8bcbe06d065de732f23a6ebc2dd6a19cfc"
|
|
60
60
|
}
|
|
@@ -6,6 +6,24 @@ import { GoogleTms, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
|
|
|
6
6
|
import { mockUrlRequest } from '../../__tests__/xyz.util.js';
|
|
7
7
|
import { Validate } from '../validate.js';
|
|
8
8
|
|
|
9
|
+
describe('Validate.blockedApiKeys', () => {
|
|
10
|
+
const validApiKey = 'c01jswmpe1yn3mwne7e0ggtp8vg';
|
|
11
|
+
it('should disable api keys', () => {
|
|
12
|
+
const req = mockUrlRequest('/v1/blank', `api=${validApiKey}`);
|
|
13
|
+
const parsedKey = Validate.apiKey(req);
|
|
14
|
+
assert.equal(parsedKey, validApiKey);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should disable api keys', () => {
|
|
18
|
+
const req = mockUrlRequest('/v1/blank', `api=${validApiKey}`);
|
|
19
|
+
Validate.blockedApiKeys.add(validApiKey);
|
|
20
|
+
assert.throws(() => Validate.apiKey(req));
|
|
21
|
+
|
|
22
|
+
Validate.blockedApiKeys.delete(validApiKey);
|
|
23
|
+
assert.equal(Validate.apiKey(req), validApiKey);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
9
27
|
describe('GetImageFormats', () => {
|
|
10
28
|
it('should parse all formats', () => {
|
|
11
29
|
const req = mockUrlRequest('/v1/blank', 'format=png&format=jpeg');
|
package/src/util/validate.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigTileSetRaster, ConfigTileSetRasterOutput } from '@basemaps/config';
|
|
2
2
|
import { ImageFormat, LatLon, Projection, TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
|
|
3
|
-
import { Const, isValidApiKey, truncateApiKey } from '@basemaps/shared';
|
|
3
|
+
import { Const, Env, isValidApiKey, LogConfig, truncateApiKey } from '@basemaps/shared';
|
|
4
4
|
import { getImageFormat } from '@basemaps/tiler';
|
|
5
5
|
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
6
6
|
|
|
@@ -23,7 +23,19 @@ export interface TileMatrixRequest {
|
|
|
23
23
|
Params: { tileMatrix?: string };
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function getBlockedApiKeys(): string[] {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(Env.get(Env.BlockedApiKeys) ?? '[]') as string[];
|
|
29
|
+
} catch (e) {
|
|
30
|
+
LogConfig.get().error(`"$${Env.BlockedApiKeys}" is invalid`);
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
export const Validate = {
|
|
36
|
+
/** list of API Keys that have been disabled */
|
|
37
|
+
blockedApiKeys: new Set<string>(getBlockedApiKeys()),
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* Validate that the api key exists and is valid
|
|
29
41
|
*
|
|
@@ -36,6 +48,11 @@ export const Validate = {
|
|
|
36
48
|
if (!valid.valid) throw new LambdaHttpResponse(400, 'API Key Invalid: ' + valid.message);
|
|
37
49
|
// Truncate the API Key so we are not logging the full key
|
|
38
50
|
req.set('api', truncateApiKey(apiKey));
|
|
51
|
+
|
|
52
|
+
if (this.blockedApiKeys.has(apiKey as string)) {
|
|
53
|
+
throw new LambdaHttpResponse(429, 'Too many requests! Please contact basemaps@linz.govt.nz for a developer key');
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
return apiKey as string;
|
|
40
57
|
},
|
|
41
58
|
|