@ultimat3/storage 31.31.0 → 31.32.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/package.json +2 -2
- package/src/signing-secret.ts +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/storage",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.32.0",
|
|
4
4
|
"description": "Named disks over Bun.file and Bun.s3: safe keys, signed URLs, sniffed uploads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@ultimat3/core": "31.
|
|
46
|
+
"@ultimat3/core": "31.32.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/signing-secret.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
devSecretsRefused,
|
|
7
7
|
type ResolveEnvironmentOptions,
|
|
8
8
|
resolveEnvironment,
|
|
9
|
+
timingSafeEqual,
|
|
9
10
|
} from '@ultimat3/core';
|
|
10
11
|
import { signingSecretMissing } from './errors';
|
|
11
12
|
|
|
@@ -37,7 +38,10 @@ export const STORAGE_SIGNING_SECRET_KEY = 'STORAGE_SIGNING_SECRET';
|
|
|
37
38
|
export function usesDevStorageSecret(options?: Pick<ResolveEnvironmentOptions, 'env'>): boolean {
|
|
38
39
|
const source = options?.env ?? (process.env as Record<string, string | undefined>);
|
|
39
40
|
const configured = source[STORAGE_SIGNING_SECRET_KEY];
|
|
40
|
-
|
|
41
|
+
// `timingSafeEqual` though the other side is published: the left side is the live secret.
|
|
42
|
+
return (
|
|
43
|
+
configured === undefined || configured === '' || timingSafeEqual(configured, DEV_SIGNING_SECRET)
|
|
44
|
+
);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
/** The two options the rule reads; `LocalDriverOptions` carries both. */
|
|
@@ -63,7 +67,7 @@ export function resolveSigningSecret(disk: string, options: SigningSecretOptions
|
|
|
63
67
|
const env = options.env ?? (process.env as Record<string, string | undefined>);
|
|
64
68
|
const supplied = options.signingSecret ?? env[STORAGE_SIGNING_SECRET_KEY];
|
|
65
69
|
const configured =
|
|
66
|
-
supplied === undefined || supplied === '' || supplied
|
|
70
|
+
supplied === undefined || supplied === '' || timingSafeEqual(supplied, DEV_SIGNING_SECRET)
|
|
67
71
|
? undefined
|
|
68
72
|
: supplied;
|
|
69
73
|
// FAILS CLOSED, through core's one rule (`devSecretsRefused`): a process that names no
|