massimo 1.5.0 → 1.5.2

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/index.d.ts CHANGED
@@ -84,10 +84,10 @@ export module errors {
84
84
  export const OptionsUrlRequiredError: () => FastifyError
85
85
  export const FormDataRequiredError: (value: string) => FastifyError
86
86
  export const MissingParamsRequiredError: (value: string) => FastifyError
87
+ export const InvalidPathParameterError: (value: string) => FastifyError
87
88
  export const WrongOptsTypeError: () => FastifyError
88
89
  export const InvalidResponseSchemaError: (value: string) => FastifyError
89
90
  export const InvalidContentTypeError: (value: string) => FastifyError
90
91
  export const InvalidResponseFormatError: () => FastifyError
91
92
  export const UnexpectedCallFailureError: (value: string) => FastifyError
92
93
  }
93
-
package/index.js CHANGED
@@ -39,6 +39,14 @@ function computeURLWithoutPath (url) {
39
39
  return url.toString()
40
40
  }
41
41
 
42
+ function encodePathParameter (value, name) {
43
+ const encoded = encodeURIComponent(value)
44
+ if (encoded === '.' || encoded === '..') {
45
+ throw new errors.InvalidPathParameterError(name)
46
+ }
47
+ return encoded
48
+ }
49
+
42
50
  async function buildCallFunction (
43
51
  spec,
44
52
  baseUrl,
@@ -87,7 +95,7 @@ async function buildCallFunction (
87
95
  if (args?.path[param.name] === undefined) {
88
96
  throw new errors.MissingParamsRequiredError(param.name)
89
97
  }
90
- pathToCall = pathToCall.replace(`{${param.name}}`, args.path[param.name])
98
+ pathToCall = pathToCall.replace(`{${param.name}}`, encodePathParameter(args.path[param.name], param.name))
91
99
  }
92
100
 
93
101
  for (const param of queryParams) {
@@ -105,7 +113,7 @@ async function buildCallFunction (
105
113
  if (body[param.name] === undefined) {
106
114
  throw new errors.MissingParamsRequiredError(param.name)
107
115
  }
108
- pathToCall = pathToCall.replace(`{${param.name}}`, body[param.name])
116
+ pathToCall = pathToCall.replace(`{${param.name}}`, encodePathParameter(body[param.name], param.name))
109
117
  body[param.name] = undefined
110
118
  }
111
119
 
package/lib/errors.js CHANGED
@@ -11,6 +11,10 @@ export const MissingParamsRequiredError = createError(
11
11
  `${ERROR_PREFIX}_MISSING_PARAMS_REQUIRED`,
12
12
  "Param %s is missing, and it's required"
13
13
  )
14
+ export const InvalidPathParameterError = createError(
15
+ `${ERROR_PREFIX}_INVALID_PATH_PARAMETER`,
16
+ 'Path parameter %s cannot be "." or ".."'
17
+ )
14
18
  export const WrongOptsTypeError = createError(
15
19
  `${ERROR_PREFIX}_WRONG_OPTS_TYPE`,
16
20
  'opts.type must be either "openapi" or "graphql"'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "massimo",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "A client for HTTP services.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -40,9 +40,9 @@
40
40
  "devDependencies": {
41
41
  "@fastify/multipart": "^10.0.0",
42
42
  "@platformatic/db": "3.67.0",
43
- "@platformatic/foundation": "3.67.0",
43
+ "@platformatic/foundation": "3.68.0",
44
44
  "@platformatic/service": "3.67.0",
45
- "@platformatic/telemetry": "3.67.0",
45
+ "@platformatic/telemetry": "3.68.0",
46
46
  "c8": "^10.0.0",
47
47
  "cleaner-spec-reporter": "^0.5.0",
48
48
  "eslint": "9",