@aws-amplify/storage 6.7.10-poc-list-paths.b7e5c4c.0 → 6.7.10-unstable.22ceeb3.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.
@@ -3,38 +3,50 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.resolveLocationsForCurrentSession = void 0;
5
5
  const constants_1 = require("../../utils/constants");
6
- const isPathPermissions = (value) => Array.isArray(value);
7
- const resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {
8
- if (includeEntityIdPath) {
9
- return accessRules.entityidentity;
10
- }
6
+ const resolvePermissions = (accessRule, isAuthenticated, groups) => {
11
7
  if (!isAuthenticated) {
12
- return accessRules.guest;
8
+ return {
9
+ permission: accessRule.guest,
10
+ };
13
11
  }
14
- if (userGroup) {
15
- const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));
16
- return selectedKey ? accessRules[selectedKey] : undefined;
12
+ if (groups) {
13
+ const selectedKey = Object.keys(accessRule).find(access => access.includes(groups));
14
+ return {
15
+ permission: selectedKey ? accessRule[selectedKey] : undefined,
16
+ };
17
17
  }
18
- return accessRules.authenticated;
18
+ return {
19
+ permission: accessRule.authenticated,
20
+ };
19
21
  };
20
22
  const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
21
23
  const locations = [];
22
- for (const { bucketName: bucket, paths } of Object.values(buckets)) {
24
+ for (const [, bucketInfo] of Object.entries(buckets)) {
25
+ const { bucketName, paths } = bucketInfo;
23
26
  if (!paths) {
24
27
  continue;
25
28
  }
26
29
  for (const [path, accessRules] of Object.entries(paths)) {
27
- const includeEntityIdPath = !userGroup &&
30
+ const shouldIncludeEntityIdPath = !userGroup &&
28
31
  path.includes(constants_1.ENTITY_IDENTITY_URL) &&
29
32
  isAuthenticated &&
30
- !!identityId;
31
- const permissions = resolvePermissions(accessRules, isAuthenticated, includeEntityIdPath, userGroup);
32
- if (isPathPermissions(permissions)) {
33
- const prefix = !includeEntityIdPath
34
- ? path
35
- : path.replace(constants_1.ENTITY_IDENTITY_URL, identityId);
36
- locations.push({ bucket, permissions, prefix, type: 'PREFIX' });
33
+ identityId;
34
+ if (shouldIncludeEntityIdPath) {
35
+ locations.push({
36
+ type: 'PREFIX',
37
+ permission: accessRules.entityidentity,
38
+ bucket: bucketName,
39
+ prefix: path.replace(constants_1.ENTITY_IDENTITY_URL, identityId),
40
+ });
37
41
  }
42
+ const location = {
43
+ type: 'PREFIX',
44
+ ...resolvePermissions(accessRules, isAuthenticated, userGroup),
45
+ bucket: bucketName,
46
+ prefix: path,
47
+ };
48
+ if (location.permission)
49
+ locations.push(location);
38
50
  }
39
51
  }
40
52
  return locations;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocationsForCurrentSession.js","sources":["../../../../../src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLocationsForCurrentSession = void 0;\nconst constants_1 = require(\"../../utils/constants\");\nconst isPathPermissions = (value) => Array.isArray(value);\nconst resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {\n if (includeEntityIdPath) {\n return accessRules.entityidentity;\n }\n if (!isAuthenticated) {\n return accessRules.guest;\n }\n if (userGroup) {\n const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));\n return selectedKey ? accessRules[selectedKey] : undefined;\n }\n return accessRules.authenticated;\n};\nconst resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {\n const locations = [];\n for (const { bucketName: bucket, paths } of Object.values(buckets)) {\n if (!paths) {\n continue;\n }\n for (const [path, accessRules] of Object.entries(paths)) {\n const includeEntityIdPath = !userGroup &&\n path.includes(constants_1.ENTITY_IDENTITY_URL) &&\n isAuthenticated &&\n !!identityId;\n const permissions = resolvePermissions(accessRules, isAuthenticated, includeEntityIdPath, userGroup);\n if (isPathPermissions(permissions)) {\n const prefix = !includeEntityIdPath\n ? path\n : path.replace(constants_1.ENTITY_IDENTITY_URL, identityId);\n locations.push({ bucket, permissions, prefix, type: 'PREFIX' });\n }\n }\n }\n return locations;\n};\nexports.resolveLocationsForCurrentSession = resolveLocationsForCurrentSession;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1D,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,KAAK;AAC7F,IAAI,IAAI,mBAAmB,EAAE;AAC7B,QAAQ,OAAO,WAAW,CAAC,cAAc,CAAC;AAC1C,KAAK;AACL,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,SAAS,EAAE;AACnB,QAAQ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAChG,QAAQ,OAAO,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;AAClE,KAAK;AACL,IAAI,OAAO,WAAW,CAAC,aAAa,CAAC;AACrC,CAAC,CAAC;AACF,MAAM,iCAAiC,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,GAAG,KAAK;AACpG,IAAI,MAAM,SAAS,GAAG,EAAE,CAAC;AACzB,IAAI,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;AACxE,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,SAAS;AACrB,SAAS;AACT,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACjE,YAAY,MAAM,mBAAmB,GAAG,CAAC,SAAS;AAClD,gBAAgB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,mBAAmB,CAAC;AAC9D,gBAAgB,eAAe;AAC/B,gBAAgB,CAAC,CAAC,UAAU,CAAC;AAC7B,YAAY,MAAM,WAAW,GAAG,kBAAkB,CAAC,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;AACjH,YAAY,IAAI,iBAAiB,CAAC,WAAW,CAAC,EAAE;AAChD,gBAAgB,MAAM,MAAM,GAAG,CAAC,mBAAmB;AACnD,sBAAsB,IAAI;AAC1B,sBAAsB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;AAChF,gBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AACF,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
1
+ {"version":3,"file":"resolveLocationsForCurrentSession.js","sources":["../../../../../src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLocationsForCurrentSession = void 0;\nconst constants_1 = require(\"../../utils/constants\");\nconst resolvePermissions = (accessRule, isAuthenticated, groups) => {\n if (!isAuthenticated) {\n return {\n permission: accessRule.guest,\n };\n }\n if (groups) {\n const selectedKey = Object.keys(accessRule).find(access => access.includes(groups));\n return {\n permission: selectedKey ? accessRule[selectedKey] : undefined,\n };\n }\n return {\n permission: accessRule.authenticated,\n };\n};\nconst resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {\n const locations = [];\n for (const [, bucketInfo] of Object.entries(buckets)) {\n const { bucketName, paths } = bucketInfo;\n if (!paths) {\n continue;\n }\n for (const [path, accessRules] of Object.entries(paths)) {\n const shouldIncludeEntityIdPath = !userGroup &&\n path.includes(constants_1.ENTITY_IDENTITY_URL) &&\n isAuthenticated &&\n identityId;\n if (shouldIncludeEntityIdPath) {\n locations.push({\n type: 'PREFIX',\n permission: accessRules.entityidentity,\n bucket: bucketName,\n prefix: path.replace(constants_1.ENTITY_IDENTITY_URL, identityId),\n });\n }\n const location = {\n type: 'PREFIX',\n ...resolvePermissions(accessRules, isAuthenticated, userGroup),\n bucket: bucketName,\n prefix: path,\n };\n if (location.permission)\n locations.push(location);\n }\n }\n return locations;\n};\nexports.resolveLocationsForCurrentSession = resolveLocationsForCurrentSession;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,KAAK;AACpE,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,UAAU,CAAC,KAAK;AACxC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5F,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS;AACzE,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,UAAU,CAAC,aAAa;AAC5C,KAAK,CAAC;AACN,CAAC,CAAC;AACF,MAAM,iCAAiC,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,GAAG,KAAK;AACpG,IAAI,MAAM,SAAS,GAAG,EAAE,CAAC;AACzB,IAAI,KAAK,MAAM,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AAC1D,QAAQ,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;AACjD,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,SAAS;AACrB,SAAS;AACT,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACjE,YAAY,MAAM,yBAAyB,GAAG,CAAC,SAAS;AACxD,gBAAgB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,mBAAmB,CAAC;AAC9D,gBAAgB,eAAe;AAC/B,gBAAgB,UAAU,CAAC;AAC3B,YAAY,IAAI,yBAAyB,EAAE;AAC3C,gBAAgB,SAAS,CAAC,IAAI,CAAC;AAC/B,oBAAoB,IAAI,EAAE,QAAQ;AAClC,oBAAoB,UAAU,EAAE,WAAW,CAAC,cAAc;AAC1D,oBAAoB,MAAM,EAAE,UAAU;AACtC,oBAAoB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,UAAU,CAAC;AACrF,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,YAAY,MAAM,QAAQ,GAAG;AAC7B,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,CAAC;AAC9E,gBAAgB,MAAM,EAAE,UAAU;AAClC,gBAAgB,MAAM,EAAE,IAAI;AAC5B,aAAa,CAAC;AACd,YAAY,IAAI,QAAQ,CAAC,UAAU;AACnC,gBAAgB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AACF,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
@@ -1,37 +1,49 @@
1
1
  import { ENTITY_IDENTITY_URL } from '../../utils/constants.mjs';
2
2
 
3
- const isPathPermissions = (value) => Array.isArray(value);
4
- const resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {
5
- if (includeEntityIdPath) {
6
- return accessRules.entityidentity;
7
- }
3
+ const resolvePermissions = (accessRule, isAuthenticated, groups) => {
8
4
  if (!isAuthenticated) {
9
- return accessRules.guest;
5
+ return {
6
+ permission: accessRule.guest,
7
+ };
10
8
  }
11
- if (userGroup) {
12
- const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));
13
- return selectedKey ? accessRules[selectedKey] : undefined;
9
+ if (groups) {
10
+ const selectedKey = Object.keys(accessRule).find(access => access.includes(groups));
11
+ return {
12
+ permission: selectedKey ? accessRule[selectedKey] : undefined,
13
+ };
14
14
  }
15
- return accessRules.authenticated;
15
+ return {
16
+ permission: accessRule.authenticated,
17
+ };
16
18
  };
17
19
  const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
18
20
  const locations = [];
19
- for (const { bucketName: bucket, paths } of Object.values(buckets)) {
21
+ for (const [, bucketInfo] of Object.entries(buckets)) {
22
+ const { bucketName, paths } = bucketInfo;
20
23
  if (!paths) {
21
24
  continue;
22
25
  }
23
26
  for (const [path, accessRules] of Object.entries(paths)) {
24
- const includeEntityIdPath = !userGroup &&
27
+ const shouldIncludeEntityIdPath = !userGroup &&
25
28
  path.includes(ENTITY_IDENTITY_URL) &&
26
29
  isAuthenticated &&
27
- !!identityId;
28
- const permissions = resolvePermissions(accessRules, isAuthenticated, includeEntityIdPath, userGroup);
29
- if (isPathPermissions(permissions)) {
30
- const prefix = !includeEntityIdPath
31
- ? path
32
- : path.replace(ENTITY_IDENTITY_URL, identityId);
33
- locations.push({ bucket, permissions, prefix, type: 'PREFIX' });
30
+ identityId;
31
+ if (shouldIncludeEntityIdPath) {
32
+ locations.push({
33
+ type: 'PREFIX',
34
+ permission: accessRules.entityidentity,
35
+ bucket: bucketName,
36
+ prefix: path.replace(ENTITY_IDENTITY_URL, identityId),
37
+ });
34
38
  }
39
+ const location = {
40
+ type: 'PREFIX',
41
+ ...resolvePermissions(accessRules, isAuthenticated, userGroup),
42
+ bucket: bucketName,
43
+ prefix: path,
44
+ };
45
+ if (location.permission)
46
+ locations.push(location);
35
47
  }
36
48
  }
37
49
  return locations;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocationsForCurrentSession.mjs","sources":["../../../../../src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts"],"sourcesContent":["import { ENTITY_IDENTITY_URL } from '../../utils/constants';\nconst isPathPermissions = (value) => Array.isArray(value);\nconst resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {\n if (includeEntityIdPath) {\n return accessRules.entityidentity;\n }\n if (!isAuthenticated) {\n return accessRules.guest;\n }\n if (userGroup) {\n const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));\n return selectedKey ? accessRules[selectedKey] : undefined;\n }\n return accessRules.authenticated;\n};\nexport const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {\n const locations = [];\n for (const { bucketName: bucket, paths } of Object.values(buckets)) {\n if (!paths) {\n continue;\n }\n for (const [path, accessRules] of Object.entries(paths)) {\n const includeEntityIdPath = !userGroup &&\n path.includes(ENTITY_IDENTITY_URL) &&\n isAuthenticated &&\n !!identityId;\n const permissions = resolvePermissions(accessRules, isAuthenticated, includeEntityIdPath, userGroup);\n if (isPathPermissions(permissions)) {\n const prefix = !includeEntityIdPath\n ? path\n : path.replace(ENTITY_IDENTITY_URL, identityId);\n locations.push({ bucket, permissions, prefix, type: 'PREFIX' });\n }\n }\n }\n return locations;\n};\n"],"names":[],"mappings":";;AACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1D,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,KAAK;AAC7F,IAAI,IAAI,mBAAmB,EAAE;AAC7B,QAAQ,OAAO,WAAW,CAAC,cAAc,CAAC;AAC1C,KAAK;AACL,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,SAAS,EAAE;AACnB,QAAQ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAChG,QAAQ,OAAO,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;AAClE,KAAK;AACL,IAAI,OAAO,WAAW,CAAC,aAAa,CAAC;AACrC,CAAC,CAAC;AACU,MAAC,iCAAiC,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,GAAG,KAAK;AAC3G,IAAI,MAAM,SAAS,GAAG,EAAE,CAAC;AACzB,IAAI,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;AACxE,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,SAAS;AACrB,SAAS;AACT,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACjE,YAAY,MAAM,mBAAmB,GAAG,CAAC,SAAS;AAClD,gBAAgB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;AAClD,gBAAgB,eAAe;AAC/B,gBAAgB,CAAC,CAAC,UAAU,CAAC;AAC7B,YAAY,MAAM,WAAW,GAAG,kBAAkB,CAAC,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;AACjH,YAAY,IAAI,iBAAiB,CAAC,WAAW,CAAC,EAAE;AAChD,gBAAgB,MAAM,MAAM,GAAG,CAAC,mBAAmB;AACnD,sBAAsB,IAAI;AAC1B,sBAAsB,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;AACpE,gBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB;;;;"}
1
+ {"version":3,"file":"resolveLocationsForCurrentSession.mjs","sources":["../../../../../src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts"],"sourcesContent":["import { ENTITY_IDENTITY_URL } from '../../utils/constants';\nconst resolvePermissions = (accessRule, isAuthenticated, groups) => {\n if (!isAuthenticated) {\n return {\n permission: accessRule.guest,\n };\n }\n if (groups) {\n const selectedKey = Object.keys(accessRule).find(access => access.includes(groups));\n return {\n permission: selectedKey ? accessRule[selectedKey] : undefined,\n };\n }\n return {\n permission: accessRule.authenticated,\n };\n};\nexport const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {\n const locations = [];\n for (const [, bucketInfo] of Object.entries(buckets)) {\n const { bucketName, paths } = bucketInfo;\n if (!paths) {\n continue;\n }\n for (const [path, accessRules] of Object.entries(paths)) {\n const shouldIncludeEntityIdPath = !userGroup &&\n path.includes(ENTITY_IDENTITY_URL) &&\n isAuthenticated &&\n identityId;\n if (shouldIncludeEntityIdPath) {\n locations.push({\n type: 'PREFIX',\n permission: accessRules.entityidentity,\n bucket: bucketName,\n prefix: path.replace(ENTITY_IDENTITY_URL, identityId),\n });\n }\n const location = {\n type: 'PREFIX',\n ...resolvePermissions(accessRules, isAuthenticated, userGroup),\n bucket: bucketName,\n prefix: path,\n };\n if (location.permission)\n locations.push(location);\n }\n }\n return locations;\n};\n"],"names":[],"mappings":";;AACA,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,KAAK;AACpE,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,UAAU,CAAC,KAAK;AACxC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5F,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS;AACzE,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,UAAU,CAAC,aAAa;AAC5C,KAAK,CAAC;AACN,CAAC,CAAC;AACU,MAAC,iCAAiC,GAAG,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,GAAG,KAAK;AAC3G,IAAI,MAAM,SAAS,GAAG,EAAE,CAAC;AACzB,IAAI,KAAK,MAAM,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AAC1D,QAAQ,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;AACjD,QAAQ,IAAI,CAAC,KAAK,EAAE;AACpB,YAAY,SAAS;AACrB,SAAS;AACT,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACjE,YAAY,MAAM,yBAAyB,GAAG,CAAC,SAAS;AACxD,gBAAgB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;AAClD,gBAAgB,eAAe;AAC/B,gBAAgB,UAAU,CAAC;AAC3B,YAAY,IAAI,yBAAyB,EAAE;AAC3C,gBAAgB,SAAS,CAAC,IAAI,CAAC;AAC/B,oBAAoB,IAAI,EAAE,QAAQ;AAClC,oBAAoB,UAAU,EAAE,WAAW,CAAC,cAAc;AAC1D,oBAAoB,MAAM,EAAE,UAAU;AACtC,oBAAoB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC;AACzE,iBAAiB,CAAC,CAAC;AACnB,aAAa;AACb,YAAY,MAAM,QAAQ,GAAG;AAC7B,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,CAAC;AAC9E,gBAAgB,MAAM,EAAE,UAAU;AAClC,gBAAgB,MAAM,EAAE,IAAI;AAC5B,aAAa,CAAC;AACd,YAAY,IAAI,QAAQ,CAAC,UAAU;AACnC,gBAAgB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB;;;;"}
@@ -64,7 +64,6 @@ export interface LocationAccess extends CredentialsLocation {
64
64
  */
65
65
  readonly type: LocationType;
66
66
  }
67
- export type PathPermissions = StorageAccess[];
68
67
  /**
69
68
  * @internal
70
69
  */
@@ -72,7 +71,7 @@ export interface PathAccess {
72
71
  /** The Amplify backend mandates that all paths conclude with '/*',
73
72
  * which means the only applicable type in this context is 'PREFIX'. */
74
73
  type: 'PREFIX';
75
- permissions: PathPermissions;
74
+ permission: StorageAccess[];
76
75
  bucket: string;
77
76
  prefix: string;
78
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/storage",
3
- "version": "6.7.10-poc-list-paths.b7e5c4c.0+b7e5c4c",
3
+ "version": "6.7.10-unstable.22ceeb3.0+22ceeb3",
4
4
  "description": "Storage category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -108,13 +108,13 @@
108
108
  "./package.json": "./package.json"
109
109
  },
110
110
  "peerDependencies": {
111
- "@aws-amplify/core": "6.9.4-poc-list-paths.b7e5c4c.0+b7e5c4c"
111
+ "@aws-amplify/core": "6.9.4-unstable.22ceeb3.0+22ceeb3"
112
112
  },
113
113
  "devDependencies": {
114
- "@aws-amplify/core": "6.9.4-poc-list-paths.b7e5c4c.0+b7e5c4c",
115
- "@aws-amplify/react-native": "1.1.8-poc-list-paths.b7e5c4c.0+b7e5c4c",
114
+ "@aws-amplify/core": "6.9.4-unstable.22ceeb3.0+22ceeb3",
115
+ "@aws-amplify/react-native": "1.1.8-unstable.22ceeb3.0+22ceeb3",
116
116
  "@types/node": "20.14.12",
117
117
  "typescript": "5.0.2"
118
118
  },
119
- "gitHead": "b7e5c4cb82b03490eb0ae517adc6ad5d4681fd63"
119
+ "gitHead": "22ceeb387bb17ac1f849b3dd2a75439ebd69ac44"
120
120
  }
@@ -1,33 +1,33 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { PathAccess, PathPermissions } from '../../types/credentials';
3
+ import { PathAccess } from '../../types/credentials';
4
4
  import { BucketInfo } from '../../../providers/s3/types/options';
5
5
  import { ENTITY_IDENTITY_URL } from '../../utils/constants';
6
-
7
- const isPathPermissions = (value: unknown): value is PathPermissions =>
8
- Array.isArray(value);
6
+ import { StorageAccess } from '../../types/common';
9
7
 
10
8
  const resolvePermissions = (
11
- accessRules: Record<string, string[] | undefined>,
9
+ accessRule: Record<string, string[] | undefined>,
12
10
  isAuthenticated: boolean,
13
- includeEntityIdPath: boolean,
14
- userGroup?: string,
15
- ): string[] | undefined => {
16
- if (includeEntityIdPath) {
17
- return accessRules.entityidentity;
18
- }
11
+ groups?: string,
12
+ ) => {
19
13
  if (!isAuthenticated) {
20
- return accessRules.guest;
14
+ return {
15
+ permission: accessRule.guest,
16
+ };
21
17
  }
22
- if (userGroup) {
23
- const selectedKey = Object.keys(accessRules).find(access =>
24
- access.includes(userGroup),
18
+ if (groups) {
19
+ const selectedKey = Object.keys(accessRule).find(access =>
20
+ access.includes(groups),
25
21
  );
26
22
 
27
- return selectedKey ? accessRules[selectedKey] : undefined;
23
+ return {
24
+ permission: selectedKey ? accessRule[selectedKey] : undefined,
25
+ };
28
26
  }
29
27
 
30
- return accessRules.authenticated;
28
+ return {
29
+ permission: accessRule.authenticated,
30
+ };
31
31
  };
32
32
 
33
33
  export const resolveLocationsForCurrentSession = ({
@@ -43,32 +43,36 @@ export const resolveLocationsForCurrentSession = ({
43
43
  }): PathAccess[] => {
44
44
  const locations: PathAccess[] = [];
45
45
 
46
- for (const { bucketName: bucket, paths } of Object.values(buckets)) {
46
+ for (const [, bucketInfo] of Object.entries(buckets)) {
47
+ const { bucketName, paths } = bucketInfo;
47
48
  if (!paths) {
48
49
  continue;
49
50
  }
50
51
 
51
52
  for (const [path, accessRules] of Object.entries(paths)) {
52
- const includeEntityIdPath =
53
+ const shouldIncludeEntityIdPath =
53
54
  !userGroup &&
54
55
  path.includes(ENTITY_IDENTITY_URL) &&
55
56
  isAuthenticated &&
56
- !!identityId;
57
+ identityId;
57
58
 
58
- const permissions = resolvePermissions(
59
- accessRules,
60
- isAuthenticated,
61
- includeEntityIdPath,
62
- userGroup,
63
- );
59
+ if (shouldIncludeEntityIdPath) {
60
+ locations.push({
61
+ type: 'PREFIX',
62
+ permission: accessRules.entityidentity as StorageAccess[],
63
+ bucket: bucketName,
64
+ prefix: path.replace(ENTITY_IDENTITY_URL, identityId),
65
+ });
66
+ }
64
67
 
65
- if (isPathPermissions(permissions)) {
66
- const prefix = !includeEntityIdPath
67
- ? path
68
- : path.replace(ENTITY_IDENTITY_URL, identityId);
68
+ const location = {
69
+ type: 'PREFIX',
70
+ ...resolvePermissions(accessRules, isAuthenticated, userGroup),
71
+ bucket: bucketName,
72
+ prefix: path,
73
+ };
69
74
 
70
- locations.push({ bucket, permissions, prefix, type: 'PREFIX' });
71
- }
75
+ if (location.permission) locations.push(location as PathAccess);
72
76
  }
73
77
  }
74
78
 
@@ -82,8 +82,6 @@ export interface LocationAccess extends CredentialsLocation {
82
82
  readonly type: LocationType;
83
83
  }
84
84
 
85
- export type PathPermissions = StorageAccess[];
86
-
87
85
  /**
88
86
  * @internal
89
87
  */
@@ -91,7 +89,7 @@ export interface PathAccess {
91
89
  /** The Amplify backend mandates that all paths conclude with '/*',
92
90
  * which means the only applicable type in this context is 'PREFIX'. */
93
91
  type: 'PREFIX';
94
- permissions: PathPermissions;
92
+ permission: StorageAccess[];
95
93
  bucket: string;
96
94
  prefix: string;
97
95
  }