@squiz/db-lib 1.39.1-alpha.10 → 1.39.1-alpha.13
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/.npm/_logs/{2023-06-26T09_07_09_141Z-debug-0.log → 2023-06-27T04_52_08_715Z-debug-0.log}
RENAMED
@@ -6,32 +6,32 @@
|
|
6
6
|
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
|
7
7
|
6 timing config:load:builtin Completed in 1ms
|
8
8
|
7 timing config:load:cli Completed in 2ms
|
9
|
-
8 timing config:load:env Completed in
|
9
|
+
8 timing config:load:env Completed in 2ms
|
10
10
|
9 info found workspace root at /builds/developer-experience/cmp
|
11
11
|
10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 0ms
|
12
|
-
11 timing config:load:project Completed in
|
12
|
+
11 timing config:load:project Completed in 24ms
|
13
13
|
12 timing config:load:file:/root/.npmrc Completed in 1ms
|
14
|
-
13 timing config:load:user Completed in
|
14
|
+
13 timing config:load:user Completed in 1ms
|
15
15
|
14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
|
16
16
|
15 timing config:load:global Completed in 0ms
|
17
17
|
16 timing config:load:setEnvs Completed in 1ms
|
18
|
-
17 timing config:load Completed in
|
19
|
-
18 timing npm:load:configload Completed in
|
20
|
-
19 timing npm:load:mkdirpcache Completed in
|
18
|
+
17 timing config:load Completed in 34ms
|
19
|
+
18 timing npm:load:configload Completed in 34ms
|
20
|
+
19 timing npm:load:mkdirpcache Completed in 1ms
|
21
21
|
20 timing npm:load:mkdirplogs Completed in 0ms
|
22
22
|
21 verbose title npm run compile
|
23
23
|
22 verbose argv "run" "compile" "--"
|
24
|
-
23 timing npm:load:setTitle Completed in
|
24
|
+
23 timing npm:load:setTitle Completed in 2ms
|
25
25
|
24 timing config:load:flatten Completed in 4ms
|
26
26
|
25 timing npm:load:display Completed in 6ms
|
27
|
-
26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-06-
|
28
|
-
27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-06-
|
27
|
+
26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-06-27T04_52_08_715Z-
|
28
|
+
27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-06-27T04_52_08_715Z-debug-0.log
|
29
29
|
28 timing npm:load:logFile Completed in 3ms
|
30
30
|
29 timing npm:load:timers Completed in 1ms
|
31
31
|
30 timing npm:load:configScope Completed in 0ms
|
32
|
-
31 timing npm:load Completed in
|
32
|
+
31 timing npm:load Completed in 49ms
|
33
33
|
32 silly logfile done cleaning log files
|
34
|
-
33 timing command:run Completed in
|
34
|
+
33 timing command:run Completed in 4500ms
|
35
35
|
34 verbose exit 0
|
36
|
-
35 timing npm Completed in
|
36
|
+
35 timing npm Completed in 4563ms
|
37
37
|
36 info ok
|
package/lib/index.js
CHANGED
@@ -49348,8 +49348,8 @@ var require_CloudflareApiKeyService = __commonJS({
|
|
49348
49348
|
var UnAuthenticatedRequestError_1 = require_UnAuthenticatedRequestError();
|
49349
49349
|
var dx_logger_lib_1 = require_lib4();
|
49350
49350
|
var validKeys = {
|
49351
|
-
keys: [],
|
49352
|
-
"
|
49351
|
+
"matrix-keys": [],
|
49352
|
+
"inter-service-keys": []
|
49353
49353
|
};
|
49354
49354
|
var refreshInterval;
|
49355
49355
|
var REFRESH_TIMER = 7 * 24 * 3600 * 1e3;
|
@@ -49364,17 +49364,28 @@ var require_CloudflareApiKeyService = __commonJS({
|
|
49364
49364
|
}
|
49365
49365
|
this.logger = logger2;
|
49366
49366
|
}
|
49367
|
-
|
49368
|
-
|
49367
|
+
/**
|
49368
|
+
* @deprecated Suggest moving towards using JWT authentication.
|
49369
|
+
*/
|
49370
|
+
matrixKeyIsValid(key, request) {
|
49371
|
+
var _a;
|
49372
|
+
if (validKeys["matrix-keys"].length == 0) {
|
49369
49373
|
throw new UnAuthenticatedRequestError_1.UnAuthenticatedRequestError("No api keys to check against");
|
49370
49374
|
}
|
49371
|
-
|
49375
|
+
if (validKeys["matrix-keys"].includes(key)) {
|
49376
|
+
this.logger.info("Request authenticated using legacy Matrix API key", {
|
49377
|
+
url: request.url,
|
49378
|
+
userAgent: (_a = request.headers) === null || _a === void 0 ? void 0 : _a["user-agent"]
|
49379
|
+
});
|
49380
|
+
return true;
|
49381
|
+
}
|
49382
|
+
return false;
|
49372
49383
|
}
|
49373
|
-
|
49374
|
-
if (validKeys["
|
49375
|
-
throw new UnAuthenticatedRequestError_1.UnAuthenticatedRequestError("No api keys to check against");
|
49384
|
+
interServiceKeyIsValid(key) {
|
49385
|
+
if (validKeys["inter-service-keys"].length == 0) {
|
49386
|
+
throw new UnAuthenticatedRequestError_1.UnAuthenticatedRequestError("No inter service api keys to check against");
|
49376
49387
|
}
|
49377
|
-
return validKeys["
|
49388
|
+
return validKeys["inter-service-keys"].includes(key);
|
49378
49389
|
}
|
49379
49390
|
async getValidApiKeys() {
|
49380
49391
|
let secretValue;
|
@@ -49391,7 +49402,7 @@ var require_CloudflareApiKeyService = __commonJS({
|
|
49391
49402
|
throw new Error("cloudflare api key SecretString undefined");
|
49392
49403
|
}
|
49393
49404
|
const secret = JSON.parse(secretValue.SecretString);
|
49394
|
-
if (secret
|
49405
|
+
if (secret["matrix-keys"] && secret["inter-service-keys"]) {
|
49395
49406
|
return secret;
|
49396
49407
|
}
|
49397
49408
|
throw new Error("api keys retrieved and decoded successfully but contained no values");
|
@@ -49402,7 +49413,8 @@ var require_CloudflareApiKeyService = __commonJS({
|
|
49402
49413
|
async refreshApiKeys() {
|
49403
49414
|
this.logger.info("refreshing keys");
|
49404
49415
|
validKeys = await this.getValidApiKeys();
|
49405
|
-
this.logger.info(`
|
49416
|
+
this.logger.info(`found ${validKeys["matrix-keys"].length} valid matrix keys`);
|
49417
|
+
this.logger.info(`found ${validKeys["inter-service-keys"].length} valid inter service keys`);
|
49406
49418
|
if (!refreshInterval) {
|
49407
49419
|
refreshInterval = setInterval(async () => {
|
49408
49420
|
await this.refreshApiKeys();
|
@@ -49410,8 +49422,8 @@ var require_CloudflareApiKeyService = __commonJS({
|
|
49410
49422
|
}
|
49411
49423
|
}
|
49412
49424
|
// temporary method, to be removed when DXP auth is properly implemented
|
49413
|
-
|
49414
|
-
return validKeys["
|
49425
|
+
getInterServiceKeys() {
|
49426
|
+
return validKeys["inter-service-keys"];
|
49415
49427
|
}
|
49416
49428
|
};
|
49417
49429
|
exports2.CloudflareApiKeyService = CloudflareApiKeyService;
|
@@ -49424,16 +49436,25 @@ var require_DevelopmentApiKeyService = __commonJS({
|
|
49424
49436
|
"use strict";
|
49425
49437
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49426
49438
|
exports2.DevelopmentApiKeyService = void 0;
|
49439
|
+
var dx_logger_lib_1 = require_lib4();
|
49427
49440
|
var DevelopmentApiKeyService = class {
|
49428
|
-
|
49429
|
-
|
49441
|
+
constructor(logger2) {
|
49442
|
+
this.logger = logger2 || (0, dx_logger_lib_1.getLogger)({ name: "DevelopmentApiKeyService" });
|
49430
49443
|
}
|
49431
|
-
matrixKeyIsValid() {
|
49444
|
+
matrixKeyIsValid(key, request) {
|
49445
|
+
var _a;
|
49446
|
+
this.logger.info("Request authenticated using legacy Matrix API key", {
|
49447
|
+
url: request.url,
|
49448
|
+
userAgent: (_a = request.headers) === null || _a === void 0 ? void 0 : _a["user-agent"]
|
49449
|
+
});
|
49432
49450
|
return true;
|
49433
49451
|
}
|
49452
|
+
interServiceKeyIsValid(key) {
|
49453
|
+
return Boolean(key && this.getInterServiceKeys().includes(key));
|
49454
|
+
}
|
49434
49455
|
// temporary method, to be removed when DXP auth is properly implemented
|
49435
|
-
|
49436
|
-
return ["
|
49456
|
+
getInterServiceKeys() {
|
49457
|
+
return ["inter-service-api-key"];
|
49437
49458
|
}
|
49438
49459
|
};
|
49439
49460
|
exports2.DevelopmentApiKeyService = DevelopmentApiKeyService;
|
@@ -49467,31 +49488,6 @@ var require_getApiKeyService = __commonJS({
|
|
49467
49488
|
}
|
49468
49489
|
});
|
49469
49490
|
|
49470
|
-
// ../dx-common-lib/lib/server-utils/apiKeyMiddleware.js
|
49471
|
-
var require_apiKeyMiddleware = __commonJS({
|
49472
|
-
"../dx-common-lib/lib/server-utils/apiKeyMiddleware.js"(exports2) {
|
49473
|
-
"use strict";
|
49474
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
49475
|
-
exports2.apiKeyMiddleware = void 0;
|
49476
|
-
var UnAuthenticatedRequestError_1 = require_UnAuthenticatedRequestError();
|
49477
|
-
function apiKeyMiddleware(apiKeyService) {
|
49478
|
-
return function(req, res, next) {
|
49479
|
-
const key = req.header("x-api-key");
|
49480
|
-
if (req.path == "/health") {
|
49481
|
-
next();
|
49482
|
-
return;
|
49483
|
-
}
|
49484
|
-
if (apiKeyService.keyIsValid(key) || apiKeyService.matrixKeyIsValid(key)) {
|
49485
|
-
next();
|
49486
|
-
return;
|
49487
|
-
}
|
49488
|
-
throw new UnAuthenticatedRequestError_1.UnAuthenticatedRequestError(`API KEY IS INVALID`);
|
49489
|
-
};
|
49490
|
-
}
|
49491
|
-
exports2.apiKeyMiddleware = apiKeyMiddleware;
|
49492
|
-
}
|
49493
|
-
});
|
49494
|
-
|
49495
49491
|
// ../dx-common-lib/lib/cache/applyDefaultRulesToCacheControlObject.js
|
49496
49492
|
var require_applyDefaultRulesToCacheControlObject = __commonJS({
|
49497
49493
|
"../dx-common-lib/lib/cache/applyDefaultRulesToCacheControlObject.js"(exports2) {
|
@@ -58310,7 +58306,6 @@ var require_lib6 = __commonJS({
|
|
58310
58306
|
__exportStar2(require_CloudflareApiKeyService(), exports2);
|
58311
58307
|
__exportStar2(require_DevelopmentApiKeyService(), exports2);
|
58312
58308
|
__exportStar2(require_getApiKeyService(), exports2);
|
58313
|
-
__exportStar2(require_apiKeyMiddleware(), exports2);
|
58314
58309
|
__exportStar2(require_cache(), exports2);
|
58315
58310
|
__exportStar2(require_formattedTextToHtmlString(), exports2);
|
58316
58311
|
__exportStar2(require_json_order(), exports2);
|