extract-base-iterator 3.4.1 → 3.4.3

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.
@@ -15,6 +15,7 @@ var _chmodts = /*#__PURE__*/ _interop_require_default(require("./fs/chmod.js"));
15
15
  var _chownts = /*#__PURE__*/ _interop_require_default(require("./fs/chown.js"));
16
16
  var _utimests = /*#__PURE__*/ _interop_require_default(require("./fs/utimes.js"));
17
17
  var _indexts = require("./shared/index.js");
18
+ var _safeJoinPathts = /*#__PURE__*/ _interop_require_default(require("./shared/safeJoinPath.js"));
18
19
  var _stripPathts = /*#__PURE__*/ _interop_require_default(require("./shared/stripPath.js"));
19
20
  var _validateAttributests = /*#__PURE__*/ _interop_require_default(require("./validateAttributes.js"));
20
21
  var _waitForAccessts = /*#__PURE__*/ _interop_require_default(require("./waitForAccess.js"));
@@ -50,7 +51,7 @@ var DirectoryEntry = /*#__PURE__*/ function() {
50
51
  if (typeof callback === 'function') {
51
52
  try {
52
53
  var normalizedPath = _path.default.normalize(this.path);
53
- var fullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedPath, options));
54
+ var fullPath = (0, _safeJoinPathts.default)(dest, (0, _stripPathts.default)(normalizedPath, options));
54
55
  // do not check for the existence of the directory but allow out-of-order calling
55
56
  var queue = new _queuecb.default(1);
56
57
  queue.defer(_mkdirpclassic.default.bind(null, fullPath));
@@ -59,14 +60,13 @@ var DirectoryEntry = /*#__PURE__*/ function() {
59
60
  queue.defer(_chownts.default.bind(null, fullPath, this, options));
60
61
  queue.defer(_utimests.default.bind(null, fullPath, this, options));
61
62
  queue.await(callback);
62
- return;
63
63
  } catch (err) {
64
64
  callback(err);
65
- return;
66
65
  }
66
+ return;
67
67
  }
