@aws-sdk/cloudfront-signer 3.1116.0 → 3.1138.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 CHANGED
@@ -104,12 +104,32 @@ function encodeUrlPath(url) {
104
104
  });
105
105
  let encodedQuery = "";
106
106
  if (rawQuery) {
107
- for (const [key, value] of new URLSearchParams(rawQuery.slice(1)).entries()) {
108
- encodedQuery += `${encodedQuery ? "&" : "?"}${encodeURIComponent(key).replace(/'/g, "%27")}=${encodeURIComponent(value).replace(/'/g, "%27")}`;
109
- }
107
+ const pairs = rawQuery
108
+ .slice(1)
109
+ .split("&")
110
+ .filter((p) => p.length > 0)
111
+ .map((pair) => {
112
+ const eqIdx = pair.indexOf("=");
113
+ const rawKey = eqIdx === -1 ? pair : pair.slice(0, eqIdx);
114
+ const rawValue = eqIdx === -1 ? "" : pair.slice(eqIdx + 1);
115
+ return `${encodeQueryComponent(rawKey)}=${encodeQueryComponent(rawValue)}`;
116
+ });
117
+ encodedQuery = pairs.length > 0 ? `?${pairs.join("&")}` : "";
110
118
  }
111
119
  return origin + encodedPath + encodedQuery;
112
120
  }
121
+ function encodeQueryComponent(component) {
122
+ const wellFormedComponent = component.replace(/[\uD800-\uDFFF]/gu, "\uFFFD");
123
+ return wellFormedComponent
124
+ .split(/(%[0-9A-Fa-f]{2}|\+)/g)
125
+ .map((part, i) => {
126
+ if (i % 2 === 1) {
127
+ return part === "+" ? "+" : part.toUpperCase();
128
+ }
129
+ return encodeURIComponent(part).replace(/'/g, "%27");
130
+ })
131
+ .join("");
132
+ }
113
133
  function getPolicyResources(policy) {
114
134
  const parsedPolicy = typeof policy === "string" ? JSON.parse(policy) : policy;
115
135
  return (parsedPolicy?.Statement ?? []).map((s) => s.Resource);
package/dist-es/sign.js CHANGED
@@ -103,12 +103,32 @@ function encodeUrlPath(url) {
103
103
  });
104
104
  let encodedQuery = "";
105
105
  if (rawQuery) {
106
- for (const [key, value] of new URLSearchParams(rawQuery.slice(1)).entries()) {
107
- encodedQuery += `${encodedQuery ? "&" : "?"}${encodeURIComponent(key).replace(/'/g, "%27")}=${encodeURIComponent(value).replace(/'/g, "%27")}`;
108
- }
106
+ const pairs = rawQuery
107
+ .slice(1)
108
+ .split("&")
109
+ .filter((p) => p.length > 0)
110
+ .map((pair) => {
111
+ const eqIdx = pair.indexOf("=");
112
+ const rawKey = eqIdx === -1 ? pair : pair.slice(0, eqIdx);
113
+ const rawValue = eqIdx === -1 ? "" : pair.slice(eqIdx + 1);
114
+ return `${encodeQueryComponent(rawKey)}=${encodeQueryComponent(rawValue)}`;
115
+ });
116
+ encodedQuery = pairs.length > 0 ? `?${pairs.join("&")}` : "";
109
117
  }
110
118
  return origin + encodedPath + encodedQuery;
111
119
  }
120
+ function encodeQueryComponent(component) {
121
+ const wellFormedComponent = component.replace(/[\uD800-\uDFFF]/gu, "\uFFFD");
122
+ return wellFormedComponent
123
+ .split(/(%[0-9A-Fa-f]{2}|\+)/g)
124
+ .map((part, i) => {
125
+ if (i % 2 === 1) {
126
+ return part === "+" ? "+" : part.toUpperCase();
127
+ }
128
+ return encodeURIComponent(part).replace(/'/g, "%27");
129
+ })
130
+ .join("");
131
+ }
112
132
  function getPolicyResources(policy) {
113
133
  const parsedPolicy = typeof policy === "string" ? JSON.parse(policy) : policy;
114
134
  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.1116.0",
3
+ "version": "3.1138.0",
4
4
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/cloudfront-signer",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -43,7 +43,7 @@
43
43
  "test:e2e:watch": "yarn g:vitest watch -c vitest.config.e2e.mts"
44
44
  },
45
45
  "dependencies": {
46
- "@smithy/core": "^3.33.3",
46
+ "@smithy/core": "^3.35.0",
47
47
  "tslib": "^2.6.2"
48
48
  },
49
49
  "devDependencies": {