@aws-sdk/cloudfront-signer 3.1036.0 → 3.1048.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/index.js +32 -11
- package/dist-es/sign.js +32 -11
- package/package.json +2 -3
package/dist-cjs/index.js
CHANGED
|
@@ -39,17 +39,7 @@ function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, privateKe
|
|
|
39
39
|
.filter(([, value]) => value !== undefined)
|
|
40
40
|
.map(([key, value]) => `${protocols.extendedEncodeURIComponent(key)}=${protocols.extendedEncodeURIComponent(value)}`)
|
|
41
41
|
.join("&");
|
|
42
|
-
|
|
43
|
-
if (url.includes("?")) {
|
|
44
|
-
const [hostAndPath, query] = url.split("?");
|
|
45
|
-
const params = [...new URLSearchParams(query).entries()]
|
|
46
|
-
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
47
|
-
.join("&");
|
|
48
|
-
return `${hostAndPath}?${params}`;
|
|
49
|
-
}
|
|
50
|
-
return url;
|
|
51
|
-
}
|
|
52
|
-
const urlString = encodeBaseUrlQuery(baseUrl) + startFlag + params;
|
|
42
|
+
const urlString = encodeUrlPath(baseUrl) + startFlag + params;
|
|
53
43
|
return getResource(urlString);
|
|
54
44
|
}
|
|
55
45
|
function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLessThan, dateGreaterThan, policy, passphrase, }) {
|
|
@@ -82,6 +72,37 @@ function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLessThan,
|
|
|
82
72
|
}
|
|
83
73
|
return cookies;
|
|
84
74
|
}
|
|
75
|
+
function encodeUrlPath(url) {
|
|
76
|
+
const protocolEnd = url.indexOf("//");
|
|
77
|
+
if (protocolEnd === -1) {
|
|
78
|
+
return url;
|
|
79
|
+
}
|
|
80
|
+
const authorityStart = protocolEnd + 2;
|
|
81
|
+
const pathStart = url.indexOf("/", authorityStart);
|
|
82
|
+
if (pathStart === -1) {
|
|
83
|
+
return url;
|
|
84
|
+
}
|
|
85
|
+
const origin = url.slice(0, pathStart);
|
|
86
|
+
const rest = url.slice(pathStart);
|
|
87
|
+
const queryIndex = rest.indexOf("?");
|
|
88
|
+
const rawPath = queryIndex === -1 ? rest : rest.slice(0, queryIndex);
|
|
89
|
+
const rawQuery = queryIndex === -1 ? "" : rest.slice(queryIndex);
|
|
90
|
+
const encodedPath = rawPath.replace(/[^/]+/g, (segment) => {
|
|
91
|
+
try {
|
|
92
|
+
return encodeURIComponent(decodeURIComponent(segment));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return encodeURIComponent(segment);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
let encodedQuery = "";
|
|
99
|
+
if (rawQuery) {
|
|
100
|
+
for (const [key, value] of new URLSearchParams(rawQuery.slice(1)).entries()) {
|
|
101
|
+
encodedQuery += `${encodedQuery ? "&" : "?"}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return origin + encodedPath + encodedQuery;
|
|
105
|
+
}
|
|
85
106
|
function getPolicyResources(policy) {
|
|
86
107
|
const parsedPolicy = typeof policy === "string" ? JSON.parse(policy) : policy;
|
|
87
108
|
return (parsedPolicy?.Statement ?? []).map((s) => s.Resource);
|
package/dist-es/sign.js
CHANGED
|
@@ -36,17 +36,7 @@ export function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, pr
|
|
|
36
36
|
.filter(([, value]) => value !== undefined)
|
|
37
37
|
.map(([key, value]) => `${extendedEncodeURIComponent(key)}=${extendedEncodeURIComponent(value)}`)
|
|
38
38
|
.join("&");
|
|
39
|
-
|
|
40
|
-
if (url.includes("?")) {
|
|
41
|
-
const [hostAndPath, query] = url.split("?");
|
|
42
|
-
const params = [...new URLSearchParams(query).entries()]
|
|
43
|
-
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
44
|
-
.join("&");
|
|
45
|
-
return `${hostAndPath}?${params}`;
|
|
46
|
-
}
|
|
47
|
-
return url;
|
|
48
|
-
}
|
|
49
|
-
const urlString = encodeBaseUrlQuery(baseUrl) + startFlag + params;
|
|
39
|
+
const urlString = encodeUrlPath(baseUrl) + startFlag + params;
|
|
50
40
|
return getResource(urlString);
|
|
51
41
|
}
|
|
52
42
|
export function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLessThan, dateGreaterThan, policy, passphrase, }) {
|
|
@@ -79,6 +69,37 @@ export function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLe
|
|
|
79
69
|
}
|
|
80
70
|
return cookies;
|
|
81
71
|
}
|
|
72
|
+
function encodeUrlPath(url) {
|
|
73
|
+
const protocolEnd = url.indexOf("//");
|
|
74
|
+
if (protocolEnd === -1) {
|
|
75
|
+
return url;
|
|
76
|
+
}
|
|
77
|
+
const authorityStart = protocolEnd + 2;
|
|
78
|
+
const pathStart = url.indexOf("/", authorityStart);
|
|
79
|
+
if (pathStart === -1) {
|
|
80
|
+
return url;
|
|
81
|
+
}
|
|
82
|
+
const origin = url.slice(0, pathStart);
|
|
83
|
+
const rest = url.slice(pathStart);
|
|
84
|
+
const queryIndex = rest.indexOf("?");
|
|
85
|
+
const rawPath = queryIndex === -1 ? rest : rest.slice(0, queryIndex);
|
|
86
|
+
const rawQuery = queryIndex === -1 ? "" : rest.slice(queryIndex);
|
|
87
|
+
const encodedPath = rawPath.replace(/[^/]+/g, (segment) => {
|
|
88
|
+
try {
|
|
89
|
+
return encodeURIComponent(decodeURIComponent(segment));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return encodeURIComponent(segment);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
let encodedQuery = "";
|
|
96
|
+
if (rawQuery) {
|
|
97
|
+
for (const [key, value] of new URLSearchParams(rawQuery.slice(1)).entries()) {
|
|
98
|
+
encodedQuery += `${encodedQuery ? "&" : "?"}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return origin + encodedPath + encodedQuery;
|
|
102
|
+
}
|
|
82
103
|
function getPolicyResources(policy) {
|
|
83
104
|
const parsedPolicy = typeof policy === "string" ? JSON.parse(policy) : policy;
|
|
84
105
|
return (parsedPolicy?.Statement ?? []).map((s) => s.Resource);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/cloudfront-signer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1048.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline cloudfront-signer",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@smithy/core": "^3.
|
|
27
|
-
"@smithy/url-parser": "^4.2.14",
|
|
26
|
+
"@smithy/core": "^3.24.2",
|
|
28
27
|
"tslib": "^2.6.2"
|
|
29
28
|
},
|
|
30
29
|
"files": [
|