68
68
  return new Promise(function(resolve, reject) {
69
- _this.create(dest, options, function(err, done) {
69
+ return _this.create(dest, options, function(err, done) {
70
70
  return err ? reject(err) : resolve(done);
71
71
  });
72
72
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: DirectoryAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["DirectoryEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","type","undefined","basename","path","create","dest","options","callback","normalizedPath","normalize","fullPath","join","stripPath","queue","Queue","defer","mkdirp","bind","waitForAccess","chmod","chown","utimes","await","err","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAgBqBA;;;oEAhBF;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;kEACP;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAKvC,IAAA,AAAMD,+BAAN;;aAAMA,eAOPE,UAA+B;gCAPxBF;QAQjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;QACzC,IAAI,IAAI,CAACE,QAAQ,KAAKD,WAAW,IAAI,CAACC,QAAQ,GAAGC,aAAI,CAACD,QAAQ,CAAC,IAAI,CAACC,IAAI;;iBAXvDR;IAiBnBS,OAAAA,MA2BC,GA3BDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzFA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,IAAMC,iBAAiBL,aAAI,CAACM,SAAS,CAAC,IAAI,CAACN,IAAI;gBAC/C,IAAMO,WAAWP,aAAI,CAACQ,IAAI,CAACN,MAAMO,IAAAA,oBAAS,EAACJ,gBAAgBF;gBAE3D,iFAAiF;gBACjF,IAAMO,QAAQ,IAAIC,gBAAK,CAAC;gBACxBD,MAAME,KAAK,CAACC,sBAAM,CAACC,IAAI,CAAC,MAAMP;gBAC9BG,MAAME,KAAK,CAACG,wBAAa,CAACD,IAAI,CAAC,MAAMP;gBACrCG,MAAME,KAAK,CAACI,gBAAK,CAACF,IAAI,CAAC,MAAMP,UAAU,IAAI,EAAEJ;gBAC7CO,MAAME,KAAK,CAACK,gBAAK,CAACH,IAAI,CAAC,MAAMP,UAAU,IAAI,EAAEJ;gBAC7CO,MAAME,KAAK,CAACM,iBAAM,CAACJ,IAAI,CAAC,MAAMP,UAAU,IAAI,EAAEJ;gBAC9CO,MAAMS,KAAK,CAACf;gBACZ;YACF,EAAE,OAAOgB,KAAK;gBACZhB,SAASgB;gBACT;YACF;QACF;QAEA,OAAO,IAAIC,QAAQ,SAACC,SAASC;YAC3B,MAAKtB,MAAM,CAACC,MAAMC,SAAS,SAACiB,KAAaI;uBAAoBJ,MAAMG,OAAOH,OAAOE,QAAQE;;QAC3F;IACF;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WA9CQjC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: DirectoryAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["DirectoryEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","type","undefined","basename","path","create","dest","options","callback","normalizedPath","normalize","fullPath","safeJoinPath","stripPath","queue","Queue","defer","mkdirp","bind","waitForAccess","chmod","chown","utimes","await","err","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAiBqBA;;;oEAjBF;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;qEACJ;kEACH;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAKvC,IAAA,AAAMD,+BAAN;;aAAMA,eAOPE,UAA+B;gCAPxBF;QAQjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;QACzC,IAAI,IAAI,CAACE,QAAQ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));
17
17
  var _chownts = /*#__PURE__*/ _interop_require_default(require("./fs/chown.js"));
18
18
  var _utimests = /*#__PURE__*/ _interop_require_default(require("./fs/utimes.js"));
19
19
  var _indexts = require("./shared/index.js");
20
+ var _safeJoinPathts = /*#__PURE__*/ _interop_require_default(require("./shared/safeJoinPath.js"));
20
21
  var _stripPathts = /*#__PURE__*/ _interop_require_default(require("./shared/stripPath.js"));
21
22
  var _validateAttributests = /*#__PURE__*/ _interop_require_default(require("./validateAttributes.js"));
22
23
  var _waitForAccessts = /*#__PURE__*/ _interop_require_default(require("./waitForAccess.js"));
@@ -53,7 +54,7 @@ var FileEntry = /*#__PURE__*/ function() {
53
54
  if (typeof callback === 'function') {
54
55
  try {
55
56
  var normalizedPath = _path.default.normalize(this.path);
56
- var fullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedPath, options));
57
+ var fullPath = (0, _safeJoinPathts.default)(dest, (0, _stripPathts.default)(normalizedPath, options));
57
58
  var queue = new _queuecb.default(1);
58
59
  if (options.force) {
59
60
  queue.defer(function(callback) {
@@ -85,14 +86,13 @@ var FileEntry = /*#__PURE__*/ function() {
85
86
  queue.defer(_chownts.default.bind(null, fullPath, this, options));
86
87
  queue.defer(_utimests.default.bind(null, fullPath, this, options));
87
88
  queue.await(callback);
88
- return;
89
89
  } catch (err) {
90
90
  callback(err);
91
- return;
92
91
  }
92
+ return;
93
93
  }
94
94
  return new Promise(function(resolve, reject) {
95
- _this.create(dest, options, function(err, done) {
95
+ return _this.create(dest, options, function(err, done) {
96
96
  return err ? reject(err) : resolve(done);
97
97
  });
98
98
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: FileAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if ((this as unknown as AbstractFileEntry)._writeFile === undefined) throw new Error('File this missing _writeFile. Please implement this method in your subclass');\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n } else {\n // Check if file exists - throw EEXIST if it does\n queue.defer((callback) => {\n fs.stat(fullPath, (err) => {\n if (!err) {\n const existsErr = new Error(`EEXIST: file already exists, open '${fullPath}'`) as NodeJS.ErrnoException;\n existsErr.code = 'EEXIST';\n existsErr.path = fullPath;\n return callback(existsErr);\n }\n // ENOENT means file doesn't exist - that's what we want\n if (err.code === 'ENOENT') return callback();\n // Other errors should be reported\n callback(err);\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer((this as unknown as AbstractFileEntry)._writeFile.bind(this, fullPath, options));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["FileEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","_writeFile","Error","create","dest","options","callback","normalizedPath","normalize","fullPath","join","stripPath","queue","Queue","force","defer","rm","err","code","fs","stat","existsErr","mkdirp","bind","dirname","waitForAccess","chmod","chown","utimes","await","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAsBqBA;;;8BAtBF;iEACJ;oEACI;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;kEACP;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AASvC,IAAA,AAAMD,0BAAN;;aAAMA,UAOPE,UAA0B;gCAPnBF;QAQjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGE,aAAI,CAACF,QAAQ,CAAC,IAAI,CAACE,IAAI;QACxE,IAAI,IAAI,CAACC,IAAI,KAAKF,WAAW,IAAI,CAACE,IAAI,GAAG;QACzC,IAAI,AAAC,IAAI,CAAkCC,UAAU,KAAKH,WAAW,MAAM,IAAII,MAAM;;iBAZpEV;IAkBnBW,OAAAA,MAkDC,GAlDDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzF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AMG,KAAK,CAACY,gBAAK,CAACJ,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC7CO,MAAMG,KAAK,CAACa,iBAAM,CAACL,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC9CO,MAAMiB,KAAK,CAACvB;gBACZ;YACF,EAAE,OAAOW,KAAK;gBACZX,SAASW;gBACT;YACF;QACF;QAEA,OAAO,IAAIa,QAAQ,SAACC,SAASC;YAC3B,MAAK7B,MAAM,CAACC,MAAMC,SAAS,SAACY,KAAagB;uBAAoBhB,MAAMe,OAAOf,OAAOc,QAAQE;;QAC3F;IACF;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WAtEQ1C"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: FileAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if ((this as unknown as AbstractFileEntry)._writeFile === undefined) throw new Error('File this missing _writeFile. Please implement this method in your subclass');\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n } else {\n // Check if file exists - throw EEXIST if it does\n queue.defer((callback) => {\n fs.stat(fullPath, (err) => {\n if (!err) {\n const existsErr = new Error(`EEXIST: file already exists, open '${fullPath}'`) as NodeJS.ErrnoException;\n existsErr.code = 'EEXIST';\n existsErr.path = fullPath;\n return callback(existsErr);\n }\n // ENOENT means file doesn't exist - that's what we want\n if (err.code === 'ENOENT') return callback();\n // Other errors should be reported\n callback(err);\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer((this as unknown as AbstractFileEntry)._writeFile.bind(this, fullPath, options));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["FileEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","_writeFile","Error","create","dest","options","callback","normalizedPath","normalize","fullPath","safeJoinPath","stripPath","queue","Queue","force","defer","rm","err","code","fs","stat","existsErr","mkdirp","bind","dirname","waitForAccess","chmod","chown","utimes","await","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAuBqBA;;;8BAvBF;iEACJ;oEACI;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;qEACJ;kEACH;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AASvC,IAAA,AAAMD,0BAAN;;aAAMA,UAOPE,UAA0B;gCAPnBF;QAQjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGE,aAAI,CAACF,QAAQ,CAAC,IAAI,CAACE,IAAI;QACxE,IAAI,IAAI,CAACC,IAAI,KAAKF,WAAW,IAAI,CAACE,IAAI,GAAG;QACzC,IAAI,AAAC,IAAI,CAAkCC,UAAU,KAAKH,WAAW,MAAM,IAAII,MAAM;;iBAZpEV;IAkBnBW,OAAAA,MA+CC,GA/CDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzFA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,IAAMC,iBAAiBR,aAAI,CAACS,SAAS,CAAC,IAAI,CAACT,IAAI;gBAC/C,IAAMU,WAAWC,IAAAA,uBAAY,EAACN,MAAMO,IAAAA,oBAAS,EAACJ,gBAAgBF;gBAE9D,IAAMO,QAAQ,IAAIC,gBAAK,CAAC;gBACxB,IAAIR,QAAQS,KAAK,EAAE;oBACjBF,MAAMG,KAAK,CAAC,SAACT;wBACXU,IAAAA,kBAAE,EAACP,UAAU,SAACQ;4BACZA,OAAOA,IAAIC,IAAI,KAAK,WAAWZ,SAASW,OAAOX;wBACjD;oBACF;gBACF,OAAO;oBACL,iDAAiD;oBACjDM,MAAMG,KAAK,CAAC,SAACT;wBACXa,mBAAE,CAACC,IAAI,CAACX,UAAU,SAACQ;4BACjB,IAAI,CAACA,KAAK;gCACR,IAAMI,YAAY,IAAInB,MAAM,AAAC,sCAA8C,OAATO,UAAS;gCAC3EY,UAAUH,IAAI,GAAG;gCACjBG,UAAUtB,IAAI,GAAGU;gCACjB,OAAOH,SAASe;4BAClB;4BACA,wDAAwD;4BACxD,IAAIJ,IAAIC,IAAI,KAAK,UAAU,OAAOZ;4BAClC,kCAAkC;4BAClCA,SAASW;wBACX;oBACF;gBACF;gBACAL,MAAMG,KAAK,CAACO,sBAAM,CAACC,IAAI,CAAC,MAAMxB,aAAI,CAACyB,OAAO,CAACf;gBAC3CG,MAAMG,KAAK,CAAC,AAAC,IAAI,CAAkCd,UAAU,CAACsB,IAAI,CAAC,IAAI,EAAEd,UAAUJ;gBACnFO,MAAMG,KAAK,CAACU,wBAAa,CAACF,IAAI,CAAC,MAAMd;gBACrCG,MAAMG,KAAK,CAACW,gBAAK,CAACH,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC7CO,MAAMG,KAAK,CAACY,gBAAK,CAACJ,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC7CO,MAAMG,KAAK,CAACa,iBAAM,CAACL,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC9CO,MAAMiB,KAAK,CAACvB;YACd,EAAE,OAAOW,KAAK;gBACZX,SAASW;YACX;YACA;QACF;QAEA,OAAO,IAAIa,QAAQ,SAACC,SAASC;mBAAW,MAAK7B,MAAM,CAACC,MAAMC,SAAS,SAACY,KAAagB;uBAAoBhB,MAAMe,OAAOf,OAAOc,QAAQE;;;IACnI;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WAnEQ1C"}
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
12
  var _fsremovecompat = require("fs-remove-compat");
13
+ var _isabsolute = /*#__PURE__*/ _interop_require_default(require("is-absolute"));
13
14
  var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
14
15
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
15
16
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
@@ -17,6 +18,7 @@ var _chmodts = /*#__PURE__*/ _interop_require_default(require("./fs/chmod.js"));
17
18
  var _chownts = /*#__PURE__*/ _interop_require_default(require("./fs/chown.js"));
18
19
  var _utimests = /*#__PURE__*/ _interop_require_default(require("./fs/utimes.js"));
19
20
  var _indexts = require("./shared/index.js");
21
+ var _safeJoinPathts = /*#__PURE__*/ _interop_require_default(require("./shared/safeJoinPath.js"));
20
22
  var _stripPathts = /*#__PURE__*/ _interop_require_default(require("./shared/stripPath.js"));
21
23
  var _validateAttributests = /*#__PURE__*/ _interop_require_default(require("./validateAttributes.js"));
22
24
  var _waitForAccessts = /*#__PURE__*/ _interop_require_default(require("./waitForAccess.js"));
@@ -53,9 +55,14 @@ var LinkEntry = /*#__PURE__*/ function() {
53
55
  if (typeof callback === 'function') {
54
56
  try {
55
57
  var normalizedPath = _path.default.normalize(this.path);
56
- var fullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedPath, options));
58
+ var fullPath = (0, _safeJoinPathts.default)(dest, (0, _stripPathts.default)(normalizedPath, options));
59
+ if ((0, _isabsolute.default)(this.linkpath)) {
60
+ var _$err = new Error("Absolute linkpath rejected: '".concat(this.linkpath, "'"));
61
+ _$err.code = 'ETRAVERSAL';
62
+ throw _$err;
63
+ }
57
64
  var normalizedLinkpath = _path.default.normalize(this.linkpath);
58
- var linkFullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedLinkpath, options));
65
+ var linkFullPath = (0, _safeJoinPathts.default)(dest, (0, _stripPathts.default)(normalizedLinkpath, options));
59
66
  var queue = new _queuecb.default(1);
60
67
  if (options.force) {
61
68
  queue.defer(function(callback) {
@@ -72,14 +79,13 @@ var LinkEntry = /*#__PURE__*/ function() {
72
79
  queue.defer(_chownts.default.bind(null, fullPath, this, options));
73
80
  queue.defer(_utimests.default.bind(null, fullPath, this, options));
74
81
  queue.await(callback);
75
- return;
76
82
  } catch (err) {
77
83
  callback(err);
78
- return;
79
84
  }
85
+ return;
80
86
  }
81
87
  return new Promise(function(resolve, reject) {
82
- _this.create(dest, options, function(err, done) {
88
+ return _this.create(dest, options, function(err, done) {
83
89
  return err ? reject(err) : resolve(done);
84
90
  });
85
91
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n const normalizedLinkpath = path.normalize(this.linkpath);\n const linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer(waitForAccess.bind(null, linkFullPath)); // ensure target file is accessible before linking\n queue.defer(fs.link.bind(fs, linkFullPath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["LinkEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","create","dest","options","callback","normalizedPath","normalize","fullPath","join","stripPath","normalizedLinkpath","linkpath","linkFullPath","queue","Queue","force","defer","rm","err","code","mkdirp","bind","dirname","waitForAccess","fs","link","chmod","chown","utimes","await","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAkBqBA;;;yDAlBN;8BACI;oEACA;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;kEACP;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMD,0BAAN;;aAAMA,UAQPE,UAA0B;gCARnBF;QASjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACn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ACF,IAAI,CAAC,MAAMd;gBACrCM,MAAMG,KAAK,CAACU,gBAAK,CAACL,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC7CU,MAAMG,KAAK,CAACW,gBAAK,CAACN,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC7CU,MAAMG,KAAK,CAACY,iBAAM,CAACP,IAAI,CAAC,MAAMd,UAAU,IAAI,EAAEJ;gBAC9CU,MAAMgB,KAAK,CAACzB;gBACZ;YACF,EAAE,OAAOc,KAAK;gBACZd,SAASc;gBACT;YACF;QACF;QAEA,OAAO,IAAIY,QAAQ,SAACC,SAASC;YAC3B,MAAK/B,MAAM,CAACC,MAAMC,SAAS,SAACe,KAAae;uBAAoBf,MAAMc,OAAOd,OAAOa,QAAQE;;QAC3F;IACF;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WAzDQ1C"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n const normalizedLinkpath = path.normalize(this.linkpath);\n const linkFullPath = safeJoinPath(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer(waitForAccess.bind(null, linkFullPath)); // ensure target file is accessible before linking\n queue.defer(fs.link.bind(fs, linkFullPath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["LinkEntry","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","create","dest","options","callback","normalizedPath","normalize","fullPath","safeJoinPath","stripPath","isAbsolute","linkpath","err","Error","code","normalizedLinkpath","linkFullPath","queue","Queue","force","defer","rm","mkdirp","bind","dirname","waitForAccess","fs","link","chmod","chown","utimes","await","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAoBqBA;;;yDApBN;8BACI;iEACI;oEACJ;2DACF;8DACC;8DACA;8DACA;+DACC;uBACU;qEACJ;kEACH;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMD,0BAAN;;aAAMA,UAQPE,UAA0B;gCARnBF;QASjBG,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGE,aAAI,CAACF,QAAQ,CAAC,IAAI,CAACE,IAAI;QACxE,IAAI,IAAI,CAACC,IAAI,KAAKF,WAAW,IAAI,CAACE,IAAI,GAAG;;iBAZxBR;IAkBnBS,OAAAA,MAuCC,GAvCDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzFA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,IAAMC,iBAAiBN,aAAI,CAACO,SAAS,CAAC,IAAI,CAACP,IAAI;gBAC/C,IAAMQ,WAAWC,IAAAA,uBAAY,EAACN,MAAMO,IAAAA,oBAAS,EAACJ,gBAAgBF;gBAC9D,IAAIO,IAAAA,mBAAU,EAAC,IAAI,CAACC,QAAQ,GAAG;oBAC7B,IAAMC,QAAM,IAAIC,MAAM,AAAC,gCAA6C,OAAd,IAAI,CAACF,QAAQ,EAAC;oBACpEC,MAAIE,IAAI,GAAG;oBACX,MAAMF;gBACR;gBACA,IAAMG,qBAAqBhB,aAAI,CAACO,SAAS,CAAC,IAAI,CAACK,QAAQ;gBACvD,IAAMK,eAAeR,I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op_require_default(require("./fs/lutimes.js"));
20
20
  var _symlinkWin32ts = /*#__PURE__*/ _interop_require_default(require("./fs/symlinkWin32.js"));
21
21
  var _indexts = require("./shared/index.js");
22
+ var _safeJoinPathts = /*#__PURE__*/ _interop_require_default(require("./shared/safeJoinPath.js"));
22
23
  var _stripPathts = /*#__PURE__*/ _interop_require_default(require("./shared/stripPath.js"));
23
24
  var _validateAttributests = /*#__PURE__*/ _interop_require_default(require("./validateAttributes.js"));
24
25
  var _waitForAccessts = /*#__PURE__*/ _interop_require_default(require("./waitForAccess.js"));
@@ -56,14 +57,18 @@ var SymbolicLinkEntry = /*#__PURE__*/ function() {
56
57
  if (typeof callback === 'function') {
57
58
  try {
58
59
  var normalizedPath = _path.default.normalize(this.path);
59
- var fullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedPath, options));
60
- var normalizedLinkpath = _path.default.normalize(this.linkpath);
61
- var linkFullPath = _path.default.join(dest, (0, _stripPathts.default)(normalizedLinkpath, options));
62
- if (!(0, _isabsolute.default)(normalizedLinkpath)) {
63
- var linkRelativePath = _path.default.join(_path.default.dirname(normalizedPath), this.linkpath);
64
- linkFullPath = _path.default.join(dest, (0, _stripPathts.default)(linkRelativePath, options));
65
- normalizedLinkpath = _path.default.relative(_path.default.dirname(fullPath), linkFullPath);
60
+ var fullPath = (0, _safeJoinPathts.default)(dest, (0, _stripPathts.default)(normalizedPath, options));
61
+ if ((0, _isabsolute.default)(this.linkpath)) {
62
+ var _$err = new Error("Absolute linkpath rejected: '".concat(this.linkpath, "'"));
63
+ _$err.code = 'ETRAVERSAL';
64
+ throw _$err;
66
65
  }
66
+ // Resolve the symlink target against the symlink's own directory and verify it
67
+ // stays within dest. safeJoinPath throws ETRAVERSAL if it escapes.
68
+ var targetAbs = _path.default.resolve(_path.default.dirname(fullPath), this.linkpath);
69
+ (0, _safeJoinPathts.default)(dest, _path.default.relative(dest, targetAbs));
70
+ var normalizedLinkpath = _path.default.relative(_path.default.dirname(fullPath), targetAbs);
71
+ var linkFullPath = targetAbs;
67
72
  var queue = new _queuecb.default(1);
68
73
  if (options.force) {
69
74
  queue.defer(function(callback) {
@@ -80,14 +85,13 @@ var SymbolicLinkEntry = /*#__PURE__*/ function() {
80
85
  queue.defer(_chownts.default.bind(null, fullPath, this, options));
81
86
  queue.defer(_lutimests.default.bind(null, fullPath, this, options));
82
87
  queue.await(callback);
83
- return;
84
88
  } catch (err) {
85
89
  callback(err);
86
- return;
87
90
  }
91
+ return;
88
92
  }
89
93
  return new Promise(function(resolve, reject) {
90
- _this.create(dest, options, function(err, done) {
94
+ return _this.create(dest, options, function(err, done) {
91
95
  return err ? reject(err) : resolve(done);
92
96
  });
93
97
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n let normalizedLinkpath = path.normalize(this.linkpath);\n let linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n if (!isAbsolute(normalizedLinkpath)) {\n const linkRelativePath = path.join(path.dirname(normalizedPath), this.linkpath);\n linkFullPath = path.join(dest, stripPath(linkRelativePath, options));\n normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);\n }\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));\n else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath, true)); // noFollow=true for symlinks\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(lutimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["SymbolicLinkEntry","isWindows","process","platform","test","env","OSTYPE","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","create","dest","options","callback","normalizedPath","normalize","fullPath","join","stripPath","normalizedLinkpath","linkpath","linkFullPath","isAbsolute","linkRelativePath","dirname","relative","queue","Queue","force","defer","rm","err","code","mkdirp","bind","symlinkWin32","fs","symlink","waitForAccess","chmod","chown","lutimes","await","Promise","resolve","reject","done","destroy"],"mappings":";;;;;;;eAsBqBA;;;yDAtBN;8BACI;iEACI;oEACJ;2DACF;8DACC;8DACA;8DACA;gEACE;qEACK;uBACI;kEACP;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAE3F,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMP,kCAAN;;aAAMA,kBAQPQ,UAA0B;gCARnBR;QASjBS,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGE,aAAI,CAACF,QAAQ,CAAC,IAAI,CAACE,IAAI;QACxE,IAAI,IAAI,CAACC,IAAI,KAAKF,WAAW,IAAI,CAACE,IAAI,GAAG;;iBAZxBd;IAkBnBe,OAAAA,MA0CC,GA1CDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzFA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,IAAMC,iBAAiBN,aAAI,CAACO,SAAS,CAAC,IAAI,CAACP,IAAI;gBAC/C,IAAMQ,WAAWR,aAAI,CAACS,IAAI,CAACN,MAAMO,IAAAA,oBAAS,EAACJ,gBAAgBF;gBAC3D,IAAIO,qBAAqBX,aAAI,CAACO,SAAS,CAAC,IAAI,CAACK,QAAQ;gBACrD,IAAIC,eAAe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AK,CAAC7B;gBACZ;YACF,EAAE,OAAOkB,KAAK;gBACZlB,SAASkB;gBACT;YACF;QACF;QAEA,OAAO,IAAIY,QAAQ,SAACC,SAASC;YAC3B,MAAKnC,MAAM,CAACC,MAAMC,SAAS,SAACmB,KAAae;uBAAoBf,MAAMc,OAAOd,OAAOa,QAAQE;;QAC3F;IACF;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WA9DQpD"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n // Resolve the symlink target against the symlink's own directory and verify it\n // stays within dest. safeJoinPath throws ETRAVERSAL if it escapes.\n const targetAbs = path.resolve(path.dirname(fullPath), this.linkpath);\n safeJoinPath(dest, path.relative(dest, targetAbs));\n const normalizedLinkpath = path.relative(path.dirname(fullPath), targetAbs);\n const linkFullPath = targetAbs;\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));\n else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath, true)); // noFollow=true for symlinks\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(lutimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["SymbolicLinkEntry","isWindows","process","platform","test","env","OSTYPE","MANDATORY_ATTRIBUTES","attributes","validateAttributes","objectAssign","basename","undefined","path","type","create","dest","options","callback","normalizedPath","normalize","fullPath","safeJoinPath","stripPath","isAbsolute","linkpath","err","Error","code","targetAbs","resolve","dirname","relative","normalizedLinkpath","linkFullPath","queue","Queue","force","defer","rm","mkdirp","bind","symlinkWin32","fs","symlink","waitForAccess","chmod","chown","lutimes","await","Promise","reject","done","destroy"],"mappings":";;;;;;;eAuBqBA;;;yDAvBN;8BACI;iEACI;oEACJ;2DACF;8DACC;8DACA;8DACA;gEACE;qEACK;uBACI;qEACJ;kEACH;2EACS;sEACL;;;;;;;;;;;AAE1B,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAE3F,IAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMP,kCAAN;;aAAMA,kBAQPQ,UAA0B;gCARnBR;QASjBS,IAAAA,6BAAkB,EAACD,YAAYD;QAC/BG,IAAAA,qBAAY,EAAC,IAAI,EAAEF;QACnB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGE,aAAI,CAACF,QAAQ,CAAC,IAAI,CAACE,IAAI;QACxE,IAAI,IAAI,CAACC,IAAI,KAAKF,WAAW,IAAI,CAACE,IAAI,GAAG;;iBAZxBd;IAkBnBe,OAAAA,MA4CC,GA5CDA,SAAAA,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;;QACzFA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,IAAMC,iBAAiBN,aAAI,CAACO,SAAS,CAAC,IAAI,CAACP,IAAI;gBAC/C,IAAMQ,WAAWC,IAAAA,uBAAY,EAACN,MAAMO,IAAAA,oBAAS,EAACJ,gBAAgBF;gBAE9D,IAAIO,IAAAA,mBAAU,EAAC,IAAI,CAACC,QAAQ,GAAG;oBAC7B,IAAMC,QAAM,IAAIC,MAAM,AAAC,gCAA6C,OAAd,IAAI,CAAC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AAC/B;YACd,EAAE,OAAOQ,KAAK;gBACZR,SAASQ;YACX;YACA;QACF;QAEA,OAAO,IAAIwB,QAAQ,SAACpB,SAASqB;mBAAW,MAAKpC,MAAM,CAACC,MAAMC,SAAS,SAACS,KAAa0B;uBAAoB1B,MAAMyB,OAAOzB,OAAOI,QAAQsB;;;IACnI;IAEAC,OAAAA,OAAY,GAAZA,SAAAA,WAAW;WAhEQrD"}
@@ -22,5 +22,6 @@ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
22
22
  export { default as EntryStream } from './EntryStream.js';
23
23
  export { type CleanupFn, default as Lock } from './Lock.js';
24
24
  export { default as normalizePath } from './normalizePath.js';
25
+ export { default as safeJoinPath } from './safeJoinPath.js';
25
26
  export { default as streamToString, type StreamToStringCallback } from './streamToString.js';
26
27
  export { default as stripPath } from './stripPath.js';
@@ -22,5 +22,6 @@ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
22
22
  export { default as EntryStream } from './EntryStream.js';
23
23
  export { type CleanupFn, default as Lock } from './Lock.js';
24
24
  export { default as normalizePath } from './normalizePath.js';
25
+ export { default as safeJoinPath } from './safeJoinPath.js';
25
26
  export { default as streamToString, type StreamToStringCallback } from './streamToString.js';
26
27
  export { default as stripPath } from './stripPath.js';
@@ -91,6 +91,9 @@ _export(exports, {
91
91
  get readUInt64LE () {
92
92
  return _compatts.readUInt64LE;
93
93
  },
94
+ get safeJoinPath () {
95
+ return _safeJoinPathts.default;
96
+ },
94
97
  get streamToString () {
95
98
  return _streamToStringts.default;
96
99
  },
@@ -113,6 +116,7 @@ var _crc32ts = require("./crc32.js");
113
116
  var _EntryStreamts = /*#__PURE__*/ _interop_require_default(require("./EntryStream.js"));
114
117
  var _Lockts = /*#__PURE__*/ _interop_require_default(require("./Lock.js"));
115
118
  var _normalizePathts = /*#__PURE__*/ _interop_require_default(require("./normalizePath.js"));
119
+ var _safeJoinPathts = /*#__PURE__*/ _interop_require_default(require("./safeJoinPath.js"));
116
120
  var _streamToStringts = /*#__PURE__*/ _interop_require_default(require("./streamToString.js"));
117
121
  var _stripPathts = /*#__PURE__*/ _interop_require_default(require("./stripPath.js"));
118
122
  function _interop_require_default(obj) {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nimport BufferList from './BufferList.ts';\n\nexport { BufferList };\n\n/**\n * Type alias for Buffer or BufferList - both can be read byte-by-byte.\n * Use this when an API should accept either contiguous data (Buffer)\n * or chunked streaming data (BufferList).\n */\nexport type BufferLike = Buffer | BufferList;\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n canAllocateBufferSize,\n createInflateRawStream,\n inflateRaw,\n isNaN,\n MAX_SAFE_BUFFER_LENGTH,\n objectAssign,\n PassThrough,\n Readable,\n readUInt64LE,\n Transform,\n Writable,\n writeUInt64LE,\n} from './compat.ts';\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\nexport { default as EntryStream } from './EntryStream.ts';\nexport { type CleanupFn, default as Lock } from './Lock.ts';\nexport { default as normalizePath } from './normalizePath.ts';\nexport { default as streamToString, type StreamToStringCallback } from './streamToString.ts';\nexport { default as stripPath } from './stripPath.ts';\n"],"names":["BufferList","EntryStream","Lock","MAX_SAFE_BUFFER_LENGTH","PassThrough","Readable","Transform","Writable","allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","canAllocateBufferSize","crc32","crc32Region","createInflateRawStream","inflateRaw","isNaN","normalizePath","objectAssign","readUInt64LE","streamToString","stripPath","verifyCrc32","verifyCrc32Region","writeUInt64LE"],"mappings":"AAAA;;;;;;;;;;CAUC;;;;;;;;;;;QAIQA;eAAAA,qBAAU;;QA8BCC;eAAAA,sBAAW;;QACKC;eAAAA,eAAI;;QAXtCC;eAAAA,gCAAsB;;QAEtBC;eAAAA,qBAAW;;QACXC;eAAAA,kBAAQ;;QAERC;eAAAA,mBAAS;;QACTC;eAAAA,kBAAQ;;QAjBRC;eAAAA,qBAAW;;QACXC;eAAAA,2BAAiB;;QACjBC;eAAAA,uBAAa;;QACbC;eAAAA,sBAAY;;QACZC;eAAAA,sBAAY;;QACZC;eAAAA,oBAAU;;QACVC;eAAAA,yBAAe;;QACfC;eAAAA,+BAAqB;;QAadC;eAAAA,cAAK;;QAAEC;eAAAA,oBAAW;;QAZzBC;eAAAA,gCAAsB;;QACtBC;eAAAA,oBAAU;;QACVC;eAAAA,eAAK;;QAaaC;eAAAA,wBAAa;;QAX/BC;eAAAA,sBAAY;;QAGZC;eAAAA,sBAAY;;QASMC;eAAAA,yBAAc;;QACdC;eAAAA,oBAAS;;QALAC;eAAAA,oBAAW;;QAAEC;eAAAA,0BAAiB;;QAFzDC;eAAAA,uBAAa;;;mEA7BQ;wBA8BhB;uBAC4D;oEAC5B;6DACS;sEACP;uEAC8B;kEAClC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nimport BufferList from './BufferList.ts';\n\nexport { BufferList };\n\n/**\n * Type alias for Buffer or BufferList - both can be read byte-by-byte.\n * Use this when an API should accept either contiguous data (Buffer)\n * or chunked streaming data (BufferList).\n */\nexport type BufferLike = Buffer | BufferList;\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n canAllocateBufferSize,\n createInflateRawStream,\n inflateRaw,\n isNaN,\n MAX_SAFE_BUFFER_LENGTH,\n objectAssign,\n PassThrough,\n Readable,\n readUInt64LE,\n Transform,\n Writable,\n writeUInt64LE,\n} from './compat.ts';\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\nexport { default as EntryStream } from './EntryStream.ts';\nexport { type CleanupFn, default as Lock } from './Lock.ts';\nexport { default as normalizePath } from './normalizePath.ts';\nexport { default as safeJoinPath } from './safeJoinPath.ts';\nexport { default as streamToString, type StreamToStringCallback } from './streamToString.ts';\nexport { default as stripPath } from './stripPath.ts';\n"],"names":["BufferList","EntryStream","Lock","MAX_SAFE_BUFFER_LENGTH","PassThrough","Readable","Transform","Writable","allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","canAllocateBufferSize","crc32","crc32Region","createInflateRawStream","inflateRaw","isNaN","normalizePath","objectAssign","readUInt64LE","safeJoinPath","streamToString","stripPath","verifyCrc32","verifyCrc32Region","writeUInt64LE"],"mappings":"AAAA;;;;;;;;;;CAUC;;;;;;;;;;;QAIQA;eAAAA,qBAAU;;QA8BCC;eAAAA,sBAAW;;QACKC;eAAAA,eAAI;;QAXtCC;eAAAA,gCAAsB;;QAEtBC;eAAAA,qBAAW;;QACXC;eAAAA,kBAAQ;;QAERC;eAAAA,mBAAS;;QACTC;eAAAA,kBAAQ;;QAjBRC;eAAAA,qBAAW;;QACXC;eAAAA,2BAAiB;;QACjBC;eAAAA,uBAAa;;QACbC;eAAAA,sBAAY;;QACZC;eAAAA,sBAAY;;QACZC;eAAAA,oBAAU;;QACVC;eAAAA,yBAAe;;QACfC;eAAAA,+BAAqB;;QAadC;eAAAA,cAAK;;QAAEC;eAAAA,oBAAW;;QAZzBC;eAAAA,gCAAsB;;QACtBC;eAAAA,oBAAU;;QACVC;eAAAA,eAAK;;QAaaC;eAAAA,wBAAa;;QAX/BC;eAAAA,sBAAY;;QAGZC;eAAAA,sBAAY;;QASMC;eAAAA,uBAAY;;QACZC;eAAAA,yBAAc;;QACdC;eAAAA,oBAAS;;QANAC;eAAAA,oBAAW;;QAAEC;eAAAA,0BAAiB;;QAFzDC;eAAAA,uBAAa;;;mEA7BQ;wBA8BhB;uBAC4D;oEAC5B;6DACS;sEACP;qEACD;uEAC+B;kEAClC"}
@@ -0,0 +1 @@
1
+ export default function safeJoinPath(dest: string, relPath: string): string;
@@ -0,0 +1 @@
1
+ export default function safeJoinPath(dest: string, relPath: string): string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return safeJoinPath;
9
+ }
10
+ });
11
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function safeJoinPath(dest, relPath) {
18
+ var resolvedDest = _path.default.resolve(dest);
19
+ var resolvedFull = _path.default.resolve(dest, relPath);
20
+ if (resolvedFull !== resolvedDest && !resolvedFull.startsWith(resolvedDest + _path.default.sep)) {
21
+ var err = new Error("Path traversal detected: '".concat(relPath, "' escapes destination '").concat(dest, "'"));
22
+ err.code = 'ETRAVERSAL';
23
+ throw err;
24
+ }
25
+ return resolvedFull;
26
+ }
27
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/safeJoinPath.ts"],"sourcesContent":["import path from 'path';\n\nexport default function safeJoinPath(dest: string, relPath: string): string {\n const resolvedDest = path.resolve(dest);\n const resolvedFull = path.resolve(dest, relPath);\n if (resolvedFull !== resolvedDest && !resolvedFull.startsWith(resolvedDest + path.sep)) {\n const err = new Error(`Path traversal detected: '${relPath}' escapes destination '${dest}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n return resolvedFull;\n}\n"],"names":["safeJoinPath","dest","relPath","resolvedDest","path","resolve","resolvedFull","startsWith","sep","err","Error","code"],"mappings":";;;;+BAEA;;;eAAwBA;;;2DAFP;;;;;;AAEF,SAASA,aAAaC,IAAY,EAAEC,OAAe;IAChE,IAAMC,eAAeC,aAAI,CAACC,OAAO,CAACJ;IAClC,IAAMK,eAAeF,aAAI,CAACC,OAAO,CAACJ,MAAMC;IACxC,IAAII,iBAAiBH,gBAAgB,CAACG,aAAaC,UAAU,CAACJ,eAAeC,aAAI,CAACI,GAAG,GAAG;QACtF,IAAMC,MAAM,IAAIC,MAAM,AAAC,6BAA6DT,OAAjCC,SAAQ,2BAA8B,OAALD,MAAK;QACzFQ,IAAIE,IAAI,GAAG;QACX,MAAMF;IACR;IACA,OAAOH;AACT"}
@@ -5,6 +5,7 @@ import chmod from './fs/chmod.js';
5
5
  import chown from './fs/chown.js';
6
6
  import utimes from './fs/utimes.js';
7
7
  import { objectAssign } from './shared/index.js';
8
+ import safeJoinPath from './shared/safeJoinPath.js';
8
9
  import stripPath from './shared/stripPath.js';
9
10
  import validateAttributes from './validateAttributes.js';
10
11
  import waitForAccess from './waitForAccess.js';
@@ -20,7 +21,7 @@ let DirectoryEntry = class DirectoryEntry {
20
21
  if (typeof callback === 'function') {
21
22
  try {
22
23
  const normalizedPath = path.normalize(this.path);
23
- const fullPath = path.join(dest, stripPath(normalizedPath, options));
24
+ const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));
24
25
  // do not check for the existence of the directory but allow out-of-order calling
25
26
  const queue = new Queue(1);
26
27
  queue.defer(mkdirp.bind(null, fullPath));
@@ -29,15 +30,12 @@ let DirectoryEntry = class DirectoryEntry {
29
30
  queue.defer(chown.bind(null, fullPath, this, options));
30
31
  queue.defer(utimes.bind(null, fullPath, this, options));
31
32
  queue.await(callback);
32
- return;
33
33
  } catch (err) {
34
34
  callback(err);
35
- return;
36
35
  }
36
+ return;
37
37
  }
38
- return new Promise((resolve, reject)=>{
39
- this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done));
40
- });
38
+ return new Promise((resolve, reject)=>this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done)));
41
39
  }
42
40
  destroy() {}
43
41
  constructor(attributes){
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: DirectoryAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["mkdirp","path","Queue","chmod","chown","utimes","objectAssign","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","DirectoryEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","join","queue","defer","bind","await","err","Promise","resolve","reject","done","destroy","attributes","type","undefined","basename"],"mappings":"AAAA,OAAOA,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAKvC,IAAA,AAAMC,iBAAN,MAAMA;IAiBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBf,KAAKgB,SAAS,CAAC,IAAI,CAAChB,IAAI;gBAC/C,MAAMiB,WAAWjB,KAAKkB,IAAI,CAACN,MAAMN,UAAUS,gBAAgBF;gBAE3D,iFAAiF;gBACjF,MAAMM,QAAQ,IAAIlB,MAAM;gBACxBkB,MAAMC,KAAK,CAACrB,OAAOsB,IAAI,CAAC,MAAMJ;gBAC9BE,MAAMC,KAAK,CAACZ,cAAca,IAAI,CAAC,MAAMJ;gBACrCE,MAAMC,KAAK,CAAClB,MAAMmB,IAAI,CAAC,MAAMJ,UAAU,IAAI,EAAEJ;gBAC7CM,MAAMC,KAAK,CAACjB,MAAMkB,IAAI,CAAC,MAAMJ,UAAU,IAAI,EAAEJ;gBAC7CM,MAAMC,KAAK,CAAChB,OAAOiB,IAAI,CAAC,MAAMJ,UAAU,IAAI,EAAEJ;gBAC9CM,MAAMG,KAAK,CAACR;gBACZ;YACF,EAAE,OAAOS,KAAK;gBACZT,SAASS;gBACT;YACF;QACF;QAEA,OAAO,IAAIC,QAAQ,CAACC,SAASC;YAC3B,IAAI,CAACf,MAAM,CAACC,MAAMC,SAAS,CAACU,KAAaI,OAAoBJ,MAAMG,OAAOH,OAAOE,QAAQE;QAC3F;IACF;IAEAC,UAAU,CAAC;IAvCX,YAAYC,UAA+B,CAAE;QAC3CtB,mBAAmBsB,YAAYpB;QAC/BJ,aAAa,IAAI,EAAEwB;QACnB,IAAI,IAAI,CAACC,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;QACzC,IAAI,IAAI,CAACE,QAAQ,KAAKD,WAAW,IAAI,CAACC,QAAQ,GAAGhC,KAAKgC,QAAQ,CAAC,IAAI,CAAChC,IAAI;IAC1E;AAmCF;AA/CA,SAAqBU,4BA+CpB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: DirectoryAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","DirectoryEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","queue","defer","bind","await","err","Promise","resolve","reject","done","destroy","attributes","type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,IAAIC,QAAQ,CAACC,SAASC,SAAW,IAAI,CAACd,MAAM,CAACC,MAAMC,SAAS,CAACS,KAAaI,OAAoBJ,MAAMG,OAAOH,OAAOE,QAAQE;IACnI;IAEAC,UAAU,CAAC;IApCX,YAAYC,UAA+B,CAAE;QAC3CrB,mBAAmBqB,YAAYnB;QAC/BL,aAAa,IAAI,EAAEwB;QACnB,IAAI,IAAI,CAACC,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;QACzC,IAAI,IAAI,CAACE,QAAQ,KAAKD,WAAW,IAAI,CAACC,QAAQ,GAAGhC,KAAKgC,QAAQ,CAAC,IAAI,CAAChC,IAAI;IAC1E;AAgCF;AA5CA,SAAqBW,4BA4CpB"}
@@ -7,6 +7,7 @@ import chmod from './fs/chmod.js';
7
7
  import chown from './fs/chown.js';
8
8
  import utimes from './fs/utimes.js';
9
9
  import { objectAssign } from './shared/index.js';
10
+ import safeJoinPath from './shared/safeJoinPath.js';
10
11
  import stripPath from './shared/stripPath.js';
11
12
  import validateAttributes from './validateAttributes.js';
12
13
  import waitForAccess from './waitForAccess.js';
@@ -22,7 +23,7 @@ let FileEntry = class FileEntry {
22
23
  if (typeof callback === 'function') {
23
24
  try {
24
25
  const normalizedPath = path.normalize(this.path);
25
- const fullPath = path.join(dest, stripPath(normalizedPath, options));
26
+ const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));
26
27
  const queue = new Queue(1);
27
28
  if (options.force) {
28
29
  queue.defer((callback)=>{
@@ -54,15 +55,12 @@ let FileEntry = class FileEntry {
54
55
  queue.defer(chown.bind(null, fullPath, this, options));
55
56
  queue.defer(utimes.bind(null, fullPath, this, options));
56
57
  queue.await(callback);
57
- return;
58
58
  } catch (err) {
59
59
  callback(err);
60
- return;
61
60
  }
61
+ return;
62
62
  }
63
- return new Promise((resolve, reject)=>{
64
- this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done));
65
- });
63
+ return new Promise((resolve, reject)=>this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done)));
66
64
  }
67
65
  destroy() {}
68
66
  constructor(attributes){
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: FileAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if ((this as unknown as AbstractFileEntry)._writeFile === undefined) throw new Error('File this missing _writeFile. Please implement this method in your subclass');\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n } else {\n // Check if file exists - throw EEXIST if it does\n queue.defer((callback) => {\n fs.stat(fullPath, (err) => {\n if (!err) {\n const existsErr = new Error(`EEXIST: file already exists, open '${fullPath}'`) as NodeJS.ErrnoException;\n existsErr.code = 'EEXIST';\n existsErr.path = fullPath;\n return callback(existsErr);\n }\n // ENOENT means file doesn't exist - that's what we want\n if (err.code === 'ENOENT') return callback();\n // Other errors should be reported\n callback(err);\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer((this as unknown as AbstractFileEntry)._writeFile.bind(this, fullPath, options));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["rm","fs","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","FileEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","join","queue","force","defer","err","code","stat","existsErr","Error","bind","dirname","_writeFile","await","Promise","resolve","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,SAASA,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB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,CAAC,MAAMV;gBACrCE,MAAME,KAAK,CAACnB,MAAMyB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC7CM,MAAME,KAAK,CAAClB,MAAMwB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC7CM,MAAME,KAAK,CAACjB,OAAOuB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC9CM,MAAMW,KAAK,CAAChB;gBACZ;YACF,EAAE,OAAOQ,KAAK;gBACZR,SAASQ;gBACT;YACF;QACF;QAEA,OAAO,IAAIS,QAAQ,CAACC,SAASC;YAC3B,IAAI,CAACtB,MAAM,CAACC,MAAMC,SAAS,CAACS,KAAaY,OAAoBZ,MAAMW,OAAOX,OAAOU,QAAQE;QAC3F;IACF;IAEAC,UAAU,CAAC;IA/DX,YAAYC,UAA0B,CAAE;QACtC7B,mBAAmB6B,YAAY3B;QAC/BJ,aAAa,IAAI,EAAE+B;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGrC,KAAKqC,QAAQ,CAAC,IAAI,CAACrC,IAAI;QACxE,IAAI,IAAI,CAACuC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;QACzC,IAAI,AAAC,IAAI,CAAkCV,UAAU,KAAKS,WAAW,MAAM,IAAIZ,MAAM;IACvF;AA0DF;AAvEA,SAAqBhB,uBAuEpB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n\n constructor(attributes: FileAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if ((this as unknown as AbstractFileEntry)._writeFile === undefined) throw new Error('File this missing _writeFile. Please implement this method in your subclass');\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n } else {\n // Check if file exists - throw EEXIST if it does\n queue.defer((callback) => {\n fs.stat(fullPath, (err) => {\n if (!err) {\n const existsErr = new Error(`EEXIST: file already exists, open '${fullPath}'`) as NodeJS.ErrnoException;\n existsErr.code = 'EEXIST';\n existsErr.path = fullPath;\n return callback(existsErr);\n }\n // ENOENT means file doesn't exist - that's what we want\n if (err.code === 'ENOENT') return callback();\n // Other errors should be reported\n callback(err);\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer((this as unknown as AbstractFileEntry)._writeFile.bind(this, fullPath, options));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["rm","fs","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","FileEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","queue","force","defer","err","code","stat","existsErr","Error","bind","dirname","_writeFile","await","Promise","resolve","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,SAASA,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AASvC,IAAA,AAAMC,YAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBhB,KAAKiB,SAAS,CAAC,IAAI,CAACjB,IAAI;gB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CAACrB,MAAM,CAACC,MAAMC,SAAS,CAACQ,KAAaY,OAAoBZ,MAAMW,OAAOX,OAAOU,QAAQE;IACnI;IAEAC,UAAU,CAAC;IA5DX,YAAYC,UAA0B,CAAE;QACtC5B,mBAAmB4B,YAAY1B;QAC/BL,aAAa,IAAI,EAAE+B;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGrC,KAAKqC,QAAQ,CAAC,IAAI,CAACrC,IAAI;QACxE,IAAI,IAAI,CAACuC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;QACzC,IAAI,AAAC,IAAI,CAAkCV,UAAU,KAAKS,WAAW,MAAM,IAAIZ,MAAM;IACvF;AAuDF;AApEA,SAAqBf,uBAoEpB"}
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import { rm } from 'fs-remove-compat';
3
+ import isAbsolute from 'is-absolute';
3
4
  import mkdirp from 'mkdirp-classic';
4
5
  import path from 'path';
5
6
  import Queue from 'queue-cb';
@@ -7,6 +8,7 @@ import chmod from './fs/chmod.js';
7
8
  import chown from './fs/chown.js';
8
9
  import utimes from './fs/utimes.js';
9
10
  import { objectAssign } from './shared/index.js';
11
+ import safeJoinPath from './shared/safeJoinPath.js';
10
12
  import stripPath from './shared/stripPath.js';
11
13
  import validateAttributes from './validateAttributes.js';
12
14
  import waitForAccess from './waitForAccess.js';
@@ -23,9 +25,14 @@ let LinkEntry = class LinkEntry {
23
25
  if (typeof callback === 'function') {
24
26
  try {
25
27
  const normalizedPath = path.normalize(this.path);
26
- const fullPath = path.join(dest, stripPath(normalizedPath, options));
28
+ const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));
29
+ if (isAbsolute(this.linkpath)) {
30
+ const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`);
31
+ err.code = 'ETRAVERSAL';
32
+ throw err;
33
+ }
27
34
  const normalizedLinkpath = path.normalize(this.linkpath);
28
- const linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
35
+ const linkFullPath = safeJoinPath(dest, stripPath(normalizedLinkpath, options));
29
36
  const queue = new Queue(1);
30
37
  if (options.force) {
31
38
  queue.defer((callback)=>{
@@ -42,15 +49,12 @@ let LinkEntry = class LinkEntry {
42
49
  queue.defer(chown.bind(null, fullPath, this, options));
43
50
  queue.defer(utimes.bind(null, fullPath, this, options));
44
51
  queue.await(callback);
45
- return;
46
52
  } catch (err) {
47
53
  callback(err);
48
- return;
49
54
  }
55
+ return;
50
56
  }
51
- return new Promise((resolve, reject)=>{
52
- this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done));
53
- });
57
+ return new Promise((resolve, reject)=>this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done)));
54
58
  }
55
59
  destroy() {}
56
60
  constructor(attributes){
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n const normalizedLinkpath = path.normalize(this.linkpath);\n const linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer(waitForAccess.bind(null, linkFullPath)); // ensure target file is accessible before linking\n queue.defer(fs.link.bind(fs, linkFullPath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["fs","rm","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","LinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","join","normalizedLinkpath","linkpath","linkFullPath","queue","force","defer","err","code","bind","dirname","link","await","Promise","resolve","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,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AAC,MAAMV;gBACrCK,MAAME,KAAK,CAACtB,MAAMyB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC7CS,MAAME,KAAK,CAACrB,MAAMwB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC7CS,MAAME,KAAK,CAACpB,OAAOuB,IAAI,CAAC,MAAMV,UAAU,IAAI,EAAEJ;gBAC9CS,MAAMQ,KAAK,CAAChB;gBACZ;YACF,EAAE,OAAOW,KAAK;gBACZX,SAASW;gBACT;YACF;QACF;QAEA,OAAO,IAAIM,QAAQ,CAACC,SAASC;YAC3B,IAAI,CAACtB,MAAM,CAACC,MAAMC,SAAS,CAACY,KAAaS,OAAoBT,MAAMQ,OAAOR,OAAOO,QAAQE;QAC3F;IACF;IAEAC,UAAU,CAAC;IAjDX,YAAYC,UAA0B,CAAE;QACtC7B,mBAAmB6B,YAAY3B;QAC/BJ,aAAa,IAAI,EAAE+B;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGrC,KAAKqC,QAAQ,CAAC,IAAI,CAACrC,IAAI;QACxE,IAAI,IAAI,CAACuC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AA6CF;AA1DA,SAAqB7B,uBA0DpB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n const normalizedLinkpath = path.normalize(this.linkpath);\n const linkFullPath = safeJoinPath(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n queue.defer(waitForAccess.bind(null, linkFullPath)); // ensure target file is accessible before linking\n queue.defer(fs.link.bind(fs, linkFullPath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(utimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["fs","rm","isAbsolute","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","LinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","linkpath","err","Error","code","normalizedLinkpath","linkFullPath","queue","force","defer","bind","dirname","link","await","Promise","resolve","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMC,YAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBhB,KAAKiB,SAAS,CAAC,IAAI,CAACjB,IAAI;gBAC/C,MAAMkB,WAAWZ,aAAaO,MAAMN,UAAUS,gBAAgBF;gBAC9D,IAAIhB,WAAW,IAAI,CAACqB,QAAQ,GAAG;oBAC7B,MAAMC,MAAM,IAAIC,MAAM,CAA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Y3B;QAC/BL,aAAa,IAAI,EAAEgC;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGtC,KAAKsC,QAAQ,CAAC,IAAI,CAACtC,IAAI;QACxE,IAAI,IAAI,CAACwC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AA+CF;AA5DA,SAAqB7B,uBA4DpB"}
@@ -9,6 +9,7 @@ import chown from './fs/chown.js';
9
9
  import lutimes from './fs/lutimes.js';
10
10
  import symlinkWin32 from './fs/symlinkWin32.js';
11
11
  import { objectAssign } from './shared/index.js';
12
+ import safeJoinPath from './shared/safeJoinPath.js';
12
13
  import stripPath from './shared/stripPath.js';
13
14
  import validateAttributes from './validateAttributes.js';
14
15
  import waitForAccess from './waitForAccess.js';
@@ -26,14 +27,18 @@ let SymbolicLinkEntry = class SymbolicLinkEntry {
26
27
  if (typeof callback === 'function') {
27
28
  try {
28
29
  const normalizedPath = path.normalize(this.path);
29
- const fullPath = path.join(dest, stripPath(normalizedPath, options));
30
- let normalizedLinkpath = path.normalize(this.linkpath);
31
- let linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
32
- if (!isAbsolute(normalizedLinkpath)) {
33
- const linkRelativePath = path.join(path.dirname(normalizedPath), this.linkpath);
34
- linkFullPath = path.join(dest, stripPath(linkRelativePath, options));
35
- normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);
30
+ const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));
31
+ if (isAbsolute(this.linkpath)) {
32
+ const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`);
33
+ err.code = 'ETRAVERSAL';
34
+ throw err;
36
35
  }
36
+ // Resolve the symlink target against the symlink's own directory and verify it
37
+ // stays within dest. safeJoinPath throws ETRAVERSAL if it escapes.
38
+ const targetAbs = path.resolve(path.dirname(fullPath), this.linkpath);
39
+ safeJoinPath(dest, path.relative(dest, targetAbs));
40
+ const normalizedLinkpath = path.relative(path.dirname(fullPath), targetAbs);
41
+ const linkFullPath = targetAbs;
37
42
  const queue = new Queue(1);
38
43
  if (options.force) {
39
44
  queue.defer((callback)=>{
@@ -50,15 +55,12 @@ let SymbolicLinkEntry = class SymbolicLinkEntry {
50
55
  queue.defer(chown.bind(null, fullPath, this, options));
51
56
  queue.defer(lutimes.bind(null, fullPath, this, options));
52
57
  queue.await(callback);
53
- return;
54
58
  } catch (err) {
55
59
  callback(err);
56
- return;
57
60
  }
61
+ return;
58
62
  }
59
- return new Promise((resolve, reject)=>{
60
- this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done));
61
- });
63
+ return new Promise((resolve, reject)=>this.create(dest, options, (err, done)=>err ? reject(err) : resolve(done)));
62
64
  }
63
65
  destroy() {}
64
66
  constructor(attributes){
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n let normalizedLinkpath = path.normalize(this.linkpath);\n let linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n if (!isAbsolute(normalizedLinkpath)) {\n const linkRelativePath = path.join(path.dirname(normalizedPath), this.linkpath);\n linkFullPath = path.join(dest, stripPath(linkRelativePath, options));\n normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);\n }\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));\n else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath, true)); // noFollow=true for symlinks\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(lutimes.bind(null, fullPath, this, options));\n queue.await(callback);\n return;\n } catch (err) {\n callback(err);\n return;\n }\n }\n\n return new Promise((resolve, reject) => {\n this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done)));\n });\n }\n\n destroy() {}\n}\n"],"names":["fs","rm","isAbsolute","mkdirp","path","Queue","chmod","chown","lutimes","symlinkWin32","objectAssign","stripPath","validateAttributes","waitForAccess","isWindows","process","platform","test","env","OSTYPE","MANDATORY_ATTRIBUTES","SymbolicLinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","join","normalizedLinkpath","linkpath","linkFullPath","linkRelativePath","dirname","relative","queue","force","defer","err","code","bind","symlink","await","Promise","resolve","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,aAAa,kBAAkB;AACtC,OAAOC,kBAAkB,uBAAuB;AAChD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAE3F,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMC,oBAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBtB,KAAKuB,SAAS,CAAC,IAAI,CAACvB,IAAI;gBAC/C,MAAMwB,WAAWxB,KAAKyB,IAAI,CAACN,MAAMZ,UAAUe,gBAAgBF;gBAC3D,IAAIM,qBAAqB1B,KAAKuB,SAAS,CAAC,IAAI,CAACI,QAAQ;gBACrD,IAAIC,eAA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AACxB,MAAM,CAACC,MAAMC,SAAS,CAACe,KAAaQ,OAAoBR,MAAMO,OAAOP,OAAOM,QAAQE;QAC3F;IACF;IAEAC,UAAU,CAAC;IAtDX,YAAYC,UAA0B,CAAE;QACtCrC,mBAAmBqC,YAAY7B;QAC/BV,aAAa,IAAI,EAAEuC;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAG9C,KAAK8C,QAAQ,CAAC,IAAI,CAAC9C,IAAI;QACxE,IAAI,IAAI,CAACgD,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AAkDF;AA/DA,SAAqB/B,+BA+DpB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n basename: string;\n type: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n // Resolve the symlink target against the symlink's own directory and verify it\n // stays within dest. safeJoinPath throws ETRAVERSAL if it escapes.\n const targetAbs = path.resolve(path.dirname(fullPath), this.linkpath);\n safeJoinPath(dest, path.relative(dest, targetAbs));\n const normalizedLinkpath = path.relative(path.dirname(fullPath), targetAbs);\n const linkFullPath = targetAbs;\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkdirp.bind(null, path.dirname(fullPath)));\n if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));\n else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));\n queue.defer(waitForAccess.bind(null, fullPath, true)); // noFollow=true for symlinks\n queue.defer(chmod.bind(null, fullPath, this, options));\n queue.defer(chown.bind(null, fullPath, this, options));\n queue.defer(lutimes.bind(null, fullPath, this, options));\n queue.await(callback);\n } catch (err) {\n callback(err);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options, (err?: Error, done?: boolean) => (err ? reject(err) : resolve(done))));\n }\n\n destroy() {}\n}\n"],"names":["fs","rm","isAbsolute","mkdirp","path","Queue","chmod","chown","lutimes","symlinkWin32","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","isWindows","process","platform","test","env","OSTYPE","MANDATORY_ATTRIBUTES","SymbolicLinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","linkpath","err","Error","code","targetAbs","resolve","dirname","relative","normalizedLinkpath","linkFullPath","queue","force","defer","bind","symlink","await","Promise","reject","done","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,aAAa,kBAAkB;AACtC,OAAOC,kBAAkB,uBAAuB;AAChD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAE3F,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMC,oBAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBvB,KAAKwB,SAAS,CAAC,IAAI,CAACxB,IAAI;gBAC/C,MAAMyB,WAAWlB,aAAaa,MAAMZ,UAAUe,gBAAgBF;gBAE9D,IAAIvB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K,CAACnB;YACd,EAAE,OAAOK,KAAK;gBACZL,SAASK;YACX;YACA;QACF;QAEA,OAAO,IAAIe,QAAQ,CAACX,SAASY,SAAW,IAAI,CAACxB,MAAM,CAACC,MAAMC,SAAS,CAACM,KAAaiB,OAAoBjB,MAAMgB,OAAOhB,OAAOI,QAAQa;IACnI;IAEAC,UAAU,CAAC;IAxDX,YAAYC,UAA0B,CAAE;QACtCrC,mBAAmBqC,YAAY7B;QAC/BX,aAAa,IAAI,EAAEwC;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAG/C,KAAK+C,QAAQ,CAAC,IAAI,CAAC/C,IAAI;QACxE,IAAI,IAAI,CAACiD,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AAoDF;AAjEA,SAAqB/B,+BAiEpB"}
@@ -22,5 +22,6 @@ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
22
22
  export { default as EntryStream } from './EntryStream.js';
23
23
  export { type CleanupFn, default as Lock } from './Lock.js';
24
24
  export { default as normalizePath } from './normalizePath.js';
25
+ export { default as safeJoinPath } from './safeJoinPath.js';
25
26
  export { default as streamToString, type StreamToStringCallback } from './streamToString.js';
26
27
  export { default as stripPath } from './stripPath.js';
@@ -15,5 +15,6 @@ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
15
15
  export { default as EntryStream } from './EntryStream.js';
16
16
  export { default as Lock } from './Lock.js';
17
17
  export { default as normalizePath } from './normalizePath.js';
18
+ export { default as safeJoinPath } from './safeJoinPath.js';
18
19
  export { default as streamToString } from './streamToString.js';
19
20
  export { default as stripPath } from './stripPath.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nimport BufferList from './BufferList.ts';\n\nexport { BufferList };\n\n/**\n * Type alias for Buffer or BufferList - both can be read byte-by-byte.\n * Use this when an API should accept either contiguous data (Buffer)\n * or chunked streaming data (BufferList).\n */\nexport type BufferLike = Buffer | BufferList;\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n canAllocateBufferSize,\n createInflateRawStream,\n inflateRaw,\n isNaN,\n MAX_SAFE_BUFFER_LENGTH,\n objectAssign,\n PassThrough,\n Readable,\n readUInt64LE,\n Transform,\n Writable,\n writeUInt64LE,\n} from './compat.ts';\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\nexport { default as EntryStream } from './EntryStream.ts';\nexport { type CleanupFn, default as Lock } from './Lock.ts';\nexport { default as normalizePath } from './normalizePath.ts';\nexport { default as streamToString, type StreamToStringCallback } from './streamToString.ts';\nexport { default as stripPath } from './stripPath.ts';\n"],"names":["BufferList","allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","canAllocateBufferSize","createInflateRawStream","inflateRaw","isNaN","MAX_SAFE_BUFFER_LENGTH","objectAssign","PassThrough","Readable","readUInt64LE","Transform","Writable","writeUInt64LE","crc32","crc32Region","verifyCrc32","verifyCrc32Region","default","EntryStream","Lock","normalizePath","streamToString","stripPath"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,OAAOA,gBAAgB,kBAAkB;AAEzC,SAASA,UAAU,GAAG;AAQtB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,eAAe,EACfC,qBAAqB,EACrBC,sBAAsB,EACtBC,UAAU,EACVC,KAAK,EACLC,sBAAsB,EACtBC,YAAY,EACZC,WAAW,EACXC,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,QAAQ,EACRC,aAAa,QACR,cAAc;AACrB,SAASC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,aAAa;AAChF,SAASC,WAAWC,WAAW,QAAQ,mBAAmB;AAC1D,SAAyBD,WAAWE,IAAI,QAAQ,YAAY;AAC5D,SAASF,WAAWG,aAAa,QAAQ,qBAAqB;AAC9D,SAASH,WAAWI,cAAc,QAAqC,sBAAsB;AAC7F,SAASJ,WAAWK,SAAS,QAAQ,iBAAiB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nimport BufferList from './BufferList.ts';\n\nexport { BufferList };\n\n/**\n * Type alias for Buffer or BufferList - both can be read byte-by-byte.\n * Use this when an API should accept either contiguous data (Buffer)\n * or chunked streaming data (BufferList).\n */\nexport type BufferLike = Buffer | BufferList;\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n canAllocateBufferSize,\n createInflateRawStream,\n inflateRaw,\n isNaN,\n MAX_SAFE_BUFFER_LENGTH,\n objectAssign,\n PassThrough,\n Readable,\n readUInt64LE,\n Transform,\n Writable,\n writeUInt64LE,\n} from './compat.ts';\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\nexport { default as EntryStream } from './EntryStream.ts';\nexport { type CleanupFn, default as Lock } from './Lock.ts';\nexport { default as normalizePath } from './normalizePath.ts';\nexport { default as safeJoinPath } from './safeJoinPath.ts';\nexport { default as streamToString, type StreamToStringCallback } from './streamToString.ts';\nexport { default as stripPath } from './stripPath.ts';\n"],"names":["BufferList","allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","canAllocateBufferSize","createInflateRawStream","inflateRaw","isNaN","MAX_SAFE_BUFFER_LENGTH","objectAssign","PassThrough","Readable","readUInt64LE","Transform","Writable","writeUInt64LE","crc32","crc32Region","verifyCrc32","verifyCrc32Region","default","EntryStream","Lock","normalizePath","safeJoinPath","streamToString","stripPath"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,OAAOA,gBAAgB,kBAAkB;AAEzC,SAASA,UAAU,GAAG;AAQtB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,eAAe,EACfC,qBAAqB,EACrBC,sBAAsB,EACtBC,UAAU,EACVC,KAAK,EACLC,sBAAsB,EACtBC,YAAY,EACZC,WAAW,EACXC,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,QAAQ,EACRC,aAAa,QACR,cAAc;AACrB,SAASC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,aAAa;AAChF,SAASC,WAAWC,WAAW,QAAQ,mBAAmB;AAC1D,SAAyBD,WAAWE,IAAI,QAAQ,YAAY;AAC5D,SAASF,WAAWG,aAAa,QAAQ,qBAAqB;AAC9D,SAASH,WAAWI,YAAY,QAAQ,oBAAoB;AAC5D,SAASJ,WAAWK,cAAc,QAAqC,sBAAsB;AAC7F,SAASL,WAAWM,SAAS,QAAQ,iBAAiB"}
@@ -0,0 +1 @@
1
+ export default function safeJoinPath(dest: string, relPath: string): string;
@@ -0,0 +1,11 @@
1
+ import path from 'path';
2
+ export default function safeJoinPath(dest, relPath) {
3
+ const resolvedDest = path.resolve(dest);
4
+ const resolvedFull = path.resolve(dest, relPath);
5
+ if (resolvedFull !== resolvedDest && !resolvedFull.startsWith(resolvedDest + path.sep)) {
6
+ const err = new Error(`Path traversal detected: '${relPath}' escapes destination '${dest}'`);
7
+ err.code = 'ETRAVERSAL';
8
+ throw err;
9
+ }
10
+ return resolvedFull;
11
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/safeJoinPath.ts"],"sourcesContent":["import path from 'path';\n\nexport default function safeJoinPath(dest: string, relPath: string): string {\n const resolvedDest = path.resolve(dest);\n const resolvedFull = path.resolve(dest, relPath);\n if (resolvedFull !== resolvedDest && !resolvedFull.startsWith(resolvedDest + path.sep)) {\n const err = new Error(`Path traversal detected: '${relPath}' escapes destination '${dest}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n return resolvedFull;\n}\n"],"names":["path","safeJoinPath","dest","relPath","resolvedDest","resolve","resolvedFull","startsWith","sep","err","Error","code"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,eAAe,SAASC,aAAaC,IAAY,EAAEC,OAAe;IAChE,MAAMC,eAAeJ,KAAKK,OAAO,CAACH;IAClC,MAAMI,eAAeN,KAAKK,OAAO,CAACH,MAAMC;IACxC,IAAIG,iBAAiBF,gBAAgB,CAACE,aAAaC,UAAU,CAACH,eAAeJ,KAAKQ,GAAG,GAAG;QACtF,MAAMC,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEP,QAAQ,uBAAuB,EAAED,KAAK,CAAC,CAAC;QAC3FO,IAAIE,IAAI,GAAG;QACX,MAAMF;IACR;IACA,OAAOH;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-base-iterator",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
5
5
  "keywords": [
6
6
  "extract",