diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..001a49c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,31 @@ +/** + * Resolve a relative path against `process.cwd()` (the process's current working directory) and return an absolute path. This will throw if the resulting resolution seems malicious. The following are malicious: + * + * - The relative path is an absolute path + * - The relative path contains a NULL byte + * - The relative path resolves to a path outside of `process.cwd()` + * - The relative path traverses above `process.cwd()` and back down + * + * @param {string} relativePath + * @return {string} + */ +declare function resolvePath(relativePath: string): string; + +/** + * Resolve a relative path against the provided root path and return an absolute path. This will throw if the resulting resolution seems malicious. The following are malicious: + * + * - The relative path is an absolute path + * - The relative path contains a NULL byte + * - The relative path resolves to a path outside of the root path + * - The relative path traverses above the root and back down + * + * @param {string} rootPath + * @param {string} relativePath + * @return {string} + */ +declare function resolvePath(rootPath: string, relativePath: string): string; + +declare namespace resolvePath { +} + +export = resolvePath; diff --git a/package.json b/package.json index bb35698..3c1ed8b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "HISTORY.md", "LICENSE", "README.md", - "index.js" + "index.js", + "index.d.ts" ], "engines": { "node": ">= 0.8" @@ -42,5 +43,6 @@ "resolve", "path", "safe" - ] + ], + "typings": "index.d.ts" }