@shushed/helpers 0.0.132 → 0.0.133
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/dist/index.js +11 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171455,32 +171455,24 @@ var TriggerHelper = class {
|
|
|
171455
171455
|
url: options.request.host
|
|
171456
171456
|
}, options.request.headers, getFirestore(runtime.systemEnvName));
|
|
171457
171457
|
} catch (err) {
|
|
171458
|
-
options.req.throw(401,
|
|
171459
|
-
error: `Invalid Authorization Header. ${err.message}`
|
|
171460
|
-
}));
|
|
171458
|
+
options.req.throw(401, `Invalid Authorization Header. ${err.message}`);
|
|
171461
171459
|
return;
|
|
171462
171460
|
}
|
|
171463
171461
|
if (reqIsScheduler) {
|
|
171464
171462
|
if (!(validationResult.email === defaultServiceAccount || this.helperOpts.serviceAccounts?.scheduler?.some((y) => y === validationResult.email))) {
|
|
171465
|
-
options.req.throw(401,
|
|
171466
|
-
error: `Invalid Authorization Header`
|
|
171467
|
-
}));
|
|
171463
|
+
options.req.throw(401, `Invalid Authorization Header`);
|
|
171468
171464
|
return;
|
|
171469
171465
|
}
|
|
171470
171466
|
}
|
|
171471
171467
|
if (reqIsPubSub) {
|
|
171472
171468
|
if (!(validationResult.email === defaultServiceAccount || this.helperOpts.serviceAccounts?.pubsub?.some((y) => y === validationResult.email))) {
|
|
171473
|
-
options.req.throw(401,
|
|
171474
|
-
error: `Invalid Authorization Header`
|
|
171475
|
-
}));
|
|
171469
|
+
options.req.throw(401, `Invalid Authorization Header`);
|
|
171476
171470
|
return;
|
|
171477
171471
|
}
|
|
171478
171472
|
}
|
|
171479
171473
|
if (reqIsCloudTask) {
|
|
171480
171474
|
if (!(validationResult.email === defaultServiceAccount || this.helperOpts.serviceAccounts?.cloudtasks?.some((y) => y === validationResult.email))) {
|
|
171481
|
-
options.req.throw(401,
|
|
171482
|
-
error: `Invalid Authorization Header`
|
|
171483
|
-
}));
|
|
171475
|
+
options.req.throw(401, `Invalid Authorization Header`);
|
|
171484
171476
|
return;
|
|
171485
171477
|
}
|
|
171486
171478
|
}
|
|
@@ -171492,15 +171484,11 @@ var TriggerHelper = class {
|
|
|
171492
171484
|
try {
|
|
171493
171485
|
message = await pubsub_default.decodeMessageFromRequest(optionsEnchanced.nodeReq);
|
|
171494
171486
|
} catch (err) {
|
|
171495
|
-
optionsEnchanced.req.throw(400,
|
|
171496
|
-
error: `Malformed Message. ${err.message}`
|
|
171497
|
-
}));
|
|
171487
|
+
optionsEnchanced.req.throw(400, `Malformed Message. ${err.message}`);
|
|
171498
171488
|
return;
|
|
171499
171489
|
}
|
|
171500
171490
|
if (!message) {
|
|
171501
|
-
optionsEnchanced.req.throw(400,
|
|
171502
|
-
error: `Missing Message.`
|
|
171503
|
-
}));
|
|
171491
|
+
optionsEnchanced.req.throw(400, `Missing Message.`);
|
|
171504
171492
|
return;
|
|
171505
171493
|
}
|
|
171506
171494
|
} else {
|
|
@@ -171513,23 +171501,19 @@ var TriggerHelper = class {
|
|
|
171513
171501
|
limit: "2mb"
|
|
171514
171502
|
});
|
|
171515
171503
|
} catch (err) {
|
|
171516
|
-
optionsEnchanced.req.throw(400,
|
|
171517
|
-
error: `Unfetchable Body. ${err.message}`
|
|
171518
|
-
}));
|
|
171504
|
+
optionsEnchanced.req.throw(400, `Unfetchable Body. ${err.message}`);
|
|
171519
171505
|
return;
|
|
171520
171506
|
}
|
|
171521
171507
|
if (rawBody) {
|
|
171522
171508
|
try {
|
|
171523
171509
|
bodyAsJson = JSON.parse(rawBody);
|
|
171524
171510
|
} catch (err) {
|
|
171525
|
-
optionsEnchanced.req.throw(400,
|
|
171526
|
-
error: `Unparsable body ${err.message}`
|
|
171527
|
-
}));
|
|
171511
|
+
optionsEnchanced.req.throw(400, `Unparsable body ${err.message}`);
|
|
171528
171512
|
return;
|
|
171529
171513
|
}
|
|
171530
171514
|
}
|
|
171531
171515
|
} else {
|
|
171532
|
-
optionsEnchanced.req.throw(400,
|
|
171516
|
+
optionsEnchanced.req.throw(400, "Invalid Content-Type");
|
|
171533
171517
|
return;
|
|
171534
171518
|
}
|
|
171535
171519
|
message = {
|
|
@@ -171555,9 +171539,7 @@ var TriggerHelper = class {
|
|
|
171555
171539
|
atLeastOneHandlerMatched = true;
|
|
171556
171540
|
try {
|
|
171557
171541
|
if (!apiKeyIsValid && (action.actionOptions.routingConditions || {}).havingApiKey) {
|
|
171558
|
-
return optionsEnchanced.req.throw(401,
|
|
171559
|
-
error: `Invalid Authorization Header`
|
|
171560
|
-
}));
|
|
171542
|
+
return optionsEnchanced.req.throw(401, `Invalid Authorization Header`);
|
|
171561
171543
|
}
|
|
171562
171544
|
await action.onExecute(config, optionsEnchanced, message);
|
|
171563
171545
|
} catch (error) {
|
|
@@ -171573,7 +171555,7 @@ var TriggerHelper = class {
|
|
|
171573
171555
|
}
|
|
171574
171556
|
}
|
|
171575
171557
|
if (!atLeastOneHandlerMatched) {
|
|
171576
|
-
optionsEnchanced.req.throw(404,
|
|
171558
|
+
optionsEnchanced.req.throw(404, "No matching handler found");
|
|
171577
171559
|
}
|
|
171578
171560
|
};
|
|
171579
171561
|
fn.$TriggerHelper = this;
|