@bymax-one/nest-storage 1.1.13 → 1.1.14
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 +16 -1
- package/README.md +1 -1
- package/dist/server/index.cjs +21 -14
- package/dist/server/index.mjs +21 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,20 @@ note on each entry is the compatibility contract — read it, not the number.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [1.1.14] - 2026-11-16
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **The provider-failure log masks more, and says less when nothing failed.** The warning that carries what
|
|
21
|
+
the driver or the provider said now also masks the credential scope and signature of an `Authorization`
|
|
22
|
+
header (`Credential=...`) and a bare access key id (`AKIA...`, `ASIA...`), still before it cuts the
|
|
23
|
+
message. A request the caller cancelled is no longer logged, and a multipart upload that fails opens its
|
|
24
|
+
line with `Multipart upload failed` (it was `Provider call failed`, which a failure of the caller's own
|
|
25
|
+
source stream is not). Nothing a client receives changes.
|
|
26
|
+
|
|
27
|
+
**Apply to a derived backend:** nothing, unless a log search matched the old line start for a multipart
|
|
28
|
+
failure or the cancelled-request warning.
|
|
29
|
+
|
|
16
30
|
## [1.1.13] - 2026-11-16
|
|
17
31
|
|
|
18
32
|
### Security
|
|
@@ -850,4 +864,5 @@ have regressed from. They are kept because the reasoning is worth having.
|
|
|
850
864
|
[1.1.11]: https://github.com/bymaxone/nest-storage/compare/v1.1.10...v1.1.11
|
|
851
865
|
[1.1.12]: https://github.com/bymaxone/nest-storage/compare/v1.1.11...v1.1.12
|
|
852
866
|
[1.1.13]: https://github.com/bymaxone/nest-storage/compare/v1.1.12...v1.1.13
|
|
853
|
-
[
|
|
867
|
+
[1.1.14]: https://github.com/bymaxone/nest-storage/compare/v1.1.13...v1.1.14
|
|
868
|
+
[Unreleased]: https://github.com/bymaxone/nest-storage/compare/v1.1.14...HEAD
|
package/README.md
CHANGED
|
@@ -760,7 +760,7 @@ All errors are thrown as `StorageException extends HttpException`. The response
|
|
|
760
760
|
| `STORAGE_SCAN_INFECTED` | 422 | Scanner returned `'infected'` (`details.threat`); `details.cleanup: 'failed'` means the object is still stored |
|
|
761
761
|
| `STORAGE_SCAN_INCONCLUSIVE` | 422 | Scanner returned `'unknown'` and `rejectOnUnknown: true` |
|
|
762
762
|
| `STORAGE_OBJECT_NOT_FOUND` | 404 | `head()`, `download()`, or `copy()` on a nonexistent key |
|
|
763
|
-
| `STORAGE_PROVIDER_ERROR` | 502 | The provider rejected the request (`AccessControlListNotSupported`, an `AccessDenied` on an object, any other rejection). **503** when it could not be reached (connection refused or reset, DNS failure) or answered with a server error (`SlowDown`, 500, 502, 504; not 501), which is worth retrying; **500** when it refused the credentials (`InvalidAccessKeyId`, `SignatureDoesNotMatch`), a deployment fault that a retry does not fix. `details` carries `awsCode`, `httpStatus`, `requestId` and a fixed `reason` (`unreachable`, `provider-error`, `credentials-refused` or `rejected`; never the text of the driver or of the provider) plus the operation context (`op`, `bucket`, and `key` or `prefix`) |
|
|
763
|
+
| `STORAGE_PROVIDER_ERROR` | 502 | The provider rejected the request (`AccessControlListNotSupported`, an `AccessDenied` on an object, any other rejection). **503** when it could not be reached (connection refused or reset, DNS failure) or answered with a server error (`SlowDown`, 500, 502, 504; not 501), which is worth retrying; **500** when it refused the credentials (`InvalidAccessKeyId`, `SignatureDoesNotMatch`), a deployment fault that a retry does not fix (a `HEAD` answer carries no body and so no code: a refused `head()` stays **502** with reason `rejected`, and the credentials case is not told apart there). `details` carries `awsCode`, `httpStatus`, `requestId` and a fixed `reason` (`unreachable`, `provider-error`, `credentials-refused` or `rejected`; never the text of the driver or of the provider) plus the operation context (`op`, `bucket`, and `key` or `prefix`) |
|
|
764
764
|
| `STORAGE_SIGNED_URL_TTL_INVALID` | 400 | Per-request `ttlSeconds` ≤ 0 |
|
|
765
765
|
| `STORAGE_PART_TOO_SMALL` | 400 | Never thrown: a `multipart.partSizeBytes` below 5 MiB fails at init as `STORAGE_INVALID_CONFIG` |
|
|
766
766
|
| `STORAGE_INVALID_PART_COUNT` | 400 | `getMultipartUploadUrls()` with `parts` not an integer from 1 to 10 000 (`details.provided`, `details.reason`) |
|
package/dist/server/index.cjs
CHANGED
|
@@ -541,7 +541,8 @@ function logValue(value) {
|
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
// src/server/utils/provider-failure-log.ts
|
|
544
|
-
var SECRET_IN_MESSAGE = /(X-Amz-(?:Signature|Credential|Security-Token)|AWSAccessKeyId|Signature)=[^&\s"']+/gi;
|
|
544
|
+
var SECRET_IN_MESSAGE = /(X-Amz-(?:Signature|Credential|Security-Token)|AWSAccessKeyId|Credential|Signature)=[^&\s"']+/gi;
|
|
545
|
+
var BARE_ACCESS_KEY_ID = /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g;
|
|
545
546
|
var MAX_MESSAGE_LENGTH = 300;
|
|
546
547
|
var logger = new common.Logger("StorageProvider");
|
|
547
548
|
function field(value) {
|
|
@@ -549,7 +550,7 @@ function field(value) {
|
|
|
549
550
|
}
|
|
550
551
|
function describeProviderFailure(err) {
|
|
551
552
|
const failure = typeof err === "object" && err !== null ? err : {};
|
|
552
|
-
const message = describeError(err).replace(SECRET_IN_MESSAGE, "$1=[redacted]");
|
|
553
|
+
const message = describeError(err).replace(SECRET_IN_MESSAGE, "$1=[redacted]").replace(BARE_ACCESS_KEY_ID, "[redacted-key-id]");
|
|
553
554
|
return [
|
|
554
555
|
`name=${field(failure.name)}`,
|
|
555
556
|
`code=${field(failure.Code)}`,
|
|
@@ -558,10 +559,13 @@ function describeProviderFailure(err) {
|
|
|
558
559
|
`message=${logValue(message.slice(0, MAX_MESSAGE_LENGTH))}`
|
|
559
560
|
].join(" ");
|
|
560
561
|
}
|
|
561
|
-
function logProviderFailure(err, context) {
|
|
562
|
+
function logProviderFailure(err, context, label = "Provider call failed") {
|
|
563
|
+
if (err?.name === "AbortError") {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
562
566
|
const op = typeof context?.op === "string" ? logValue(context.op) : "-";
|
|
563
567
|
const key = typeof context?.key === "string" ? logValue(context.key) : "-";
|
|
564
|
-
logger.warn(
|
|
568
|
+
logger.warn(`${label}: op=${op} key=${key} ${describeProviderFailure(err)}`);
|
|
565
569
|
}
|
|
566
570
|
var UNREACHABLE_CODES = /* @__PURE__ */ new Set([
|
|
567
571
|
"ECONNREFUSED",
|
|
@@ -630,10 +634,17 @@ function providerFailureStatus(err) {
|
|
|
630
634
|
}
|
|
631
635
|
|
|
632
636
|
// src/server/errors/aws-error-mapper.ts
|
|
637
|
+
function awsCodeOf(err) {
|
|
638
|
+
const e = err ?? {};
|
|
639
|
+
return e.Code ?? e.name;
|
|
640
|
+
}
|
|
641
|
+
function isNoSuchBucket(err) {
|
|
642
|
+
return awsCodeOf(err) === "NoSuchBucket";
|
|
643
|
+
}
|
|
633
644
|
function mapAwsError(err, context) {
|
|
634
645
|
const e = err ?? {};
|
|
635
646
|
const httpStatus = e.$metadata?.httpStatusCode;
|
|
636
|
-
const awsCode =
|
|
647
|
+
const awsCode = awsCodeOf(err);
|
|
637
648
|
const requestId = e.$metadata?.requestId;
|
|
638
649
|
const details = {
|
|
639
650
|
...context ?? {},
|
|
@@ -643,7 +654,7 @@ function mapAwsError(err, context) {
|
|
|
643
654
|
// A fixed word, never what the driver or the provider wrote.
|
|
644
655
|
reason: providerFailureReason(err)
|
|
645
656
|
};
|
|
646
|
-
if (
|
|
657
|
+
if (isNoSuchBucket(err)) {
|
|
647
658
|
return new StorageException(
|
|
648
659
|
STORAGE_ERROR_CODES.STORAGE_BUCKET_NOT_FOUND,
|
|
649
660
|
common.HttpStatus.NOT_FOUND,
|
|
@@ -673,11 +684,7 @@ function mapAwsError(err, context) {
|
|
|
673
684
|
}
|
|
674
685
|
if (e.name === "TimeoutError") {
|
|
675
686
|
logProviderFailure(err, context);
|
|
676
|
-
return new StorageException(
|
|
677
|
-
STORAGE_ERROR_CODES.STORAGE_TIMEOUT,
|
|
678
|
-
void 0,
|
|
679
|
-
details
|
|
680
|
-
);
|
|
687
|
+
return new StorageException(STORAGE_ERROR_CODES.STORAGE_TIMEOUT, void 0, details);
|
|
681
688
|
}
|
|
682
689
|
logProviderFailure(err, context);
|
|
683
690
|
return new StorageException(
|
|
@@ -1395,10 +1402,10 @@ function mapMultipartError(err, context) {
|
|
|
1395
1402
|
if (tooLong) {
|
|
1396
1403
|
return tooLong;
|
|
1397
1404
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
return bucketMissing;
|
|
1405
|
+
if (isNoSuchBucket(err)) {
|
|
1406
|
+
return mapAwsError(err, context);
|
|
1401
1407
|
}
|
|
1408
|
+
logProviderFailure(err, context, "Multipart upload failed");
|
|
1402
1409
|
return new StorageException(
|
|
1403
1410
|
STORAGE_ERROR_CODES.STORAGE_MULTIPART_ABORTED,
|
|
1404
1411
|
// An outage ends the upload as an outage; any other cause is a failure of the upload itself.
|
package/dist/server/index.mjs
CHANGED
|
@@ -539,7 +539,8 @@ function logValue(value) {
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
// src/server/utils/provider-failure-log.ts
|
|
542
|
-
var SECRET_IN_MESSAGE = /(X-Amz-(?:Signature|Credential|Security-Token)|AWSAccessKeyId|Signature)=[^&\s"']+/gi;
|
|
542
|
+
var SECRET_IN_MESSAGE = /(X-Amz-(?:Signature|Credential|Security-Token)|AWSAccessKeyId|Credential|Signature)=[^&\s"']+/gi;
|
|
543
|
+
var BARE_ACCESS_KEY_ID = /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g;
|
|
543
544
|
var MAX_MESSAGE_LENGTH = 300;
|
|
544
545
|
var logger = new Logger("StorageProvider");
|
|
545
546
|
function field(value) {
|
|
@@ -547,7 +548,7 @@ function field(value) {
|
|
|
547
548
|
}
|
|
548
549
|
function describeProviderFailure(err) {
|
|
549
550
|
const failure = typeof err === "object" && err !== null ? err : {};
|
|
550
|
-
const message = describeError(err).replace(SECRET_IN_MESSAGE, "$1=[redacted]");
|
|
551
|
+
const message = describeError(err).replace(SECRET_IN_MESSAGE, "$1=[redacted]").replace(BARE_ACCESS_KEY_ID, "[redacted-key-id]");
|
|
551
552
|
return [
|
|
552
553
|
`name=${field(failure.name)}`,
|
|
553
554
|
`code=${field(failure.Code)}`,
|
|
@@ -556,10 +557,13 @@ function describeProviderFailure(err) {
|
|
|
556
557
|
`message=${logValue(message.slice(0, MAX_MESSAGE_LENGTH))}`
|
|
557
558
|
].join(" ");
|
|
558
559
|
}
|
|
559
|
-
function logProviderFailure(err, context) {
|
|
560
|
+
function logProviderFailure(err, context, label = "Provider call failed") {
|
|
561
|
+
if (err?.name === "AbortError") {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
560
564
|
const op = typeof context?.op === "string" ? logValue(context.op) : "-";
|
|
561
565
|
const key = typeof context?.key === "string" ? logValue(context.key) : "-";
|
|
562
|
-
logger.warn(
|
|
566
|
+
logger.warn(`${label}: op=${op} key=${key} ${describeProviderFailure(err)}`);
|
|
563
567
|
}
|
|
564
568
|
var UNREACHABLE_CODES = /* @__PURE__ */ new Set([
|
|
565
569
|
"ECONNREFUSED",
|
|
@@ -628,10 +632,17 @@ function providerFailureStatus(err) {
|
|
|
628
632
|
}
|
|
629
633
|
|
|
630
634
|
// src/server/errors/aws-error-mapper.ts
|
|
635
|
+
function awsCodeOf(err) {
|
|
636
|
+
const e = err ?? {};
|
|
637
|
+
return e.Code ?? e.name;
|
|
638
|
+
}
|
|
639
|
+
function isNoSuchBucket(err) {
|
|
640
|
+
return awsCodeOf(err) === "NoSuchBucket";
|
|
641
|
+
}
|
|
631
642
|
function mapAwsError(err, context) {
|
|
632
643
|
const e = err ?? {};
|
|
633
644
|
const httpStatus = e.$metadata?.httpStatusCode;
|
|
634
|
-
const awsCode =
|
|
645
|
+
const awsCode = awsCodeOf(err);
|
|
635
646
|
const requestId = e.$metadata?.requestId;
|
|
636
647
|
const details = {
|
|
637
648
|
...context ?? {},
|
|
@@ -641,7 +652,7 @@ function mapAwsError(err, context) {
|
|
|
641
652
|
// A fixed word, never what the driver or the provider wrote.
|
|
642
653
|
reason: providerFailureReason(err)
|
|
643
654
|
};
|
|
644
|
-
if (
|
|
655
|
+
if (isNoSuchBucket(err)) {
|
|
645
656
|
return new StorageException(
|
|
646
657
|
STORAGE_ERROR_CODES.STORAGE_BUCKET_NOT_FOUND,
|
|
647
658
|
HttpStatus.NOT_FOUND,
|
|
@@ -671,11 +682,7 @@ function mapAwsError(err, context) {
|
|
|
671
682
|
}
|
|
672
683
|
if (e.name === "TimeoutError") {
|
|
673
684
|
logProviderFailure(err, context);
|
|
674
|
-
return new StorageException(
|
|
675
|
-
STORAGE_ERROR_CODES.STORAGE_TIMEOUT,
|
|
676
|
-
void 0,
|
|
677
|
-
details
|
|
678
|
-
);
|
|
685
|
+
return new StorageException(STORAGE_ERROR_CODES.STORAGE_TIMEOUT, void 0, details);
|
|
679
686
|
}
|
|
680
687
|
logProviderFailure(err, context);
|
|
681
688
|
return new StorageException(
|
|
@@ -1393,10 +1400,10 @@ function mapMultipartError(err, context) {
|
|
|
1393
1400
|
if (tooLong) {
|
|
1394
1401
|
return tooLong;
|
|
1395
1402
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
return bucketMissing;
|
|
1403
|
+
if (isNoSuchBucket(err)) {
|
|
1404
|
+
return mapAwsError(err, context);
|
|
1399
1405
|
}
|
|
1406
|
+
logProviderFailure(err, context, "Multipart upload failed");
|
|
1400
1407
|
return new StorageException(
|
|
1401
1408
|
STORAGE_ERROR_CODES.STORAGE_MULTIPART_ABORTED,
|
|
1402
1409
|
// An outage ends the upload as an outage; any other cause is a failure of the upload itself.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-storage",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"description": "Provider-agnostic S3-compatible object storage for NestJS. Works with AWS S3, DigitalOcean Spaces, Cloudflare R2, Backblaze B2, MinIO, Wasabi.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|