├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── examples ├── images.js ├── images │ ├── hello-rootfs.ext4 │ └── hello-vmlinux.bin ├── spawn.js └── startvm.js ├── lib ├── drive.js ├── firecracker.js ├── interface.js ├── machineconfig.js ├── mmds.js └── modem.js ├── package-lock.json ├── package.json └── test ├── firecracker.js └── helper.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | examples -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # firecrackerode 2 | 3 | Node.js client for Amazon's [Firecracker](http://firecracker-microvm.io) MicroVM platform. 4 | 5 | ## Installation 6 | 7 | `npm install firecrackerode` 8 | 9 | ## Usage 10 | 11 | * Check [Fireracker API documentation](https://github.com/firecracker-microvm/firecracker/blob/main/src/firecracker/swagger/firecracker.yaml) for more details. 12 | 13 | 14 | ### Getting started 15 | 16 | To use `firecrackerode` first you need to instantiate it: 17 | 18 | ``` js 19 | var Firecracker = require('firecrackerode'); 20 | var firecracker = new Firecracker({socketPath: '/tmp/firecracker.socket'}); 21 | ``` 22 | 23 | ### Creating a MicroVM 24 | 25 | ``` js 26 | //https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin 27 | firecracker.bootSource({ 28 | 'kernel_image_path': process.cwd() + '/images/hello-vmlinux.bin', 29 | 'boot_args': 'console=ttyS0 reboot=k panic=1 pci=off' 30 | }).then(function(data) { 31 | //https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4 32 | var drive = firecracker.drive('rootfs'); 33 | return drive.updatePreboot({ 34 | 'path_on_host': process.cwd() + '/images/hello-rootfs.ext4', 35 | 'is_root_device': true, 36 | 'is_read_only': false 37 | }); 38 | }).then(function(data) { 39 | return firecracker.action('InstanceStart'); 40 | }).then(function(data){ 41 | console.log('MicroVM booted!'); 42 | }).catch(function(err) { 43 | console.log(err); 44 | }); 45 | ``` 46 | 47 | ### Helper functions 48 | 49 | ``` js 50 | //Downloading an image 51 | firecracker.downloadImage('https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin', os.tmpdir() + '/hello-vmlinux.bin').then(function () { 52 | console.log('Kernel image downloaded!'); 53 | }).catch(function(err) { 54 | console.log(err); 55 | }); 56 | 57 | //Spawn Firecracker process 58 | firecracker.spawn().then(function () { 59 | console.log('Firecracker spawned!'); 60 | }).catch(function(err) { 61 | console.log(err); 62 | }); 63 | 64 | //Kill Firecracker process 65 | firecracker.kill() 66 | 67 | ``` 68 | 69 | ## Tests 70 | 71 | * You need a KVM host. 72 | * Tests are implemented using `mocha` and `chai`. Run them with `npm test`. 73 | 74 | ## Examples 75 | 76 | Check the examples folder for more specific use cases examples. 77 | 78 | ## License 79 | 80 | Pedro Dias - [@pedromdias](https://twitter.com/pedromdias) 81 | 82 | Licensed under the Apache license, version 2.0 (the "license"); You may not use this file except in compliance with the license. You may obtain a copy of the license at: 83 | 84 | http://www.apache.org/licenses/LICENSE-2.0.html 85 | 86 | Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license. 87 | -------------------------------------------------------------------------------- /examples/images.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | 3 | var Firecracker = require('../lib/firecracker'); 4 | var firecracker = new Firecracker({ socketPath: '/tmp/firecracker.socket' }); 5 | 6 | var kernelImg = 'https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin'; 7 | var rootImg = 'https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4'; 8 | 9 | firecracker.downloadImage(kernelImg, os.tmpdir() + '/hello-vmlinux.bin').then(function () { 10 | console.log('Kernel image downloaded!'); 11 | return firecracker.downloadImage(rootImg, os.tmpdir() + '/hello-rootfs.ext4'); 12 | }).then(function () { 13 | console.log('Filesystem image downloaded!'); 14 | }).catch(function (err) { 15 | console.log(err); 16 | }); -------------------------------------------------------------------------------- /examples/images/hello-rootfs.ext4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocas/firecrackerode/9ecc5fd742b681ba17c10263e285afa41e3248ee/examples/images/hello-rootfs.ext4 -------------------------------------------------------------------------------- /examples/images/hello-vmlinux.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocas/firecrackerode/9ecc5fd742b681ba17c10263e285afa41e3248ee/examples/images/hello-vmlinux.bin -------------------------------------------------------------------------------- /examples/spawn.js: -------------------------------------------------------------------------------- 1 | var Firecracker = require('../lib/firecracker'); 2 | 3 | var firecracker = new Firecracker({ socketPath: '/tmp/firecracker.socket' }); 4 | var streams = firecracker.spawn('/root/firecracker'); 5 | 6 | process.on('SIGINT', function () { 7 | console.log('Killing Firecracker...'); 8 | firecracker.kill(); 9 | }); 10 | 11 | streams.stdout.on('data', (data) => { 12 | console.log(data.toString('utf8')); 13 | }); 14 | 15 | streams.stderr.on('data', (data) => { 16 | console.log(data.toString('utf8')); 17 | }); 18 | 19 | console.log('Firecracker started!'); -------------------------------------------------------------------------------- /examples/startvm.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | 3 | var Firecracker = require('../lib/firecracker'); 4 | var firecracker = new Firecracker({ socketPath: '/tmp/firecracker.socket' }); 5 | 6 | firecracker.bootSource({ 7 | 'kernel_image_path': os.tmpdir() + '/hello-vmlinux.bin', 8 | 'boot_args': 'console=ttyS0 reboot=k panic=1 pci=off' 9 | }).then(function () { 10 | var drive = firecracker.drive('rootfs'); 11 | return drive.updatePreboot({ 12 | 'path_on_host': os.tmpdir() + '/hello-rootfs.ext4', 13 | 'is_root_device': true, 14 | 'is_read_only': false 15 | }); 16 | }).then(function () { 17 | return firecracker.action('InstanceStart'); 18 | }).then(function () { 19 | console.log('MicroVM booted!'); 20 | }).catch(function (err) { 21 | console.log(err); 22 | }); 23 | -------------------------------------------------------------------------------- /lib/drive.js: -------------------------------------------------------------------------------- 1 | var Drive = function(modem, drive_id) { 2 | this.id = drive_id; 3 | this.modem = modem; 4 | }; 5 | 6 | Drive.prototype.updatePreboot = function (data, callback) { 7 | var self = this; 8 | if (!callback && typeof opts === 'function') { 9 | callback = opts; 10 | opts = undefined; 11 | } 12 | 13 | data.drive_id = this.id; 14 | 15 | var optsf = { 16 | path: '/drives/' + this.id, 17 | method: 'PUT', 18 | data: data, 19 | statusCodes: { 20 | 204: true, 21 | 400: 'Drive cannot be created/updated due to bad input' 22 | } 23 | }; 24 | 25 | if (callback === undefined) { 26 | return new Promise(function (resolve, reject) { 27 | self.modem.dial(optsf, function (err, data) { 28 | if (err) { 29 | return reject(err); 30 | } 31 | resolve(data); 32 | }); 33 | }); 34 | } else { 35 | this.modem.dial(optsf, function (err, data) { 36 | callback(err, data); 37 | }); 38 | } 39 | }; 40 | 41 | Drive.prototype.createPreboot = function(data, callback) { 42 | return this.updatePreboot.apply(this, [data, callback]); 43 | }; 44 | 45 | Drive.prototype.updatePostboot = function (data, callback) { 46 | var self = this; 47 | if (!callback && typeof opts === 'function') { 48 | callback = opts; 49 | opts = undefined; 50 | } 51 | 52 | data.drive_id = this.id; 53 | 54 | var optsf = { 55 | path: '/drives/' + this.id, 56 | method: 'PATCH', 57 | data: data, 58 | statusCodes: { 59 | 204: true, 60 | 400: 'Drive cannot be updated due to bad input' 61 | } 62 | }; 63 | 64 | if (callback === undefined) { 65 | return new Promise(function (resolve, reject) { 66 | self.modem.dial(optsf, function (err, data) { 67 | if (err) { 68 | return reject(err); 69 | } 70 | resolve(data); 71 | }); 72 | }); 73 | } else { 74 | this.modem.dial(optsf, function (err, data) { 75 | callback(err, data); 76 | }); 77 | } 78 | }; 79 | 80 | module.exports = Drive -------------------------------------------------------------------------------- /lib/firecracker.js: -------------------------------------------------------------------------------- 1 | const http = require('http'), 2 | https = require('https'), 3 | fs = require('fs'), 4 | path = require('path'), 5 | child_process = require('child_process'); 6 | 7 | const Modem = require('./modem'), 8 | Drive = require('./drive'), 9 | Interface = require('./interface'), 10 | MMDS = require('./mmds'), 11 | MachineConfig = require('./machineconfig'); 12 | 13 | var Firecracker = function (opts) { 14 | this.options = opts; 15 | this.modem = new Modem(opts); 16 | }; 17 | 18 | Firecracker.prototype.info = function (callback) { 19 | var self = this; 20 | if (!callback && typeof opts === 'function') { 21 | callback = opts; 22 | opts = undefined; 23 | } 24 | 25 | var optsf = { 26 | path: '/', 27 | method: 'GET', 28 | statusCodes: { 29 | 200: true 30 | } 31 | }; 32 | 33 | if (callback === undefined) { 34 | return new Promise(function (resolve, reject) { 35 | self.modem.dial(optsf, function (err, data) { 36 | if (err) { 37 | return reject(err); 38 | } 39 | resolve(data); 40 | }); 41 | }); 42 | } else { 43 | this.modem.dial(optsf, function (err, data) { 44 | callback(err, data); 45 | }); 46 | } 47 | }; 48 | 49 | Firecracker.prototype.action = function (action, callback) { 50 | var self = this; 51 | if (!callback && typeof opts === 'function') { 52 | callback = opts; 53 | opts = undefined; 54 | } 55 | 56 | var optsf = { 57 | path: '/actions', 58 | method: 'PUT', 59 | data: { 'action_type': action }, 60 | statusCodes: { 61 | 204: true, 62 | 400: 'The action cannot be executed due to bad input' 63 | } 64 | }; 65 | 66 | if (callback === undefined) { 67 | return new Promise(function (resolve, reject) { 68 | self.modem.dial(optsf, function (err, data) { 69 | if (err) { 70 | return reject(err); 71 | } 72 | resolve(data); 73 | }); 74 | }); 75 | } else { 76 | this.modem.dial(optsf, function (err, data) { 77 | callback(err, data); 78 | }); 79 | } 80 | }; 81 | 82 | Firecracker.prototype.bootSource = function (data, callback) { 83 | var self = this; 84 | if (!callback && typeof opts === 'function') { 85 | callback = opts; 86 | opts = undefined; 87 | } 88 | 89 | var optsf = { 90 | path: '/boot-source', 91 | method: 'PUT', 92 | data: data, 93 | statusCodes: { 94 | 204: true, 95 | 400: 'Boot source cannot be created due to bad input' 96 | } 97 | }; 98 | 99 | if (callback === undefined) { 100 | return new Promise(function (resolve, reject) { 101 | self.modem.dial(optsf, function (err, data) { 102 | if (err) { 103 | return reject(err); 104 | } 105 | resolve(data); 106 | }); 107 | }); 108 | } else { 109 | this.modem.dial(optsf, function (err, data) { 110 | callback(err, data); 111 | }); 112 | } 113 | }; 114 | 115 | Firecracker.prototype.mmds = function () { 116 | return new MMDS(this.modem); 117 | }; 118 | 119 | Firecracker.prototype.drive = function (id) { 120 | return new Drive(this.modem, id); 121 | }; 122 | 123 | Firecracker.prototype.interface = function (id) { 124 | return new Interface(this.modem, id); 125 | }; 126 | 127 | Firecracker.prototype.machineConfig = function () { 128 | return new MachineConfig(this.modem); 129 | }; 130 | 131 | Firecracker.prototype.logger = function (data, callback) { 132 | var self = this; 133 | if (!callback && typeof opts === 'function') { 134 | callback = opts; 135 | opts = undefined; 136 | } 137 | 138 | var optsf = { 139 | path: '/logger', 140 | method: 'PUT', 141 | data: data, 142 | statusCodes: { 143 | 204: true, 144 | 400: 'Logger cannot be initialized due to bad input.' 145 | } 146 | }; 147 | 148 | if (callback === undefined) { 149 | return new Promise(function (resolve, reject) { 150 | self.modem.dial(optsf, function (err, data) { 151 | if (err) { 152 | return reject(err); 153 | } 154 | resolve(data); 155 | }); 156 | }); 157 | } else { 158 | this.modem.dial(optsf, function (err, data) { 159 | callback(err, data); 160 | }); 161 | } 162 | }; 163 | 164 | Firecracker.prototype.metrics = function (data, callback) { 165 | var self = this; 166 | if (!callback && typeof opts === 'function') { 167 | callback = opts; 168 | opts = undefined; 169 | } 170 | 171 | var optsf = { 172 | path: '/metrics', 173 | method: 'PUT', 174 | data: data, 175 | statusCodes: { 176 | 204: true, 177 | 400: 'Metrics system cannot be initialized due to bad input.' 178 | } 179 | }; 180 | 181 | if (callback === undefined) { 182 | return new Promise(function (resolve, reject) { 183 | self.modem.dial(optsf, function (err, data) { 184 | if (err) { 185 | return reject(err); 186 | } 187 | resolve(data); 188 | }); 189 | }); 190 | } else { 191 | this.modem.dial(optsf, function (err, data) { 192 | callback(err, data); 193 | }); 194 | } 195 | }; 196 | 197 | Firecracker.prototype.vsock = function (data, callback) { 198 | var self = this; 199 | if (!callback && typeof opts === 'function') { 200 | callback = opts; 201 | opts = undefined; 202 | } 203 | 204 | var optsf = { 205 | path: '/vsock', 206 | method: 'PUT', 207 | data: data, 208 | statusCodes: { 209 | 204: true, 210 | 400: 'Vsock cannot be created due to bad input' 211 | } 212 | }; 213 | 214 | if (callback === undefined) { 215 | return new Promise(function (resolve, reject) { 216 | self.modem.dial(optsf, function (err, data) { 217 | if (err) { 218 | return reject(err); 219 | } 220 | resolve(data); 221 | }); 222 | }); 223 | } else { 224 | this.modem.dial(optsf, function (err, data) { 225 | callback(err, data); 226 | }); 227 | } 228 | }; 229 | 230 | Firecracker.prototype.downloadImage = function (url, dest) { 231 | const uri = new URL(url); 232 | var proto = http; 233 | if (uri.protocol === 'https:') { 234 | proto = https; 235 | } 236 | 237 | //var filename = path.posix.basename(uri.pathname); 238 | //dest = dest + path.delimiter + filename; 239 | 240 | return new Promise((resolve, reject) => { 241 | if (fs.existsSync(dest)) { 242 | return reject('File already exists'); 243 | } 244 | 245 | let file = fs.createWriteStream(dest, { flags: 'wx' }); 246 | 247 | file.on('finish', () => { 248 | resolve(); 249 | }); 250 | 251 | file.on('error', err => { 252 | file.close(); 253 | fs.unlink(dest, () => { }); 254 | reject(err.message); 255 | }); 256 | 257 | const request = proto.get(url, response => { 258 | if (response.statusCode === 200) { 259 | response.pipe(file); 260 | } else { 261 | file.close(); 262 | fs.unlink(dest, () => { }); 263 | reject(`Server responded with ${response.statusCode}: ${response.statusMessage}`); 264 | } 265 | }); 266 | 267 | request.on('error', err => { 268 | file.close(); 269 | fs.unlink(dest, () => { }); 270 | reject(err.message); 271 | }); 272 | }); 273 | }; 274 | 275 | Firecracker.prototype.spawn = function (binPath) { 276 | var self = this; 277 | binPath = binPath || '/usr/bin/firecracker'; 278 | 279 | return new Promise(function (resolve, reject) { 280 | self.child = child_process.spawn(binPath, ['--api-sock', self.options.socketPath], { detached: true }); 281 | 282 | self.child.on('exit', function (code, signal) { 283 | fs.unlink(self.options.socketPath, () => { }); 284 | self.child = undefined; 285 | }); 286 | 287 | self.child.on('close', function (code, signal) { 288 | fs.unlink(self.options.socketPath, () => { }); 289 | self.child = undefined; 290 | }); 291 | 292 | self.child.on('error', function (err) { 293 | fs.unlink(self.options.socketPath, () => { }); 294 | }); 295 | 296 | resolve(self.child); 297 | }); 298 | }; 299 | 300 | Firecracker.prototype.kill = function () { 301 | var killed = this.child.kill(); 302 | if(killed === true) { 303 | fs.unlink(this.options.socketPath, () => { }); 304 | this.child = undefined; 305 | } 306 | return killed; 307 | }; 308 | 309 | module.exports = Firecracker; -------------------------------------------------------------------------------- /lib/interface.js: -------------------------------------------------------------------------------- 1 | var Interface = function(modem, interface_id) { 2 | this.id = interface_id; 3 | this.modem = modem; 4 | }; 5 | 6 | Interface.prototype.create = function (data, callback) { 7 | var self = this; 8 | if (!callback && typeof opts === 'function') { 9 | callback = opts; 10 | opts = undefined; 11 | } 12 | 13 | data.iface_id = this.id; 14 | 15 | var optsf = { 16 | path: '/network-interfaces/' + this.id, 17 | method: 'PUT', 18 | data: data, 19 | statusCodes: { 20 | 204: true, 21 | 400: 'Network interface cannot be created due to bad input' 22 | } 23 | }; 24 | 25 | if (callback === undefined) { 26 | return new Promise(function (resolve, reject) { 27 | self.modem.dial(optsf, function (err, data) { 28 | if (err) { 29 | return reject(err); 30 | } 31 | resolve(data); 32 | }); 33 | }); 34 | } else { 35 | this.modem.dial(optsf, function (err, data) { 36 | callback(err, data); 37 | }); 38 | } 39 | }; 40 | 41 | Interface.prototype.update = function (data, callback) { 42 | var self = this; 43 | if (!callback && typeof opts === 'function') { 44 | callback = opts; 45 | opts = undefined; 46 | } 47 | 48 | data.iface_id = this.id; 49 | 50 | var optsf = { 51 | path: '/network-interfaces/' + this.id, 52 | method: 'PATCH', 53 | data: data, 54 | statusCodes: { 55 | 204: true, 56 | 400: 'Network interface cannot be updated due to bad input' 57 | } 58 | }; 59 | 60 | if (callback === undefined) { 61 | return new Promise(function (resolve, reject) { 62 | self.modem.dial(optsf, function (err, data) { 63 | if (err) { 64 | return reject(err); 65 | } 66 | resolve(data); 67 | }); 68 | }); 69 | } else { 70 | this.modem.dial(optsf, function (err, data) { 71 | callback(err, data); 72 | }); 73 | } 74 | }; 75 | 76 | module.exports = Interface -------------------------------------------------------------------------------- /lib/machineconfig.js: -------------------------------------------------------------------------------- 1 | var MachineConfig = function (modem) { 2 | this.modem = modem; 3 | }; 4 | 5 | 6 | MachineConfig.prototype.get = function (callback) { 7 | var self = this; 8 | if (!callback && typeof opts === 'function') { 9 | callback = opts; 10 | opts = undefined; 11 | } 12 | 13 | var optsf = { 14 | path: '/machine-config', 15 | method: 'GET', 16 | statusCodes: { 17 | 200: true 18 | } 19 | }; 20 | 21 | if (callback === undefined) { 22 | return new Promise(function (resolve, reject) { 23 | self.modem.dial(optsf, function (err, data) { 24 | if (err) { 25 | return reject(err); 26 | } 27 | resolve(data); 28 | }); 29 | }); 30 | } else { 31 | this.modem.dial(optsf, function (err, data) { 32 | callback(err, data); 33 | }); 34 | } 35 | }; 36 | 37 | MachineConfig.prototype.update = function (data, callback) { 38 | var self = this; 39 | if (!callback && typeof opts === 'function') { 40 | callback = opts; 41 | opts = undefined; 42 | } 43 | 44 | var optsf = { 45 | path: '/machine-config', 46 | method: 'PUT', 47 | data: data, 48 | statusCodes: { 49 | 204: true, 50 | 400: 'Machine Configuration cannot be updated due to bad input' 51 | } 52 | }; 53 | 54 | if (callback === undefined) { 55 | return new Promise(function (resolve, reject) { 56 | self.modem.dial(optsf, function (err, data) { 57 | if (err) { 58 | return reject(err); 59 | } 60 | resolve(data); 61 | }); 62 | }); 63 | } else { 64 | this.modem.dial(optsf, function (err, data) { 65 | callback(err, data); 66 | }); 67 | } 68 | }; 69 | 70 | MachineConfig.prototype.partialUpdate = function (data, callback) { 71 | var self = this; 72 | if (!callback && typeof opts === 'function') { 73 | callback = opts; 74 | opts = undefined; 75 | } 76 | 77 | var optsf = { 78 | path: '/machine-config', 79 | method: 'PATCH', 80 | data: data, 81 | statusCodes: { 82 | 204: true, 83 | 400: 'Machine Configuration cannot be updated due to bad input' 84 | } 85 | }; 86 | 87 | if (callback === undefined) { 88 | return new Promise(function (resolve, reject) { 89 | self.modem.dial(optsf, function (err, data) { 90 | if (err) { 91 | return reject(err); 92 | } 93 | resolve(data); 94 | }); 95 | }); 96 | } else { 97 | this.modem.dial(optsf, function (err, data) { 98 | callback(err, data); 99 | }); 100 | } 101 | }; 102 | 103 | module.exports = MachineConfig; -------------------------------------------------------------------------------- /lib/mmds.js: -------------------------------------------------------------------------------- 1 | var MMDS = function(modem) { 2 | this.modem = modem; 3 | }; 4 | 5 | 6 | MMDS.prototype.create = function (callback) { 7 | var self = this; 8 | if (!callback && typeof opts === 'function') { 9 | callback = opts; 10 | opts = undefined; 11 | } 12 | 13 | var optsf = { 14 | path: '/mmds', 15 | method: 'PUT', 16 | data: {}, 17 | statusCodes: { 18 | 204: true, 19 | 400: 'MMDS data store cannot be created due to bad input.' 20 | } 21 | }; 22 | 23 | if (callback === undefined) { 24 | return new Promise(function (resolve, reject) { 25 | self.modem.dial(optsf, function (err, data) { 26 | if (err) { 27 | return reject(err); 28 | } 29 | resolve(data); 30 | }); 31 | }); 32 | } else { 33 | this.modem.dial(optsf, function (err, data) { 34 | callback(err, data); 35 | }); 36 | } 37 | }; 38 | 39 | MMDS.prototype.get = function (callback) { 40 | var self = this; 41 | if (!callback && typeof opts === 'function') { 42 | callback = opts; 43 | opts = undefined; 44 | } 45 | 46 | var optsf = { 47 | path: '/mmds', 48 | method: 'GET', 49 | statusCodes: { 50 | 204: true, 51 | 400: 'Cannot get the MMDS data store due to bad input.' 52 | } 53 | }; 54 | 55 | if (callback === undefined) { 56 | return new Promise(function (resolve, reject) { 57 | self.modem.dial(optsf, function (err, data) { 58 | if (err) { 59 | return reject(err); 60 | } 61 | resolve(data); 62 | }); 63 | }); 64 | } else { 65 | this.modem.dial(optsf, function (err, data) { 66 | callback(err, data); 67 | }); 68 | } 69 | }; 70 | 71 | MMDS.prototype.update = function (data, callback) { 72 | var self = this; 73 | if (!callback && typeof opts === 'function') { 74 | callback = opts; 75 | opts = undefined; 76 | } 77 | 78 | var optsf = { 79 | path: '/mmds/', 80 | method: 'PATCH', 81 | data: data, 82 | statusCodes: { 83 | 204: true, 84 | 400: 'MMDS data store cannot be updated due to bad input.' 85 | } 86 | }; 87 | 88 | if (callback === undefined) { 89 | return new Promise(function (resolve, reject) { 90 | self.modem.dial(optsf, function (err, data) { 91 | if (err) { 92 | return reject(err); 93 | } 94 | resolve(data); 95 | }); 96 | }); 97 | } else { 98 | this.modem.dial(optsf, function (err, data) { 99 | callback(err, data); 100 | }); 101 | } 102 | }; 103 | 104 | module.exports = MMDS; -------------------------------------------------------------------------------- /lib/modem.js: -------------------------------------------------------------------------------- 1 | var http = require('http'), 2 | debug = require('debug')('modem'), 3 | util = require('util'); 4 | 5 | 6 | var Modem = function (options) { 7 | this.socketPath = options.socketPath; 8 | this.timeout = options.timeout; 9 | this.connectionTimeout = options.connectionTimeout; 10 | this.headers = options.headers || {}; 11 | }; 12 | 13 | Modem.prototype.dial = function (options, callback) { 14 | var data; 15 | var self = this; 16 | 17 | var optionsf = { 18 | path: options.path, 19 | method: options.method, 20 | headers: options.headers || Object.assign({}, self.headers), 21 | }; 22 | 23 | optionsf.headers['Content-Type'] = 'application/json'; 24 | 25 | if (options.data) { 26 | data = JSON.stringify(options.data); 27 | optionsf.headers['Content-Length'] = Buffer.byteLength(data); 28 | } 29 | 30 | optionsf.socketPath = this.socketPath; 31 | 32 | this.buildRequest(optionsf, options, data, callback); 33 | }; 34 | 35 | Modem.prototype.buildRequest = function (options, context, data, callback) { 36 | var self = this; 37 | var connectionTimeoutTimer; 38 | 39 | var req = http.request(options, function () { }); 40 | 41 | debug('Sending: %s', util.inspect(options, { 42 | showHidden: true, 43 | depth: null 44 | })); 45 | 46 | if (self.connectionTimeout) { 47 | connectionTimeoutTimer = setTimeout(function () { 48 | debug('Connection Timeout of %s ms exceeded', self.connectionTimeout); 49 | req.abort(); 50 | }, self.connectionTimeout); 51 | } 52 | 53 | if (self.timeout) { 54 | req.on('socket', function (socket) { 55 | socket.setTimeout(self.timeout); 56 | socket.on('timeout', function () { 57 | debug('Timeout of %s ms exceeded', self.timeout); 58 | req.abort(); 59 | }); 60 | }); 61 | } 62 | 63 | req.on('connect', function () { 64 | clearTimeout(connectionTimeoutTimer); 65 | }); 66 | 67 | req.on('disconnect', function () { 68 | clearTimeout(connectionTimeoutTimer); 69 | }); 70 | 71 | req.on('response', function (res) { 72 | clearTimeout(connectionTimeoutTimer); 73 | 74 | var chunks = []; 75 | res.on('data', function (chunk) { 76 | chunks.push(chunk); 77 | }); 78 | 79 | res.on('end', function () { 80 | var buffer = Buffer.concat(chunks); 81 | var result = buffer.toString(); 82 | 83 | debug('Received: %s', result); 84 | 85 | var json; 86 | try { 87 | json = JSON.parse(result); 88 | } catch (e) { 89 | json = null; 90 | } 91 | self.buildPayload(null, context.statusCodes, res, json, callback); 92 | }); 93 | }); 94 | 95 | req.on('error', function (error) { 96 | clearTimeout(connectionTimeoutTimer); 97 | self.buildPayload(error, context.statusCodes, {}, null, callback); 98 | }); 99 | 100 | if(data) { 101 | req.write(data); 102 | } 103 | req.end(); 104 | }; 105 | 106 | Modem.prototype.buildPayload = function (err, statusCodes, res, json, cb) { 107 | if (err) return cb(err, null); 108 | 109 | if (statusCodes[res.statusCode] !== true) { 110 | var msg = new Error( 111 | '(HTTP code ' + res.statusCode + ') ' + 112 | (statusCodes[res.statusCode] || 'unexpected') + ' - ' + 113 | (json.fault_message || json) + ' ' 114 | ); 115 | msg.reason = statusCodes[res.statusCode]; 116 | msg.statusCode = res.statusCode; 117 | msg.json = json; 118 | cb(msg, null); 119 | } else { 120 | cb(null, json); 121 | } 122 | }; 123 | 124 | 125 | module.exports = Modem; 126 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firecrackerode", 3 | "version": "1.0.2", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ansi-colors": { 8 | "version": "4.1.1", 9 | "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", 10 | "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", 11 | "dev": true 12 | }, 13 | "ansi-regex": { 14 | "version": "5.0.1", 15 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 16 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", 17 | "dev": true 18 | }, 19 | "ansi-styles": { 20 | "version": "4.3.0", 21 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", 22 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", 23 | "dev": true, 24 | "requires": { 25 | "color-convert": "^2.0.1" 26 | } 27 | }, 28 | "anymatch": { 29 | "version": "3.1.3", 30 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 31 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 32 | "dev": true, 33 | "requires": { 34 | "normalize-path": "^3.0.0", 35 | "picomatch": "^2.0.4" 36 | } 37 | }, 38 | "argparse": { 39 | "version": "2.0.1", 40 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 41 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", 42 | "dev": true 43 | }, 44 | "assertion-error": { 45 | "version": "1.1.0", 46 | "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", 47 | "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", 48 | "dev": true 49 | }, 50 | "balanced-match": { 51 | "version": "1.0.2", 52 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 53 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 54 | "dev": true 55 | }, 56 | "binary-extensions": { 57 | "version": "2.2.0", 58 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", 59 | "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", 60 | "dev": true 61 | }, 62 | "brace-expansion": { 63 | "version": "1.1.11", 64 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 65 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 66 | "dev": true, 67 | "requires": { 68 | "balanced-match": "^1.0.0", 69 | "concat-map": "0.0.1" 70 | } 71 | }, 72 | "braces": { 73 | "version": "3.0.3", 74 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", 75 | "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", 76 | "dev": true, 77 | "requires": { 78 | "fill-range": "^7.1.1" 79 | }, 80 | "dependencies": { 81 | "fill-range": { 82 | "version": "7.1.1", 83 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", 84 | "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", 85 | "dev": true, 86 | "requires": { 87 | "to-regex-range": "^5.0.1" 88 | } 89 | } 90 | } 91 | }, 92 | "browser-stdout": { 93 | "version": "1.3.1", 94 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 95 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 96 | "dev": true 97 | }, 98 | "camelcase": { 99 | "version": "6.3.0", 100 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", 101 | "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", 102 | "dev": true 103 | }, 104 | "chai": { 105 | "version": "4.2.0", 106 | "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", 107 | "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", 108 | "dev": true, 109 | "requires": { 110 | "assertion-error": "^1.1.0", 111 | "check-error": "^1.0.2", 112 | "deep-eql": "^3.0.1", 113 | "get-func-name": "^2.0.0", 114 | "pathval": "^1.1.0", 115 | "type-detect": "^4.0.5" 116 | } 117 | }, 118 | "chalk": { 119 | "version": "4.1.2", 120 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", 121 | "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", 122 | "dev": true, 123 | "requires": { 124 | "ansi-styles": "^4.1.0", 125 | "supports-color": "^7.1.0" 126 | }, 127 | "dependencies": { 128 | "supports-color": { 129 | "version": "7.2.0", 130 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", 131 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", 132 | "dev": true, 133 | "requires": { 134 | "has-flag": "^4.0.0" 135 | } 136 | } 137 | } 138 | }, 139 | "check-error": { 140 | "version": "1.0.2", 141 | "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", 142 | "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", 143 | "dev": true 144 | }, 145 | "chokidar": { 146 | "version": "3.5.3", 147 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", 148 | "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", 149 | "dev": true, 150 | "requires": { 151 | "anymatch": "~3.1.2", 152 | "braces": "~3.0.2", 153 | "fsevents": "~2.3.2", 154 | "glob-parent": "~5.1.2", 155 | "is-binary-path": "~2.1.0", 156 | "is-glob": "~4.0.1", 157 | "normalize-path": "~3.0.0", 158 | "readdirp": "~3.6.0" 159 | } 160 | }, 161 | "cliui": { 162 | "version": "7.0.4", 163 | "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", 164 | "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", 165 | "dev": true, 166 | "requires": { 167 | "string-width": "^4.2.0", 168 | "strip-ansi": "^6.0.0", 169 | "wrap-ansi": "^7.0.0" 170 | } 171 | }, 172 | "color-convert": { 173 | "version": "2.0.1", 174 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", 175 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 176 | "dev": true, 177 | "requires": { 178 | "color-name": "~1.1.4" 179 | } 180 | }, 181 | "color-name": { 182 | "version": "1.1.4", 183 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 184 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", 185 | "dev": true 186 | }, 187 | "concat-map": { 188 | "version": "0.0.1", 189 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 190 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", 191 | "dev": true 192 | }, 193 | "debug": { 194 | "version": "4.3.4", 195 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 196 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 197 | "dev": true, 198 | "requires": { 199 | "ms": "2.1.2" 200 | }, 201 | "dependencies": { 202 | "ms": { 203 | "version": "2.1.2", 204 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 205 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 206 | "dev": true 207 | } 208 | } 209 | }, 210 | "decamelize": { 211 | "version": "4.0.0", 212 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", 213 | "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", 214 | "dev": true 215 | }, 216 | "deep-eql": { 217 | "version": "3.0.1", 218 | "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", 219 | "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", 220 | "dev": true, 221 | "requires": { 222 | "type-detect": "^4.0.0" 223 | } 224 | }, 225 | "diff": { 226 | "version": "5.0.0", 227 | "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", 228 | "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", 229 | "dev": true 230 | }, 231 | "emoji-regex": { 232 | "version": "8.0.0", 233 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 234 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", 235 | "dev": true 236 | }, 237 | "escalade": { 238 | "version": "3.1.1", 239 | "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", 240 | "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", 241 | "dev": true 242 | }, 243 | "escape-string-regexp": { 244 | "version": "4.0.0", 245 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", 246 | "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", 247 | "dev": true 248 | }, 249 | "find-up": { 250 | "version": "5.0.0", 251 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", 252 | "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", 253 | "dev": true, 254 | "requires": { 255 | "locate-path": "^6.0.0", 256 | "path-exists": "^4.0.0" 257 | } 258 | }, 259 | "flat": { 260 | "version": "5.0.2", 261 | "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", 262 | "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", 263 | "dev": true 264 | }, 265 | "fs.realpath": { 266 | "version": "1.0.0", 267 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 268 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", 269 | "dev": true 270 | }, 271 | "fsevents": { 272 | "version": "2.3.2", 273 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", 274 | "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", 275 | "dev": true, 276 | "optional": true 277 | }, 278 | "get-caller-file": { 279 | "version": "2.0.5", 280 | "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", 281 | "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", 282 | "dev": true 283 | }, 284 | "get-func-name": { 285 | "version": "2.0.0", 286 | "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", 287 | "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", 288 | "dev": true 289 | }, 290 | "glob": { 291 | "version": "7.2.0", 292 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", 293 | "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", 294 | "dev": true, 295 | "requires": { 296 | "fs.realpath": "^1.0.0", 297 | "inflight": "^1.0.4", 298 | "inherits": "2", 299 | "minimatch": "^3.0.4", 300 | "once": "^1.3.0", 301 | "path-is-absolute": "^1.0.0" 302 | }, 303 | "dependencies": { 304 | "minimatch": { 305 | "version": "3.1.2", 306 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 307 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 308 | "dev": true, 309 | "requires": { 310 | "brace-expansion": "^1.1.7" 311 | } 312 | } 313 | } 314 | }, 315 | "glob-parent": { 316 | "version": "5.1.2", 317 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 318 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 319 | "dev": true, 320 | "requires": { 321 | "is-glob": "^4.0.1" 322 | } 323 | }, 324 | "has-flag": { 325 | "version": "4.0.0", 326 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", 327 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", 328 | "dev": true 329 | }, 330 | "he": { 331 | "version": "1.2.0", 332 | "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", 333 | "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", 334 | "dev": true 335 | }, 336 | "inflight": { 337 | "version": "1.0.6", 338 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 339 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 340 | "dev": true, 341 | "requires": { 342 | "once": "^1.3.0", 343 | "wrappy": "1" 344 | } 345 | }, 346 | "inherits": { 347 | "version": "2.0.4", 348 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 349 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 350 | "dev": true 351 | }, 352 | "is-binary-path": { 353 | "version": "2.1.0", 354 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 355 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 356 | "dev": true, 357 | "requires": { 358 | "binary-extensions": "^2.0.0" 359 | } 360 | }, 361 | "is-extglob": { 362 | "version": "2.1.1", 363 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 364 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 365 | "dev": true 366 | }, 367 | "is-fullwidth-code-point": { 368 | "version": "3.0.0", 369 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 370 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", 371 | "dev": true 372 | }, 373 | "is-glob": { 374 | "version": "4.0.3", 375 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 376 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 377 | "dev": true, 378 | "requires": { 379 | "is-extglob": "^2.1.1" 380 | } 381 | }, 382 | "is-number": { 383 | "version": "7.0.0", 384 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 385 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 386 | "dev": true 387 | }, 388 | "is-plain-obj": { 389 | "version": "2.1.0", 390 | "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", 391 | "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", 392 | "dev": true 393 | }, 394 | "is-unicode-supported": { 395 | "version": "0.1.0", 396 | "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", 397 | "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", 398 | "dev": true 399 | }, 400 | "js-yaml": { 401 | "version": "4.1.0", 402 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", 403 | "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", 404 | "dev": true, 405 | "requires": { 406 | "argparse": "^2.0.1" 407 | } 408 | }, 409 | "locate-path": { 410 | "version": "6.0.0", 411 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", 412 | "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", 413 | "dev": true, 414 | "requires": { 415 | "p-locate": "^5.0.0" 416 | } 417 | }, 418 | "log-symbols": { 419 | "version": "4.1.0", 420 | "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", 421 | "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", 422 | "dev": true, 423 | "requires": { 424 | "chalk": "^4.1.0", 425 | "is-unicode-supported": "^0.1.0" 426 | } 427 | }, 428 | "minimatch": { 429 | "version": "5.0.1", 430 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", 431 | "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", 432 | "dev": true, 433 | "requires": { 434 | "brace-expansion": "^2.0.1" 435 | }, 436 | "dependencies": { 437 | "brace-expansion": { 438 | "version": "2.0.1", 439 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", 440 | "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", 441 | "dev": true, 442 | "requires": { 443 | "balanced-match": "^1.0.0" 444 | } 445 | } 446 | } 447 | }, 448 | "mocha": { 449 | "version": "10.2.0", 450 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", 451 | "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", 452 | "dev": true, 453 | "requires": { 454 | "ansi-colors": "4.1.1", 455 | "browser-stdout": "1.3.1", 456 | "chokidar": "3.5.3", 457 | "debug": "4.3.4", 458 | "diff": "5.0.0", 459 | "escape-string-regexp": "4.0.0", 460 | "find-up": "5.0.0", 461 | "glob": "7.2.0", 462 | "he": "1.2.0", 463 | "js-yaml": "4.1.0", 464 | "log-symbols": "4.1.0", 465 | "minimatch": "5.0.1", 466 | "ms": "2.1.3", 467 | "nanoid": "3.3.3", 468 | "serialize-javascript": "6.0.0", 469 | "strip-json-comments": "3.1.1", 470 | "supports-color": "8.1.1", 471 | "workerpool": "6.2.1", 472 | "yargs": "16.2.0", 473 | "yargs-parser": "20.2.4", 474 | "yargs-unparser": "2.0.0" 475 | } 476 | }, 477 | "ms": { 478 | "version": "2.1.3", 479 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 480 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 481 | "dev": true 482 | }, 483 | "nanoid": { 484 | "version": "3.3.3", 485 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", 486 | "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", 487 | "dev": true 488 | }, 489 | "normalize-path": { 490 | "version": "3.0.0", 491 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 492 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 493 | "dev": true 494 | }, 495 | "once": { 496 | "version": "1.4.0", 497 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 498 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 499 | "dev": true, 500 | "requires": { 501 | "wrappy": "1" 502 | } 503 | }, 504 | "p-limit": { 505 | "version": "3.1.0", 506 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", 507 | "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", 508 | "dev": true, 509 | "requires": { 510 | "yocto-queue": "^0.1.0" 511 | } 512 | }, 513 | "p-locate": { 514 | "version": "5.0.0", 515 | "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", 516 | "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", 517 | "dev": true, 518 | "requires": { 519 | "p-limit": "^3.0.2" 520 | } 521 | }, 522 | "path-exists": { 523 | "version": "4.0.0", 524 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", 525 | "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", 526 | "dev": true 527 | }, 528 | "path-is-absolute": { 529 | "version": "1.0.1", 530 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 531 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 532 | "dev": true 533 | }, 534 | "pathval": { 535 | "version": "1.1.1", 536 | "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", 537 | "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", 538 | "dev": true 539 | }, 540 | "picomatch": { 541 | "version": "2.3.1", 542 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 543 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 544 | "dev": true 545 | }, 546 | "randombytes": { 547 | "version": "2.1.0", 548 | "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", 549 | "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", 550 | "dev": true, 551 | "requires": { 552 | "safe-buffer": "^5.1.0" 553 | } 554 | }, 555 | "readdirp": { 556 | "version": "3.6.0", 557 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 558 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 559 | "dev": true, 560 | "requires": { 561 | "picomatch": "^2.2.1" 562 | } 563 | }, 564 | "require-directory": { 565 | "version": "2.1.1", 566 | "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", 567 | "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", 568 | "dev": true 569 | }, 570 | "safe-buffer": { 571 | "version": "5.2.1", 572 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 573 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 574 | "dev": true 575 | }, 576 | "serialize-javascript": { 577 | "version": "6.0.0", 578 | "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", 579 | "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", 580 | "dev": true, 581 | "requires": { 582 | "randombytes": "^2.1.0" 583 | } 584 | }, 585 | "string-width": { 586 | "version": "4.2.3", 587 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 588 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 589 | "dev": true, 590 | "requires": { 591 | "emoji-regex": "^8.0.0", 592 | "is-fullwidth-code-point": "^3.0.0", 593 | "strip-ansi": "^6.0.1" 594 | } 595 | }, 596 | "strip-ansi": { 597 | "version": "6.0.1", 598 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 599 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 600 | "dev": true, 601 | "requires": { 602 | "ansi-regex": "^5.0.1" 603 | } 604 | }, 605 | "strip-json-comments": { 606 | "version": "3.1.1", 607 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", 608 | "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", 609 | "dev": true 610 | }, 611 | "supports-color": { 612 | "version": "8.1.1", 613 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", 614 | "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", 615 | "dev": true, 616 | "requires": { 617 | "has-flag": "^4.0.0" 618 | } 619 | }, 620 | "to-regex-range": { 621 | "version": "5.0.1", 622 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 623 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 624 | "dev": true, 625 | "requires": { 626 | "is-number": "^7.0.0" 627 | } 628 | }, 629 | "type-detect": { 630 | "version": "4.0.8", 631 | "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", 632 | "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", 633 | "dev": true 634 | }, 635 | "workerpool": { 636 | "version": "6.2.1", 637 | "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", 638 | "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", 639 | "dev": true 640 | }, 641 | "wrap-ansi": { 642 | "version": "7.0.0", 643 | "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", 644 | "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", 645 | "dev": true, 646 | "requires": { 647 | "ansi-styles": "^4.0.0", 648 | "string-width": "^4.1.0", 649 | "strip-ansi": "^6.0.0" 650 | } 651 | }, 652 | "wrappy": { 653 | "version": "1.0.2", 654 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 655 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", 656 | "dev": true 657 | }, 658 | "y18n": { 659 | "version": "5.0.8", 660 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", 661 | "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", 662 | "dev": true 663 | }, 664 | "yargs": { 665 | "version": "16.2.0", 666 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", 667 | "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", 668 | "dev": true, 669 | "requires": { 670 | "cliui": "^7.0.2", 671 | "escalade": "^3.1.1", 672 | "get-caller-file": "^2.0.5", 673 | "require-directory": "^2.1.1", 674 | "string-width": "^4.2.0", 675 | "y18n": "^5.0.5", 676 | "yargs-parser": "^20.2.2" 677 | } 678 | }, 679 | "yargs-parser": { 680 | "version": "20.2.4", 681 | "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", 682 | "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", 683 | "dev": true 684 | }, 685 | "yargs-unparser": { 686 | "version": "2.0.0", 687 | "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", 688 | "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", 689 | "dev": true, 690 | "requires": { 691 | "camelcase": "^6.0.0", 692 | "decamelize": "^4.0.0", 693 | "flat": "^5.0.2", 694 | "is-plain-obj": "^2.1.0" 695 | } 696 | }, 697 | "yocto-queue": { 698 | "version": "0.1.0", 699 | "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", 700 | "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", 701 | "dev": true 702 | } 703 | } 704 | } 705 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firecrackerode", 3 | "description": "Firecracker API module.", 4 | "version": "1.0.2", 5 | "author": "Pedro Dias ", 6 | "maintainers": [ 7 | "apocas " 8 | ], 9 | "repository": { 10 | "type": "git", 11 | "url": "http://github.com/apocas/firecrackerode.git" 12 | }, 13 | "keywords": [ 14 | "firecracker" 15 | ], 16 | "dependencies": {}, 17 | "devDependencies": { 18 | "chai": "~4.2.0", 19 | "mocha": "^10.2.0" 20 | }, 21 | "main": "./lib/firecracker", 22 | "scripts": { 23 | "test": "./node_modules/mocha/bin/mocha -R spec --timeout 10000" 24 | }, 25 | "license": "Apache-2.0", 26 | "engines": { 27 | "node": ">= 8.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/firecracker.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | const expect = require('chai').expect; 3 | var firecracker = require('./helper').firecracker; 4 | 5 | before(async () => { 6 | try { 7 | let process = await firecracker.spawn(); 8 | } catch (err) { 9 | expect(err).to.be.null; 10 | } 11 | }); 12 | 13 | after(function () { 14 | var killed = firecracker.kill(); 15 | expect(killed).to.be.true; 16 | }); 17 | 18 | describe('#firecracker', function () { 19 | 20 | describe('#images', function () { 21 | it('should download kernel & filesystem images', async function () { 22 | var kernelImg = 'https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin'; 23 | var rootImg = 'https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4'; 24 | 25 | try { 26 | await firecracker.downloadImage(kernelImg, os.tmpdir() + '/hello-vmlinux.bin'); 27 | await firecracker.downloadImage(rootImg, os.tmpdir() + '/hello-rootfs.ext4'); 28 | } 29 | catch (err) { 30 | expect(err).satisfy(function (value) { 31 | if (value === null || value == 'File already exists') { 32 | return true; 33 | } else { 34 | return false; 35 | } 36 | }); 37 | } 38 | }); 39 | 40 | it('should use load the kernel image', async function () { 41 | try { 42 | await firecracker.bootSource({ 43 | 'kernel_image_path': os.tmpdir() + '/hello-vmlinux.bin', 44 | 'boot_args': 'console=ttyS0 reboot=k panic=1 pci=off' 45 | }); 46 | } 47 | catch (err) { 48 | expect(err).to.be.null; 49 | } 50 | }); 51 | 52 | it('should use load the filesystem image', async function () { 53 | var drive = firecracker.drive('rootfs'); 54 | try { 55 | await drive.updatePreboot({ 56 | 'path_on_host': os.tmpdir() + '/hello-rootfs.ext4', 57 | 'is_root_device': true, 58 | 'is_read_only': false 59 | }); 60 | } 61 | catch (err) { 62 | expect(err).to.be.null; 63 | } 64 | }); 65 | }); 66 | 67 | describe('#firecracker', function () { 68 | it('should get info', async function () { 69 | try { 70 | const data = await firecracker.info(); 71 | expect(data).to.be.ok; 72 | expect(data.state).to.equal('Uninitialized'); 73 | } 74 | catch (err) { 75 | expect(err).to.be.null; 76 | } 77 | }); 78 | 79 | it('should start microvm', async function () { 80 | try { 81 | await firecracker.action('InstanceStart'); 82 | const data = await firecracker.info(); 83 | expect(data).to.be.ok; 84 | expect(data.state).to.equal('Running'); 85 | } 86 | catch (err) { 87 | expect(err).to.be.null; 88 | } 89 | }); 90 | }); 91 | 92 | describe('#machine-config', function () { 93 | it('should get machine-config', async function () { 94 | try { 95 | var machineConfig = firecracker.machineConfig(); 96 | const data = await machineConfig.get(); 97 | expect(data).to.be.ok; 98 | expect(data.vcpu_count).to.equal(1); 99 | expect(data.mem_size_mib).to.equal(128); 100 | } 101 | catch (err) { 102 | expect(err).to.be.null; 103 | } 104 | }); 105 | 106 | it('should partially update machine-config', async function () { 107 | try { 108 | firecracker.kill(); 109 | await firecracker.spawn(); 110 | var machineConfig = firecracker.machineConfig(); 111 | await machineConfig.partialUpdate({ 'mem_size_mib': 256 }); 112 | var machineConfig = firecracker.machineConfig(); 113 | let data = await machineConfig.get(); 114 | expect(data).to.be.ok; 115 | expect(data.vcpu_count).to.equal(1); 116 | expect(data.mem_size_mib).to.equal(256); 117 | } 118 | catch (err) { 119 | expect(err).to.be.null; 120 | } 121 | }); 122 | }); 123 | }); -------------------------------------------------------------------------------- /test/helper.js: -------------------------------------------------------------------------------- 1 | var Firecracker = require('../lib/firecracker'); 2 | firecracker = new Firecracker({ socketPath: '/tmp/firecracker.socket' }); 3 | 4 | module.exports = { 5 | 'firecracker': firecracker 6 | }; --------------------------------------------------------------------------------