* @param {CloudOptions} cloudOptions * @returns {Promise }
(cloudOptions)
| 109 | * @returns {Promise<void>} |
| 110 | */ |
| 111 | async function parseZipFile(cloudOptions) { |
| 112 | if (cloudOptions.serviceUrl) { |
| 113 | // Service url already was provided |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | if (!cloudOptions.secureConnectBundle) { |
| 118 | throw new TypeError('secureConnectBundle must be provided'); |
| 119 | } |
| 120 | |
| 121 | const data = await readFile(cloudOptions.secureConnectBundle); |
| 122 | const zip = new AdmZip(data); |
| 123 | const zipEntries = new Map(zip.getEntries().map(e => [e.entryName, e.getData()])); |
| 124 | |
| 125 | if (!zipEntries.get('config.json')) { |
| 126 | throw new TypeError('Config file must be contained in secure bundle'); |
| 127 | } |
| 128 | |
| 129 | const config = JSON.parse(zipEntries.get('config.json').toString('utf8')); |
| 130 | if (!config['host'] || !config['port']) { |
| 131 | throw new TypeError('Config file must include host and port information'); |
| 132 | } |
| 133 | |
| 134 | cloudOptions.serviceUrl = `${config['host']}:${config['port']}/metadata`; |
| 135 | cloudOptions.setSslOptions(zipEntries); |
| 136 | cloudOptions.setAuthProvider(config.username, config.password); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Gets the information retrieved from the metadata service. |
no test coverage detected