@scality/data-browser-library 1.0.0-preview.9 → 1.0.1
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/components/DataBrowserUI.d.ts +12 -0
- package/dist/components/DataBrowserUI.js +99 -0
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketAccessor.test.js +214 -0
- package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
- package/dist/components/__tests__/BucketCreate.test.js +271 -105
- package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
- package/dist/components/__tests__/BucketDetails.test.js +421 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +13 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +178 -178
- package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
- package/dist/components/__tests__/BucketList.test.js +463 -239
- package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
- package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
- package/dist/components/__tests__/BucketOverview.test.js +281 -266
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +15 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +544 -544
- package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
- package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
- package/dist/components/__tests__/EmptyBucketButton.test.js +59 -59
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +741 -240
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/components/breadcrumb/Breadcrumb.js +37 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
- package/dist/components/breadcrumb/index.d.ts +8 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
- package/dist/components/buckets/BucketAccessor.d.ts +2 -0
- package/dist/components/buckets/BucketAccessor.js +125 -0
- package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
- package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
- package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
- package/dist/components/buckets/BucketCorsPage.js +234 -0
- package/dist/components/buckets/BucketCreate.d.ts +3 -2
- package/dist/components/buckets/BucketCreate.js +89 -47
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +249 -85
- package/dist/components/buckets/BucketLifecycleFormPage.js +206 -190
- package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
- package/dist/components/buckets/BucketLifecycleList.js +47 -47
- package/dist/components/buckets/BucketList.d.ts +7 -8
- package/dist/components/buckets/BucketList.js +158 -101
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +22 -2
- package/dist/components/buckets/BucketOverview.js +394 -187
- package/dist/components/buckets/BucketPage.js +43 -21
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.js +134 -133
- package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
- package/dist/components/buckets/BucketReplicationList.js +42 -42
- package/dist/components/buckets/BucketVersioning.d.ts +4 -0
- package/dist/components/buckets/BucketVersioning.js +76 -0
- package/dist/components/buckets/DeleteBucketButton.js +8 -8
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +2 -2
- package/dist/components/buckets/EmptyBucketButton.js +24 -24
- package/dist/components/buckets/EmptyBucketSummary.d.ts +2 -2
- package/dist/components/buckets/EmptyBucketSummary.js +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
- package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
- package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
- package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
- package/dist/components/buckets/notifications/EventsSection.js +145 -29
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +27 -20
- package/dist/components/index.js +17 -10
- package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
- package/dist/components/layouts/ArrowNavigation.js +28 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
- package/dist/components/layouts/BrowserPageLayout.js +10 -5
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +12 -12
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +19 -21
- package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
- package/dist/components/objects/GetPresignedUrlButton.js +255 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +263 -230
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectTags.js +95 -123
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
- package/dist/components/objects/ObjectDetails/index.js +152 -40
- package/dist/components/objects/ObjectList.d.ts +12 -10
- package/dist/components/objects/ObjectList.js +590 -263
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +4 -4
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +15 -15
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +32 -31
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +51 -51
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +78 -78
- package/dist/components/objects/ObjectPage.js +12 -8
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +10 -10
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +21 -0
- package/dist/components/search/MetadataSearch.js +29 -28
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.js +12 -7
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +2 -2
- package/dist/components/ui/ConfirmDeleteRuleModal.js +6 -1
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +2 -2
- package/dist/components/ui/FilterFormSection.js +29 -29
- package/dist/components/ui/Search.elements.d.ts +2 -2
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.d.ts +2 -1
- package/dist/components/ui/Table.elements.js +18 -12
- package/dist/config/__tests__/factory.test.d.ts +1 -0
- package/dist/config/__tests__/factory.test.js +311 -0
- package/dist/config/factory.d.ts +10 -56
- package/dist/config/factory.js +23 -71
- package/dist/config/types.d.ts +212 -34
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
- package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +45 -45
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +27 -27
- package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
- package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
- package/dist/hooks/bucketConfiguration.d.ts +8 -1
- package/dist/hooks/bucketConfiguration.js +52 -51
- package/dist/hooks/bucketOperations.d.ts +10 -1
- package/dist/hooks/bucketOperations.js +10 -9
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +65 -65
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/index.js +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +11 -6
- package/dist/hooks/index.d.ts +19 -12
- package/dist/hooks/index.js +16 -9
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +50 -49
- package/dist/hooks/presignedOperations.d.ts +4 -4
- package/dist/hooks/presignedOperations.js +5 -5
- package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
- package/dist/hooks/useAccessibleBuckets.js +115 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +48 -0
- package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
- package/dist/hooks/useBucketConfigEditor.js +82 -0
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
- package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
- package/dist/hooks/useEmptyBucket.js +11 -11
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.js +6 -6
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
- package/dist/hooks/useLimitedAccessFlow.js +23 -0
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/schemas/bucketPolicySchema.json +3 -13
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +32 -17
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +77 -54
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/index.js +1 -1
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +13 -30
- package/dist/test/testUtils.d.ts +85 -33
- package/dist/test/testUtils.js +176 -111
- package/dist/test/utils/errorHandling.test.js +119 -119
- package/dist/types/index.d.ts +49 -36
- package/dist/types/monaco.d.ts +13 -0
- package/dist/types/monaco.js +0 -0
- package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
- package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
- package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
- package/dist/utils/__tests__/s3Client.test.js +340 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +19 -9
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/index.js +1 -1
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +3 -3
- package/dist/utils/errorHandling.js +6 -6
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +4 -2
- package/dist/utils/proxyMiddleware.d.ts +32 -13
- package/dist/utils/proxyMiddleware.js +90 -36
- package/dist/utils/s3Client.d.ts +14 -4
- package/dist/utils/s3Client.js +5 -26
- package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
- package/dist/utils/s3ConfigIdentifier.js +57 -0
- package/dist/utils/s3RuleUtils.d.ts +5 -5
- package/dist/utils/s3RuleUtils.js +17 -17
- package/package.json +10 -8
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
- package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
- package/dist/hooks/useLoginMutation.d.ts +0 -21
- package/dist/hooks/useLoginMutation.js +0 -9
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
- /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to check if a feature is enabled in the S3 configuration.
|
|
3
|
+
*
|
|
4
|
+
* @param feature - The feature name to check
|
|
5
|
+
* @returns true if enabled, false if disabled, undefined if config not available
|
|
6
|
+
*/
|
|
7
|
+
export declare function useFeatures(feature: string): boolean | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
2
|
+
function useFeatures(feature) {
|
|
3
|
+
const { getS3Config } = useDataBrowserContext();
|
|
4
|
+
if (!getS3Config) return;
|
|
5
|
+
const config = getS3Config();
|
|
6
|
+
return config.features?.includes(feature) ?? false;
|
|
7
|
+
}
|
|
8
|
+
export { useFeatures };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useGetBucketTagging } from "./bucketConfiguration.js";
|
|
2
|
-
import { useFeatures } from "../utils/useFeatures.js";
|
|
3
1
|
import { BUCKET_TAG_APPLICATION, BUCKET_TAG_VEEAM_APPLICATION, COMMVAULT_APPLICATION, VEEAM_BACKUP_REPLICATION, VEEAM_OFFICE_365, VEEAM_OFFICE_365_V8, VEEAM_VBO_APPLICATION } from "../utils/constants.js";
|
|
2
|
+
import { useGetBucketTagging } from "./bucketConfiguration.js";
|
|
3
|
+
import { useFeatures } from "./useFeatures.js";
|
|
4
4
|
const useISVBucketStatus = (bucketName)=>{
|
|
5
|
-
const isISVFeatureEnabled = useFeatures(
|
|
5
|
+
const isISVFeatureEnabled = useFeatures('ISV');
|
|
6
6
|
const { data: bucketTags, status: bucketTagsStatus } = useGetBucketTagging({
|
|
7
7
|
Bucket: bucketName
|
|
8
8
|
}, {
|
|
9
|
-
enabled: isISVFeatureEnabled
|
|
9
|
+
enabled: true === isISVFeatureEnabled
|
|
10
10
|
});
|
|
11
11
|
const veeamTagApplication = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_VEEAM_APPLICATION)?.Value;
|
|
12
12
|
const ISVApplicationTag = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_APPLICATION)?.Value;
|
|
@@ -19,8 +19,8 @@ const useISVBucketStatus = (bucketName)=>{
|
|
|
19
19
|
isVeeamBucket: isVeeam,
|
|
20
20
|
isCommvaultBucket,
|
|
21
21
|
isISVManaged,
|
|
22
|
-
isvApplication: isCommvaultBucket ?
|
|
23
|
-
isLoading: isISVFeatureEnabled &&
|
|
22
|
+
isvApplication: isCommvaultBucket ? 'Commvault' : isVeeam ? 'Veeam' : void 0,
|
|
23
|
+
isLoading: isISVFeatureEnabled && 'pending' === bucketTagsStatus,
|
|
24
24
|
bucketTagsStatus
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useListObjects } from "./objectOperations.js";
|
|
3
|
-
const isInfiniteData = (data)=>null != data &&
|
|
3
|
+
const isInfiniteData = (data)=>null != data && 'object' == typeof data && 'pages' in data && Array.isArray(data.pages);
|
|
4
4
|
const useIsBucketEmpty = (bucketName)=>{
|
|
5
5
|
const { data, status, error } = useListObjects({
|
|
6
6
|
Bucket: bucketName,
|
|
7
7
|
MaxKeys: 1,
|
|
8
|
-
Delimiter:
|
|
8
|
+
Delimiter: '/'
|
|
9
9
|
}, {
|
|
10
10
|
enabled: !!bucketName
|
|
11
11
|
});
|
|
12
12
|
const isEmpty = useMemo(()=>{
|
|
13
|
-
if (
|
|
13
|
+
if ('pending' === status || !data) return null;
|
|
14
14
|
if (!isInfiniteData(data)) return null;
|
|
15
15
|
for (const page of data.pages){
|
|
16
16
|
if (page?.Contents && page.Contents.length > 0) {
|
|
@@ -29,7 +29,7 @@ const useIsBucketEmpty = (bucketName)=>{
|
|
|
29
29
|
]);
|
|
30
30
|
return {
|
|
31
31
|
isEmpty,
|
|
32
|
-
isLoading:
|
|
32
|
+
isLoading: 'pending' === status,
|
|
33
33
|
error: error instanceof Error ? error : null
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limited Access Flow Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* This module centralizes all logic related to handling users with limited S3 permissions
|
|
5
|
+
* (specifically users who lack ListBuckets permission but have access to specific buckets).
|
|
6
|
+
*
|
|
7
|
+
* It provides a clean abstraction that:
|
|
8
|
+
* - Encapsulates storage key patterns
|
|
9
|
+
* - Manages the limited access flag
|
|
10
|
+
* - Provides navigation logic
|
|
11
|
+
* - Coordinates between authentication, storage, and routing
|
|
12
|
+
*/
|
|
13
|
+
import type { LoginConfig } from './loginOperations';
|
|
14
|
+
export interface UseLimitedAccessFlowOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Callback invoked when a user successfully authenticates with limited access.
|
|
17
|
+
* This should be used to persist the config and transition the app state.
|
|
18
|
+
*/
|
|
19
|
+
onLimitedAccessGranted: (config: LoginConfig) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface LimitedAccessFlowHandlers {
|
|
22
|
+
/**
|
|
23
|
+
* Activates the limited access flow for a given S3 configuration.
|
|
24
|
+
* Sets the necessary flags and navigates to the bucket accessor form.
|
|
25
|
+
*/
|
|
26
|
+
activateLimitedAccessFlow: (config: LoginConfig) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook that orchestrates the limited access flow.
|
|
30
|
+
*
|
|
31
|
+
* This hook provides methods to activate and check the limited access mode
|
|
32
|
+
* for users who lack ListBuckets permission.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* const { activateLimitedAccessFlow } = useLimitedAccessFlow({
|
|
37
|
+
* onLimitedAccessGranted: (config) => {
|
|
38
|
+
* setAppConfig(config);
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // In login error handler:
|
|
43
|
+
* if (error.name === 'AccessDenied') {
|
|
44
|
+
* activateLimitedAccessFlow(variables);
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const useLimitedAccessFlow: (options: UseLimitedAccessFlowOptions) => LimitedAccessFlowHandlers;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useNavigate } from "react-router";
|
|
3
|
+
import { computeS3ConfigIdentifier } from "../utils/s3ConfigIdentifier.js";
|
|
4
|
+
import { setLimitedAccessFlag } from "./useAccessibleBuckets.js";
|
|
5
|
+
const useLimitedAccessFlow = (options)=>{
|
|
6
|
+
const navigate = useNavigate();
|
|
7
|
+
const { onLimitedAccessGranted } = options;
|
|
8
|
+
const activateLimitedAccessFlow = useCallback((config)=>{
|
|
9
|
+
const s3ConfigIdentifier = computeS3ConfigIdentifier(config);
|
|
10
|
+
setLimitedAccessFlag(s3ConfigIdentifier, true);
|
|
11
|
+
onLimitedAccessGranted(config);
|
|
12
|
+
navigate('/buckets/-/access', {
|
|
13
|
+
replace: true
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
navigate,
|
|
17
|
+
onLimitedAccessGranted
|
|
18
|
+
]);
|
|
19
|
+
return {
|
|
20
|
+
activateLimitedAccessFlow
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { useLimitedAccessFlow };
|
|
@@ -2,12 +2,13 @@ import { useMemo } from "react";
|
|
|
2
2
|
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
3
3
|
import { createS3Client } from "../utils/s3Client.js";
|
|
4
4
|
const useS3Client = ()=>{
|
|
5
|
-
const { getS3Config } = useDataBrowserContext();
|
|
5
|
+
const { s3ConfigIdentifier, getS3Config } = useDataBrowserContext();
|
|
6
|
+
if (!getS3Config) throw new Error('useS3Client: S3 config not available. Ensure DataBrowserProvider has getS3Config prop set.');
|
|
6
7
|
return useMemo(()=>{
|
|
7
8
|
const config = getS3Config();
|
|
8
9
|
return createS3Client(config);
|
|
9
10
|
}, [
|
|
10
|
-
|
|
11
|
+
s3ConfigIdentifier
|
|
11
12
|
]);
|
|
12
13
|
};
|
|
13
14
|
export { useS3Client };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that handles navigation and query cleanup when S3 config changes.
|
|
3
|
+
* Must be used inside both DataBrowserProvider and DataBrowserUICustomizationProvider.
|
|
4
|
+
*
|
|
5
|
+
* When the S3 config identifier changes:
|
|
6
|
+
* - Navigates to the buckets page first (to trigger component unmounting)
|
|
7
|
+
* - Clears all queries associated with the previous config (after navigation)
|
|
8
|
+
*
|
|
9
|
+
* @internal This hook is designed for internal use within DataBrowserUI only.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useS3ConfigSwitch: () => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useNavigate } from "react-router";
|
|
4
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
5
|
+
import { useDataBrowserUICustomization } from "../contexts/DataBrowserUICustomizationContext.js";
|
|
6
|
+
import { normalizePath } from "./useDataBrowserNavigate.js";
|
|
7
|
+
const useS3ConfigSwitch = ()=>{
|
|
8
|
+
const { s3ConfigIdentifier } = useDataBrowserContext();
|
|
9
|
+
const { basePath = '' } = useDataBrowserUICustomization();
|
|
10
|
+
const queryClient = useQueryClient();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
const prevConfigIdRef = useRef();
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
if (void 0 !== prevConfigIdRef.current && prevConfigIdRef.current !== s3ConfigIdentifier) {
|
|
15
|
+
const previousConfigId = prevConfigIdRef.current;
|
|
16
|
+
const bucketsPath = normalizePath(basePath, '/buckets');
|
|
17
|
+
navigate(bucketsPath, {
|
|
18
|
+
replace: true
|
|
19
|
+
});
|
|
20
|
+
queueMicrotask(()=>{
|
|
21
|
+
queryClient.removeQueries({
|
|
22
|
+
queryKey: [
|
|
23
|
+
previousConfigId
|
|
24
|
+
],
|
|
25
|
+
exact: false
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
prevConfigIdRef.current = s3ConfigIdentifier;
|
|
30
|
+
}, [
|
|
31
|
+
s3ConfigIdentifier,
|
|
32
|
+
navigate,
|
|
33
|
+
basePath,
|
|
34
|
+
queryClient
|
|
35
|
+
]);
|
|
36
|
+
};
|
|
37
|
+
export { useS3ConfigSwitch };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { S3EventType } from '../config/types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get supported notification events from the DataBrowser configuration
|
|
4
|
+
* If no supported events are configured, returns undefined (meaning all events are supported)
|
|
5
|
+
*/
|
|
6
|
+
export declare function useSupportedNotificationEvents(): S3EventType[] | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
2
|
+
function useSupportedNotificationEvents() {
|
|
3
|
+
const { getS3Config } = useDataBrowserContext();
|
|
4
|
+
if (!getS3Config) return;
|
|
5
|
+
const config = getS3Config();
|
|
6
|
+
return config?.s3Capabilities?.supportedNotificationEvents;
|
|
7
|
+
}
|
|
8
|
+
export { useSupportedNotificationEvents };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './config/factory';
|
|
3
|
+
export * from './config/types';
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./components/index.js";
|
|
2
|
+
export * from "./config/factory.js";
|
|
3
|
+
export * from "./config/types.js";
|
|
2
4
|
export * from "./hooks/index.js";
|
|
3
5
|
export * from "./types/index.js";
|
|
4
6
|
export * from "./utils/index.js";
|
|
5
|
-
export * from "./config/factory.js";
|
|
6
|
-
export * from "./config/types.js";
|
|
@@ -20,10 +20,7 @@
|
|
|
20
20
|
"items": {
|
|
21
21
|
"type": "object",
|
|
22
22
|
"required": ["Effect"],
|
|
23
|
-
"oneOf": [
|
|
24
|
-
{ "required": ["Principal"] },
|
|
25
|
-
{ "required": ["NotPrincipal"] }
|
|
26
|
-
],
|
|
23
|
+
"oneOf": [{ "required": ["Principal"] }, { "required": ["NotPrincipal"] }],
|
|
27
24
|
"properties": {
|
|
28
25
|
"Sid": {
|
|
29
26
|
"type": "string",
|
|
@@ -276,10 +273,7 @@
|
|
|
276
273
|
"oneOf": [{ "required": ["Action"] }, { "required": ["NotAction"] }]
|
|
277
274
|
},
|
|
278
275
|
{
|
|
279
|
-
"oneOf": [
|
|
280
|
-
{ "required": ["Resource"] },
|
|
281
|
-
{ "required": ["NotResource"] }
|
|
282
|
-
]
|
|
276
|
+
"oneOf": [{ "required": ["Resource"] }, { "required": ["NotResource"] }]
|
|
283
277
|
}
|
|
284
278
|
]
|
|
285
279
|
}
|
|
@@ -306,11 +300,7 @@
|
|
|
306
300
|
{
|
|
307
301
|
"type": "array",
|
|
308
302
|
"items": {
|
|
309
|
-
"oneOf": [
|
|
310
|
-
{ "type": "string" },
|
|
311
|
-
{ "type": "number" },
|
|
312
|
-
{ "type": "boolean" }
|
|
313
|
-
]
|
|
303
|
+
"oneOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }]
|
|
314
304
|
},
|
|
315
305
|
"description": "Multiple condition values"
|
|
316
306
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const deleteBucketHandler: import("msw").
|
|
1
|
+
export declare const deleteBucketHandler: import("msw").HttpHandler;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const deleteBucketHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
if (
|
|
6
|
-
if (bucketName.includes(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (bucketName.includes(
|
|
10
|
-
|
|
3
|
+
const deleteBucketHandler = http["delete"](`${getS3BaseUrl()}/:bucketName`, async ({ params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
if ('string' == typeof bucketName) {
|
|
6
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
7
|
+
status: 404
|
|
8
|
+
});
|
|
9
|
+
if (bucketName.includes('bucket-not-empty')) return HttpResponse.xml(createS3ErrorXml('BucketNotEmpty', 'The bucket you tried to delete is not empty', bucketName), {
|
|
10
|
+
status: 409
|
|
11
|
+
});
|
|
12
|
+
if (bucketName.includes('restricted-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
13
|
+
status: 403
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
16
|
+
if (bucketName.includes('error-callback-bucket')) return HttpResponse.xml(createS3ErrorXml('InternalError', 'We encountered an internal error. Please try again.'), {
|
|
17
|
+
status: 500
|
|
18
|
+
});
|
|
11
19
|
}
|
|
12
|
-
return
|
|
20
|
+
return new Response(null, {
|
|
21
|
+
status: 204
|
|
22
|
+
});
|
|
13
23
|
});
|
|
14
24
|
export { deleteBucketHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getBucketAclHandler: import("msw").
|
|
1
|
+
export declare const getBucketAclHandler: import("msw").HttpHandler;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketAclHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (bucketName.includes(
|
|
3
|
+
const getBucketAclHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('acl')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
15
|
+
if (bucketName.includes('private-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
12
16
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
13
17
|
<Owner>
|
|
14
18
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -23,8 +27,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
23
27
|
<Permission>FULL_CONTROL</Permission>
|
|
24
28
|
</Grant>
|
|
25
29
|
</AccessControlList>
|
|
26
|
-
</AccessControlPolicy
|
|
27
|
-
|
|
30
|
+
</AccessControlPolicy>`, {
|
|
31
|
+
status: 200
|
|
32
|
+
});
|
|
33
|
+
if (bucketName.includes('public-read-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
34
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
29
35
|
<Owner>
|
|
30
36
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -45,8 +51,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
45
51
|
<Permission>READ</Permission>
|
|
46
52
|
</Grant>
|
|
47
53
|
</AccessControlList>
|
|
48
|
-
</AccessControlPolicy
|
|
49
|
-
|
|
54
|
+
</AccessControlPolicy>`, {
|
|
55
|
+
status: 200
|
|
56
|
+
});
|
|
57
|
+
if (bucketName.includes('shared-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
50
58
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
51
59
|
<Owner>
|
|
52
60
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -74,9 +82,11 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
74
82
|
<Permission>READ</Permission>
|
|
75
83
|
</Grant>
|
|
76
84
|
</AccessControlList>
|
|
77
|
-
</AccessControlPolicy
|
|
85
|
+
</AccessControlPolicy>`, {
|
|
86
|
+
status: 200
|
|
87
|
+
});
|
|
78
88
|
}
|
|
79
|
-
return
|
|
89
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
80
90
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
81
91
|
<Owner>
|
|
82
92
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -91,6 +101,8 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
91
101
|
<Permission>FULL_CONTROL</Permission>
|
|
92
102
|
</Grant>
|
|
93
103
|
</AccessControlList>
|
|
94
|
-
</AccessControlPolicy
|
|
104
|
+
</AccessControlPolicy>`, {
|
|
105
|
+
status: 200
|
|
106
|
+
});
|
|
95
107
|
});
|
|
96
108
|
export { getBucketAclHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getBucketLocationHandler: import("msw").
|
|
1
|
+
export declare const getBucketLocationHandler: import("msw").HttpHandler;
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketLocationHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const getBucketLocationHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('location')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
11
15
|
let locationConstraint = null;
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
else if (bucketName.includes(
|
|
14
|
-
else if (bucketName.includes(
|
|
16
|
+
if (bucketName.includes('eu-west-1')) locationConstraint = 'eu-west-1';
|
|
17
|
+
else if (bucketName.includes('ap-southeast-1')) locationConstraint = 'ap-southeast-1';
|
|
18
|
+
else if (bucketName.includes('us-west-2')) locationConstraint = 'us-west-2';
|
|
15
19
|
const response = locationConstraint ? `<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">${locationConstraint}</LocationConstraint>` : `<?xml version="1.0" encoding="UTF-8"?>
|
|
17
21
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`;
|
|
18
|
-
return
|
|
22
|
+
return HttpResponse.xml(response, {
|
|
23
|
+
status: 200,
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/xml'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
19
28
|
}
|
|
20
|
-
return
|
|
21
|
-
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint
|
|
29
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
30
|
+
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`, {
|
|
31
|
+
status: 200,
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/xml'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
22
36
|
});
|
|
23
37
|
export { getBucketLocationHandler };
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* - "invalid-json-bucket" returns malformed JSON for testing
|
|
9
9
|
* - Other buckets return a default allow-all policy
|
|
10
10
|
*/
|
|
11
|
-
export declare const getBucketPolicyHandler: import("msw").
|
|
11
|
+
export declare const getBucketPolicyHandler: import("msw").HttpHandler;
|
|
@@ -1,65 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketPolicyHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const getBucketPolicyHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('policy')) return;
|
|
7
|
+
if ('no-policy-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('NoSuchBucketPolicy', 'The bucket policy does not exist', bucketName), {
|
|
8
|
+
status: 404,
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/xml'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if ('access-denied-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied', bucketName), {
|
|
14
|
+
status: 403,
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/xml'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if ('invalid-json-bucket' === bucketName) return HttpResponse.text('{"Version": "2012-10-17", "Statement": [invalid json}', {
|
|
20
|
+
status: 200,
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
10
25
|
let policy;
|
|
11
|
-
policy =
|
|
12
|
-
Version:
|
|
26
|
+
policy = 'string' == typeof bucketName && bucketName.startsWith('policy-readonly-') ? {
|
|
27
|
+
Version: '2012-10-17',
|
|
13
28
|
Statement: [
|
|
14
29
|
{
|
|
15
|
-
Sid:
|
|
16
|
-
Effect:
|
|
17
|
-
Principal:
|
|
18
|
-
Action:
|
|
30
|
+
Sid: 'PublicReadGetObject',
|
|
31
|
+
Effect: 'Allow',
|
|
32
|
+
Principal: '*',
|
|
33
|
+
Action: 's3:GetObject',
|
|
19
34
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
20
35
|
}
|
|
21
36
|
]
|
|
22
|
-
} :
|
|
23
|
-
Version:
|
|
37
|
+
} : 'string' == typeof bucketName && bucketName.startsWith('policy-complex-') ? {
|
|
38
|
+
Version: '2012-10-17',
|
|
24
39
|
Statement: [
|
|
25
40
|
{
|
|
26
|
-
Sid:
|
|
27
|
-
Effect:
|
|
41
|
+
Sid: 'AllowSpecificUser',
|
|
42
|
+
Effect: 'Allow',
|
|
28
43
|
Principal: {
|
|
29
|
-
AWS:
|
|
44
|
+
AWS: 'arn:aws:iam::123456789012:user/ExampleUser'
|
|
30
45
|
},
|
|
31
46
|
Action: [
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
's3:GetObject',
|
|
48
|
+
's3:PutObject'
|
|
34
49
|
],
|
|
35
50
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
36
51
|
},
|
|
37
52
|
{
|
|
38
|
-
Sid:
|
|
39
|
-
Effect:
|
|
40
|
-
Principal:
|
|
41
|
-
Action:
|
|
53
|
+
Sid: 'DenyInsecureConnections',
|
|
54
|
+
Effect: 'Deny',
|
|
55
|
+
Principal: '*',
|
|
56
|
+
Action: 's3:*',
|
|
42
57
|
Resource: [
|
|
43
58
|
`arn:aws:s3:::${bucketName}`,
|
|
44
59
|
`arn:aws:s3:::${bucketName}/*`
|
|
45
60
|
],
|
|
46
61
|
Condition: {
|
|
47
62
|
Bool: {
|
|
48
|
-
|
|
63
|
+
'aws:SecureTransport': 'false'
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
}
|
|
52
67
|
]
|
|
53
68
|
} : {
|
|
54
|
-
Version:
|
|
69
|
+
Version: '2012-10-17',
|
|
55
70
|
Statement: [
|
|
56
71
|
{
|
|
57
|
-
Sid:
|
|
58
|
-
Effect:
|
|
72
|
+
Sid: 'DefaultStatement',
|
|
73
|
+
Effect: 'Allow',
|
|
59
74
|
Principal: {
|
|
60
|
-
AWS:
|
|
75
|
+
AWS: 'arn:aws:iam::123456789012:root'
|
|
61
76
|
},
|
|
62
|
-
Action:
|
|
77
|
+
Action: 's3:*',
|
|
63
78
|
Resource: [
|
|
64
79
|
`arn:aws:s3:::${bucketName}`,
|
|
65
80
|
`arn:aws:s3:::${bucketName}/*`
|
|
@@ -67,6 +82,11 @@ const getBucketPolicyHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, r
|
|
|
67
82
|
}
|
|
68
83
|
]
|
|
69
84
|
};
|
|
70
|
-
return
|
|
85
|
+
return HttpResponse.json(policy, {
|
|
86
|
+
status: 200,
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/json'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
71
91
|
});
|
|
72
92
|
export { getBucketPolicyHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const headObjectHandler: import("msw").
|
|
1
|
+
export declare const headObjectHandler: import("msw").HttpHandler;
|