@aws-sdk/cloudfront-signer 3.1046.0 → 3.1052.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 +13 -13
- package/dist-es/sign.js +13 -13
- package/package.json +2 -2
package/dist-cjs/index.js
CHANGED
|
@@ -12,20 +12,9 @@ function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, privateKe
|
|
|
12
12
|
if (!url && !policy) {
|
|
13
13
|
throw new Error("@aws-sdk/cloudfront-signer: Please provide 'url' or 'policy'.");
|
|
14
14
|
}
|
|
15
|
-
if (policy) {
|
|
16
|
-
cloudfrontSignBuilder.setCustomPolicy(policy);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
cloudfrontSignBuilder.setPolicyParameters({
|
|
20
|
-
url,
|
|
21
|
-
dateLessThan,
|
|
22
|
-
dateGreaterThan,
|
|
23
|
-
ipAddress,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
15
|
let baseUrl;
|
|
27
16
|
if (url) {
|
|
28
|
-
baseUrl = url;
|
|
17
|
+
baseUrl = encodeUrlPath(url);
|
|
29
18
|
}
|
|
30
19
|
else if (policy) {
|
|
31
20
|
const resources = getPolicyResources(policy);
|
|
@@ -34,12 +23,23 @@ function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, privateKe
|
|
|
34
23
|
}
|
|
35
24
|
baseUrl = resources[0].replace("*://", "https://");
|
|
36
25
|
}
|
|
26
|
+
if (policy) {
|
|
27
|
+
cloudfrontSignBuilder.setCustomPolicy(policy);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
cloudfrontSignBuilder.setPolicyParameters({
|
|
31
|
+
url: baseUrl,
|
|
32
|
+
dateLessThan,
|
|
33
|
+
dateGreaterThan,
|
|
34
|
+
ipAddress,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
37
|
const startFlag = baseUrl.includes("?") ? "&" : "?";
|
|
38
38
|
const params = Object.entries(cloudfrontSignBuilder.createCloudfrontAttribute())
|
|
39
39
|
.filter(([, value]) => value !== undefined)
|
|
40
40
|
.map(([key, value]) => `${protocols.extendedEncodeURIComponent(key)}=${protocols.extendedEncodeURIComponent(value)}`)
|
|
41
41
|
.join("&");
|
|
42
|
-
const urlString =
|
|
42
|
+
const urlString = baseUrl + startFlag + params;
|
|
43
43
|
return getResource(urlString);
|
|
44
44
|
}
|
|
45
45
|
function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLessThan, dateGreaterThan, policy, passphrase, }) {
|
package/dist-es/sign.js
CHANGED
|
@@ -9,20 +9,9 @@ export function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, pr
|
|
|
9
9
|
if (!url && !policy) {
|
|
10
10
|
throw new Error("@aws-sdk/cloudfront-signer: Please provide 'url' or 'policy'.");
|
|
11
11
|
}
|
|
12
|
-
if (policy) {
|
|
13
|
-
cloudfrontSignBuilder.setCustomPolicy(policy);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
cloudfrontSignBuilder.setPolicyParameters({
|
|
17
|
-
url,
|
|
18
|
-
dateLessThan,
|
|
19
|
-
dateGreaterThan,
|
|
20
|
-
ipAddress,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
12
|
let baseUrl;
|
|
24
13
|
if (url) {
|
|
25
|
-
baseUrl = url;
|
|
14
|
+
baseUrl = encodeUrlPath(url);
|
|
26
15
|
}
|
|
27
16
|
else if (policy) {
|
|
28
17
|
const resources = getPolicyResources(policy);
|
|
@@ -31,12 +20,23 @@ export function getSignedUrl({ dateLessThan, dateGreaterThan, url, keyPairId, pr
|
|
|
31
20
|
}
|
|
32
21
|
baseUrl = resources[0].replace("*://", "https://");
|
|
33
22
|
}
|
|
23
|
+
if (policy) {
|
|
24
|
+
cloudfrontSignBuilder.setCustomPolicy(policy);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
cloudfrontSignBuilder.setPolicyParameters({
|
|
28
|
+
url: baseUrl,
|
|
29
|
+
dateLessThan,
|
|
30
|
+
dateGreaterThan,
|
|
31
|
+
ipAddress,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
34
|
const startFlag = baseUrl.includes("?") ? "&" : "?";
|
|
35
35
|
const params = Object.entries(cloudfrontSignBuilder.createCloudfrontAttribute())
|
|
36
36
|
.filter(([, value]) => value !== undefined)
|
|
37
37
|
.map(([key, value]) => `${extendedEncodeURIComponent(key)}=${extendedEncodeURIComponent(value)}`)
|
|
38
38
|
.join("&");
|
|
39
|
-
const urlString =
|
|
39
|
+
const urlString = baseUrl + startFlag + params;
|
|
40
40
|
return getResource(urlString);
|
|
41
41
|
}
|
|
42
42
|
export function getSignedCookies({ ipAddress, url, privateKey, keyPairId, dateLessThan, dateGreaterThan, policy, passphrase, }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/cloudfront-signer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1052.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,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@smithy/core": "^3.24.
|
|
26
|
+
"@smithy/core": "^3.24.3",
|
|
27
27
|
"tslib": "^2.6.2"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|