@aws-amplify/storage 6.7.10-poc-list-paths.b7e5c4c.0 → 6.7.10-unstable.289f3e8.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 +31 -19
- package/dist/cjs/internals/apis/listPaths/resolveLocationsForCurrentSession.js.map +1 -1
- package/dist/esm/internals/apis/listPaths/resolveLocationsForCurrentSession.mjs +31 -19
- package/dist/esm/internals/apis/listPaths/resolveLocationsForCurrentSession.mjs.map +1 -1
- package/dist/esm/internals/types/credentials.d.ts +1 -2
- package/package.json +5 -5
- package/src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts +36 -32
- package/src/internals/types/credentials.ts +1 -3
|
@@ -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
|
|
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
|
|
8
|
+
return {
|
|
9
|
+
permission: accessRule.guest,
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
|
-
if (
|
|
15
|
-
const selectedKey = Object.keys(
|
|
16
|
-
return
|
|
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
|
|
18
|
+
return {
|
|
19
|
+
permission: accessRule.authenticated,
|
|
20
|
+
};
|
|
19
21
|
};
|
|
20
22
|
const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
|
|
21
23
|
const locations = [];
|
|
22
|
-
for (const
|
|
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
|
|
30
|
+
const shouldIncludeEntityIdPath = !userGroup &&
|
|
28
31
|
path.includes(constants_1.ENTITY_IDENTITY_URL) &&
|
|
29
32
|
isAuthenticated &&
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
|
|
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
|
|
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,IA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;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
|
|
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
|
|
5
|
+
return {
|
|
6
|
+
permission: accessRule.guest,
|
|
7
|
+
};
|
|
10
8
|
}
|
|
11
|
-
if (
|
|
12
|
-
const selectedKey = Object.keys(
|
|
13
|
-
return
|
|
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
|
|
15
|
+
return {
|
|
16
|
+
permission: accessRule.authenticated,
|
|
17
|
+
};
|
|
16
18
|
};
|
|
17
19
|
const resolveLocationsForCurrentSession = ({ buckets, isAuthenticated, identityId, userGroup, }) => {
|
|
18
20
|
const locations = [];
|
|
19
|
-
for (const
|
|
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
|
|
27
|
+
const shouldIncludeEntityIdPath = !userGroup &&
|
|
25
28
|
path.includes(ENTITY_IDENTITY_URL) &&
|
|
26
29
|
isAuthenticated &&
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
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
|
|
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;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W,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
|
-
|
|
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-
|
|
3
|
+
"version": "6.7.10-unstable.289f3e8.0+289f3e8",
|
|
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-
|
|
111
|
+
"@aws-amplify/core": "6.9.4-unstable.289f3e8.0+289f3e8"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@aws-amplify/core": "6.9.4-
|
|
115
|
-
"@aws-amplify/react-native": "1.1.8-
|
|
114
|
+
"@aws-amplify/core": "6.9.4-unstable.289f3e8.0+289f3e8",
|
|
115
|
+
"@aws-amplify/react-native": "1.1.8-unstable.289f3e8.0+289f3e8",
|
|
116
116
|
"@types/node": "20.14.12",
|
|
117
117
|
"typescript": "5.0.2"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "289f3e8d1bbf8c95abffb553b612699f43cdccb5"
|
|
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
|
|
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
|
-
|
|
9
|
+
accessRule: Record<string, string[] | undefined>,
|
|
12
10
|
isAuthenticated: boolean,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
): string[] | undefined => {
|
|
16
|
-
if (includeEntityIdPath) {
|
|
17
|
-
return accessRules.entityidentity;
|
|
18
|
-
}
|
|
11
|
+
groups?: string,
|
|
12
|
+
) => {
|
|
19
13
|
if (!isAuthenticated) {
|
|
20
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
permission: accessRule.guest,
|
|
16
|
+
};
|
|
21
17
|
}
|
|
22
|
-
if (
|
|
23
|
-
const selectedKey = Object.keys(
|
|
24
|
-
access.includes(
|
|
18
|
+
if (groups) {
|
|
19
|
+
const selectedKey = Object.keys(accessRule).find(access =>
|
|
20
|
+
access.includes(groups),
|
|
25
21
|
);
|
|
26
22
|
|
|
27
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
permission: selectedKey ? accessRule[selectedKey] : undefined,
|
|
25
|
+
};
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
return
|
|
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
|
|
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
|
|
53
|
+
const shouldIncludeEntityIdPath =
|
|
53
54
|
!userGroup &&
|
|
54
55
|
path.includes(ENTITY_IDENTITY_URL) &&
|
|
55
56
|
isAuthenticated &&
|
|
56
|
-
|
|
57
|
+
identityId;
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
const location = {
|
|
69
|
+
type: 'PREFIX',
|
|
70
|
+
...resolvePermissions(accessRules, isAuthenticated, userGroup),
|
|
71
|
+
bucket: bucketName,
|
|
72
|
+
prefix: path,
|
|
73
|
+
};
|
|
69
74
|
|
|
70
|
-
|
|
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
|
-
|
|
92
|
+
permission: StorageAccess[];
|
|
95
93
|
bucket: string;
|
|
96
94
|
prefix: string;
|
|
97
95
|
}
|