@cytario/web 2.2.2 → 2.2.4

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.
@@ -52,7 +52,9 @@ const fetchTemporaryCredentials = async (
52
52
  // Non-AWS providers (e.g. MinIO) may ignore or reject the `Policy` field,
53
53
  // so we omit it there — the role's intrinsic scope is the only bound.
54
54
  const sessionPolicy =
55
- provider === "aws" ? buildSessionPolicy({ bucketName, prefix }) : undefined;
55
+ provider === "aws"
56
+ ? buildSessionPolicy({ bucketName, prefix, region: actualRegion })
57
+ : undefined;
56
58
 
57
59
  const command = new AssumeRoleWithWebIdentityCommand({
58
60
  RoleArn: roleArn ?? undefined,
@@ -12,12 +12,13 @@
12
12
  export interface SessionPolicyArgs {
13
13
  bucketName: string;
14
14
  prefix: string | null | undefined;
15
+ region: string;
15
16
  }
16
17
 
17
18
  const stripSlashes = (prefix: string): string => prefix.replace(/^\/+|\/+$/g, "");
18
19
 
19
20
  /** Build an inline IAM session policy for `AssumeRoleWithWebIdentityCommand`. */
20
- export const buildSessionPolicy = ({ bucketName, prefix }: SessionPolicyArgs): string => {
21
+ export const buildSessionPolicy = ({ bucketName, prefix, region }: SessionPolicyArgs): string => {
21
22
  const normalised = typeof prefix === "string" ? stripSlashes(prefix) : "";
22
23
  // Defense-in-depth: refuse wildcards here so the schema is not the only gate
23
24
  // protecting cross-tenant `StringLike` conditions.
@@ -52,6 +53,23 @@ export const buildSessionPolicy = ({ bucketName, prefix }: SessionPolicyArgs): s
52
53
  Resource: bucketArn,
53
54
  };
54
55
 
56
+ // STS intersects this policy with the role's attached policy. Without an
57
+ // explicit `kms:Decrypt` here, the role's KMS grant is stripped and
58
+ // `GetObject` against SSE-KMS-encrypted buckets fails. `kms:ViaService`
59
+ // restricts use of the minted credential to the S3 data path; the role's
60
+ // attached policy remains the authoritative key allowlist.
61
+ const decryptStatement = {
62
+ Sid: "DecryptViaS3",
63
+ Effect: "Allow",
64
+ Action: "kms:Decrypt",
65
+ Resource: "*",
66
+ Condition: {
67
+ StringEquals: {
68
+ "kms:ViaService": `s3.${region}.amazonaws.com`,
69
+ },
70
+ },
71
+ };
72
+
55
73
  const policy = {
56
74
  Version: "2012-10-17",
57
75
  Statement: [
@@ -62,6 +80,7 @@ export const buildSessionPolicy = ({ bucketName, prefix }: SessionPolicyArgs): s
62
80
  Action: "s3:GetObject",
63
81
  Resource: objectArn,
64
82
  },
83
+ decryptStatement,
65
84
  ],
66
85
  };
67
86
 
package/app/root.tsx CHANGED
@@ -7,7 +7,6 @@ import {
7
7
  Outlet,
8
8
  Scripts,
9
9
  ScrollRestoration,
10
- useHref,
11
10
  useLocation,
12
11
  useNavigate,
13
12
  useNavigation,
@@ -156,7 +155,9 @@ export function Layout({ children }: { children: React.ReactNode }) {
156
155
  </div>
157
156
  )}
158
157
 
159
- <RouterProvider navigate={navigate} useHref={useHref}>
158
+ {/* No `useHref`: RR's collapses `//` in absolute URLs (C-201).
159
+ Only needed for basename / hash routing — neither is in use. */}
160
+ <RouterProvider navigate={navigate}>
160
161
  {data?.user && <AppHeader />}
161
162
 
162
163
  <main id="main-content" className="relative flex-1 min-h-0 outline-none">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cytario/web",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "Cytario Web — scientific imaging data browser and viewer for OME-TIFF, OME-Zarr, Parquet and GeoTIFF on S3-compatible storage.",
5
5
  "license": "AGPL-3.0",
6
6
  "sideEffects": false,