(options)
| 304 | } |
| 305 | |
| 306 | async inject(options) { |
| 307 | |
| 308 | let settings = options; |
| 309 | if (typeof settings === 'string') { |
| 310 | settings = { url: settings }; |
| 311 | } |
| 312 | |
| 313 | if (!settings.authority || |
| 314 | settings.auth || |
| 315 | settings.app || |
| 316 | settings.plugins || |
| 317 | settings.allowInternals !== undefined) { // Can be false |
| 318 | |
| 319 | settings = Object.assign({}, settings); // options can be reused (shallow cloned) |
| 320 | delete settings.auth; |
| 321 | delete settings.app; |
| 322 | delete settings.plugins; |
| 323 | delete settings.allowInternals; |
| 324 | |
| 325 | settings.authority = settings.authority ?? this._core.info.host + ':' + this._core.info.port; |
| 326 | } |
| 327 | |
| 328 | Hoek.assert(!options.credentials, 'options.credentials no longer supported (use options.auth)'); |
| 329 | |
| 330 | if (options.auth) { |
| 331 | Hoek.assert(typeof options.auth === 'object', 'options.auth must be an object'); |
| 332 | Hoek.assert(options.auth.credentials, 'options.auth.credentials is missing'); |
| 333 | Hoek.assert(options.auth.strategy, 'options.auth.strategy is missing'); |
| 334 | } |
| 335 | |
| 336 | const needle = this._core._dispatch({ |
| 337 | auth: options.auth, |
| 338 | allowInternals: options.allowInternals, |
| 339 | app: options.app, |
| 340 | plugins: options.plugins, |
| 341 | isInjected: true |
| 342 | }); |
| 343 | |
| 344 | const res = await Shot.inject(needle, settings); |
| 345 | const custom = res.raw.res[Config.symbol]; |
| 346 | if (custom) { |
| 347 | delete res.raw.res[Config.symbol]; |
| 348 | |
| 349 | res.request = custom.request; |
| 350 | |
| 351 | if (custom.error) { |
| 352 | throw custom.error; |
| 353 | } |
| 354 | |
| 355 | if (custom.result !== undefined) { |
| 356 | res.result = custom.result; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if (res.result === undefined) { |
| 361 | res.result = res.payload; |
| 362 | } |
| 363 |
no test coverage detected