@aws-amplify/storage 6.7.9 → 6.7.10-poc-list-paths.b7e5c4c.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/dist/cjs/internals/apis/listPaths/resolveLocationsForCurrentSession.js +19 -31
- package/dist/cjs/internals/apis/listPaths/resolveLocationsForCurrentSession.js.map +1 -1
- package/dist/esm/internals/apis/listPaths/resolveLocationsForCurrentSession.mjs +19 -31
- package/dist/esm/internals/apis/listPaths/resolveLocationsForCurrentSession.mjs.map +1 -1
- package/dist/esm/internals/types/credentials.d.ts +2 -1
- package/package.json +118 -118
- package/src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts +32 -36
- package/src/internals/types/credentials.ts +3 -1
|
@@ -3,50 +3,38 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.resolveLocationsForCurrentSession = void 0;
|
|
5
5
|
const constants_1 = require("../../utils/constants");
|
|
6
|
-
const
|
|
6
|
+
const isPathPermissions = (value) => Array.isArray(value);
|
|
7
|
+
const resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {
|
|
8
|
+
if (includeEntityIdPath) {
|
|
9
|
+
return accessRules.entityidentity;
|
|
10
|
+
}
|
|
7
11
|
if (!isAuthenticated) {
|
|
8
|
-
return
|
|
9
|
-
permission: accessRule.guest,
|
|
10
|
-
};
|
|
12
|
+
return accessRules.guest;
|
|
11
13
|
}
|
|
12
|
-
if (
|
|
13
|
-
const selectedKey = Object.keys(
|
|
14
|
-
return
|
|
15
|
-
permission: selectedKey ? accessRule[selectedKey] : undefined,
|
|
16
|
-
};
|
|
14
|
+
if (userGroup) {
|
|
15
|
+
const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));
|
|
16
|
+
return selectedKey ? accessRules[selectedKey] : undefined;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
permission: accessRule.authenticated,
|
|
20
|
-
};
|
|
18
|
+
return accessRules.authenticated;
|
|
21
19
|
};
|
|
22
20
|
const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
|
|
23
21
|
const locations = [];
|
|
24
|
-
for (const
|
|
25
|
-
const { bucketName, paths } = bucketInfo;
|
|
22
|
+
for (const { bucketName: bucket, paths } of Object.values(buckets)) {
|
|
26
23
|
if (!paths) {
|
|
27
24
|
continue;
|
|
28
25
|
}
|
|
29
26
|
for (const [path, accessRules] of Object.entries(paths)) {
|
|
30
|
-
const
|
|
27
|
+
const includeEntityIdPath = !userGroup &&
|
|
31
28
|
path.includes(constants_1.ENTITY_IDENTITY_URL) &&
|
|
32
29
|
isAuthenticated &&
|
|
33
|
-
identityId;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
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' });
|
|
41
37
|
}
|
|
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);
|
|
50
38
|
}
|
|
51
39
|
}
|
|
52
40
|
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 resolvePermissions = (
|
|
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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C,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,49 +1,37 @@
|
|
|
1
1
|
import { ENTITY_IDENTITY_URL } from '../../utils/constants.mjs';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const isPathPermissions = (value) => Array.isArray(value);
|
|
4
|
+
const resolvePermissions = (accessRules, isAuthenticated, includeEntityIdPath, userGroup) => {
|
|
5
|
+
if (includeEntityIdPath) {
|
|
6
|
+
return accessRules.entityidentity;
|
|
7
|
+
}
|
|
4
8
|
if (!isAuthenticated) {
|
|
5
|
-
return
|
|
6
|
-
permission: accessRule.guest,
|
|
7
|
-
};
|
|
9
|
+
return accessRules.guest;
|
|
8
10
|
}
|
|
9
|
-
if (
|
|
10
|
-
const selectedKey = Object.keys(
|
|
11
|
-
return
|
|
12
|
-
permission: selectedKey ? accessRule[selectedKey] : undefined,
|
|
13
|
-
};
|
|
11
|
+
if (userGroup) {
|
|
12
|
+
const selectedKey = Object.keys(accessRules).find(access => access.includes(userGroup));
|
|
13
|
+
return selectedKey ? accessRules[selectedKey] : undefined;
|
|
14
14
|
}
|
|
15
|
-
return
|
|
16
|
-
permission: accessRule.authenticated,
|
|
17
|
-
};
|
|
15
|
+
return accessRules.authenticated;
|
|
18
16
|
};
|
|
19
17
|
const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
|
|
20
18
|
const locations = [];
|
|
21
|
-
for (const
|
|
22
|
-
const { bucketName, paths } = bucketInfo;
|
|
19
|
+
for (const { bucketName: bucket, paths } of Object.values(buckets)) {
|
|
23
20
|
if (!paths) {
|
|
24
21
|
continue;
|
|
25
22
|
}
|
|
26
23
|
for (const [path, accessRules] of Object.entries(paths)) {
|
|
27
|
-
const
|
|
24
|
+
const includeEntityIdPath = !userGroup &&
|
|
28
25
|
path.includes(ENTITY_IDENTITY_URL) &&
|
|
29
26
|
isAuthenticated &&
|
|
30
|
-
identityId;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
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' });
|
|
38
34
|
}
|
|
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);
|
|
47
35
|
}
|
|
48
36
|
}
|
|
49
37
|
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 resolvePermissions = (
|
|
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;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E,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB;;;;"}
|
|
@@ -64,6 +64,7 @@ export interface LocationAccess extends CredentialsLocation {
|
|
|
64
64
|
*/
|
|
65
65
|
readonly type: LocationType;
|
|
66
66
|
}
|
|
67
|
+
export type PathPermissions = StorageAccess[];
|
|
67
68
|
/**
|
|
68
69
|
* @internal
|
|
69
70
|
*/
|
|
@@ -71,7 +72,7 @@ export interface PathAccess {
|
|
|
71
72
|
/** The Amplify backend mandates that all paths conclude with '/*',
|
|
72
73
|
* which means the only applicable type in this context is 'PREFIX'. */
|
|
73
74
|
type: 'PREFIX';
|
|
74
|
-
|
|
75
|
+
permissions: PathPermissions;
|
|
75
76
|
bucket: string;
|
|
76
77
|
prefix: string;
|
|
77
78
|
}
|
package/package.json
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
2
|
+
"name": "@aws-amplify/storage",
|
|
3
|
+
"version": "6.7.10-poc-list-paths.b7e5c4c.0+b7e5c4c",
|
|
4
|
+
"description": "Storage category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"react-native": {
|
|
8
|
+
"./dist/cjs/index": "./src/index.ts",
|
|
9
|
+
"fast-xml-parser": "fast-xml-parser",
|
|
10
|
+
"buffer": "buffer"
|
|
11
|
+
},
|
|
12
|
+
"typings": "./dist/esm/index.d.ts",
|
|
13
|
+
"browser": {
|
|
14
|
+
"./dist/esm/providers/s3/utils/client/runtime/base64/index.native.mjs": "./dist/esm/providers/s3/utils/client/runtime/base64/index.browser.mjs",
|
|
15
|
+
"./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/fetch.mjs": "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/xhr.mjs",
|
|
16
|
+
"./dist/esm/providers/s3/utils/client/runtime/xmlParser/pureJs.mjs": "./dist/esm/providers/s3/utils/client/runtime/xmlParser/dom.mjs",
|
|
17
|
+
"fast-xml-parser": false,
|
|
18
|
+
"buffer": false
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
|
|
26
|
+
"build-with-test": "npm test && npm run build",
|
|
27
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
28
|
+
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
|
|
29
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
30
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
31
|
+
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
32
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
33
|
+
"format": "echo \"Not implemented\"",
|
|
34
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
35
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
36
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
|
|
37
|
+
},
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
">=4.2": {
|
|
40
|
+
"s3": [
|
|
41
|
+
"./dist/esm/providers/s3/index.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"internals": [
|
|
44
|
+
"./dist/esm/internals/index.d.ts"
|
|
45
|
+
],
|
|
46
|
+
"server": [
|
|
47
|
+
"./dist/esm/server.d.ts"
|
|
48
|
+
],
|
|
49
|
+
"s3/server": [
|
|
50
|
+
"./dist/esm/providers/s3/server.d.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
57
|
+
},
|
|
58
|
+
"author": "Amazon Web Services",
|
|
59
|
+
"license": "Apache-2.0",
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
64
|
+
"files": [
|
|
65
|
+
"dist/cjs",
|
|
66
|
+
"dist/esm",
|
|
67
|
+
"internals",
|
|
68
|
+
"src",
|
|
69
|
+
"server",
|
|
70
|
+
"s3"
|
|
71
|
+
],
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@aws-sdk/types": "3.398.0",
|
|
74
|
+
"@smithy/md5-js": "2.0.7",
|
|
75
|
+
"buffer": "4.9.2",
|
|
76
|
+
"crc-32": "1.2.2",
|
|
77
|
+
"fast-xml-parser": "^4.4.1",
|
|
78
|
+
"tslib": "^2.5.0"
|
|
79
|
+
},
|
|
80
|
+
"exports": {
|
|
81
|
+
".": {
|
|
82
|
+
"types": "./dist/esm/index.d.ts",
|
|
83
|
+
"import": "./dist/esm/index.mjs",
|
|
84
|
+
"require": "./dist/cjs/index.js",
|
|
85
|
+
"react-native": "./src/index.ts"
|
|
86
|
+
},
|
|
87
|
+
"./internals": {
|
|
88
|
+
"types": "./dist/esm/internals/index.d.ts",
|
|
89
|
+
"import": "./dist/esm/internals/index.mjs",
|
|
90
|
+
"require": "./dist/cjs/internals/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./server": {
|
|
93
|
+
"types": "./dist/esm/server.d.ts",
|
|
94
|
+
"import": "./dist/esm/server.mjs",
|
|
95
|
+
"require": "./dist/cjs/server.js"
|
|
96
|
+
},
|
|
97
|
+
"./s3": {
|
|
98
|
+
"types": "./dist/esm/providers/s3/index.d.ts",
|
|
99
|
+
"import": "./dist/esm/providers/s3/index.mjs",
|
|
100
|
+
"require": "./dist/cjs/providers/s3/index.js",
|
|
101
|
+
"react-native": "./src/providers/s3/index.ts"
|
|
102
|
+
},
|
|
103
|
+
"./s3/server": {
|
|
104
|
+
"types": "./dist/esm/providers/s3/server.d.ts",
|
|
105
|
+
"import": "./dist/esm/providers/s3/server.mjs",
|
|
106
|
+
"require": "./dist/cjs/providers/s3/server.js"
|
|
107
|
+
},
|
|
108
|
+
"./package.json": "./package.json"
|
|
109
|
+
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"@aws-amplify/core": "6.9.4-poc-list-paths.b7e5c4c.0+b7e5c4c"
|
|
112
|
+
},
|
|
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",
|
|
116
|
+
"@types/node": "20.14.12",
|
|
117
|
+
"typescript": "5.0.2"
|
|
118
|
+
},
|
|
119
|
+
"gitHead": "b7e5c4cb82b03490eb0ae517adc6ad5d4681fd63"
|
|
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 } from '../../types/credentials';
|
|
3
|
+
import { PathAccess, PathPermissions } from '../../types/credentials';
|
|
4
4
|
import { BucketInfo } from '../../../providers/s3/types/options';
|
|
5
5
|
import { ENTITY_IDENTITY_URL } from '../../utils/constants';
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const isPathPermissions = (value: unknown): value is PathPermissions =>
|
|
8
|
+
Array.isArray(value);
|
|
7
9
|
|
|
8
10
|
const resolvePermissions = (
|
|
9
|
-
|
|
11
|
+
accessRules: Record<string, string[] | undefined>,
|
|
10
12
|
isAuthenticated: boolean,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
includeEntityIdPath: boolean,
|
|
14
|
+
userGroup?: string,
|
|
15
|
+
): string[] | undefined => {
|
|
16
|
+
if (includeEntityIdPath) {
|
|
17
|
+
return accessRules.entityidentity;
|
|
18
|
+
}
|
|
13
19
|
if (!isAuthenticated) {
|
|
14
|
-
return
|
|
15
|
-
permission: accessRule.guest,
|
|
16
|
-
};
|
|
20
|
+
return accessRules.guest;
|
|
17
21
|
}
|
|
18
|
-
if (
|
|
19
|
-
const selectedKey = Object.keys(
|
|
20
|
-
access.includes(
|
|
22
|
+
if (userGroup) {
|
|
23
|
+
const selectedKey = Object.keys(accessRules).find(access =>
|
|
24
|
+
access.includes(userGroup),
|
|
21
25
|
);
|
|
22
26
|
|
|
23
|
-
return
|
|
24
|
-
permission: selectedKey ? accessRule[selectedKey] : undefined,
|
|
25
|
-
};
|
|
27
|
+
return selectedKey ? accessRules[selectedKey] : undefined;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
return
|
|
29
|
-
permission: accessRule.authenticated,
|
|
30
|
-
};
|
|
30
|
+
return accessRules.authenticated;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export const resolveLocationsForCurrentSession = ({
|
|
@@ -43,36 +43,32 @@ export const resolveLocationsForCurrentSession = ({
|
|
|
43
43
|
}): PathAccess[] => {
|
|
44
44
|
const locations: PathAccess[] = [];
|
|
45
45
|
|
|
46
|
-
for (const
|
|
47
|
-
const { bucketName, paths } = bucketInfo;
|
|
46
|
+
for (const { bucketName: bucket, paths } of Object.values(buckets)) {
|
|
48
47
|
if (!paths) {
|
|
49
48
|
continue;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
for (const [path, accessRules] of Object.entries(paths)) {
|
|
53
|
-
const
|
|
52
|
+
const includeEntityIdPath =
|
|
54
53
|
!userGroup &&
|
|
55
54
|
path.includes(ENTITY_IDENTITY_URL) &&
|
|
56
55
|
isAuthenticated &&
|
|
57
|
-
identityId;
|
|
56
|
+
!!identityId;
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
}
|
|
58
|
+
const permissions = resolvePermissions(
|
|
59
|
+
accessRules,
|
|
60
|
+
isAuthenticated,
|
|
61
|
+
includeEntityIdPath,
|
|
62
|
+
userGroup,
|
|
63
|
+
);
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
prefix: path,
|
|
73
|
-
};
|
|
65
|
+
if (isPathPermissions(permissions)) {
|
|
66
|
+
const prefix = !includeEntityIdPath
|
|
67
|
+
? path
|
|
68
|
+
: path.replace(ENTITY_IDENTITY_URL, identityId);
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
locations.push({ bucket, permissions, prefix, type: 'PREFIX' });
|
|
71
|
+
}
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
74
|
|
|
@@ -82,6 +82,8 @@ export interface LocationAccess extends CredentialsLocation {
|
|
|
82
82
|
readonly type: LocationType;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
export type PathPermissions = StorageAccess[];
|
|
86
|
+
|
|
85
87
|
/**
|
|
86
88
|
* @internal
|
|
87
89
|
*/
|
|
@@ -89,7 +91,7 @@ export interface PathAccess {
|
|
|
89
91
|
/** The Amplify backend mandates that all paths conclude with '/*',
|
|
90
92
|
* which means the only applicable type in this context is 'PREFIX'. */
|
|
91
93
|
type: 'PREFIX';
|
|
92
|
-
|
|
94
|
+
permissions: PathPermissions;
|
|
93
95
|
bucket: string;
|
|
94
96
|
prefix: string;
|
|
95
97
|
}
|