@aws-amplify/storage
Version:
Storage category of aws-amplify
1 lines • 2.7 kB
Source Map (JSON)
{"version":3,"file":"listPaths.mjs","sources":["../../../../../src/internals/apis/listPaths/listPaths.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getGlobalContext } from '@aws-amplify/core';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { StorageValidationErrorCode } from '../../../errors/types/validation';\nimport { resolveLocationsForCurrentSession } from './resolveLocationsForCurrentSession';\nimport { getHighestPrecedenceUserGroup } from './getHighestPrecedenceUserGroup';\nexport async function listPaths(maybeCtx) {\n // Resolve the optional leading context. The global context is resolved at\n // CALL time (never cached) so zero-arg callers follow live configuration.\n const ctx = maybeCtx ?? getGlobalContext();\n const { Storage, Auth } = ctx.resourcesConfig;\n const s3Config = Storage?.S3;\n assertValidationError(!!s3Config, StorageValidationErrorCode.NoS3Config);\n const authConfig = Auth?.Cognito;\n assertValidationError(!!authConfig, StorageValidationErrorCode.NoAuthConfig);\n const { buckets } = s3Config;\n const { groups } = authConfig;\n if (!buckets) {\n return { locations: [] };\n }\n const { tokens, identityId } = await ctx.fetchAuthSession();\n const currentUserGroups = tokens?.accessToken.payload['cognito:groups'];\n const userGroupToUse = getHighestPrecedenceUserGroup(groups, currentUserGroups);\n const locations = resolveLocationsForCurrentSession({\n buckets,\n isAuthenticated: !!tokens,\n identityId,\n userGroup: userGroupToUse,\n });\n return { locations };\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAMO,eAAe,SAAS,CAAC,QAAQ,EAAE;AAC1C;AACA;AACA,IAAI,MAAM,GAAG,GAAG,QAAQ,IAAI,gBAAgB,EAAE;AAC9C,IAAI,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,eAAe;AACjD,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,EAAE;AAChC,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,0BAA0B,CAAC,UAAU,CAAC;AAC5E,IAAI,MAAM,UAAU,GAAG,IAAI,EAAE,OAAO;AACpC,IAAI,qBAAqB,CAAC,CAAC,CAAC,UAAU,EAAE,0BAA0B,CAAC,YAAY,CAAC;AAChF,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ;AAChC,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU;AACjC,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;AAChC,IAAI;AACJ,IAAI,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,CAAC,gBAAgB,EAAE;AAC/D,IAAI,MAAM,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC;AAC3E,IAAI,MAAM,cAAc,GAAG,6BAA6B,CAAC,MAAM,EAAE,iBAAiB,CAAC;AACnF,IAAI,MAAM,SAAS,GAAG,iCAAiC,CAAC;AACxD,QAAQ,OAAO;AACf,QAAQ,eAAe,EAAE,CAAC,CAAC,MAAM;AACjC,QAAQ,UAAU;AAClB,QAAQ,SAAS,EAAE,cAAc;AACjC,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,SAAS,EAAE;AACxB;;;;"}