{"analyzedAt":"2022-07-13T08:18:28.525Z","collected":{"metadata":{"name":"@everis-scp/smb2","scope":"everis-scp","version":"0.19.1","description":"SMB2 Client","keywords":["SMB","SMB2","SMB3","NTLM","CIFS","Samba"],"date":"2021-07-29T00:53:25.851Z","author":{"name":"Benjamin Chelli","email":"benjamin@chelli.net","url":"https://github.com/bchelli"},"publisher":{"username":"ctapisab","email":"christian.eduardo.tapia.sabogal@everis.com"},"maintainers":[{"username":"ctapisab","email":"christian.eduardo.tapia.sabogal@everis.com"},{"username":"dgarciac","email":"diego.sebastian.garcia.carlos@everis.com"}],"contributors":[{"name":"Fabrice Marsaud","email":"fabrice.marsaud@vates.fr","url":"https://github.com/marsaud"}],"repository":{"type":"git","url":"git+https://github.com/everis-scp/smb2-client.git"},"links":{"npm":"https://www.npmjs.com/package/%40everis-scp%2Fsmb2","homepage":"https://github.com/everis-scp/smb2-client","repository":"https://github.com/everis-scp/smb2-client","bugs":"https://github.com/everis-scp/smb2-client/issues"},"license":"MIT","dependencies":{"ntlm":"~0.1.1","readable-stream":"^3.0.6"},"devDependencies":{"@iarna/toml":"^2.2.1","eslint":"^5.9.0","eslint-config-prettier":"^4.2.0","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.14.0","eslint-plugin-node":"^9.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","get-stream":"^5.1.0","golike-defer":"^0.4.1","husky":"^2.2.0","lint-staged":"^8.1.0","prettier":"^1.15.3","promise-toolbox":"^0.15.0","tap":"^13.1.2"},"releases":[{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":1},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":3},{"from":"2020-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":6}],"hasTestScript":true,"readme":"# SMB2 Client for Node.js\n\n[![Node compatibility](https://badgen.net/npm/node/@marsaud/smb2)](https://npmjs.org/package/@marsaud/smb2) [![License](https://badgen.net/npm/license/@marsaud/smb2)](https://npmjs.org/package/@marsaud/smb2) [![PackagePhobia](https://badgen.net/packagephobia/install/@marsaud/smb2)](https://packagephobia.now.sh/result?p=@marsaud/smb2)\n\n[![Package Version](https://badgen.net/npm/v/@marsaud/smb2)](https://npmjs.org/package/@marsaud/smb2) [![Build Status](https://travis-ci.org/Node-SMB/marsaud-smb2.png?branch=master)](https://travis-ci.org/Node-SMB/marsaud-smb2) [![Latest Commit](https://badgen.net/github/last-commit/Node-SMB/marsaud-smb2)](https://github.com/Node-SMB/marsaud-smb2/commits/master)\n\n## Introduction\n\nThis library is a simple implementation of SMB2 for Node.js. It allows you to access a SMB2 share as if you were using the native fs library.\n\nThe development is still at an experimental stage and should not be yet considered for production environment.\n\n## Installation\n\n```bash\nnpm install -S @everis-scp/smb2\n```\n\n## API\n\n### Asynchronicity\n\nAll async methods can be used with Node-style callbacks or return promises if\nnone is passed:\n\n```js\n// Node-style callback\nsmb2Client.readFile('foo.txt', function(err, content) {\n  if (err) throw err;\n  console.log(content);\n});\n\n// With promise, ideal with ES2017 async functions\nconst content = await smb2Client.readFile('foo.txt');\nconsole.log(content);\n```\n\n### Construction\n\n> `var smb2Client = new SMB2 ( options )`\n\nThe SMB2 class is the constructor of your SMB2 client.\n\nthe parameter `options` accepts this list of attributes:\n\n- `share`: the share you want to access\n- `domain`: the domain of which the user is registered\n- `username`: the username of the user that access the share\n- `password`: the password\n- `port` (optional): default `445`, the port of the SMB server\n- `socket` (optional): default `new net.Socket (from NodeJS Core)`, the socket used for communication with the SMB Server\n- `packetConcurrency` (optional): default `20`, the number of simultaneous packet when writing / reading data from the share\n- `autoCloseTimeout` (optional): default `10000`, the timeout in milliseconds before to close the SMB2 session and the socket, if set to `0` the connection will never be closed unless you do it\n\nExample:\n\n```javascript\n// load the library\nvar SMB2 = require('@everis-scp/smb2');\n\n// create an SMB2 instance\nvar smb2Client = new SMB2({\n  share: '\\\\\\\\000.000.000.000\\\\c$',\n  domain: 'DOMAIN',\n  username: 'username',\n  password: 'password!',\n});\n```\n\n### Connection management\n\nThe connection to the SMB server will be automatically open when necessary.\n\nUnless you have set `autoCloseTimeout` to `0` during client construction, the connection will be closed automatically.\n\nIf you have set `autoCloseTimeout` to `0`, the connection MUST be closed manually:\n\n```js\nsmb2Client.disconnect();\n```\n\n### High level methods\n\n> `smb2Client.exists ( path, callback )`\n\nTest whether or not the given path exists by checking with the file system.\n\nExample:\n\n```javascript\nsmb2Client.exists('path\\\\to\\\\my\\\\file.txt', function(err, exists) {\n  if (err) throw err;\n  console.log(exists ? \"it's there\" : \"it's not there!\");\n});\n```\n\n> `smb2Client.mkdir ( path, [mode], callback )`\n\nAsynchronous `mkdir(2)`: create a directory.\n\n`mode` defaults to `0o777`.\n\nExample:\n\n```javascript\nsmb2Client.mkdir('path\\\\to\\\\the\\\\directory', function(err) {\n  if (err) throw err;\n  console.log('Directory created!');\n});\n```\n\n> `smb2Client.readdir ( path, [options], callback )`\n\n- `path` String\n- `options` Object\n  - `encoding` String | Null default = null\n- `callback` Function\n\nAsynchronous `readdir(3)`: reads the contents of a directory.\n\nThe result is an array of the names of the files in the directory excluding `'.'` and `'..'`.\n\nIf you want the response to include stats, you need to pass the `stats: true`. Response will be an Array of this form:\n\n```\n[\n    {\n        name: String,\n        birthtime: Date,\n        mtime: Date,\n        atime: Date,\n        ctime: Date,\n        isDirectory(): boolean\n    },\n...\n]\n```\n\nExample:\n\n```javascript\nsmb2Client.readdir('Windows\\\\System32', function(err, files) {\n  if (err) throw err;\n  console.log(files);\n});\n```\n\n> `smb2Client.stat ( path, callback )`\n\n- `path` String\n- `callback` Function\n\nAsynchronous `stat`: query stats of a directory or file.\n\nResponse will be an object with the following structure :\n\n```\n{\n    birthtime: Date,\n    mtime: Date,\n    atime: Date,\n    ctime: Date,\n    isDirectory(): boolean\n}\n```\n\n> `smb2Client.readFile ( path, [options], callback )`\n\n- `path` String\n- `options` Object\n  - `encoding` String | Null default = null\n- `callback` Function\n\nAsynchronously reads the entire content of a file.\n\nExample:\n\n```javascript\nsmb2Client.readFile('path\\\\to\\\\my\\\\file.txt', function(err, content) {\n  if (err) throw err;\n  console.log(content);\n});\n```\n\nIf no encoding is specified, then the raw buffer is returned.\n\n> `smb2Client.rename ( oldPath, newPath, [ options, ] callback )`\n\nAsynchronous `rename(2)`: rename a file.\n\n```javascript\nsmb2Client.rename(\n  'path\\\\to\\\\my\\\\file.txt',\n  'new\\\\path\\\\to\\\\my\\\\new-file-name.txt',\n  function(err) {\n    if (err) throw err;\n    console.log('file has been renamed');\n  }\n);\n```\n\nExisting files are not replaced by default, you need to pass the `replace: true` option for this use case:\n\n```javascript\nsmb2Client.rename(\n  'path\\\\to\\\\my\\\\file.txt',\n  'path\\\\to\\\\existing\\\\file.txt',\n  {\n    replace: true\n  }\n  function(err) {\n    if (err) throw err;\n    console.log('file has been renamed');\n  }\n);\n```\n\n> `smb2Client.rmdir ( path, callback )`\n\nAsynchronous `rmdir(2)`: delete an empty directory.\n\nExample:\n\n```javascript\nsmb2Client.rmdir('path\\\\to\\\\the\\\\directory', function(err) {\n  if (err) throw err;\n  console.log('Directory deleted!');\n});\n```\n\n> `smb2Client.unlink ( path, callback )`\n\nAsynchronous `unlink(2)`: delete a file.\n\n```javascript\nsmb2Client.unlink('path\\\\to\\\\my\\\\file.txt', function(err) {\n  if (err) throw err;\n  console.log('file has been deleted');\n});\n```\n\n> `smb2Client.writeFile ( filename, data, [options], callback )`\n\n- `filename` String\n- `data` String | Buffer\n- `options` Object\n  - `encoding` String | Null default = `'utf8'`\n- `callback` Function\n\nAsynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer.\n\nThe encoding option is ignored if data is a buffer.\n\nExample:\n\n```javascript\nsmb2Client.writeFile('path\\\\to\\\\my\\\\file.txt', 'Hello Node', function(err) {\n  if (err) throw err;\n  console.log(\"It's saved!\");\n});\n```\n\n> `smb2Client.truncate ( filename, length, callback )`\n\n- `filename` String\n- `length` Number\n- `callback` Function\n\nAsynchronously truncate a file to a size of precisely length bytes.\n\nExample:\n\n```javascript\nsmb2Client.truncate('path\\\\to\\\\my\\\\file.txt', 10, function(err) {\n  if (err) throw err;\n  console.log(\"It's truncated!\");\n});\n```\n\n### Streams\n\n> `smb2Client.createReadStream ( fileName, [options], callback )`\n\nReturns a read stream on the file.\n\n> Unlike `fs.createReadStream`, this function is asynchronous, as we need use asynchronous smb requests to get the stream.\n\nExample:\n\n```javascript\nsmb2Client.createReadStream('path\\\\to\\\\the\\\\file', function(err, readStream) {\n  if (err) throw err;\n  var writeStream = fs.createWriteStream('localFile');\n  readStream.pipe(writeStream);\n});\n```\n\nSupported options:\n\n- `autoClose`: whether the `fd` should be closed at the end or on error, default `true`\n- `end`: offset in the file after which to stop reading, default `Infinity`\n- `fd`: if specified, the path will be ignored and this opened file will be used instead\n- `flags`: see [Node documentation](https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_file_system_flags), default `'r'`\n- `start`: offset in the file from which to start reading, default `0`\n\n> `smb2Client.createWriteStream ( fileName, [options], callback )`\n\nReturns a write stream on the file.\n\n> Unlike `fs.createWriteStream`, this function is asynchronous, as we need use asynchronous smb requests to get the stream.\n\nExample:\n\n```javascript\nsmb2Client.createWriteStream('path\\\\to\\\\the\\\\file', function(err, writeStream) {\n  if (err) throw err;\n  var readStream = fs.createReadStream('localFile');\n  readStream.pipe(writeStream);\n});\n```\n\nSupported options:\n\n- `autoClose`: whether the `fd` should be closed at the end or on error, default `true`\n- `fd`: if specified, the path will be ignored and this opened file will be used instead\n- `flags`: see [Node documentation](https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_file_system_flags), default `'wx'`\n- `start`: offset in the file from which to start writing, default `0`\n\n### Low-level API\n\n```javascript\nsmb2Client.open('path\\\\to\\\\the\\\\file', 'r', function(err, fd) {\n  if (err) throw err;\n\n  smb2Client.read(\n    fd, // file descriptor\n    Buffer.alloc(10), // buffer where to store the data\n    0, // offset in the buffer\n    10, // number of bytes to read\n    0, // offset in the file\n    function(err, bytesRead, buffer) {\n      smb2Client.close(fd, function() {});\n\n      if (err) throw cb(err);\n      console.log(bytesRead, buffer);\n    }\n  );\n});\n\nsmb2Client.open('path\\\\to\\\\the\\\\file', 'w', function(err, fd) {\n  if (err) throw err;\n\n  smb2Client.write(\n    fd, // file descriptor\n    Buffer.from('foo bar\\n'), // data to write to the file\n    0, // offset in the buffer\n    10, // number of bytes to write\n    0, // offset in the file\n    function(err, bytesWritten, buffer) {\n      smb2Client.close(fd, function() {});\n\n      if (err) throw cb(err);\n      console.log(bytesWritten);\n    }\n  );\n});\n```\n\n> This API is modeled after Node's `fs` module.\n\n> Note: be careful of `autoCloseTimeout` with this process as it is not intended to cover multiple method calls, you should set it to `0` and manually `disconnect()`.\n\n## Contributors\n\n- [Benjamin Chelli](https://github.com/bchelli)\n- [Fabrice Marsaud](https://github.com/marsaud)\n\n## References\n\n    The[MS-SMB2]: Server Message Block (SMB) Protocol Versions 2 and 3\n    Copyright (C) 2014 Microsoft\n    http://msdn.microsoft.com/en-us/library/cc246482.aspx\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013-2014 Benjamin Chelli &lt;benjamin@chelli.net&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."},"npm":{"downloads":[{"from":"2022-07-12T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":5},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":173},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":458},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":802}],"starsCount":0},"github":{"forkOf":"justnotherdev/smb2-client","starsCount":1,"forksCount":0,"subscribersCount":1,"issues":{"count":0,"openCount":0,"distribution":{"3600":0,"10800":0,"32400":0,"97200":0,"291600":0,"874800":0,"2624400":0,"7873200":0,"23619600":0,"70858800":0,"212576400":0},"isDisabled":true},"contributors":[{"username":"vdiez","commitsCount":4},{"username":"bhsdodo","commitsCount":1},{"username":"pkeuter","commitsCount":3},{"username":"julien-f","commitsCount":76},{"username":"jalfonso","commitsCount":1},{"username":"DGarcia1197","commitsCount":2},{"username":"ctapisab","commitsCount":1},{"username":"marsaud","commitsCount":23},{"username":"nraynaud","commitsCount":2},{"username":"jpogas","commitsCount":1},{"username":"Wescoeur","commitsCount":6},{"username":"nerminator","commitsCount":1},{"username":"bitdeli-chef","commitsCount":1},{"username":"bchelli","commitsCount":30},{"username":"GHEMID-Mohamed","commitsCount":2}],"commits":[{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":1}]},"source":{"files":{"readmeSize":11327,"testsSize":5108,"hasNpmIgnore":true},"badges":[{"urls":{"original":"https://travis-ci.org/Node-SMB/marsaud-smb2.png?branch=master","service":"https://api.travis-ci.org/Node-SMB/marsaud-smb2.svg?branch=master","shields":"https://img.shields.io/travis/Node-SMB/marsaud-smb2/master.svg","content":"https://img.shields.io/travis/Node-SMB/marsaud-smb2/master.json"},"info":{"service":"travis","type":"build","modifiers":{"branch":"master"}}}],"linters":["editorconfig","eslint","prettier"],"outdatedDependencies":{"readable-stream":{"required":"^3.0.6","stable":"4.1.0","latest":"4.1.0"}}}},"evaluation":{"quality":{"carefulness":0.45999999999999996,"tests":0.6,"health":0.75,"branding":0.15},"popularity":{"communityInterest":17,"downloadsCount":57.666666666666664,"downloadsAcceleration":-0.4208523592085236,"dependentsCount":0},"maintenance":{"releasesFrequency":0.44691780821917815,"commitsFrequency":0.011506849315068493,"openIssues":0.7,"issuesDistribution":0.7}},"score":{"final":0.5487678339696349,"detail":{"quality":0.8389283188634583,"popularity":0.05576906142254566,"maintenance":0.7930576194648757}}}