steelseries-sonar-sdk 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1550 -1553
- package/package.json +1 -1
- package/dist/functions/custom-fetch.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -4915,1753 +4915,1750 @@ function convertVolumeToUser(value) {
|
|
|
4915
4915
|
return result;
|
|
4916
4916
|
}
|
|
4917
4917
|
|
|
4918
|
-
// src/
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
import { Buffer as Buffer3 } from "node:buffer";
|
|
4927
|
-
|
|
4928
|
-
// node_modules/data-uri-to-buffer/dist/index.js
|
|
4929
|
-
function dataUriToBuffer(uri) {
|
|
4930
|
-
if (!/^data:/i.test(uri)) {
|
|
4931
|
-
throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
|
|
4932
|
-
}
|
|
4933
|
-
uri = uri.replace(/\r?\n/g, "");
|
|
4934
|
-
const firstComma = uri.indexOf(",");
|
|
4935
|
-
if (firstComma === -1 || firstComma <= 4) {
|
|
4936
|
-
throw new TypeError("malformed data: URI");
|
|
4918
|
+
// src/sonar/requests/volume-settings/request-volume-settings-classic.ts
|
|
4919
|
+
async function requestVolumeSettingsClassic(sonarEndpoint) {
|
|
4920
|
+
let response;
|
|
4921
|
+
try {
|
|
4922
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/classic`);
|
|
4923
|
+
response = await fetch(url);
|
|
4924
|
+
} catch (error) {
|
|
4925
|
+
throw new SonarRequestException({ innerException: error });
|
|
4937
4926
|
}
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
let typeFull = type;
|
|
4943
|
-
for (let i = 1;i < meta.length; i++) {
|
|
4944
|
-
if (meta[i] === "base64") {
|
|
4945
|
-
base64 = true;
|
|
4946
|
-
} else if (meta[i]) {
|
|
4947
|
-
typeFull += `;${meta[i]}`;
|
|
4948
|
-
if (meta[i].indexOf("charset=") === 0) {
|
|
4949
|
-
charset = meta[i].substring(8);
|
|
4950
|
-
}
|
|
4927
|
+
if (response.ok) {
|
|
4928
|
+
const data = await response.json();
|
|
4929
|
+
if (data?.masters?.classic == null) {
|
|
4930
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
4951
4931
|
}
|
|
4932
|
+
return data;
|
|
4933
|
+
} else {
|
|
4934
|
+
const data = await response.json();
|
|
4935
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
4952
4936
|
}
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
// src/functions/audio/get-audio-data-classic.ts
|
|
4940
|
+
async function getAudioDataClassic(sonarEndpoint) {
|
|
4941
|
+
const data = await requestVolumeSettingsClassic(sonarEndpoint);
|
|
4942
|
+
const volumeData = {
|
|
4943
|
+
["master" /* Master */]: createResponseVolumeData(data.masters.classic),
|
|
4944
|
+
["game" /* Game */]: data.devices.game && createResponseVolumeData(data.devices.game.classic),
|
|
4945
|
+
["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData(data.devices.chatRender.classic),
|
|
4946
|
+
["media" /* Media */]: data.devices.media && createResponseVolumeData(data.devices.media.classic),
|
|
4947
|
+
["aux" /* Aux */]: data.devices.aux && createResponseVolumeData(data.devices.aux.classic),
|
|
4948
|
+
["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData(data.devices.chatCapture.classic)
|
|
4949
|
+
};
|
|
4950
|
+
return volumeData;
|
|
4951
|
+
}
|
|
4952
|
+
function createResponseVolumeData(volumeData) {
|
|
4953
|
+
return {
|
|
4954
|
+
volume: convertVolumeToUser(volumeData.volume),
|
|
4955
|
+
isMuted: volumeData.muted
|
|
4956
|
+
};
|
|
4957
|
+
}
|
|
4958
|
+
// src/sonar/requests/volume-settings/request-volume-settings-streamer.ts
|
|
4959
|
+
async function requestVolumeSettingsStreamer(sonarEndpoint) {
|
|
4960
|
+
let response;
|
|
4961
|
+
try {
|
|
4962
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/streamer`);
|
|
4963
|
+
response = await fetch(url);
|
|
4964
|
+
} catch (error) {
|
|
4965
|
+
throw new SonarRequestException({ innerException: error });
|
|
4966
|
+
}
|
|
4967
|
+
if (response.ok) {
|
|
4968
|
+
const data = await response.json();
|
|
4969
|
+
if (data?.masters?.stream == null) {
|
|
4970
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
4971
|
+
}
|
|
4972
|
+
return data;
|
|
4973
|
+
} else {
|
|
4974
|
+
const data = await response.json();
|
|
4975
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
4956
4976
|
}
|
|
4957
|
-
const encoding = base64 ? "base64" : "ascii";
|
|
4958
|
-
const data = unescape(uri.substring(firstComma + 1));
|
|
4959
|
-
const buffer = Buffer.from(data, encoding);
|
|
4960
|
-
buffer.type = type;
|
|
4961
|
-
buffer.typeFull = typeFull;
|
|
4962
|
-
buffer.charset = charset;
|
|
4963
|
-
return buffer;
|
|
4964
4977
|
}
|
|
4965
|
-
var dist_default = dataUriToBuffer;
|
|
4966
4978
|
|
|
4967
|
-
//
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4979
|
+
// src/functions/audio/get-audio-data-stream.ts
|
|
4980
|
+
async function getAudioDataStream(sonarEndpoint) {
|
|
4981
|
+
const data = await requestVolumeSettingsStreamer(sonarEndpoint);
|
|
4982
|
+
const volumeData = {
|
|
4983
|
+
["master" /* Master */]: createResponseVolumeData2(data.masters.stream),
|
|
4984
|
+
["game" /* Game */]: data.devices.game && createResponseVolumeData2(data.devices.game.stream),
|
|
4985
|
+
["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData2(data.devices.chatRender.stream),
|
|
4986
|
+
["media" /* Media */]: data.devices.media && createResponseVolumeData2(data.devices.media.stream),
|
|
4987
|
+
["aux" /* Aux */]: data.devices.aux && createResponseVolumeData2(data.devices.aux.stream),
|
|
4988
|
+
["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData2(data.devices.chatCapture.stream)
|
|
4989
|
+
};
|
|
4990
|
+
return volumeData;
|
|
4991
|
+
}
|
|
4992
|
+
function createResponseVolumeData2(volumeData) {
|
|
4993
|
+
return {
|
|
4994
|
+
["streaming" /* Streaming */]: {
|
|
4995
|
+
volume: convertVolumeToUser(volumeData.streaming.volume),
|
|
4996
|
+
isMuted: volumeData.streaming.muted
|
|
4997
|
+
},
|
|
4998
|
+
["monitoring" /* Monitoring */]: {
|
|
4999
|
+
volume: convertVolumeToUser(volumeData.monitoring.volume),
|
|
5000
|
+
isMuted: volumeData.monitoring.muted
|
|
5001
|
+
}
|
|
5002
|
+
};
|
|
5003
|
+
}
|
|
5004
|
+
// src/sonar/models/audio-settings/enums/audio-mode.ts
|
|
5005
|
+
var AudioMode2;
|
|
5006
|
+
((AudioMode3) => {
|
|
5007
|
+
AudioMode3["Classic"] = "classic";
|
|
5008
|
+
AudioMode3["Streamer"] = "stream";
|
|
5009
|
+
})(AudioMode2 ||= {});
|
|
4973
5010
|
|
|
4974
|
-
//
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
}
|
|
4981
|
-
|
|
4982
|
-
return this.constructor.name;
|
|
5011
|
+
// src/sonar/requests/mode/request-audio-mode.ts
|
|
5012
|
+
async function requestAudioMode(sonarEndpoint) {
|
|
5013
|
+
let response;
|
|
5014
|
+
const url = new URL(`${sonarEndpoint}/mode`);
|
|
5015
|
+
try {
|
|
5016
|
+
response = await fetch(url);
|
|
5017
|
+
} catch (error) {
|
|
5018
|
+
throw new SonarRequestException({ innerException: error });
|
|
4983
5019
|
}
|
|
4984
|
-
|
|
4985
|
-
|
|
5020
|
+
if (response.ok) {
|
|
5021
|
+
const data = await response.json();
|
|
5022
|
+
if (Object.values(AudioMode2).includes(data)) {
|
|
5023
|
+
return data;
|
|
5024
|
+
}
|
|
5025
|
+
throw new SonarRequestException({ message: "Received unhandled audio mode from Sonar server" });
|
|
5026
|
+
} else {
|
|
5027
|
+
const data = await response.text();
|
|
5028
|
+
throw new SonarRequestException({ innerException: new Error(data) });
|
|
4986
5029
|
}
|
|
4987
5030
|
}
|
|
4988
5031
|
|
|
4989
|
-
//
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5032
|
+
// src/functions/audio/get-audio-mode.ts
|
|
5033
|
+
async function getAudioMode(sonarEndpoint) {
|
|
5034
|
+
return await requestAudioMode(sonarEndpoint);
|
|
5035
|
+
}
|
|
5036
|
+
// src/sonar/requests/mode/change-audio-mode.ts
|
|
5037
|
+
async function changeAudioMode(sonarEndpoint, audioMode) {
|
|
5038
|
+
let response;
|
|
5039
|
+
const url = new URL(`${sonarEndpoint}/mode/${audioMode}`);
|
|
5040
|
+
try {
|
|
5041
|
+
response = await fetch(url, {
|
|
5042
|
+
method: "PUT"
|
|
5043
|
+
});
|
|
5044
|
+
} catch (error) {
|
|
5045
|
+
throw new SonarRequestException({ innerException: error });
|
|
5046
|
+
}
|
|
5047
|
+
if (response.ok) {
|
|
5048
|
+
const data = await response.json();
|
|
5049
|
+
if (data !== audioMode) {
|
|
5050
|
+
throw new SonarRequestException({ message: "Returned audio mode does not match requested mode" });
|
|
4996
5051
|
}
|
|
5052
|
+
return data;
|
|
5053
|
+
} else {
|
|
5054
|
+
const data = await response.text();
|
|
5055
|
+
throw new SonarRequestException({ innerException: new Error(data) });
|
|
4997
5056
|
}
|
|
4998
5057
|
}
|
|
4999
5058
|
|
|
5000
|
-
//
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
}
|
|
5059
|
+
// src/functions/audio/set-audio-mode.ts
|
|
5060
|
+
async function setAudioMode(sonarEndpoint, audioMode) {
|
|
5061
|
+
return await changeAudioMode(sonarEndpoint, audioMode);
|
|
5062
|
+
}
|
|
5063
|
+
// src/functions/converters/convert-channel-to-api.ts
|
|
5064
|
+
function convertChannelToApi(channel) {
|
|
5065
|
+
switch (channel) {
|
|
5066
|
+
case "master" /* Master */:
|
|
5067
|
+
return "master" /* Master */;
|
|
5068
|
+
case "game" /* Game */:
|
|
5069
|
+
return "chatRender" /* ChatRender */;
|
|
5070
|
+
case "media" /* Media */:
|
|
5071
|
+
return "media" /* Media */;
|
|
5072
|
+
case "aux" /* Aux */:
|
|
5073
|
+
return "aux" /* Aux */;
|
|
5074
|
+
case "mic" /* Mic */:
|
|
5075
|
+
return "chatCapture" /* ChatCapture */;
|
|
5076
|
+
default:
|
|
5077
|
+
throw new Error(`Unsupported AudioChannel: ${channel}`);
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5021
5080
|
|
|
5022
|
-
//
|
|
5023
|
-
|
|
5024
|
-
|
|
5081
|
+
// src/sonar/requests/volume-settings/change-volume-mute-classic.ts
|
|
5082
|
+
async function changeVolumeMuteClassic(sonarEndpoint, isMuted, deviceRole) {
|
|
5083
|
+
let response;
|
|
5084
|
+
try {
|
|
5085
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/classic/${deviceRole}/mute/${isMuted}`);
|
|
5086
|
+
response = await fetch(url, { method: "PUT" });
|
|
5087
|
+
} catch (error) {
|
|
5088
|
+
throw new SonarRequestException({ innerException: error });
|
|
5089
|
+
}
|
|
5090
|
+
if (response.ok) {
|
|
5091
|
+
const data = await response.json();
|
|
5092
|
+
if (data?.masters?.classic == null) {
|
|
5093
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
5094
|
+
}
|
|
5095
|
+
return data;
|
|
5096
|
+
} else {
|
|
5097
|
+
const data = await response.json();
|
|
5098
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5025
5101
|
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
} else if (isURLSearchParameters(body)) {
|
|
5034
|
-
body = Buffer2.from(body.toString());
|
|
5035
|
-
} else if (isBlob(body)) {} else if (Buffer2.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) {
|
|
5036
|
-
body = Buffer2.from(body);
|
|
5037
|
-
} else if (ArrayBuffer.isView(body)) {
|
|
5038
|
-
body = Buffer2.from(body.buffer, body.byteOffset, body.byteLength);
|
|
5039
|
-
} else if (body instanceof Stream) {} else if (body instanceof FormData) {
|
|
5040
|
-
body = formDataToBlob(body);
|
|
5041
|
-
boundary = body.type.split("=")[1];
|
|
5042
|
-
} else {
|
|
5043
|
-
body = Buffer2.from(String(body));
|
|
5044
|
-
}
|
|
5045
|
-
let stream = body;
|
|
5046
|
-
if (Buffer2.isBuffer(body)) {
|
|
5047
|
-
stream = Stream.Readable.from(body);
|
|
5048
|
-
} else if (isBlob(body)) {
|
|
5049
|
-
stream = Stream.Readable.from(body.stream());
|
|
5050
|
-
}
|
|
5051
|
-
this[INTERNALS] = {
|
|
5052
|
-
body,
|
|
5053
|
-
stream,
|
|
5054
|
-
boundary,
|
|
5055
|
-
disturbed: false,
|
|
5056
|
-
error: null
|
|
5057
|
-
};
|
|
5058
|
-
this.size = size;
|
|
5059
|
-
if (body instanceof Stream) {
|
|
5060
|
-
body.on("error", (error_) => {
|
|
5061
|
-
const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
|
|
5062
|
-
this[INTERNALS].error = error;
|
|
5063
|
-
});
|
|
5064
|
-
}
|
|
5065
|
-
}
|
|
5066
|
-
get body() {
|
|
5067
|
-
return this[INTERNALS].stream;
|
|
5068
|
-
}
|
|
5069
|
-
get bodyUsed() {
|
|
5070
|
-
return this[INTERNALS].disturbed;
|
|
5102
|
+
// src/functions/audio/set-channel-mute-classic.ts
|
|
5103
|
+
async function setChannelMuteClassic(sonarEndpoint, isMuted, channel) {
|
|
5104
|
+
const sonarChannel = convertChannelToApi(channel);
|
|
5105
|
+
const data = await changeVolumeMuteClassic(sonarEndpoint, isMuted, sonarChannel);
|
|
5106
|
+
const device = sonarChannel === "master" /* Master */ ? data.masters.classic : data.devices[sonarChannel]?.classic;
|
|
5107
|
+
if (!device) {
|
|
5108
|
+
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
5071
5109
|
}
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5110
|
+
const result = {
|
|
5111
|
+
volume: convertVolumeToUser(device.volume),
|
|
5112
|
+
isMuted: device.muted
|
|
5113
|
+
};
|
|
5114
|
+
return result;
|
|
5115
|
+
}
|
|
5116
|
+
// src/sonar/requests/volume-settings/change-volume-mute-streamer.ts
|
|
5117
|
+
async function changeVolumeMuteStreamer(sonarEndpoint, isMuted, deviceRole, path) {
|
|
5118
|
+
let response;
|
|
5119
|
+
try {
|
|
5120
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/streamer/${path}/${deviceRole}/isMuted/${isMuted}`);
|
|
5121
|
+
response = await fetch(url, { method: "PUT" });
|
|
5122
|
+
} catch (error) {
|
|
5123
|
+
throw new SonarRequestException({ innerException: error });
|
|
5075
5124
|
}
|
|
5076
|
-
|
|
5077
|
-
const
|
|
5078
|
-
if (
|
|
5079
|
-
|
|
5080
|
-
const parameters = new URLSearchParams(await this.text());
|
|
5081
|
-
for (const [name, value] of parameters) {
|
|
5082
|
-
formData.append(name, value);
|
|
5083
|
-
}
|
|
5084
|
-
return formData;
|
|
5125
|
+
if (response.ok) {
|
|
5126
|
+
const data = await response.json();
|
|
5127
|
+
if (data?.masters?.stream == null) {
|
|
5128
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
5085
5129
|
}
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
const ct = this.headers && this.headers.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
|
|
5091
|
-
const buf = await this.arrayBuffer();
|
|
5092
|
-
return new fetch_blob_default([buf], {
|
|
5093
|
-
type: ct
|
|
5094
|
-
});
|
|
5130
|
+
return data;
|
|
5131
|
+
} else {
|
|
5132
|
+
const data = await response.json();
|
|
5133
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
5095
5134
|
}
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5135
|
+
}
|
|
5136
|
+
|
|
5137
|
+
// src/functions/audio/set-channel-mute-streamer.ts
|
|
5138
|
+
async function setChannelMuteStreamer(sonarEndpoint, isMuted, channel, path) {
|
|
5139
|
+
const sonarChannel = convertChannelToApi(channel);
|
|
5140
|
+
const streamPath = path === "streaming" /* Streaming */ ? "streaming" /* Streaming */ : "monitoring" /* Monitoring */;
|
|
5141
|
+
const data = await changeVolumeMuteStreamer(sonarEndpoint, isMuted, sonarChannel, streamPath);
|
|
5142
|
+
const device = sonarChannel === "master" /* Master */ ? data.masters.stream : data.devices[sonarChannel]?.stream;
|
|
5143
|
+
if (!device) {
|
|
5144
|
+
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
5099
5145
|
}
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5146
|
+
const devicePath = path === "streaming" /* Streaming */ ? device.streaming : device.monitoring;
|
|
5147
|
+
const result = {
|
|
5148
|
+
volume: convertVolumeToUser(devicePath.volume),
|
|
5149
|
+
isMuted: devicePath.muted
|
|
5150
|
+
};
|
|
5151
|
+
return result;
|
|
5152
|
+
}
|
|
5153
|
+
// src/functions/converters/convert-volume-to-api.ts
|
|
5154
|
+
function convertVolumeToApi(value) {
|
|
5155
|
+
let result = value / 100;
|
|
5156
|
+
result = Math.min(Math.max(result, 0), 1);
|
|
5157
|
+
return result;
|
|
5158
|
+
}
|
|
5159
|
+
|
|
5160
|
+
// src/sonar/requests/volume-settings/change-volume-level-classic.ts
|
|
5161
|
+
async function changeVolumeLevelClassic(sonarEndpoint, volume, deviceRole) {
|
|
5162
|
+
let response;
|
|
5163
|
+
try {
|
|
5164
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/classic/${deviceRole}/volume/${volume}`);
|
|
5165
|
+
response = await fetch(url, { method: "PUT" });
|
|
5166
|
+
} catch (error) {
|
|
5167
|
+
throw new SonarRequestException({ innerException: error });
|
|
5103
5168
|
}
|
|
5104
|
-
|
|
5105
|
-
|
|
5169
|
+
if (response.ok) {
|
|
5170
|
+
const data = await response.json();
|
|
5171
|
+
if (data?.masters?.classic == null) {
|
|
5172
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
5173
|
+
}
|
|
5174
|
+
return data;
|
|
5175
|
+
} else {
|
|
5176
|
+
const data = await response.json();
|
|
5177
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
5106
5178
|
}
|
|
5107
5179
|
}
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
});
|
|
5118
|
-
async function consumeBody(data) {
|
|
5119
|
-
if (data[INTERNALS].disturbed) {
|
|
5120
|
-
throw new TypeError(`body used already for: ${data.url}`);
|
|
5180
|
+
|
|
5181
|
+
// src/functions/audio/set-channel-volume-classic.ts
|
|
5182
|
+
async function setChannelVolumeClassic(sonarEndpoint, volumePercent, channel) {
|
|
5183
|
+
const sonarChannel = convertChannelToApi(channel);
|
|
5184
|
+
const formattedVolume = convertVolumeToApi(volumePercent);
|
|
5185
|
+
const data = await changeVolumeLevelClassic(sonarEndpoint, formattedVolume, sonarChannel);
|
|
5186
|
+
const device = sonarChannel === "master" /* Master */ ? data.masters.classic : data.devices[sonarChannel]?.classic;
|
|
5187
|
+
if (!device) {
|
|
5188
|
+
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
5121
5189
|
}
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5190
|
+
const result = {
|
|
5191
|
+
volume: convertVolumeToUser(device.volume),
|
|
5192
|
+
isMuted: device.muted
|
|
5193
|
+
};
|
|
5194
|
+
return result;
|
|
5195
|
+
}
|
|
5196
|
+
// src/sonar/requests/volume-settings/change-volume-level-streamer.ts
|
|
5197
|
+
async function changeVolumeLevelStreamer(sonarEndpoint, volume, channel, path) {
|
|
5198
|
+
let response;
|
|
5199
|
+
try {
|
|
5200
|
+
const url = new URL(`${sonarEndpoint}/volumeSettings/streamer/${path}/${channel}/volume/${volume}`);
|
|
5201
|
+
response = await fetch(url, { method: "PUT" });
|
|
5202
|
+
} catch (error) {
|
|
5203
|
+
throw new SonarRequestException({ innerException: error });
|
|
5125
5204
|
}
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5205
|
+
if (response.ok) {
|
|
5206
|
+
const data = await response.json();
|
|
5207
|
+
if (data?.masters?.stream == null) {
|
|
5208
|
+
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
5209
|
+
}
|
|
5210
|
+
return data;
|
|
5211
|
+
} else {
|
|
5212
|
+
const data = await response.json();
|
|
5213
|
+
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
5129
5214
|
}
|
|
5130
|
-
|
|
5131
|
-
|
|
5215
|
+
}
|
|
5216
|
+
|
|
5217
|
+
// src/functions/audio/set-channel-volume-streamer.ts
|
|
5218
|
+
async function setChannelVolumeStreamer(sonarEndpoint, volumePercent, channel, path) {
|
|
5219
|
+
const sonarChannel = convertChannelToApi(channel);
|
|
5220
|
+
const formattedVolume = convertVolumeToApi(volumePercent);
|
|
5221
|
+
const streamPath = path === "streaming" /* Streaming */ ? "streaming" /* Streaming */ : "monitoring" /* Monitoring */;
|
|
5222
|
+
const data = await changeVolumeLevelStreamer(sonarEndpoint, formattedVolume, sonarChannel, streamPath);
|
|
5223
|
+
const device = sonarChannel === "master" /* Master */ ? data.masters.stream : data.devices[sonarChannel]?.stream;
|
|
5224
|
+
if (!device) {
|
|
5225
|
+
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
5132
5226
|
}
|
|
5133
|
-
const
|
|
5134
|
-
|
|
5227
|
+
const devicePath = path === "streaming" /* Streaming */ ? device.streaming : device.monitoring;
|
|
5228
|
+
const result = {
|
|
5229
|
+
volume: convertVolumeToUser(devicePath.volume),
|
|
5230
|
+
isMuted: devicePath.muted
|
|
5231
|
+
};
|
|
5232
|
+
return result;
|
|
5233
|
+
}
|
|
5234
|
+
// src/functions/converters/convert-chat-mix-balance-to-user.ts
|
|
5235
|
+
function convertChatMixBalanceToUser(balance) {
|
|
5236
|
+
let result = (balance + 1) / 2 * 100;
|
|
5237
|
+
result = Math.floor(result);
|
|
5238
|
+
result = Math.min(Math.max(result, 0), 100);
|
|
5239
|
+
return result;
|
|
5240
|
+
}
|
|
5241
|
+
|
|
5242
|
+
// src/sonar/requests/chatmix/request-chat-mix-state.ts
|
|
5243
|
+
async function requestChatMixState(sonarEndpoint) {
|
|
5244
|
+
const url = new URL(`${sonarEndpoint}/chatMix`);
|
|
5245
|
+
let response;
|
|
5135
5246
|
try {
|
|
5136
|
-
|
|
5137
|
-
if (data.size > 0 && accumBytes + chunk.length > data.size) {
|
|
5138
|
-
const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
|
|
5139
|
-
body.destroy(error);
|
|
5140
|
-
throw error;
|
|
5141
|
-
}
|
|
5142
|
-
accumBytes += chunk.length;
|
|
5143
|
-
accum.push(chunk);
|
|
5144
|
-
}
|
|
5247
|
+
response = await fetch(url);
|
|
5145
5248
|
} catch (error) {
|
|
5146
|
-
|
|
5147
|
-
throw error_;
|
|
5249
|
+
throw new SonarRequestException({ innerException: error });
|
|
5148
5250
|
}
|
|
5149
|
-
if (
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
}
|
|
5154
|
-
return Buffer2.concat(accum, accumBytes);
|
|
5155
|
-
} catch (error) {
|
|
5156
|
-
throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
|
|
5251
|
+
if (response.ok) {
|
|
5252
|
+
const data = await response.json();
|
|
5253
|
+
if (data?.balance == null || data?.state == null) {
|
|
5254
|
+
throw new SonarRequestException({ message: "Missing required data in response" });
|
|
5157
5255
|
}
|
|
5256
|
+
return data;
|
|
5158
5257
|
} else {
|
|
5159
|
-
|
|
5258
|
+
const data = await response.text();
|
|
5259
|
+
throw new SonarRequestException({ innerException: new Error(data) });
|
|
5160
5260
|
}
|
|
5161
5261
|
}
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5262
|
+
|
|
5263
|
+
// src/functions/chatmix/get-chat-mix-state.ts
|
|
5264
|
+
async function getChatMixState(sonarEndpoint) {
|
|
5265
|
+
const data = await requestChatMixState(sonarEndpoint);
|
|
5266
|
+
const chatMixData = {
|
|
5267
|
+
chatBalance: convertChatMixBalanceToUser(data.balance),
|
|
5268
|
+
state: data.state,
|
|
5269
|
+
isEnabled: data.state === "enabled" /* Enabled */
|
|
5270
|
+
};
|
|
5271
|
+
return chatMixData;
|
|
5272
|
+
}
|
|
5273
|
+
// src/functions/converters/convert-chat-mix-balance-to-api.ts
|
|
5274
|
+
function convertChatMixBalanceToApi(balance) {
|
|
5275
|
+
let result = balance / 100 * 2 - 1;
|
|
5276
|
+
result = Math.min(Math.max(result, -1), 1);
|
|
5277
|
+
return result;
|
|
5278
|
+
}
|
|
5279
|
+
|
|
5280
|
+
// src/sonar/requests/chatmix/change-chat-mix-balance.ts
|
|
5281
|
+
async function changeChatMixBalance(sonarEndpoint, chatBalance) {
|
|
5282
|
+
const url = new URL(`${sonarEndpoint}/chatMix?balance=${chatBalance}`);
|
|
5283
|
+
let response;
|
|
5284
|
+
try {
|
|
5285
|
+
response = await fetch(url, {
|
|
5286
|
+
method: "PUT"
|
|
5287
|
+
});
|
|
5288
|
+
} catch (error) {
|
|
5289
|
+
throw new SonarRequestException({ innerException: error });
|
|
5168
5290
|
}
|
|
5169
|
-
if (
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5291
|
+
if (response.ok) {
|
|
5292
|
+
const data = await response.json();
|
|
5293
|
+
if (data?.balance == null || data?.state == null) {
|
|
5294
|
+
throw new SonarRequestException({ message: "Missing required data in response" });
|
|
5295
|
+
}
|
|
5296
|
+
return data;
|
|
5297
|
+
} else {
|
|
5298
|
+
const data = await response.json();
|
|
5299
|
+
throw new SonarRequestException({ message: data.Message });
|
|
5176
5300
|
}
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5301
|
+
}
|
|
5302
|
+
|
|
5303
|
+
// src/functions/chatmix/set-chat-mix-balance.ts
|
|
5304
|
+
async function setChatMixBalance(sonarEndpoint, chatBalance) {
|
|
5305
|
+
const balance = convertChatMixBalanceToApi(chatBalance);
|
|
5306
|
+
const data = await changeChatMixBalance(sonarEndpoint, balance);
|
|
5307
|
+
const chatMixData = {
|
|
5308
|
+
chatBalance: convertChatMixBalanceToUser(data.balance),
|
|
5309
|
+
state: data.state,
|
|
5310
|
+
isEnabled: data.state === "enabled" /* Enabled */
|
|
5311
|
+
};
|
|
5312
|
+
return chatMixData;
|
|
5313
|
+
}
|
|
5314
|
+
// src/sonar/requests/audio-devices/request-audio-devices.ts
|
|
5315
|
+
async function requestAudioDevices(sonarEndpoint, params) {
|
|
5316
|
+
const { deviceDataFlow, onlySteelSeriesVAD = false, removeSteelSeriesVAD = false } = params;
|
|
5317
|
+
const url = new URL(`${sonarEndpoint}/audioDevices`);
|
|
5318
|
+
url.searchParams.append("onlySteelSeriesVAD", String(onlySteelSeriesVAD));
|
|
5319
|
+
url.searchParams.append("removeSteelSeriesVAD", String(removeSteelSeriesVAD));
|
|
5320
|
+
if (deviceDataFlow !== undefined) {
|
|
5321
|
+
url.searchParams.append("deviceDataFlow", deviceDataFlow.toString());
|
|
5183
5322
|
}
|
|
5184
|
-
|
|
5185
|
-
|
|
5323
|
+
let response;
|
|
5324
|
+
try {
|
|
5325
|
+
response = await fetch(url);
|
|
5326
|
+
} catch (error) {
|
|
5327
|
+
throw new SonarRequestException({
|
|
5328
|
+
innerException: error
|
|
5329
|
+
});
|
|
5186
5330
|
}
|
|
5187
|
-
if (
|
|
5188
|
-
|
|
5331
|
+
if (!response.ok) {
|
|
5332
|
+
const error = await response.text();
|
|
5333
|
+
throw new SonarRequestException({ message: `Failed to get audio devices: ${error}` });
|
|
5189
5334
|
}
|
|
5190
|
-
|
|
5191
|
-
|
|
5335
|
+
const data = await response.json();
|
|
5336
|
+
if (!Array.isArray(data)) {
|
|
5337
|
+
throw new SonarRequestException({ message: "Invalid audio devices response format." });
|
|
5192
5338
|
}
|
|
5193
|
-
|
|
5194
|
-
|
|
5339
|
+
return data;
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
// src/functions/devices/get-audio-devices.ts
|
|
5343
|
+
async function getAudioDevices(sonarEndpoint, deviceType) {
|
|
5344
|
+
let deviceDataFlow;
|
|
5345
|
+
switch (deviceType) {
|
|
5346
|
+
case "input" /* Input */:
|
|
5347
|
+
deviceDataFlow = "capture" /* Capture */;
|
|
5348
|
+
break;
|
|
5349
|
+
case "output" /* Output */:
|
|
5350
|
+
deviceDataFlow = "render" /* Render */;
|
|
5351
|
+
break;
|
|
5352
|
+
case undefined:
|
|
5353
|
+
deviceDataFlow = "all" /* All */;
|
|
5354
|
+
break;
|
|
5195
5355
|
}
|
|
5196
|
-
|
|
5197
|
-
|
|
5356
|
+
const data = await requestAudioDevices(sonarEndpoint, { deviceDataFlow, removeSteelSeriesVAD: true });
|
|
5357
|
+
const audioDevices = data.map((device) => ({
|
|
5358
|
+
id: device.id,
|
|
5359
|
+
name: device.friendlyName,
|
|
5360
|
+
type: getDeviceTypeFromDataFlow(device.dataFlow)
|
|
5361
|
+
}));
|
|
5362
|
+
return audioDevices;
|
|
5363
|
+
}
|
|
5364
|
+
function getDeviceTypeFromDataFlow(dataFlow) {
|
|
5365
|
+
switch (dataFlow) {
|
|
5366
|
+
case "capture" /* Capture */:
|
|
5367
|
+
return "input" /* Input */;
|
|
5368
|
+
case "render" /* Render */:
|
|
5369
|
+
return "output" /* Output */;
|
|
5370
|
+
default:
|
|
5371
|
+
throw new SonarRequestException({ message: `Unknown device data flow: ${dataFlow}` });
|
|
5198
5372
|
}
|
|
5199
|
-
|
|
5200
|
-
|
|
5373
|
+
}
|
|
5374
|
+
// src/sonar/requests/audio-devices/change-audio-device.ts
|
|
5375
|
+
async function changeAudioDevice(sonarEndpoint, deviceChannel, deviceId) {
|
|
5376
|
+
let response;
|
|
5377
|
+
const url = new URL(`${sonarEndpoint}/classicRedirections/${deviceChannel}/deviceId/${deviceId}`);
|
|
5378
|
+
try {
|
|
5379
|
+
response = await fetch(url, { method: "PUT" });
|
|
5380
|
+
} catch (error) {
|
|
5381
|
+
throw new SonarRequestException({
|
|
5382
|
+
innerException: error
|
|
5383
|
+
});
|
|
5201
5384
|
}
|
|
5202
|
-
if (
|
|
5203
|
-
|
|
5385
|
+
if (!response.ok) {
|
|
5386
|
+
const error = await response.text();
|
|
5387
|
+
throw new SonarRequestException({ message: `Failed to get audio devices: ${error}` });
|
|
5204
5388
|
}
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
return 0;
|
|
5389
|
+
const unknownData = await response.json();
|
|
5390
|
+
const data = Array.isArray(unknownData) ? unknownData : [unknownData];
|
|
5391
|
+
const devices = data.filter((x) => x?.deviceId === deviceId);
|
|
5392
|
+
if (devices.length === 0) {
|
|
5393
|
+
throw new SonarRequestException({ message: "The changed audio devices list is empty." });
|
|
5211
5394
|
}
|
|
5212
|
-
|
|
5213
|
-
|
|
5395
|
+
return devices;
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
// src/functions/devices/set-audio-device.ts
|
|
5399
|
+
async function setAudioDevice(sonarEndpoint, deviceChannel, deviceId) {
|
|
5400
|
+
const data = await changeAudioDevice(sonarEndpoint, deviceChannel, deviceId);
|
|
5401
|
+
const result = data.map((x) => ({
|
|
5402
|
+
deviceId: x.deviceId,
|
|
5403
|
+
deviceChannel: x.id,
|
|
5404
|
+
isRunning: x.isRunning
|
|
5405
|
+
}));
|
|
5406
|
+
return result;
|
|
5407
|
+
}
|
|
5408
|
+
// src/functions/endpoint/get-app-endpoint.ts
|
|
5409
|
+
import { promises as fsAsync } from "node:fs";
|
|
5410
|
+
import { platform as getPlatform } from "node:os";
|
|
5411
|
+
import { join as joinPath } from "node:path";
|
|
5412
|
+
var WINDOWS_PATHS = ["SteelSeries", "SteelSeries Engine 3", "coreProps.json"];
|
|
5413
|
+
async function getAppEndpoint() {
|
|
5414
|
+
const appDataPath = getPath();
|
|
5415
|
+
const fileContents = await getContents(appDataPath);
|
|
5416
|
+
const data = parseContents(fileContents);
|
|
5417
|
+
if (data.ggEncryptedAddress) {
|
|
5418
|
+
return `https://${data.ggEncryptedAddress}`;
|
|
5214
5419
|
}
|
|
5215
|
-
|
|
5216
|
-
|
|
5420
|
+
throw new SonarInitializationException({
|
|
5421
|
+
reason: "Bad Config" /* BadConfig */
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5424
|
+
function getPath() {
|
|
5425
|
+
const os = getPlatform();
|
|
5426
|
+
switch (os) {
|
|
5427
|
+
case "win32": {
|
|
5428
|
+
const programData = process.env.ProgramData ?? "C:\\ProgramData";
|
|
5429
|
+
return joinPath(programData, ...WINDOWS_PATHS);
|
|
5430
|
+
}
|
|
5431
|
+
default:
|
|
5432
|
+
throw new SonarInitializationException({
|
|
5433
|
+
reason: "OS Unsupported" /* OSUnsupported */
|
|
5434
|
+
});
|
|
5217
5435
|
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5436
|
+
}
|
|
5437
|
+
async function getContents(path) {
|
|
5438
|
+
try {
|
|
5439
|
+
return await fsAsync.readFile(path, "utf8");
|
|
5440
|
+
} catch (error) {
|
|
5441
|
+
throw new SonarInitializationException({
|
|
5442
|
+
reason: "Bad Config" /* BadConfig */,
|
|
5443
|
+
innerException: error
|
|
5444
|
+
});
|
|
5220
5445
|
}
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5446
|
+
}
|
|
5447
|
+
function parseContents(contents) {
|
|
5448
|
+
try {
|
|
5449
|
+
return JSON.parse(contents);
|
|
5450
|
+
} catch (error) {
|
|
5451
|
+
throw new SonarInitializationException({
|
|
5452
|
+
reason: "Bad Config" /* BadConfig */,
|
|
5453
|
+
innerException: error
|
|
5454
|
+
});
|
|
5228
5455
|
}
|
|
5229
|
-
}
|
|
5456
|
+
}
|
|
5457
|
+
// src/functions/endpoint/get-sonar-endpoint.ts
|
|
5458
|
+
import https2 from "node:https";
|
|
5230
5459
|
|
|
5231
|
-
// node_modules/node-fetch/src/
|
|
5232
|
-
import
|
|
5233
|
-
import
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5460
|
+
// node_modules/node-fetch/src/index.js
|
|
5461
|
+
import http2 from "node:http";
|
|
5462
|
+
import https from "node:https";
|
|
5463
|
+
import zlib from "node:zlib";
|
|
5464
|
+
import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
5465
|
+
import { Buffer as Buffer3 } from "node:buffer";
|
|
5466
|
+
|
|
5467
|
+
// node_modules/data-uri-to-buffer/dist/index.js
|
|
5468
|
+
function dataUriToBuffer(uri) {
|
|
5469
|
+
if (!/^data:/i.test(uri)) {
|
|
5470
|
+
throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
|
|
5239
5471
|
}
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
if (
|
|
5243
|
-
|
|
5244
|
-
Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
|
|
5245
|
-
throw error;
|
|
5472
|
+
uri = uri.replace(/\r?\n/g, "");
|
|
5473
|
+
const firstComma = uri.indexOf(",");
|
|
5474
|
+
if (firstComma === -1 || firstComma <= 4) {
|
|
5475
|
+
throw new TypeError("malformed data: URI");
|
|
5246
5476
|
}
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
}
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
if (method == null) {
|
|
5260
|
-
result.push(...Object.entries(init));
|
|
5261
|
-
} else {
|
|
5262
|
-
if (typeof method !== "function") {
|
|
5263
|
-
throw new TypeError("Header pairs must be iterable");
|
|
5264
|
-
}
|
|
5265
|
-
result = [...init].map((pair) => {
|
|
5266
|
-
if (typeof pair !== "object" || types2.isBoxedPrimitive(pair)) {
|
|
5267
|
-
throw new TypeError("Each header pair must be an iterable object");
|
|
5268
|
-
}
|
|
5269
|
-
return [...pair];
|
|
5270
|
-
}).map((pair) => {
|
|
5271
|
-
if (pair.length !== 2) {
|
|
5272
|
-
throw new TypeError("Each header pair must be a name/value tuple");
|
|
5273
|
-
}
|
|
5274
|
-
return [...pair];
|
|
5275
|
-
});
|
|
5477
|
+
const meta = uri.substring(5, firstComma).split(";");
|
|
5478
|
+
let charset = "";
|
|
5479
|
+
let base64 = false;
|
|
5480
|
+
const type = meta[0] || "text/plain";
|
|
5481
|
+
let typeFull = type;
|
|
5482
|
+
for (let i = 1;i < meta.length; i++) {
|
|
5483
|
+
if (meta[i] === "base64") {
|
|
5484
|
+
base64 = true;
|
|
5485
|
+
} else if (meta[i]) {
|
|
5486
|
+
typeFull += `;${meta[i]}`;
|
|
5487
|
+
if (meta[i].indexOf("charset=") === 0) {
|
|
5488
|
+
charset = meta[i].substring(8);
|
|
5276
5489
|
}
|
|
5277
|
-
} else {
|
|
5278
|
-
throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
|
|
5279
5490
|
}
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
}
|
|
5312
|
-
});
|
|
5491
|
+
}
|
|
5492
|
+
if (!meta[0] && !charset.length) {
|
|
5493
|
+
typeFull += ";charset=US-ASCII";
|
|
5494
|
+
charset = "US-ASCII";
|
|
5495
|
+
}
|
|
5496
|
+
const encoding = base64 ? "base64" : "ascii";
|
|
5497
|
+
const data = unescape(uri.substring(firstComma + 1));
|
|
5498
|
+
const buffer = Buffer.from(data, encoding);
|
|
5499
|
+
buffer.type = type;
|
|
5500
|
+
buffer.typeFull = typeFull;
|
|
5501
|
+
buffer.charset = charset;
|
|
5502
|
+
return buffer;
|
|
5503
|
+
}
|
|
5504
|
+
var dist_default = dataUriToBuffer;
|
|
5505
|
+
|
|
5506
|
+
// node_modules/node-fetch/src/body.js
|
|
5507
|
+
init_fetch_blob();
|
|
5508
|
+
init_esm_min();
|
|
5509
|
+
import Stream, { PassThrough } from "node:stream";
|
|
5510
|
+
import { types, deprecate, promisify } from "node:util";
|
|
5511
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
5512
|
+
|
|
5513
|
+
// node_modules/node-fetch/src/errors/base.js
|
|
5514
|
+
class FetchBaseError extends Error {
|
|
5515
|
+
constructor(message, type) {
|
|
5516
|
+
super(message);
|
|
5517
|
+
Error.captureStackTrace(this, this.constructor);
|
|
5518
|
+
this.type = type;
|
|
5519
|
+
}
|
|
5520
|
+
get name() {
|
|
5521
|
+
return this.constructor.name;
|
|
5313
5522
|
}
|
|
5314
5523
|
get [Symbol.toStringTag]() {
|
|
5315
5524
|
return this.constructor.name;
|
|
5316
5525
|
}
|
|
5317
|
-
|
|
5318
|
-
|
|
5526
|
+
}
|
|
5527
|
+
|
|
5528
|
+
// node_modules/node-fetch/src/errors/fetch-error.js
|
|
5529
|
+
class FetchError extends FetchBaseError {
|
|
5530
|
+
constructor(message, type, systemError) {
|
|
5531
|
+
super(message, type);
|
|
5532
|
+
if (systemError) {
|
|
5533
|
+
this.code = this.errno = systemError.code;
|
|
5534
|
+
this.erroredSysCall = systemError.syscall;
|
|
5535
|
+
}
|
|
5319
5536
|
}
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5539
|
+
// node_modules/node-fetch/src/utils/is.js
|
|
5540
|
+
var NAME = Symbol.toStringTag;
|
|
5541
|
+
var isURLSearchParameters = (object) => {
|
|
5542
|
+
return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
|
|
5543
|
+
};
|
|
5544
|
+
var isBlob = (object) => {
|
|
5545
|
+
return object && typeof object === "object" && typeof object.arrayBuffer === "function" && typeof object.type === "string" && typeof object.stream === "function" && typeof object.constructor === "function" && /^(Blob|File)$/.test(object[NAME]);
|
|
5546
|
+
};
|
|
5547
|
+
var isAbortSignal = (object) => {
|
|
5548
|
+
return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
|
|
5549
|
+
};
|
|
5550
|
+
var isDomainOrSubdomain = (destination, original) => {
|
|
5551
|
+
const orig = new URL(original).hostname;
|
|
5552
|
+
const dest = new URL(destination).hostname;
|
|
5553
|
+
return orig === dest || orig.endsWith(`.${dest}`);
|
|
5554
|
+
};
|
|
5555
|
+
var isSameProtocol = (destination, original) => {
|
|
5556
|
+
const orig = new URL(original).protocol;
|
|
5557
|
+
const dest = new URL(destination).protocol;
|
|
5558
|
+
return orig === dest;
|
|
5559
|
+
};
|
|
5560
|
+
|
|
5561
|
+
// node_modules/node-fetch/src/body.js
|
|
5562
|
+
var pipeline = promisify(Stream.pipeline);
|
|
5563
|
+
var INTERNALS = Symbol("Body internals");
|
|
5564
|
+
|
|
5565
|
+
class Body {
|
|
5566
|
+
constructor(body, {
|
|
5567
|
+
size = 0
|
|
5568
|
+
} = {}) {
|
|
5569
|
+
let boundary = null;
|
|
5570
|
+
if (body === null) {
|
|
5571
|
+
body = null;
|
|
5572
|
+
} else if (isURLSearchParameters(body)) {
|
|
5573
|
+
body = Buffer2.from(body.toString());
|
|
5574
|
+
} else if (isBlob(body)) {} else if (Buffer2.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) {
|
|
5575
|
+
body = Buffer2.from(body);
|
|
5576
|
+
} else if (ArrayBuffer.isView(body)) {
|
|
5577
|
+
body = Buffer2.from(body.buffer, body.byteOffset, body.byteLength);
|
|
5578
|
+
} else if (body instanceof Stream) {} else if (body instanceof FormData) {
|
|
5579
|
+
body = formDataToBlob(body);
|
|
5580
|
+
boundary = body.type.split("=")[1];
|
|
5581
|
+
} else {
|
|
5582
|
+
body = Buffer2.from(String(body));
|
|
5324
5583
|
}
|
|
5325
|
-
let
|
|
5326
|
-
if (
|
|
5327
|
-
|
|
5584
|
+
let stream = body;
|
|
5585
|
+
if (Buffer2.isBuffer(body)) {
|
|
5586
|
+
stream = Stream.Readable.from(body);
|
|
5587
|
+
} else if (isBlob(body)) {
|
|
5588
|
+
stream = Stream.Readable.from(body.stream());
|
|
5328
5589
|
}
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5590
|
+
this[INTERNALS] = {
|
|
5591
|
+
body,
|
|
5592
|
+
stream,
|
|
5593
|
+
boundary,
|
|
5594
|
+
disturbed: false,
|
|
5595
|
+
error: null
|
|
5596
|
+
};
|
|
5597
|
+
this.size = size;
|
|
5598
|
+
if (body instanceof Stream) {
|
|
5599
|
+
body.on("error", (error_) => {
|
|
5600
|
+
const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
|
|
5601
|
+
this[INTERNALS].error = error;
|
|
5602
|
+
});
|
|
5334
5603
|
}
|
|
5335
5604
|
}
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
yield this.get(name);
|
|
5339
|
-
}
|
|
5605
|
+
get body() {
|
|
5606
|
+
return this[INTERNALS].stream;
|
|
5340
5607
|
}
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5608
|
+
get bodyUsed() {
|
|
5609
|
+
return this[INTERNALS].disturbed;
|
|
5610
|
+
}
|
|
5611
|
+
async arrayBuffer() {
|
|
5612
|
+
const { buffer, byteOffset, byteLength } = await consumeBody(this);
|
|
5613
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
5614
|
+
}
|
|
5615
|
+
async formData() {
|
|
5616
|
+
const ct = this.headers.get("content-type");
|
|
5617
|
+
if (ct.startsWith("application/x-www-form-urlencoded")) {
|
|
5618
|
+
const formData = new FormData;
|
|
5619
|
+
const parameters = new URLSearchParams(await this.text());
|
|
5620
|
+
for (const [name, value] of parameters) {
|
|
5621
|
+
formData.append(name, value);
|
|
5622
|
+
}
|
|
5623
|
+
return formData;
|
|
5344
5624
|
}
|
|
5625
|
+
const { toFormData: toFormData2 } = await Promise.resolve().then(() => (init_multipart_parser(), exports_multipart_parser));
|
|
5626
|
+
return toFormData2(this.body, ct);
|
|
5345
5627
|
}
|
|
5346
|
-
|
|
5347
|
-
|
|
5628
|
+
async blob() {
|
|
5629
|
+
const ct = this.headers && this.headers.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
|
|
5630
|
+
const buf = await this.arrayBuffer();
|
|
5631
|
+
return new fetch_blob_default([buf], {
|
|
5632
|
+
type: ct
|
|
5633
|
+
});
|
|
5348
5634
|
}
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
return result;
|
|
5353
|
-
}, {});
|
|
5635
|
+
async json() {
|
|
5636
|
+
const text = await this.text();
|
|
5637
|
+
return JSON.parse(text);
|
|
5354
5638
|
}
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
result[key] = values.length > 1 ? values : values[0];
|
|
5362
|
-
}
|
|
5363
|
-
return result;
|
|
5364
|
-
}, {});
|
|
5639
|
+
async text() {
|
|
5640
|
+
const buffer = await consumeBody(this);
|
|
5641
|
+
return new TextDecoder().decode(buffer);
|
|
5642
|
+
}
|
|
5643
|
+
buffer() {
|
|
5644
|
+
return consumeBody(this);
|
|
5365
5645
|
}
|
|
5366
5646
|
}
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5647
|
+
Body.prototype.buffer = deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
|
|
5648
|
+
Object.defineProperties(Body.prototype, {
|
|
5649
|
+
body: { enumerable: true },
|
|
5650
|
+
bodyUsed: { enumerable: true },
|
|
5651
|
+
arrayBuffer: { enumerable: true },
|
|
5652
|
+
blob: { enumerable: true },
|
|
5653
|
+
json: { enumerable: true },
|
|
5654
|
+
text: { enumerable: true },
|
|
5655
|
+
data: { get: deprecate(() => {}, "data doesn't exist, use json(), text(), arrayBuffer(), or body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (response)") }
|
|
5656
|
+
});
|
|
5657
|
+
async function consumeBody(data) {
|
|
5658
|
+
if (data[INTERNALS].disturbed) {
|
|
5659
|
+
throw new TypeError(`body used already for: ${data.url}`);
|
|
5660
|
+
}
|
|
5661
|
+
data[INTERNALS].disturbed = true;
|
|
5662
|
+
if (data[INTERNALS].error) {
|
|
5663
|
+
throw data[INTERNALS].error;
|
|
5664
|
+
}
|
|
5665
|
+
const { body } = data;
|
|
5666
|
+
if (body === null) {
|
|
5667
|
+
return Buffer2.alloc(0);
|
|
5668
|
+
}
|
|
5669
|
+
if (!(body instanceof Stream)) {
|
|
5670
|
+
return Buffer2.alloc(0);
|
|
5671
|
+
}
|
|
5672
|
+
const accum = [];
|
|
5673
|
+
let accumBytes = 0;
|
|
5674
|
+
try {
|
|
5675
|
+
for await (const chunk of body) {
|
|
5676
|
+
if (data.size > 0 && accumBytes + chunk.length > data.size) {
|
|
5677
|
+
const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
|
|
5678
|
+
body.destroy(error);
|
|
5679
|
+
throw error;
|
|
5680
|
+
}
|
|
5681
|
+
accumBytes += chunk.length;
|
|
5682
|
+
accum.push(chunk);
|
|
5375
5683
|
}
|
|
5376
|
-
|
|
5377
|
-
|
|
5684
|
+
} catch (error) {
|
|
5685
|
+
const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
|
|
5686
|
+
throw error_;
|
|
5687
|
+
}
|
|
5688
|
+
if (body.readableEnded === true || body._readableState.ended === true) {
|
|
5378
5689
|
try {
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
return true;
|
|
5382
|
-
} catch {
|
|
5383
|
-
return false;
|
|
5384
|
-
}
|
|
5385
|
-
}));
|
|
5386
|
-
}
|
|
5387
|
-
|
|
5388
|
-
// node_modules/node-fetch/src/utils/is-redirect.js
|
|
5389
|
-
var redirectStatus = new Set([301, 302, 303, 307, 308]);
|
|
5390
|
-
var isRedirect = (code) => {
|
|
5391
|
-
return redirectStatus.has(code);
|
|
5392
|
-
};
|
|
5393
|
-
|
|
5394
|
-
// node_modules/node-fetch/src/response.js
|
|
5395
|
-
var INTERNALS2 = Symbol("Response internals");
|
|
5396
|
-
|
|
5397
|
-
class Response extends Body {
|
|
5398
|
-
constructor(body = null, options = {}) {
|
|
5399
|
-
super(body, options);
|
|
5400
|
-
const status = options.status != null ? options.status : 200;
|
|
5401
|
-
const headers = new Headers(options.headers);
|
|
5402
|
-
if (body !== null && !headers.has("Content-Type")) {
|
|
5403
|
-
const contentType = extractContentType(body, this);
|
|
5404
|
-
if (contentType) {
|
|
5405
|
-
headers.append("Content-Type", contentType);
|
|
5690
|
+
if (accum.every((c) => typeof c === "string")) {
|
|
5691
|
+
return Buffer2.from(accum.join(""));
|
|
5406
5692
|
}
|
|
5693
|
+
return Buffer2.concat(accum, accumBytes);
|
|
5694
|
+
} catch (error) {
|
|
5695
|
+
throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
|
|
5407
5696
|
}
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
url: options.url,
|
|
5411
|
-
status,
|
|
5412
|
-
statusText: options.statusText || "",
|
|
5413
|
-
headers,
|
|
5414
|
-
counter: options.counter,
|
|
5415
|
-
highWaterMark: options.highWaterMark
|
|
5416
|
-
};
|
|
5697
|
+
} else {
|
|
5698
|
+
throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
|
|
5417
5699
|
}
|
|
5418
|
-
|
|
5419
|
-
|
|
5700
|
+
}
|
|
5701
|
+
var clone = (instance, highWaterMark) => {
|
|
5702
|
+
let p1;
|
|
5703
|
+
let p2;
|
|
5704
|
+
let { body } = instance[INTERNALS];
|
|
5705
|
+
if (instance.bodyUsed) {
|
|
5706
|
+
throw new Error("cannot clone body after it is used");
|
|
5420
5707
|
}
|
|
5421
|
-
|
|
5422
|
-
|
|
5708
|
+
if (body instanceof Stream && typeof body.getBoundary !== "function") {
|
|
5709
|
+
p1 = new PassThrough({ highWaterMark });
|
|
5710
|
+
p2 = new PassThrough({ highWaterMark });
|
|
5711
|
+
body.pipe(p1);
|
|
5712
|
+
body.pipe(p2);
|
|
5713
|
+
instance[INTERNALS].stream = p1;
|
|
5714
|
+
body = p2;
|
|
5423
5715
|
}
|
|
5424
|
-
|
|
5425
|
-
|
|
5716
|
+
return body;
|
|
5717
|
+
};
|
|
5718
|
+
var getNonSpecFormDataBoundary = deprecate((body) => body.getBoundary(), "form-data doesn't follow the spec and requires special treatment. Use alternative package", "https://github.com/node-fetch/node-fetch/issues/1167");
|
|
5719
|
+
var extractContentType = (body, request) => {
|
|
5720
|
+
if (body === null) {
|
|
5721
|
+
return null;
|
|
5426
5722
|
}
|
|
5427
|
-
|
|
5428
|
-
return
|
|
5723
|
+
if (typeof body === "string") {
|
|
5724
|
+
return "text/plain;charset=UTF-8";
|
|
5429
5725
|
}
|
|
5430
|
-
|
|
5431
|
-
return
|
|
5726
|
+
if (isURLSearchParameters(body)) {
|
|
5727
|
+
return "application/x-www-form-urlencoded;charset=UTF-8";
|
|
5432
5728
|
}
|
|
5433
|
-
|
|
5434
|
-
return
|
|
5729
|
+
if (isBlob(body)) {
|
|
5730
|
+
return body.type || null;
|
|
5435
5731
|
}
|
|
5436
|
-
|
|
5437
|
-
return
|
|
5732
|
+
if (Buffer2.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
5733
|
+
return null;
|
|
5438
5734
|
}
|
|
5439
|
-
|
|
5440
|
-
return
|
|
5735
|
+
if (body instanceof FormData) {
|
|
5736
|
+
return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
|
|
5441
5737
|
}
|
|
5442
|
-
|
|
5443
|
-
return
|
|
5444
|
-
type: this.type,
|
|
5445
|
-
url: this.url,
|
|
5446
|
-
status: this.status,
|
|
5447
|
-
statusText: this.statusText,
|
|
5448
|
-
headers: this.headers,
|
|
5449
|
-
ok: this.ok,
|
|
5450
|
-
redirected: this.redirected,
|
|
5451
|
-
size: this.size,
|
|
5452
|
-
highWaterMark: this.highWaterMark
|
|
5453
|
-
});
|
|
5738
|
+
if (body && typeof body.getBoundary === "function") {
|
|
5739
|
+
return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
|
|
5454
5740
|
}
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
|
|
5458
|
-
}
|
|
5459
|
-
return new Response(null, {
|
|
5460
|
-
headers: {
|
|
5461
|
-
location: new URL(url).toString()
|
|
5462
|
-
},
|
|
5463
|
-
status
|
|
5464
|
-
});
|
|
5741
|
+
if (body instanceof Stream) {
|
|
5742
|
+
return null;
|
|
5465
5743
|
}
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5744
|
+
return "text/plain;charset=UTF-8";
|
|
5745
|
+
};
|
|
5746
|
+
var getTotalBytes = (request) => {
|
|
5747
|
+
const { body } = request[INTERNALS];
|
|
5748
|
+
if (body === null) {
|
|
5749
|
+
return 0;
|
|
5470
5750
|
}
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
if (body === undefined) {
|
|
5474
|
-
throw new TypeError("data is not JSON serializable");
|
|
5475
|
-
}
|
|
5476
|
-
const headers = new Headers(init && init.headers);
|
|
5477
|
-
if (!headers.has("content-type")) {
|
|
5478
|
-
headers.set("content-type", "application/json");
|
|
5479
|
-
}
|
|
5480
|
-
return new Response(body, {
|
|
5481
|
-
...init,
|
|
5482
|
-
headers
|
|
5483
|
-
});
|
|
5751
|
+
if (isBlob(body)) {
|
|
5752
|
+
return body.size;
|
|
5484
5753
|
}
|
|
5485
|
-
|
|
5486
|
-
return
|
|
5754
|
+
if (Buffer2.isBuffer(body)) {
|
|
5755
|
+
return body.length;
|
|
5487
5756
|
}
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
type: { enumerable: true },
|
|
5491
|
-
url: { enumerable: true },
|
|
5492
|
-
status: { enumerable: true },
|
|
5493
|
-
ok: { enumerable: true },
|
|
5494
|
-
redirected: { enumerable: true },
|
|
5495
|
-
statusText: { enumerable: true },
|
|
5496
|
-
headers: { enumerable: true },
|
|
5497
|
-
clone: { enumerable: true }
|
|
5498
|
-
});
|
|
5499
|
-
|
|
5500
|
-
// node_modules/node-fetch/src/request.js
|
|
5501
|
-
import { format as formatUrl } from "node:url";
|
|
5502
|
-
import { deprecate as deprecate2 } from "node:util";
|
|
5503
|
-
|
|
5504
|
-
// node_modules/node-fetch/src/utils/get-search.js
|
|
5505
|
-
var getSearch = (parsedURL) => {
|
|
5506
|
-
if (parsedURL.search) {
|
|
5507
|
-
return parsedURL.search;
|
|
5757
|
+
if (body && typeof body.getLengthSync === "function") {
|
|
5758
|
+
return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
|
|
5508
5759
|
}
|
|
5509
|
-
|
|
5510
|
-
const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
|
|
5511
|
-
return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
|
|
5760
|
+
return null;
|
|
5512
5761
|
};
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
return "no-referrer";
|
|
5762
|
+
var writeToStream = async (dest, { body }) => {
|
|
5763
|
+
if (body === null) {
|
|
5764
|
+
dest.end();
|
|
5765
|
+
} else {
|
|
5766
|
+
await pipeline(body, dest);
|
|
5519
5767
|
}
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5768
|
+
};
|
|
5769
|
+
|
|
5770
|
+
// node_modules/node-fetch/src/headers.js
|
|
5771
|
+
import { types as types2 } from "node:util";
|
|
5772
|
+
import http from "node:http";
|
|
5773
|
+
var validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
|
|
5774
|
+
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
|
|
5775
|
+
const error = new TypeError(`Header name must be a valid HTTP token [${name}]`);
|
|
5776
|
+
Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
|
|
5777
|
+
throw error;
|
|
5523
5778
|
}
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5779
|
+
};
|
|
5780
|
+
var validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.validateHeaderValue : (name, value) => {
|
|
5781
|
+
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
|
|
5782
|
+
const error = new TypeError(`Invalid character in header content ["${name}"]`);
|
|
5783
|
+
Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
|
|
5784
|
+
throw error;
|
|
5530
5785
|
}
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5786
|
+
};
|
|
5787
|
+
|
|
5788
|
+
class Headers extends URLSearchParams {
|
|
5789
|
+
constructor(init) {
|
|
5790
|
+
let result = [];
|
|
5791
|
+
if (init instanceof Headers) {
|
|
5792
|
+
const raw = init.raw();
|
|
5793
|
+
for (const [name, values] of Object.entries(raw)) {
|
|
5794
|
+
result.push(...values.map((value) => [name, value]));
|
|
5795
|
+
}
|
|
5796
|
+
} else if (init == null) {} else if (typeof init === "object" && !types2.isBoxedPrimitive(init)) {
|
|
5797
|
+
const method = init[Symbol.iterator];
|
|
5798
|
+
if (method == null) {
|
|
5799
|
+
result.push(...Object.entries(init));
|
|
5800
|
+
} else {
|
|
5801
|
+
if (typeof method !== "function") {
|
|
5802
|
+
throw new TypeError("Header pairs must be iterable");
|
|
5803
|
+
}
|
|
5804
|
+
result = [...init].map((pair) => {
|
|
5805
|
+
if (typeof pair !== "object" || types2.isBoxedPrimitive(pair)) {
|
|
5806
|
+
throw new TypeError("Each header pair must be an iterable object");
|
|
5807
|
+
}
|
|
5808
|
+
return [...pair];
|
|
5809
|
+
}).map((pair) => {
|
|
5810
|
+
if (pair.length !== 2) {
|
|
5811
|
+
throw new TypeError("Each header pair must be a name/value tuple");
|
|
5812
|
+
}
|
|
5813
|
+
return [...pair];
|
|
5814
|
+
});
|
|
5815
|
+
}
|
|
5816
|
+
} else {
|
|
5817
|
+
throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
|
|
5818
|
+
}
|
|
5819
|
+
result = result.length > 0 ? result.map(([name, value]) => {
|
|
5820
|
+
validateHeaderName(name);
|
|
5821
|
+
validateHeaderValue(name, String(value));
|
|
5822
|
+
return [String(name).toLowerCase(), String(value)];
|
|
5823
|
+
}) : undefined;
|
|
5824
|
+
super(result);
|
|
5825
|
+
return new Proxy(this, {
|
|
5826
|
+
get(target, p, receiver) {
|
|
5827
|
+
switch (p) {
|
|
5828
|
+
case "append":
|
|
5829
|
+
case "set":
|
|
5830
|
+
return (name, value) => {
|
|
5831
|
+
validateHeaderName(name);
|
|
5832
|
+
validateHeaderValue(name, String(value));
|
|
5833
|
+
return URLSearchParams.prototype[p].call(target, String(name).toLowerCase(), String(value));
|
|
5834
|
+
};
|
|
5835
|
+
case "delete":
|
|
5836
|
+
case "has":
|
|
5837
|
+
case "getAll":
|
|
5838
|
+
return (name) => {
|
|
5839
|
+
validateHeaderName(name);
|
|
5840
|
+
return URLSearchParams.prototype[p].call(target, String(name).toLowerCase());
|
|
5841
|
+
};
|
|
5842
|
+
case "keys":
|
|
5843
|
+
return () => {
|
|
5844
|
+
target.sort();
|
|
5845
|
+
return new Set(URLSearchParams.prototype.keys.call(target)).keys();
|
|
5846
|
+
};
|
|
5847
|
+
default:
|
|
5848
|
+
return Reflect.get(target, p, receiver);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
});
|
|
5568
5852
|
}
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
function isUrlPotentiallyTrustworthy(url) {
|
|
5572
|
-
if (/^about:(blank|srcdoc)$/.test(url)) {
|
|
5573
|
-
return true;
|
|
5853
|
+
get [Symbol.toStringTag]() {
|
|
5854
|
+
return this.constructor.name;
|
|
5574
5855
|
}
|
|
5575
|
-
|
|
5576
|
-
return
|
|
5856
|
+
toString() {
|
|
5857
|
+
return Object.prototype.toString.call(this);
|
|
5577
5858
|
}
|
|
5578
|
-
|
|
5579
|
-
|
|
5859
|
+
get(name) {
|
|
5860
|
+
const values = this.getAll(name);
|
|
5861
|
+
if (values.length === 0) {
|
|
5862
|
+
return null;
|
|
5863
|
+
}
|
|
5864
|
+
let value = values.join(", ");
|
|
5865
|
+
if (/^content-encoding$/i.test(name)) {
|
|
5866
|
+
value = value.toLowerCase();
|
|
5867
|
+
}
|
|
5868
|
+
return value;
|
|
5580
5869
|
}
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
return null;
|
|
5870
|
+
forEach(callback, thisArg = undefined) {
|
|
5871
|
+
for (const name of this.keys()) {
|
|
5872
|
+
Reflect.apply(callback, thisArg, [this.get(name), name, this]);
|
|
5873
|
+
}
|
|
5586
5874
|
}
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5875
|
+
*values() {
|
|
5876
|
+
for (const name of this.keys()) {
|
|
5877
|
+
yield this.get(name);
|
|
5878
|
+
}
|
|
5590
5879
|
}
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
referrerURL = referrerOrigin;
|
|
5880
|
+
*entries() {
|
|
5881
|
+
for (const name of this.keys()) {
|
|
5882
|
+
yield [name, this.get(name)];
|
|
5883
|
+
}
|
|
5596
5884
|
}
|
|
5597
|
-
|
|
5598
|
-
|
|
5885
|
+
[Symbol.iterator]() {
|
|
5886
|
+
return this.entries();
|
|
5599
5887
|
}
|
|
5600
|
-
|
|
5601
|
-
|
|
5888
|
+
raw() {
|
|
5889
|
+
return [...this.keys()].reduce((result, key) => {
|
|
5890
|
+
result[key] = this.getAll(key);
|
|
5891
|
+
return result;
|
|
5892
|
+
}, {});
|
|
5602
5893
|
}
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
return referrerURL;
|
|
5611
|
-
case "strict-origin":
|
|
5612
|
-
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
5613
|
-
return "no-referrer";
|
|
5614
|
-
}
|
|
5615
|
-
return referrerOrigin.toString();
|
|
5616
|
-
case "strict-origin-when-cross-origin":
|
|
5617
|
-
if (referrerURL.origin === currentURL.origin) {
|
|
5618
|
-
return referrerURL;
|
|
5619
|
-
}
|
|
5620
|
-
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
5621
|
-
return "no-referrer";
|
|
5622
|
-
}
|
|
5623
|
-
return referrerOrigin;
|
|
5624
|
-
case "same-origin":
|
|
5625
|
-
if (referrerURL.origin === currentURL.origin) {
|
|
5626
|
-
return referrerURL;
|
|
5627
|
-
}
|
|
5628
|
-
return "no-referrer";
|
|
5629
|
-
case "origin-when-cross-origin":
|
|
5630
|
-
if (referrerURL.origin === currentURL.origin) {
|
|
5631
|
-
return referrerURL;
|
|
5632
|
-
}
|
|
5633
|
-
return referrerOrigin;
|
|
5634
|
-
case "no-referrer-when-downgrade":
|
|
5635
|
-
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
5636
|
-
return "no-referrer";
|
|
5894
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
5895
|
+
return [...this.keys()].reduce((result, key) => {
|
|
5896
|
+
const values = this.getAll(key);
|
|
5897
|
+
if (key === "host") {
|
|
5898
|
+
result[key] = values[0];
|
|
5899
|
+
} else {
|
|
5900
|
+
result[key] = values.length > 1 ? values : values[0];
|
|
5637
5901
|
}
|
|
5638
|
-
return
|
|
5639
|
-
|
|
5640
|
-
throw new TypeError(`Invalid referrerPolicy: ${policy}`);
|
|
5902
|
+
return result;
|
|
5903
|
+
}, {});
|
|
5641
5904
|
}
|
|
5642
5905
|
}
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5906
|
+
Object.defineProperties(Headers.prototype, ["get", "entries", "forEach", "values"].reduce((result, property) => {
|
|
5907
|
+
result[property] = { enumerable: true };
|
|
5908
|
+
return result;
|
|
5909
|
+
}, {}));
|
|
5910
|
+
function fromRawHeaders(headers = []) {
|
|
5911
|
+
return new Headers(headers.reduce((result, value, index, array) => {
|
|
5912
|
+
if (index % 2 === 0) {
|
|
5913
|
+
result.push(array.slice(index, index + 2));
|
|
5649
5914
|
}
|
|
5650
|
-
|
|
5651
|
-
|
|
5915
|
+
return result;
|
|
5916
|
+
}, []).filter(([name, value]) => {
|
|
5917
|
+
try {
|
|
5918
|
+
validateHeaderName(name);
|
|
5919
|
+
validateHeaderValue(name, String(value));
|
|
5920
|
+
return true;
|
|
5921
|
+
} catch {
|
|
5922
|
+
return false;
|
|
5923
|
+
}
|
|
5924
|
+
}));
|
|
5652
5925
|
}
|
|
5653
5926
|
|
|
5654
|
-
// node_modules/node-fetch/src/
|
|
5655
|
-
var
|
|
5656
|
-
var
|
|
5657
|
-
return
|
|
5927
|
+
// node_modules/node-fetch/src/utils/is-redirect.js
|
|
5928
|
+
var redirectStatus = new Set([301, 302, 303, 307, 308]);
|
|
5929
|
+
var isRedirect = (code) => {
|
|
5930
|
+
return redirectStatus.has(code);
|
|
5658
5931
|
};
|
|
5659
|
-
var doBadDataWarn = deprecate2(() => {}, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
|
|
5660
5932
|
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
|
|
5672
|
-
}
|
|
5673
|
-
let method = init.method || input.method || "GET";
|
|
5674
|
-
if (/^(delete|get|head|options|post|put)$/i.test(method)) {
|
|
5675
|
-
method = method.toUpperCase();
|
|
5676
|
-
}
|
|
5677
|
-
if (!isRequest(init) && "data" in init) {
|
|
5678
|
-
doBadDataWarn();
|
|
5679
|
-
}
|
|
5680
|
-
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
|
5681
|
-
throw new TypeError("Request with GET/HEAD method cannot have body");
|
|
5682
|
-
}
|
|
5683
|
-
const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
|
5684
|
-
super(inputBody, {
|
|
5685
|
-
size: init.size || input.size || 0
|
|
5686
|
-
});
|
|
5687
|
-
const headers = new Headers(init.headers || input.headers || {});
|
|
5688
|
-
if (inputBody !== null && !headers.has("Content-Type")) {
|
|
5689
|
-
const contentType = extractContentType(inputBody, this);
|
|
5933
|
+
// node_modules/node-fetch/src/response.js
|
|
5934
|
+
var INTERNALS2 = Symbol("Response internals");
|
|
5935
|
+
|
|
5936
|
+
class Response extends Body {
|
|
5937
|
+
constructor(body = null, options = {}) {
|
|
5938
|
+
super(body, options);
|
|
5939
|
+
const status = options.status != null ? options.status : 200;
|
|
5940
|
+
const headers = new Headers(options.headers);
|
|
5941
|
+
if (body !== null && !headers.has("Content-Type")) {
|
|
5942
|
+
const contentType = extractContentType(body, this);
|
|
5690
5943
|
if (contentType) {
|
|
5691
|
-
headers.
|
|
5944
|
+
headers.append("Content-Type", contentType);
|
|
5692
5945
|
}
|
|
5693
5946
|
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
|
|
5700
|
-
}
|
|
5701
|
-
let referrer = init.referrer == null ? input.referrer : init.referrer;
|
|
5702
|
-
if (referrer === "") {
|
|
5703
|
-
referrer = "no-referrer";
|
|
5704
|
-
} else if (referrer) {
|
|
5705
|
-
const parsedReferrer = new URL(referrer);
|
|
5706
|
-
referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
|
|
5707
|
-
} else {
|
|
5708
|
-
referrer = undefined;
|
|
5709
|
-
}
|
|
5710
|
-
this[INTERNALS3] = {
|
|
5711
|
-
method,
|
|
5712
|
-
redirect: init.redirect || input.redirect || "follow",
|
|
5947
|
+
this[INTERNALS2] = {
|
|
5948
|
+
type: "default",
|
|
5949
|
+
url: options.url,
|
|
5950
|
+
status,
|
|
5951
|
+
statusText: options.statusText || "",
|
|
5713
5952
|
headers,
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
referrer
|
|
5953
|
+
counter: options.counter,
|
|
5954
|
+
highWaterMark: options.highWaterMark
|
|
5717
5955
|
};
|
|
5718
|
-
this.follow = init.follow === undefined ? input.follow === undefined ? 20 : input.follow : init.follow;
|
|
5719
|
-
this.compress = init.compress === undefined ? input.compress === undefined ? true : input.compress : init.compress;
|
|
5720
|
-
this.counter = init.counter || input.counter || 0;
|
|
5721
|
-
this.agent = init.agent || input.agent;
|
|
5722
|
-
this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
|
|
5723
|
-
this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
|
|
5724
|
-
this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
|
|
5725
5956
|
}
|
|
5726
|
-
get
|
|
5727
|
-
return this[
|
|
5957
|
+
get type() {
|
|
5958
|
+
return this[INTERNALS2].type;
|
|
5728
5959
|
}
|
|
5729
5960
|
get url() {
|
|
5730
|
-
return
|
|
5961
|
+
return this[INTERNALS2].url || "";
|
|
5731
5962
|
}
|
|
5732
|
-
get
|
|
5733
|
-
return this[
|
|
5963
|
+
get status() {
|
|
5964
|
+
return this[INTERNALS2].status;
|
|
5734
5965
|
}
|
|
5735
|
-
get
|
|
5736
|
-
return this[
|
|
5966
|
+
get ok() {
|
|
5967
|
+
return this[INTERNALS2].status >= 200 && this[INTERNALS2].status < 300;
|
|
5737
5968
|
}
|
|
5738
|
-
get
|
|
5739
|
-
return this[
|
|
5969
|
+
get redirected() {
|
|
5970
|
+
return this[INTERNALS2].counter > 0;
|
|
5740
5971
|
}
|
|
5741
|
-
get
|
|
5742
|
-
|
|
5743
|
-
return "";
|
|
5744
|
-
}
|
|
5745
|
-
if (this[INTERNALS3].referrer === "client") {
|
|
5746
|
-
return "about:client";
|
|
5747
|
-
}
|
|
5748
|
-
if (this[INTERNALS3].referrer) {
|
|
5749
|
-
return this[INTERNALS3].referrer.toString();
|
|
5750
|
-
}
|
|
5751
|
-
return;
|
|
5972
|
+
get statusText() {
|
|
5973
|
+
return this[INTERNALS2].statusText;
|
|
5752
5974
|
}
|
|
5753
|
-
get
|
|
5754
|
-
return this[
|
|
5975
|
+
get headers() {
|
|
5976
|
+
return this[INTERNALS2].headers;
|
|
5755
5977
|
}
|
|
5756
|
-
|
|
5757
|
-
this[
|
|
5978
|
+
get highWaterMark() {
|
|
5979
|
+
return this[INTERNALS2].highWaterMark;
|
|
5758
5980
|
}
|
|
5759
5981
|
clone() {
|
|
5760
|
-
return new
|
|
5982
|
+
return new Response(clone(this, this.highWaterMark), {
|
|
5983
|
+
type: this.type,
|
|
5984
|
+
url: this.url,
|
|
5985
|
+
status: this.status,
|
|
5986
|
+
statusText: this.statusText,
|
|
5987
|
+
headers: this.headers,
|
|
5988
|
+
ok: this.ok,
|
|
5989
|
+
redirected: this.redirected,
|
|
5990
|
+
size: this.size,
|
|
5991
|
+
highWaterMark: this.highWaterMark
|
|
5992
|
+
});
|
|
5993
|
+
}
|
|
5994
|
+
static redirect(url, status = 302) {
|
|
5995
|
+
if (!isRedirect(status)) {
|
|
5996
|
+
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
|
|
5997
|
+
}
|
|
5998
|
+
return new Response(null, {
|
|
5999
|
+
headers: {
|
|
6000
|
+
location: new URL(url).toString()
|
|
6001
|
+
},
|
|
6002
|
+
status
|
|
6003
|
+
});
|
|
6004
|
+
}
|
|
6005
|
+
static error() {
|
|
6006
|
+
const response = new Response(null, { status: 0, statusText: "" });
|
|
6007
|
+
response[INTERNALS2].type = "error";
|
|
6008
|
+
return response;
|
|
6009
|
+
}
|
|
6010
|
+
static json(data = undefined, init = {}) {
|
|
6011
|
+
const body = JSON.stringify(data);
|
|
6012
|
+
if (body === undefined) {
|
|
6013
|
+
throw new TypeError("data is not JSON serializable");
|
|
6014
|
+
}
|
|
6015
|
+
const headers = new Headers(init && init.headers);
|
|
6016
|
+
if (!headers.has("content-type")) {
|
|
6017
|
+
headers.set("content-type", "application/json");
|
|
6018
|
+
}
|
|
6019
|
+
return new Response(body, {
|
|
6020
|
+
...init,
|
|
6021
|
+
headers
|
|
6022
|
+
});
|
|
5761
6023
|
}
|
|
5762
6024
|
get [Symbol.toStringTag]() {
|
|
5763
|
-
return "
|
|
6025
|
+
return "Response";
|
|
5764
6026
|
}
|
|
5765
6027
|
}
|
|
5766
|
-
Object.defineProperties(
|
|
5767
|
-
|
|
6028
|
+
Object.defineProperties(Response.prototype, {
|
|
6029
|
+
type: { enumerable: true },
|
|
5768
6030
|
url: { enumerable: true },
|
|
6031
|
+
status: { enumerable: true },
|
|
6032
|
+
ok: { enumerable: true },
|
|
6033
|
+
redirected: { enumerable: true },
|
|
6034
|
+
statusText: { enumerable: true },
|
|
5769
6035
|
headers: { enumerable: true },
|
|
5770
|
-
|
|
5771
|
-
clone: { enumerable: true },
|
|
5772
|
-
signal: { enumerable: true },
|
|
5773
|
-
referrer: { enumerable: true },
|
|
5774
|
-
referrerPolicy: { enumerable: true }
|
|
6036
|
+
clone: { enumerable: true }
|
|
5775
6037
|
});
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
6038
|
+
|
|
6039
|
+
// node_modules/node-fetch/src/request.js
|
|
6040
|
+
import { format as formatUrl } from "node:url";
|
|
6041
|
+
import { deprecate as deprecate2 } from "node:util";
|
|
6042
|
+
|
|
6043
|
+
// node_modules/node-fetch/src/utils/get-search.js
|
|
6044
|
+
var getSearch = (parsedURL) => {
|
|
6045
|
+
if (parsedURL.search) {
|
|
6046
|
+
return parsedURL.search;
|
|
5781
6047
|
}
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
6048
|
+
const lastOffset = parsedURL.href.length - 1;
|
|
6049
|
+
const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
|
|
6050
|
+
return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
|
|
6051
|
+
};
|
|
6052
|
+
|
|
6053
|
+
// node_modules/node-fetch/src/utils/referrer.js
|
|
6054
|
+
import { isIP } from "node:net";
|
|
6055
|
+
function stripURLForUseAsAReferrer(url, originOnly = false) {
|
|
6056
|
+
if (url == null) {
|
|
6057
|
+
return "no-referrer";
|
|
5785
6058
|
}
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
contentLengthValue = String(totalBytes);
|
|
5790
|
-
}
|
|
6059
|
+
url = new URL(url);
|
|
6060
|
+
if (/^(about|blob|data):$/.test(url.protocol)) {
|
|
6061
|
+
return "no-referrer";
|
|
5791
6062
|
}
|
|
5792
|
-
|
|
5793
|
-
|
|
6063
|
+
url.username = "";
|
|
6064
|
+
url.password = "";
|
|
6065
|
+
url.hash = "";
|
|
6066
|
+
if (originOnly) {
|
|
6067
|
+
url.pathname = "";
|
|
6068
|
+
url.search = "";
|
|
5794
6069
|
}
|
|
5795
|
-
|
|
5796
|
-
|
|
6070
|
+
return url;
|
|
6071
|
+
}
|
|
6072
|
+
var ReferrerPolicy = new Set([
|
|
6073
|
+
"",
|
|
6074
|
+
"no-referrer",
|
|
6075
|
+
"no-referrer-when-downgrade",
|
|
6076
|
+
"same-origin",
|
|
6077
|
+
"origin",
|
|
6078
|
+
"strict-origin",
|
|
6079
|
+
"origin-when-cross-origin",
|
|
6080
|
+
"strict-origin-when-cross-origin",
|
|
6081
|
+
"unsafe-url"
|
|
6082
|
+
]);
|
|
6083
|
+
var DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
|
|
6084
|
+
function validateReferrerPolicy(referrerPolicy) {
|
|
6085
|
+
if (!ReferrerPolicy.has(referrerPolicy)) {
|
|
6086
|
+
throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
|
|
5797
6087
|
}
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
6088
|
+
return referrerPolicy;
|
|
6089
|
+
}
|
|
6090
|
+
function isOriginPotentiallyTrustworthy(url) {
|
|
6091
|
+
if (/^(http|ws)s:$/.test(url.protocol)) {
|
|
6092
|
+
return true;
|
|
5802
6093
|
}
|
|
5803
|
-
|
|
5804
|
-
|
|
6094
|
+
const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
|
|
6095
|
+
const hostIPVersion = isIP(hostIp);
|
|
6096
|
+
if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
|
|
6097
|
+
return true;
|
|
5805
6098
|
}
|
|
5806
|
-
if (
|
|
5807
|
-
|
|
6099
|
+
if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) {
|
|
6100
|
+
return true;
|
|
5808
6101
|
}
|
|
5809
|
-
if (
|
|
5810
|
-
|
|
6102
|
+
if (url.host === "localhost" || url.host.endsWith(".localhost")) {
|
|
6103
|
+
return false;
|
|
5811
6104
|
}
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
agent = agent(parsedURL);
|
|
6105
|
+
if (url.protocol === "file:") {
|
|
6106
|
+
return true;
|
|
5815
6107
|
}
|
|
5816
|
-
|
|
5817
|
-
const options = {
|
|
5818
|
-
path: parsedURL.pathname + search,
|
|
5819
|
-
method: request.method,
|
|
5820
|
-
headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
|
|
5821
|
-
insecureHTTPParser: request.insecureHTTPParser,
|
|
5822
|
-
agent
|
|
5823
|
-
};
|
|
5824
|
-
return {
|
|
5825
|
-
parsedURL,
|
|
5826
|
-
options
|
|
5827
|
-
};
|
|
5828
|
-
};
|
|
5829
|
-
|
|
5830
|
-
// node_modules/node-fetch/src/errors/abort-error.js
|
|
5831
|
-
class AbortError extends FetchBaseError {
|
|
5832
|
-
constructor(message, type = "aborted") {
|
|
5833
|
-
super(message, type);
|
|
5834
|
-
}
|
|
5835
|
-
}
|
|
5836
|
-
|
|
5837
|
-
// node_modules/node-fetch/src/index.js
|
|
5838
|
-
init_esm_min();
|
|
5839
|
-
init_from();
|
|
5840
|
-
var supportedSchemas = new Set(["data:", "http:", "https:"]);
|
|
5841
|
-
async function fetch2(url, options_) {
|
|
5842
|
-
return new Promise((resolve, reject) => {
|
|
5843
|
-
const request = new Request(url, options_);
|
|
5844
|
-
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
5845
|
-
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
5846
|
-
throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
|
|
5847
|
-
}
|
|
5848
|
-
if (parsedURL.protocol === "data:") {
|
|
5849
|
-
const data = dist_default(request.url);
|
|
5850
|
-
const response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
|
|
5851
|
-
resolve(response2);
|
|
5852
|
-
return;
|
|
5853
|
-
}
|
|
5854
|
-
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
5855
|
-
const { signal } = request;
|
|
5856
|
-
let response = null;
|
|
5857
|
-
const abort = () => {
|
|
5858
|
-
const error = new AbortError("The operation was aborted.");
|
|
5859
|
-
reject(error);
|
|
5860
|
-
if (request.body && request.body instanceof Stream2.Readable) {
|
|
5861
|
-
request.body.destroy(error);
|
|
5862
|
-
}
|
|
5863
|
-
if (!response || !response.body) {
|
|
5864
|
-
return;
|
|
5865
|
-
}
|
|
5866
|
-
response.body.emit("error", error);
|
|
5867
|
-
};
|
|
5868
|
-
if (signal && signal.aborted) {
|
|
5869
|
-
abort();
|
|
5870
|
-
return;
|
|
5871
|
-
}
|
|
5872
|
-
const abortAndFinalize = () => {
|
|
5873
|
-
abort();
|
|
5874
|
-
finalize();
|
|
5875
|
-
};
|
|
5876
|
-
const request_ = send(parsedURL.toString(), options);
|
|
5877
|
-
if (signal) {
|
|
5878
|
-
signal.addEventListener("abort", abortAndFinalize);
|
|
5879
|
-
}
|
|
5880
|
-
const finalize = () => {
|
|
5881
|
-
request_.abort();
|
|
5882
|
-
if (signal) {
|
|
5883
|
-
signal.removeEventListener("abort", abortAndFinalize);
|
|
5884
|
-
}
|
|
5885
|
-
};
|
|
5886
|
-
request_.on("error", (error) => {
|
|
5887
|
-
reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
|
|
5888
|
-
finalize();
|
|
5889
|
-
});
|
|
5890
|
-
fixResponseChunkedTransferBadEnding(request_, (error) => {
|
|
5891
|
-
if (response && response.body) {
|
|
5892
|
-
response.body.destroy(error);
|
|
5893
|
-
}
|
|
5894
|
-
});
|
|
5895
|
-
if (process.version < "v14") {
|
|
5896
|
-
request_.on("socket", (s2) => {
|
|
5897
|
-
let endedWithEventsCount;
|
|
5898
|
-
s2.prependListener("end", () => {
|
|
5899
|
-
endedWithEventsCount = s2._eventsCount;
|
|
5900
|
-
});
|
|
5901
|
-
s2.prependListener("close", (hadError) => {
|
|
5902
|
-
if (response && endedWithEventsCount < s2._eventsCount && !hadError) {
|
|
5903
|
-
const error = new Error("Premature close");
|
|
5904
|
-
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
5905
|
-
response.body.emit("error", error);
|
|
5906
|
-
}
|
|
5907
|
-
});
|
|
5908
|
-
});
|
|
5909
|
-
}
|
|
5910
|
-
request_.on("response", (response_) => {
|
|
5911
|
-
request_.setTimeout(0);
|
|
5912
|
-
const headers = fromRawHeaders(response_.rawHeaders);
|
|
5913
|
-
if (isRedirect(response_.statusCode)) {
|
|
5914
|
-
const location = headers.get("Location");
|
|
5915
|
-
let locationURL = null;
|
|
5916
|
-
try {
|
|
5917
|
-
locationURL = location === null ? null : new URL(location, request.url);
|
|
5918
|
-
} catch {
|
|
5919
|
-
if (request.redirect !== "manual") {
|
|
5920
|
-
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
|
|
5921
|
-
finalize();
|
|
5922
|
-
return;
|
|
5923
|
-
}
|
|
5924
|
-
}
|
|
5925
|
-
switch (request.redirect) {
|
|
5926
|
-
case "error":
|
|
5927
|
-
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
|
|
5928
|
-
finalize();
|
|
5929
|
-
return;
|
|
5930
|
-
case "manual":
|
|
5931
|
-
break;
|
|
5932
|
-
case "follow": {
|
|
5933
|
-
if (locationURL === null) {
|
|
5934
|
-
break;
|
|
5935
|
-
}
|
|
5936
|
-
if (request.counter >= request.follow) {
|
|
5937
|
-
reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
|
|
5938
|
-
finalize();
|
|
5939
|
-
return;
|
|
5940
|
-
}
|
|
5941
|
-
const requestOptions = {
|
|
5942
|
-
headers: new Headers(request.headers),
|
|
5943
|
-
follow: request.follow,
|
|
5944
|
-
counter: request.counter + 1,
|
|
5945
|
-
agent: request.agent,
|
|
5946
|
-
compress: request.compress,
|
|
5947
|
-
method: request.method,
|
|
5948
|
-
body: clone(request),
|
|
5949
|
-
signal: request.signal,
|
|
5950
|
-
size: request.size,
|
|
5951
|
-
referrer: request.referrer,
|
|
5952
|
-
referrerPolicy: request.referrerPolicy
|
|
5953
|
-
};
|
|
5954
|
-
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
|
5955
|
-
for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
|
|
5956
|
-
requestOptions.headers.delete(name);
|
|
5957
|
-
}
|
|
5958
|
-
}
|
|
5959
|
-
if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream2.Readable) {
|
|
5960
|
-
reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
|
|
5961
|
-
finalize();
|
|
5962
|
-
return;
|
|
5963
|
-
}
|
|
5964
|
-
if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
|
|
5965
|
-
requestOptions.method = "GET";
|
|
5966
|
-
requestOptions.body = undefined;
|
|
5967
|
-
requestOptions.headers.delete("content-length");
|
|
5968
|
-
}
|
|
5969
|
-
const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
|
|
5970
|
-
if (responseReferrerPolicy) {
|
|
5971
|
-
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
5972
|
-
}
|
|
5973
|
-
resolve(fetch2(new Request(locationURL, requestOptions)));
|
|
5974
|
-
finalize();
|
|
5975
|
-
return;
|
|
5976
|
-
}
|
|
5977
|
-
default:
|
|
5978
|
-
return reject(new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
|
|
5979
|
-
}
|
|
5980
|
-
}
|
|
5981
|
-
if (signal) {
|
|
5982
|
-
response_.once("end", () => {
|
|
5983
|
-
signal.removeEventListener("abort", abortAndFinalize);
|
|
5984
|
-
});
|
|
5985
|
-
}
|
|
5986
|
-
let body = pump(response_, new PassThrough2, (error) => {
|
|
5987
|
-
if (error) {
|
|
5988
|
-
reject(error);
|
|
5989
|
-
}
|
|
5990
|
-
});
|
|
5991
|
-
if (process.version < "v12.10") {
|
|
5992
|
-
response_.on("aborted", abortAndFinalize);
|
|
5993
|
-
}
|
|
5994
|
-
const responseOptions = {
|
|
5995
|
-
url: request.url,
|
|
5996
|
-
status: response_.statusCode,
|
|
5997
|
-
statusText: response_.statusMessage,
|
|
5998
|
-
headers,
|
|
5999
|
-
size: request.size,
|
|
6000
|
-
counter: request.counter,
|
|
6001
|
-
highWaterMark: request.highWaterMark
|
|
6002
|
-
};
|
|
6003
|
-
const codings = headers.get("Content-Encoding");
|
|
6004
|
-
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
6005
|
-
response = new Response(body, responseOptions);
|
|
6006
|
-
resolve(response);
|
|
6007
|
-
return;
|
|
6008
|
-
}
|
|
6009
|
-
const zlibOptions = {
|
|
6010
|
-
flush: zlib.Z_SYNC_FLUSH,
|
|
6011
|
-
finishFlush: zlib.Z_SYNC_FLUSH
|
|
6012
|
-
};
|
|
6013
|
-
if (codings === "gzip" || codings === "x-gzip") {
|
|
6014
|
-
body = pump(body, zlib.createGunzip(zlibOptions), (error) => {
|
|
6015
|
-
if (error) {
|
|
6016
|
-
reject(error);
|
|
6017
|
-
}
|
|
6018
|
-
});
|
|
6019
|
-
response = new Response(body, responseOptions);
|
|
6020
|
-
resolve(response);
|
|
6021
|
-
return;
|
|
6022
|
-
}
|
|
6023
|
-
if (codings === "deflate" || codings === "x-deflate") {
|
|
6024
|
-
const raw = pump(response_, new PassThrough2, (error) => {
|
|
6025
|
-
if (error) {
|
|
6026
|
-
reject(error);
|
|
6027
|
-
}
|
|
6028
|
-
});
|
|
6029
|
-
raw.once("data", (chunk) => {
|
|
6030
|
-
if ((chunk[0] & 15) === 8) {
|
|
6031
|
-
body = pump(body, zlib.createInflate(), (error) => {
|
|
6032
|
-
if (error) {
|
|
6033
|
-
reject(error);
|
|
6034
|
-
}
|
|
6035
|
-
});
|
|
6036
|
-
} else {
|
|
6037
|
-
body = pump(body, zlib.createInflateRaw(), (error) => {
|
|
6038
|
-
if (error) {
|
|
6039
|
-
reject(error);
|
|
6040
|
-
}
|
|
6041
|
-
});
|
|
6042
|
-
}
|
|
6043
|
-
response = new Response(body, responseOptions);
|
|
6044
|
-
resolve(response);
|
|
6045
|
-
});
|
|
6046
|
-
raw.once("end", () => {
|
|
6047
|
-
if (!response) {
|
|
6048
|
-
response = new Response(body, responseOptions);
|
|
6049
|
-
resolve(response);
|
|
6050
|
-
}
|
|
6051
|
-
});
|
|
6052
|
-
return;
|
|
6053
|
-
}
|
|
6054
|
-
if (codings === "br") {
|
|
6055
|
-
body = pump(body, zlib.createBrotliDecompress(), (error) => {
|
|
6056
|
-
if (error) {
|
|
6057
|
-
reject(error);
|
|
6058
|
-
}
|
|
6059
|
-
});
|
|
6060
|
-
response = new Response(body, responseOptions);
|
|
6061
|
-
resolve(response);
|
|
6062
|
-
return;
|
|
6063
|
-
}
|
|
6064
|
-
response = new Response(body, responseOptions);
|
|
6065
|
-
resolve(response);
|
|
6066
|
-
});
|
|
6067
|
-
writeToStream(request_, request).catch(reject);
|
|
6068
|
-
});
|
|
6069
|
-
}
|
|
6070
|
-
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
6071
|
-
const LAST_CHUNK = Buffer3.from(`0\r
|
|
6072
|
-
\r
|
|
6073
|
-
`);
|
|
6074
|
-
let isChunkedTransfer = false;
|
|
6075
|
-
let properLastChunkReceived = false;
|
|
6076
|
-
let previousChunk;
|
|
6077
|
-
request.on("response", (response) => {
|
|
6078
|
-
const { headers } = response;
|
|
6079
|
-
isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
|
|
6080
|
-
});
|
|
6081
|
-
request.on("socket", (socket) => {
|
|
6082
|
-
const onSocketClose = () => {
|
|
6083
|
-
if (isChunkedTransfer && !properLastChunkReceived) {
|
|
6084
|
-
const error = new Error("Premature close");
|
|
6085
|
-
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
6086
|
-
errorCallback(error);
|
|
6087
|
-
}
|
|
6088
|
-
};
|
|
6089
|
-
const onData = (buf) => {
|
|
6090
|
-
properLastChunkReceived = Buffer3.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
|
6091
|
-
if (!properLastChunkReceived && previousChunk) {
|
|
6092
|
-
properLastChunkReceived = Buffer3.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer3.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
|
|
6093
|
-
}
|
|
6094
|
-
previousChunk = buf;
|
|
6095
|
-
};
|
|
6096
|
-
socket.prependListener("close", onSocketClose);
|
|
6097
|
-
socket.on("data", onData);
|
|
6098
|
-
request.on("close", () => {
|
|
6099
|
-
socket.removeListener("close", onSocketClose);
|
|
6100
|
-
socket.removeListener("data", onData);
|
|
6101
|
-
});
|
|
6102
|
-
});
|
|
6108
|
+
return false;
|
|
6103
6109
|
}
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
rejectUnauthorized: false
|
|
6108
|
-
});
|
|
6109
|
-
async function customFetch(url, init) {
|
|
6110
|
-
if (typeof Bun !== "undefined") {
|
|
6111
|
-
return await fetch(url.toString(), {
|
|
6112
|
-
method: init?.method,
|
|
6113
|
-
tls: {
|
|
6114
|
-
rejectUnauthorized: false
|
|
6115
|
-
}
|
|
6116
|
-
});
|
|
6110
|
+
function isUrlPotentiallyTrustworthy(url) {
|
|
6111
|
+
if (/^about:(blank|srcdoc)$/.test(url)) {
|
|
6112
|
+
return true;
|
|
6117
6113
|
}
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
// src/sonar/requests/volume-settings/request-volume-settings-classic.ts
|
|
6122
|
-
async function requestVolumeSettingsClassic(sonarEndpoint) {
|
|
6123
|
-
let response;
|
|
6124
|
-
try {
|
|
6125
|
-
const url = new URL(`${sonarEndpoint}/volumeSettings/classic`);
|
|
6126
|
-
response = await customFetch(url);
|
|
6127
|
-
} catch (error) {
|
|
6128
|
-
throw new SonarRequestException({ innerException: error });
|
|
6114
|
+
if (url.protocol === "data:") {
|
|
6115
|
+
return true;
|
|
6129
6116
|
}
|
|
6130
|
-
if (
|
|
6131
|
-
|
|
6132
|
-
if (data?.masters?.classic == null) {
|
|
6133
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6134
|
-
}
|
|
6135
|
-
return data;
|
|
6136
|
-
} else {
|
|
6137
|
-
const data = await response.json();
|
|
6138
|
-
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
6117
|
+
if (/^(blob|filesystem):$/.test(url.protocol)) {
|
|
6118
|
+
return true;
|
|
6139
6119
|
}
|
|
6120
|
+
return isOriginPotentiallyTrustworthy(url);
|
|
6140
6121
|
}
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
const data = await requestVolumeSettingsClassic(sonarEndpoint);
|
|
6145
|
-
const volumeData = {
|
|
6146
|
-
["master" /* Master */]: createResponseVolumeData(data.masters.classic),
|
|
6147
|
-
["game" /* Game */]: data.devices.game && createResponseVolumeData(data.devices.game.classic),
|
|
6148
|
-
["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData(data.devices.chatRender.classic),
|
|
6149
|
-
["media" /* Media */]: data.devices.media && createResponseVolumeData(data.devices.media.classic),
|
|
6150
|
-
["aux" /* Aux */]: data.devices.aux && createResponseVolumeData(data.devices.aux.classic),
|
|
6151
|
-
["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData(data.devices.chatCapture.classic)
|
|
6152
|
-
};
|
|
6153
|
-
return volumeData;
|
|
6154
|
-
}
|
|
6155
|
-
function createResponseVolumeData(volumeData) {
|
|
6156
|
-
return {
|
|
6157
|
-
volume: convertVolumeToUser(volumeData.volume),
|
|
6158
|
-
isMuted: volumeData.muted
|
|
6159
|
-
};
|
|
6160
|
-
}
|
|
6161
|
-
// src/sonar/requests/volume-settings/request-volume-settings-streamer.ts
|
|
6162
|
-
async function requestVolumeSettingsStreamer(sonarEndpoint) {
|
|
6163
|
-
let response;
|
|
6164
|
-
try {
|
|
6165
|
-
const url = new URL(`${sonarEndpoint}/volumeSettings/streamer`);
|
|
6166
|
-
response = await customFetch(url);
|
|
6167
|
-
} catch (error) {
|
|
6168
|
-
throw new SonarRequestException({ innerException: error });
|
|
6169
|
-
}
|
|
6170
|
-
if (response.ok) {
|
|
6171
|
-
const data = await response.json();
|
|
6172
|
-
if (data?.masters?.stream == null) {
|
|
6173
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6174
|
-
}
|
|
6175
|
-
return data;
|
|
6176
|
-
} else {
|
|
6177
|
-
const data = await response.json();
|
|
6178
|
-
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
6122
|
+
function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
|
|
6123
|
+
if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
|
|
6124
|
+
return null;
|
|
6179
6125
|
}
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
async function getAudioDataStream(sonarEndpoint) {
|
|
6184
|
-
const data = await requestVolumeSettingsStreamer(sonarEndpoint);
|
|
6185
|
-
const volumeData = {
|
|
6186
|
-
["master" /* Master */]: createResponseVolumeData2(data.masters.stream),
|
|
6187
|
-
["game" /* Game */]: data.devices.game && createResponseVolumeData2(data.devices.game.stream),
|
|
6188
|
-
["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData2(data.devices.chatRender.stream),
|
|
6189
|
-
["media" /* Media */]: data.devices.media && createResponseVolumeData2(data.devices.media.stream),
|
|
6190
|
-
["aux" /* Aux */]: data.devices.aux && createResponseVolumeData2(data.devices.aux.stream),
|
|
6191
|
-
["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData2(data.devices.chatCapture.stream)
|
|
6192
|
-
};
|
|
6193
|
-
return volumeData;
|
|
6194
|
-
}
|
|
6195
|
-
function createResponseVolumeData2(volumeData) {
|
|
6196
|
-
return {
|
|
6197
|
-
["streaming" /* Streaming */]: {
|
|
6198
|
-
volume: convertVolumeToUser(volumeData.streaming.volume),
|
|
6199
|
-
isMuted: volumeData.streaming.muted
|
|
6200
|
-
},
|
|
6201
|
-
["monitoring" /* Monitoring */]: {
|
|
6202
|
-
volume: convertVolumeToUser(volumeData.monitoring.volume),
|
|
6203
|
-
isMuted: volumeData.monitoring.muted
|
|
6204
|
-
}
|
|
6205
|
-
};
|
|
6206
|
-
}
|
|
6207
|
-
// src/sonar/models/audio-settings/enums/audio-mode.ts
|
|
6208
|
-
var AudioMode2;
|
|
6209
|
-
((AudioMode3) => {
|
|
6210
|
-
AudioMode3["Classic"] = "classic";
|
|
6211
|
-
AudioMode3["Streamer"] = "stream";
|
|
6212
|
-
})(AudioMode2 ||= {});
|
|
6213
|
-
|
|
6214
|
-
// src/sonar/requests/mode/request-audio-mode.ts
|
|
6215
|
-
async function requestAudioMode(sonarEndpoint) {
|
|
6216
|
-
let response;
|
|
6217
|
-
const url = new URL(`${sonarEndpoint}/mode`);
|
|
6218
|
-
try {
|
|
6219
|
-
response = await customFetch(url);
|
|
6220
|
-
} catch (error) {
|
|
6221
|
-
throw new SonarRequestException({ innerException: error });
|
|
6126
|
+
const policy = request.referrerPolicy;
|
|
6127
|
+
if (request.referrer === "about:client") {
|
|
6128
|
+
return "no-referrer";
|
|
6222
6129
|
}
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
throw new SonarRequestException({ message: "Received unhandled audio mode from Sonar server" });
|
|
6229
|
-
} else {
|
|
6230
|
-
const data = await response.text();
|
|
6231
|
-
throw new SonarRequestException({ innerException: new Error(data) });
|
|
6130
|
+
const referrerSource = request.referrer;
|
|
6131
|
+
let referrerURL = stripURLForUseAsAReferrer(referrerSource);
|
|
6132
|
+
let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
|
|
6133
|
+
if (referrerURL.toString().length > 4096) {
|
|
6134
|
+
referrerURL = referrerOrigin;
|
|
6232
6135
|
}
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
// src/functions/audio/get-audio-mode.ts
|
|
6236
|
-
async function getAudioMode(sonarEndpoint) {
|
|
6237
|
-
return await requestAudioMode(sonarEndpoint);
|
|
6238
|
-
}
|
|
6239
|
-
// src/sonar/requests/mode/change-audio-mode.ts
|
|
6240
|
-
async function changeAudioMode(sonarEndpoint, audioMode) {
|
|
6241
|
-
let response;
|
|
6242
|
-
const url = new URL(`${sonarEndpoint}/mode/${audioMode}`);
|
|
6243
|
-
try {
|
|
6244
|
-
response = await customFetch(url, {
|
|
6245
|
-
method: "PUT"
|
|
6246
|
-
});
|
|
6247
|
-
} catch (error) {
|
|
6248
|
-
throw new SonarRequestException({ innerException: error });
|
|
6136
|
+
if (referrerURLCallback) {
|
|
6137
|
+
referrerURL = referrerURLCallback(referrerURL);
|
|
6249
6138
|
}
|
|
6250
|
-
if (
|
|
6251
|
-
|
|
6252
|
-
if (data !== audioMode) {
|
|
6253
|
-
throw new SonarRequestException({ message: "Returned audio mode does not match requested mode" });
|
|
6254
|
-
}
|
|
6255
|
-
return data;
|
|
6256
|
-
} else {
|
|
6257
|
-
const data = await response.text();
|
|
6258
|
-
throw new SonarRequestException({ innerException: new Error(data) });
|
|
6139
|
+
if (referrerOriginCallback) {
|
|
6140
|
+
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
|
6259
6141
|
}
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
return
|
|
6273
|
-
case "
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6142
|
+
const currentURL = new URL(request.url);
|
|
6143
|
+
switch (policy) {
|
|
6144
|
+
case "no-referrer":
|
|
6145
|
+
return "no-referrer";
|
|
6146
|
+
case "origin":
|
|
6147
|
+
return referrerOrigin;
|
|
6148
|
+
case "unsafe-url":
|
|
6149
|
+
return referrerURL;
|
|
6150
|
+
case "strict-origin":
|
|
6151
|
+
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
6152
|
+
return "no-referrer";
|
|
6153
|
+
}
|
|
6154
|
+
return referrerOrigin.toString();
|
|
6155
|
+
case "strict-origin-when-cross-origin":
|
|
6156
|
+
if (referrerURL.origin === currentURL.origin) {
|
|
6157
|
+
return referrerURL;
|
|
6158
|
+
}
|
|
6159
|
+
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
6160
|
+
return "no-referrer";
|
|
6161
|
+
}
|
|
6162
|
+
return referrerOrigin;
|
|
6163
|
+
case "same-origin":
|
|
6164
|
+
if (referrerURL.origin === currentURL.origin) {
|
|
6165
|
+
return referrerURL;
|
|
6166
|
+
}
|
|
6167
|
+
return "no-referrer";
|
|
6168
|
+
case "origin-when-cross-origin":
|
|
6169
|
+
if (referrerURL.origin === currentURL.origin) {
|
|
6170
|
+
return referrerURL;
|
|
6171
|
+
}
|
|
6172
|
+
return referrerOrigin;
|
|
6173
|
+
case "no-referrer-when-downgrade":
|
|
6174
|
+
if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
|
|
6175
|
+
return "no-referrer";
|
|
6176
|
+
}
|
|
6177
|
+
return referrerURL;
|
|
6279
6178
|
default:
|
|
6280
|
-
throw new
|
|
6281
|
-
}
|
|
6282
|
-
}
|
|
6283
|
-
|
|
6284
|
-
// src/sonar/requests/volume-settings/change-volume-mute-classic.ts
|
|
6285
|
-
async function changeVolumeMuteClassic(sonarEndpoint, isMuted, deviceRole) {
|
|
6286
|
-
let response;
|
|
6287
|
-
try {
|
|
6288
|
-
const url = new URL(`${sonarEndpoint}/volumeSettings/classic/${deviceRole}/mute/${isMuted}`);
|
|
6289
|
-
response = await customFetch(url, { method: "PUT" });
|
|
6290
|
-
} catch (error) {
|
|
6291
|
-
throw new SonarRequestException({ innerException: error });
|
|
6292
|
-
}
|
|
6293
|
-
if (response.ok) {
|
|
6294
|
-
const data = await response.json();
|
|
6295
|
-
if (data?.masters?.classic == null) {
|
|
6296
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6297
|
-
}
|
|
6298
|
-
return data;
|
|
6299
|
-
} else {
|
|
6300
|
-
const data = await response.json();
|
|
6301
|
-
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6304
|
-
|
|
6305
|
-
// src/functions/audio/set-channel-mute-classic.ts
|
|
6306
|
-
async function setChannelMuteClassic(sonarEndpoint, isMuted, channel) {
|
|
6307
|
-
const sonarChannel = convertChannelToApi(channel);
|
|
6308
|
-
const data = await changeVolumeMuteClassic(sonarEndpoint, isMuted, sonarChannel);
|
|
6309
|
-
const device = sonarChannel === "master" /* Master */ ? data.masters.classic : data.devices[sonarChannel]?.classic;
|
|
6310
|
-
if (!device) {
|
|
6311
|
-
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
6179
|
+
throw new TypeError(`Invalid referrerPolicy: ${policy}`);
|
|
6312
6180
|
}
|
|
6313
|
-
const result = {
|
|
6314
|
-
volume: convertVolumeToUser(device.volume),
|
|
6315
|
-
isMuted: device.muted
|
|
6316
|
-
};
|
|
6317
|
-
return result;
|
|
6318
6181
|
}
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
let
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
} catch (error) {
|
|
6326
|
-
throw new SonarRequestException({ innerException: error });
|
|
6327
|
-
}
|
|
6328
|
-
if (response.ok) {
|
|
6329
|
-
const data = await response.json();
|
|
6330
|
-
if (data?.masters?.stream == null) {
|
|
6331
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6182
|
+
function parseReferrerPolicyFromHeader(headers) {
|
|
6183
|
+
const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
|
|
6184
|
+
let policy = "";
|
|
6185
|
+
for (const token of policyTokens) {
|
|
6186
|
+
if (token && ReferrerPolicy.has(token)) {
|
|
6187
|
+
policy = token;
|
|
6332
6188
|
}
|
|
6333
|
-
return data;
|
|
6334
|
-
} else {
|
|
6335
|
-
const data = await response.json();
|
|
6336
|
-
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
6337
6189
|
}
|
|
6190
|
+
return policy;
|
|
6338
6191
|
}
|
|
6339
6192
|
|
|
6340
|
-
//
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
if (!device) {
|
|
6347
|
-
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
6348
|
-
}
|
|
6349
|
-
const devicePath = path === "streaming" /* Streaming */ ? device.streaming : device.monitoring;
|
|
6350
|
-
const result = {
|
|
6351
|
-
volume: convertVolumeToUser(devicePath.volume),
|
|
6352
|
-
isMuted: devicePath.muted
|
|
6353
|
-
};
|
|
6354
|
-
return result;
|
|
6355
|
-
}
|
|
6356
|
-
// src/functions/converters/convert-volume-to-api.ts
|
|
6357
|
-
function convertVolumeToApi(value) {
|
|
6358
|
-
let result = value / 100;
|
|
6359
|
-
result = Math.min(Math.max(result, 0), 1);
|
|
6360
|
-
return result;
|
|
6361
|
-
}
|
|
6193
|
+
// node_modules/node-fetch/src/request.js
|
|
6194
|
+
var INTERNALS3 = Symbol("Request internals");
|
|
6195
|
+
var isRequest = (object) => {
|
|
6196
|
+
return typeof object === "object" && typeof object[INTERNALS3] === "object";
|
|
6197
|
+
};
|
|
6198
|
+
var doBadDataWarn = deprecate2(() => {}, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
|
|
6362
6199
|
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
}
|
|
6372
|
-
if (response.ok) {
|
|
6373
|
-
const data = await response.json();
|
|
6374
|
-
if (data?.masters?.classic == null) {
|
|
6375
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6200
|
+
class Request extends Body {
|
|
6201
|
+
constructor(input, init = {}) {
|
|
6202
|
+
let parsedURL;
|
|
6203
|
+
if (isRequest(input)) {
|
|
6204
|
+
parsedURL = new URL(input.url);
|
|
6205
|
+
} else {
|
|
6206
|
+
parsedURL = new URL(input);
|
|
6207
|
+
input = {};
|
|
6376
6208
|
}
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6209
|
+
if (parsedURL.username !== "" || parsedURL.password !== "") {
|
|
6210
|
+
throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
|
|
6211
|
+
}
|
|
6212
|
+
let method = init.method || input.method || "GET";
|
|
6213
|
+
if (/^(delete|get|head|options|post|put)$/i.test(method)) {
|
|
6214
|
+
method = method.toUpperCase();
|
|
6215
|
+
}
|
|
6216
|
+
if (!isRequest(init) && "data" in init) {
|
|
6217
|
+
doBadDataWarn();
|
|
6218
|
+
}
|
|
6219
|
+
if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
|
6220
|
+
throw new TypeError("Request with GET/HEAD method cannot have body");
|
|
6221
|
+
}
|
|
6222
|
+
const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
|
6223
|
+
super(inputBody, {
|
|
6224
|
+
size: init.size || input.size || 0
|
|
6225
|
+
});
|
|
6226
|
+
const headers = new Headers(init.headers || input.headers || {});
|
|
6227
|
+
if (inputBody !== null && !headers.has("Content-Type")) {
|
|
6228
|
+
const contentType = extractContentType(inputBody, this);
|
|
6229
|
+
if (contentType) {
|
|
6230
|
+
headers.set("Content-Type", contentType);
|
|
6231
|
+
}
|
|
6232
|
+
}
|
|
6233
|
+
let signal = isRequest(input) ? input.signal : null;
|
|
6234
|
+
if ("signal" in init) {
|
|
6235
|
+
signal = init.signal;
|
|
6236
|
+
}
|
|
6237
|
+
if (signal != null && !isAbortSignal(signal)) {
|
|
6238
|
+
throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
|
|
6239
|
+
}
|
|
6240
|
+
let referrer = init.referrer == null ? input.referrer : init.referrer;
|
|
6241
|
+
if (referrer === "") {
|
|
6242
|
+
referrer = "no-referrer";
|
|
6243
|
+
} else if (referrer) {
|
|
6244
|
+
const parsedReferrer = new URL(referrer);
|
|
6245
|
+
referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
|
|
6246
|
+
} else {
|
|
6247
|
+
referrer = undefined;
|
|
6248
|
+
}
|
|
6249
|
+
this[INTERNALS3] = {
|
|
6250
|
+
method,
|
|
6251
|
+
redirect: init.redirect || input.redirect || "follow",
|
|
6252
|
+
headers,
|
|
6253
|
+
parsedURL,
|
|
6254
|
+
signal,
|
|
6255
|
+
referrer
|
|
6256
|
+
};
|
|
6257
|
+
this.follow = init.follow === undefined ? input.follow === undefined ? 20 : input.follow : init.follow;
|
|
6258
|
+
this.compress = init.compress === undefined ? input.compress === undefined ? true : input.compress : init.compress;
|
|
6259
|
+
this.counter = init.counter || input.counter || 0;
|
|
6260
|
+
this.agent = init.agent || input.agent;
|
|
6261
|
+
this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
|
|
6262
|
+
this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
|
|
6263
|
+
this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
|
|
6381
6264
|
}
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
// src/functions/audio/set-channel-volume-classic.ts
|
|
6385
|
-
async function setChannelVolumeClassic(sonarEndpoint, volumePercent, channel) {
|
|
6386
|
-
const sonarChannel = convertChannelToApi(channel);
|
|
6387
|
-
const formattedVolume = convertVolumeToApi(volumePercent);
|
|
6388
|
-
const data = await changeVolumeLevelClassic(sonarEndpoint, formattedVolume, sonarChannel);
|
|
6389
|
-
const device = sonarChannel === "master" /* Master */ ? data.masters.classic : data.devices[sonarChannel]?.classic;
|
|
6390
|
-
if (!device) {
|
|
6391
|
-
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
6265
|
+
get method() {
|
|
6266
|
+
return this[INTERNALS3].method;
|
|
6392
6267
|
}
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
isMuted: device.muted
|
|
6396
|
-
};
|
|
6397
|
-
return result;
|
|
6398
|
-
}
|
|
6399
|
-
// src/sonar/requests/volume-settings/change-volume-level-streamer.ts
|
|
6400
|
-
async function changeVolumeLevelStreamer(sonarEndpoint, volume, channel, path) {
|
|
6401
|
-
let response;
|
|
6402
|
-
try {
|
|
6403
|
-
const url = new URL(`${sonarEndpoint}/volumeSettings/streamer/${path}/${channel}/volume/${volume}`);
|
|
6404
|
-
response = await customFetch(url, { method: "PUT" });
|
|
6405
|
-
} catch (error) {
|
|
6406
|
-
throw new SonarRequestException({ innerException: error });
|
|
6268
|
+
get url() {
|
|
6269
|
+
return formatUrl(this[INTERNALS3].parsedURL);
|
|
6407
6270
|
}
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
if (data?.masters?.stream == null) {
|
|
6411
|
-
throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
|
|
6412
|
-
}
|
|
6413
|
-
return data;
|
|
6414
|
-
} else {
|
|
6415
|
-
const data = await response.json();
|
|
6416
|
-
throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
|
|
6271
|
+
get headers() {
|
|
6272
|
+
return this[INTERNALS3].headers;
|
|
6417
6273
|
}
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
// src/functions/audio/set-channel-volume-streamer.ts
|
|
6421
|
-
async function setChannelVolumeStreamer(sonarEndpoint, volumePercent, channel, path) {
|
|
6422
|
-
const sonarChannel = convertChannelToApi(channel);
|
|
6423
|
-
const formattedVolume = convertVolumeToApi(volumePercent);
|
|
6424
|
-
const streamPath = path === "streaming" /* Streaming */ ? "streaming" /* Streaming */ : "monitoring" /* Monitoring */;
|
|
6425
|
-
const data = await changeVolumeLevelStreamer(sonarEndpoint, formattedVolume, sonarChannel, streamPath);
|
|
6426
|
-
const device = sonarChannel === "master" /* Master */ ? data.masters.stream : data.devices[sonarChannel]?.stream;
|
|
6427
|
-
if (!device) {
|
|
6428
|
-
throw new SonarRequestException({ message: `Missing device data in response.` });
|
|
6274
|
+
get redirect() {
|
|
6275
|
+
return this[INTERNALS3].redirect;
|
|
6429
6276
|
}
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
volume: convertVolumeToUser(devicePath.volume),
|
|
6433
|
-
isMuted: devicePath.muted
|
|
6434
|
-
};
|
|
6435
|
-
return result;
|
|
6436
|
-
}
|
|
6437
|
-
// src/functions/converters/convert-chat-mix-balance-to-user.ts
|
|
6438
|
-
function convertChatMixBalanceToUser(balance) {
|
|
6439
|
-
let result = (balance + 1) / 2 * 100;
|
|
6440
|
-
result = Math.floor(result);
|
|
6441
|
-
result = Math.min(Math.max(result, 0), 100);
|
|
6442
|
-
return result;
|
|
6443
|
-
}
|
|
6444
|
-
|
|
6445
|
-
// src/sonar/requests/chatmix/request-chat-mix-state.ts
|
|
6446
|
-
async function requestChatMixState(sonarEndpoint) {
|
|
6447
|
-
const url = new URL(`${sonarEndpoint}/chatMix`);
|
|
6448
|
-
let response;
|
|
6449
|
-
try {
|
|
6450
|
-
response = await customFetch(url);
|
|
6451
|
-
} catch (error) {
|
|
6452
|
-
throw new SonarRequestException({ innerException: error });
|
|
6277
|
+
get signal() {
|
|
6278
|
+
return this[INTERNALS3].signal;
|
|
6453
6279
|
}
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6280
|
+
get referrer() {
|
|
6281
|
+
if (this[INTERNALS3].referrer === "no-referrer") {
|
|
6282
|
+
return "";
|
|
6283
|
+
}
|
|
6284
|
+
if (this[INTERNALS3].referrer === "client") {
|
|
6285
|
+
return "about:client";
|
|
6458
6286
|
}
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6287
|
+
if (this[INTERNALS3].referrer) {
|
|
6288
|
+
return this[INTERNALS3].referrer.toString();
|
|
6289
|
+
}
|
|
6290
|
+
return;
|
|
6463
6291
|
}
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
// src/functions/chatmix/get-chat-mix-state.ts
|
|
6467
|
-
async function getChatMixState(sonarEndpoint) {
|
|
6468
|
-
const data = await requestChatMixState(sonarEndpoint);
|
|
6469
|
-
const chatMixData = {
|
|
6470
|
-
chatBalance: convertChatMixBalanceToUser(data.balance),
|
|
6471
|
-
state: data.state,
|
|
6472
|
-
isEnabled: data.state === "enabled" /* Enabled */
|
|
6473
|
-
};
|
|
6474
|
-
return chatMixData;
|
|
6475
|
-
}
|
|
6476
|
-
// src/functions/converters/convert-chat-mix-balance-to-api.ts
|
|
6477
|
-
function convertChatMixBalanceToApi(balance) {
|
|
6478
|
-
let result = balance / 100 * 2 - 1;
|
|
6479
|
-
result = Math.min(Math.max(result, -1), 1);
|
|
6480
|
-
return result;
|
|
6481
|
-
}
|
|
6482
|
-
|
|
6483
|
-
// src/sonar/requests/chatmix/change-chat-mix-balance.ts
|
|
6484
|
-
async function changeChatMixBalance(sonarEndpoint, chatBalance) {
|
|
6485
|
-
const url = new URL(`${sonarEndpoint}/chatMix?balance=${chatBalance}`);
|
|
6486
|
-
let response;
|
|
6487
|
-
try {
|
|
6488
|
-
response = await customFetch(url, {
|
|
6489
|
-
method: "PUT"
|
|
6490
|
-
});
|
|
6491
|
-
} catch (error) {
|
|
6492
|
-
throw new SonarRequestException({ innerException: error });
|
|
6292
|
+
get referrerPolicy() {
|
|
6293
|
+
return this[INTERNALS3].referrerPolicy;
|
|
6493
6294
|
}
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
throw new SonarRequestException({ message: data.Message });
|
|
6295
|
+
set referrerPolicy(referrerPolicy) {
|
|
6296
|
+
this[INTERNALS3].referrerPolicy = validateReferrerPolicy(referrerPolicy);
|
|
6297
|
+
}
|
|
6298
|
+
clone() {
|
|
6299
|
+
return new Request(this);
|
|
6300
|
+
}
|
|
6301
|
+
get [Symbol.toStringTag]() {
|
|
6302
|
+
return "Request";
|
|
6503
6303
|
}
|
|
6504
6304
|
}
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
}
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
const url = new URL(`${sonarEndpoint}/audioDevices`);
|
|
6521
|
-
url.searchParams.append("onlySteelSeriesVAD", String(onlySteelSeriesVAD));
|
|
6522
|
-
url.searchParams.append("removeSteelSeriesVAD", String(removeSteelSeriesVAD));
|
|
6523
|
-
if (deviceDataFlow !== undefined) {
|
|
6524
|
-
url.searchParams.append("deviceDataFlow", deviceDataFlow.toString());
|
|
6305
|
+
Object.defineProperties(Request.prototype, {
|
|
6306
|
+
method: { enumerable: true },
|
|
6307
|
+
url: { enumerable: true },
|
|
6308
|
+
headers: { enumerable: true },
|
|
6309
|
+
redirect: { enumerable: true },
|
|
6310
|
+
clone: { enumerable: true },
|
|
6311
|
+
signal: { enumerable: true },
|
|
6312
|
+
referrer: { enumerable: true },
|
|
6313
|
+
referrerPolicy: { enumerable: true }
|
|
6314
|
+
});
|
|
6315
|
+
var getNodeRequestOptions = (request) => {
|
|
6316
|
+
const { parsedURL } = request[INTERNALS3];
|
|
6317
|
+
const headers = new Headers(request[INTERNALS3].headers);
|
|
6318
|
+
if (!headers.has("Accept")) {
|
|
6319
|
+
headers.set("Accept", "*/*");
|
|
6525
6320
|
}
|
|
6526
|
-
let
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
} catch (error) {
|
|
6530
|
-
throw new SonarRequestException({
|
|
6531
|
-
innerException: error
|
|
6532
|
-
});
|
|
6321
|
+
let contentLengthValue = null;
|
|
6322
|
+
if (request.body === null && /^(post|put)$/i.test(request.method)) {
|
|
6323
|
+
contentLengthValue = "0";
|
|
6533
6324
|
}
|
|
6534
|
-
if (
|
|
6535
|
-
const
|
|
6536
|
-
|
|
6325
|
+
if (request.body !== null) {
|
|
6326
|
+
const totalBytes = getTotalBytes(request);
|
|
6327
|
+
if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) {
|
|
6328
|
+
contentLengthValue = String(totalBytes);
|
|
6329
|
+
}
|
|
6537
6330
|
}
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
throw new SonarRequestException({ message: "Invalid audio devices response format." });
|
|
6331
|
+
if (contentLengthValue) {
|
|
6332
|
+
headers.set("Content-Length", contentLengthValue);
|
|
6541
6333
|
}
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
// src/functions/devices/get-audio-devices.ts
|
|
6546
|
-
async function getAudioDevices(sonarEndpoint, deviceType) {
|
|
6547
|
-
let deviceDataFlow;
|
|
6548
|
-
switch (deviceType) {
|
|
6549
|
-
case "input" /* Input */:
|
|
6550
|
-
deviceDataFlow = "capture" /* Capture */;
|
|
6551
|
-
break;
|
|
6552
|
-
case "output" /* Output */:
|
|
6553
|
-
deviceDataFlow = "render" /* Render */;
|
|
6554
|
-
break;
|
|
6555
|
-
case undefined:
|
|
6556
|
-
deviceDataFlow = "all" /* All */;
|
|
6557
|
-
break;
|
|
6334
|
+
if (request.referrerPolicy === "") {
|
|
6335
|
+
request.referrerPolicy = DEFAULT_REFERRER_POLICY;
|
|
6558
6336
|
}
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
type: getDeviceTypeFromDataFlow(device.dataFlow)
|
|
6564
|
-
}));
|
|
6565
|
-
return audioDevices;
|
|
6566
|
-
}
|
|
6567
|
-
function getDeviceTypeFromDataFlow(dataFlow) {
|
|
6568
|
-
switch (dataFlow) {
|
|
6569
|
-
case "capture" /* Capture */:
|
|
6570
|
-
return "input" /* Input */;
|
|
6571
|
-
case "render" /* Render */:
|
|
6572
|
-
return "output" /* Output */;
|
|
6573
|
-
default:
|
|
6574
|
-
throw new SonarRequestException({ message: `Unknown device data flow: ${dataFlow}` });
|
|
6337
|
+
if (request.referrer && request.referrer !== "no-referrer") {
|
|
6338
|
+
request[INTERNALS3].referrer = determineRequestsReferrer(request);
|
|
6339
|
+
} else {
|
|
6340
|
+
request[INTERNALS3].referrer = "no-referrer";
|
|
6575
6341
|
}
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
async function changeAudioDevice(sonarEndpoint, deviceChannel, deviceId) {
|
|
6579
|
-
let response;
|
|
6580
|
-
const url = new URL(`${sonarEndpoint}/classicRedirections/${deviceChannel}/deviceId/${deviceId}`);
|
|
6581
|
-
try {
|
|
6582
|
-
response = await customFetch(url, { method: "PUT" });
|
|
6583
|
-
} catch (error) {
|
|
6584
|
-
throw new SonarRequestException({
|
|
6585
|
-
innerException: error
|
|
6586
|
-
});
|
|
6342
|
+
if (request[INTERNALS3].referrer instanceof URL) {
|
|
6343
|
+
headers.set("Referer", request.referrer);
|
|
6587
6344
|
}
|
|
6588
|
-
if (!
|
|
6589
|
-
|
|
6590
|
-
throw new SonarRequestException({ message: `Failed to get audio devices: ${error}` });
|
|
6345
|
+
if (!headers.has("User-Agent")) {
|
|
6346
|
+
headers.set("User-Agent", "node-fetch");
|
|
6591
6347
|
}
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
const devices = data.filter((x2) => x2?.deviceId === deviceId);
|
|
6595
|
-
if (devices.length === 0) {
|
|
6596
|
-
throw new SonarRequestException({ message: "The changed audio devices list is empty." });
|
|
6348
|
+
if (request.compress && !headers.has("Accept-Encoding")) {
|
|
6349
|
+
headers.set("Accept-Encoding", "gzip, deflate, br");
|
|
6597
6350
|
}
|
|
6598
|
-
|
|
6599
|
-
|
|
6351
|
+
let { agent } = request;
|
|
6352
|
+
if (typeof agent === "function") {
|
|
6353
|
+
agent = agent(parsedURL);
|
|
6354
|
+
}
|
|
6355
|
+
const search = getSearch(parsedURL);
|
|
6356
|
+
const options = {
|
|
6357
|
+
path: parsedURL.pathname + search,
|
|
6358
|
+
method: request.method,
|
|
6359
|
+
headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
|
|
6360
|
+
insecureHTTPParser: request.insecureHTTPParser,
|
|
6361
|
+
agent
|
|
6362
|
+
};
|
|
6363
|
+
return {
|
|
6364
|
+
parsedURL,
|
|
6365
|
+
options
|
|
6366
|
+
};
|
|
6367
|
+
};
|
|
6600
6368
|
|
|
6601
|
-
// src/
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
deviceId: x2.deviceId,
|
|
6606
|
-
deviceChannel: x2.id,
|
|
6607
|
-
isRunning: x2.isRunning
|
|
6608
|
-
}));
|
|
6609
|
-
return result;
|
|
6610
|
-
}
|
|
6611
|
-
// src/functions/endpoint/get-app-endpoint.ts
|
|
6612
|
-
import { promises as fsAsync } from "node:fs";
|
|
6613
|
-
import { platform as getPlatform } from "node:os";
|
|
6614
|
-
import { join as joinPath } from "node:path";
|
|
6615
|
-
var WINDOWS_PATHS = ["SteelSeries", "SteelSeries Engine 3", "coreProps.json"];
|
|
6616
|
-
async function getAppEndpoint() {
|
|
6617
|
-
const appDataPath = getPath();
|
|
6618
|
-
const fileContents = await getContents(appDataPath);
|
|
6619
|
-
const data = parseContents(fileContents);
|
|
6620
|
-
if (data.ggEncryptedAddress) {
|
|
6621
|
-
return `https://${data.ggEncryptedAddress}`;
|
|
6369
|
+
// node_modules/node-fetch/src/errors/abort-error.js
|
|
6370
|
+
class AbortError extends FetchBaseError {
|
|
6371
|
+
constructor(message, type = "aborted") {
|
|
6372
|
+
super(message, type);
|
|
6622
6373
|
}
|
|
6623
|
-
throw new SonarInitializationException({
|
|
6624
|
-
reason: "Bad Config" /* BadConfig */
|
|
6625
|
-
});
|
|
6626
6374
|
}
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6375
|
+
|
|
6376
|
+
// node_modules/node-fetch/src/index.js
|
|
6377
|
+
init_esm_min();
|
|
6378
|
+
init_from();
|
|
6379
|
+
var supportedSchemas = new Set(["data:", "http:", "https:"]);
|
|
6380
|
+
async function fetch2(url, options_) {
|
|
6381
|
+
return new Promise((resolve, reject) => {
|
|
6382
|
+
const request = new Request(url, options_);
|
|
6383
|
+
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
6384
|
+
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
6385
|
+
throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
|
|
6386
|
+
}
|
|
6387
|
+
if (parsedURL.protocol === "data:") {
|
|
6388
|
+
const data = dist_default(request.url);
|
|
6389
|
+
const response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
|
|
6390
|
+
resolve(response2);
|
|
6391
|
+
return;
|
|
6392
|
+
}
|
|
6393
|
+
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
6394
|
+
const { signal } = request;
|
|
6395
|
+
let response = null;
|
|
6396
|
+
const abort = () => {
|
|
6397
|
+
const error = new AbortError("The operation was aborted.");
|
|
6398
|
+
reject(error);
|
|
6399
|
+
if (request.body && request.body instanceof Stream2.Readable) {
|
|
6400
|
+
request.body.destroy(error);
|
|
6401
|
+
}
|
|
6402
|
+
if (!response || !response.body) {
|
|
6403
|
+
return;
|
|
6404
|
+
}
|
|
6405
|
+
response.body.emit("error", error);
|
|
6406
|
+
};
|
|
6407
|
+
if (signal && signal.aborted) {
|
|
6408
|
+
abort();
|
|
6409
|
+
return;
|
|
6633
6410
|
}
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6411
|
+
const abortAndFinalize = () => {
|
|
6412
|
+
abort();
|
|
6413
|
+
finalize();
|
|
6414
|
+
};
|
|
6415
|
+
const request_ = send(parsedURL.toString(), options);
|
|
6416
|
+
if (signal) {
|
|
6417
|
+
signal.addEventListener("abort", abortAndFinalize);
|
|
6418
|
+
}
|
|
6419
|
+
const finalize = () => {
|
|
6420
|
+
request_.abort();
|
|
6421
|
+
if (signal) {
|
|
6422
|
+
signal.removeEventListener("abort", abortAndFinalize);
|
|
6423
|
+
}
|
|
6424
|
+
};
|
|
6425
|
+
request_.on("error", (error) => {
|
|
6426
|
+
reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
|
|
6427
|
+
finalize();
|
|
6428
|
+
});
|
|
6429
|
+
fixResponseChunkedTransferBadEnding(request_, (error) => {
|
|
6430
|
+
if (response && response.body) {
|
|
6431
|
+
response.body.destroy(error);
|
|
6432
|
+
}
|
|
6433
|
+
});
|
|
6434
|
+
if (process.version < "v14") {
|
|
6435
|
+
request_.on("socket", (s2) => {
|
|
6436
|
+
let endedWithEventsCount;
|
|
6437
|
+
s2.prependListener("end", () => {
|
|
6438
|
+
endedWithEventsCount = s2._eventsCount;
|
|
6439
|
+
});
|
|
6440
|
+
s2.prependListener("close", (hadError) => {
|
|
6441
|
+
if (response && endedWithEventsCount < s2._eventsCount && !hadError) {
|
|
6442
|
+
const error = new Error("Premature close");
|
|
6443
|
+
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
6444
|
+
response.body.emit("error", error);
|
|
6445
|
+
}
|
|
6446
|
+
});
|
|
6637
6447
|
});
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6448
|
+
}
|
|
6449
|
+
request_.on("response", (response_) => {
|
|
6450
|
+
request_.setTimeout(0);
|
|
6451
|
+
const headers = fromRawHeaders(response_.rawHeaders);
|
|
6452
|
+
if (isRedirect(response_.statusCode)) {
|
|
6453
|
+
const location = headers.get("Location");
|
|
6454
|
+
let locationURL = null;
|
|
6455
|
+
try {
|
|
6456
|
+
locationURL = location === null ? null : new URL(location, request.url);
|
|
6457
|
+
} catch {
|
|
6458
|
+
if (request.redirect !== "manual") {
|
|
6459
|
+
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
|
|
6460
|
+
finalize();
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
switch (request.redirect) {
|
|
6465
|
+
case "error":
|
|
6466
|
+
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
|
|
6467
|
+
finalize();
|
|
6468
|
+
return;
|
|
6469
|
+
case "manual":
|
|
6470
|
+
break;
|
|
6471
|
+
case "follow": {
|
|
6472
|
+
if (locationURL === null) {
|
|
6473
|
+
break;
|
|
6474
|
+
}
|
|
6475
|
+
if (request.counter >= request.follow) {
|
|
6476
|
+
reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
|
|
6477
|
+
finalize();
|
|
6478
|
+
return;
|
|
6479
|
+
}
|
|
6480
|
+
const requestOptions = {
|
|
6481
|
+
headers: new Headers(request.headers),
|
|
6482
|
+
follow: request.follow,
|
|
6483
|
+
counter: request.counter + 1,
|
|
6484
|
+
agent: request.agent,
|
|
6485
|
+
compress: request.compress,
|
|
6486
|
+
method: request.method,
|
|
6487
|
+
body: clone(request),
|
|
6488
|
+
signal: request.signal,
|
|
6489
|
+
size: request.size,
|
|
6490
|
+
referrer: request.referrer,
|
|
6491
|
+
referrerPolicy: request.referrerPolicy
|
|
6492
|
+
};
|
|
6493
|
+
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
|
6494
|
+
for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
|
|
6495
|
+
requestOptions.headers.delete(name);
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream2.Readable) {
|
|
6499
|
+
reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
|
|
6500
|
+
finalize();
|
|
6501
|
+
return;
|
|
6502
|
+
}
|
|
6503
|
+
if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
|
|
6504
|
+
requestOptions.method = "GET";
|
|
6505
|
+
requestOptions.body = undefined;
|
|
6506
|
+
requestOptions.headers.delete("content-length");
|
|
6507
|
+
}
|
|
6508
|
+
const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
|
|
6509
|
+
if (responseReferrerPolicy) {
|
|
6510
|
+
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
6511
|
+
}
|
|
6512
|
+
resolve(fetch2(new Request(locationURL, requestOptions)));
|
|
6513
|
+
finalize();
|
|
6514
|
+
return;
|
|
6515
|
+
}
|
|
6516
|
+
default:
|
|
6517
|
+
return reject(new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
if (signal) {
|
|
6521
|
+
response_.once("end", () => {
|
|
6522
|
+
signal.removeEventListener("abort", abortAndFinalize);
|
|
6523
|
+
});
|
|
6524
|
+
}
|
|
6525
|
+
let body = pump(response_, new PassThrough2, (error) => {
|
|
6526
|
+
if (error) {
|
|
6527
|
+
reject(error);
|
|
6528
|
+
}
|
|
6529
|
+
});
|
|
6530
|
+
if (process.version < "v12.10") {
|
|
6531
|
+
response_.on("aborted", abortAndFinalize);
|
|
6532
|
+
}
|
|
6533
|
+
const responseOptions = {
|
|
6534
|
+
url: request.url,
|
|
6535
|
+
status: response_.statusCode,
|
|
6536
|
+
statusText: response_.statusMessage,
|
|
6537
|
+
headers,
|
|
6538
|
+
size: request.size,
|
|
6539
|
+
counter: request.counter,
|
|
6540
|
+
highWaterMark: request.highWaterMark
|
|
6541
|
+
};
|
|
6542
|
+
const codings = headers.get("Content-Encoding");
|
|
6543
|
+
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
6544
|
+
response = new Response(body, responseOptions);
|
|
6545
|
+
resolve(response);
|
|
6546
|
+
return;
|
|
6547
|
+
}
|
|
6548
|
+
const zlibOptions = {
|
|
6549
|
+
flush: zlib.Z_SYNC_FLUSH,
|
|
6550
|
+
finishFlush: zlib.Z_SYNC_FLUSH
|
|
6551
|
+
};
|
|
6552
|
+
if (codings === "gzip" || codings === "x-gzip") {
|
|
6553
|
+
body = pump(body, zlib.createGunzip(zlibOptions), (error) => {
|
|
6554
|
+
if (error) {
|
|
6555
|
+
reject(error);
|
|
6556
|
+
}
|
|
6557
|
+
});
|
|
6558
|
+
response = new Response(body, responseOptions);
|
|
6559
|
+
resolve(response);
|
|
6560
|
+
return;
|
|
6561
|
+
}
|
|
6562
|
+
if (codings === "deflate" || codings === "x-deflate") {
|
|
6563
|
+
const raw = pump(response_, new PassThrough2, (error) => {
|
|
6564
|
+
if (error) {
|
|
6565
|
+
reject(error);
|
|
6566
|
+
}
|
|
6567
|
+
});
|
|
6568
|
+
raw.once("data", (chunk) => {
|
|
6569
|
+
if ((chunk[0] & 15) === 8) {
|
|
6570
|
+
body = pump(body, zlib.createInflate(), (error) => {
|
|
6571
|
+
if (error) {
|
|
6572
|
+
reject(error);
|
|
6573
|
+
}
|
|
6574
|
+
});
|
|
6575
|
+
} else {
|
|
6576
|
+
body = pump(body, zlib.createInflateRaw(), (error) => {
|
|
6577
|
+
if (error) {
|
|
6578
|
+
reject(error);
|
|
6579
|
+
}
|
|
6580
|
+
});
|
|
6581
|
+
}
|
|
6582
|
+
response = new Response(body, responseOptions);
|
|
6583
|
+
resolve(response);
|
|
6584
|
+
});
|
|
6585
|
+
raw.once("end", () => {
|
|
6586
|
+
if (!response) {
|
|
6587
|
+
response = new Response(body, responseOptions);
|
|
6588
|
+
resolve(response);
|
|
6589
|
+
}
|
|
6590
|
+
});
|
|
6591
|
+
return;
|
|
6592
|
+
}
|
|
6593
|
+
if (codings === "br") {
|
|
6594
|
+
body = pump(body, zlib.createBrotliDecompress(), (error) => {
|
|
6595
|
+
if (error) {
|
|
6596
|
+
reject(error);
|
|
6597
|
+
}
|
|
6598
|
+
});
|
|
6599
|
+
response = new Response(body, responseOptions);
|
|
6600
|
+
resolve(response);
|
|
6601
|
+
return;
|
|
6602
|
+
}
|
|
6603
|
+
response = new Response(body, responseOptions);
|
|
6604
|
+
resolve(response);
|
|
6647
6605
|
});
|
|
6648
|
-
|
|
6606
|
+
writeToStream(request_, request).catch(reject);
|
|
6607
|
+
});
|
|
6649
6608
|
}
|
|
6650
|
-
function
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6609
|
+
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
6610
|
+
const LAST_CHUNK = Buffer3.from(`0\r
|
|
6611
|
+
\r
|
|
6612
|
+
`);
|
|
6613
|
+
let isChunkedTransfer = false;
|
|
6614
|
+
let properLastChunkReceived = false;
|
|
6615
|
+
let previousChunk;
|
|
6616
|
+
request.on("response", (response) => {
|
|
6617
|
+
const { headers } = response;
|
|
6618
|
+
isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
|
|
6619
|
+
});
|
|
6620
|
+
request.on("socket", (socket) => {
|
|
6621
|
+
const onSocketClose = () => {
|
|
6622
|
+
if (isChunkedTransfer && !properLastChunkReceived) {
|
|
6623
|
+
const error = new Error("Premature close");
|
|
6624
|
+
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
6625
|
+
errorCallback(error);
|
|
6626
|
+
}
|
|
6627
|
+
};
|
|
6628
|
+
const onData = (buf) => {
|
|
6629
|
+
properLastChunkReceived = Buffer3.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
|
6630
|
+
if (!properLastChunkReceived && previousChunk) {
|
|
6631
|
+
properLastChunkReceived = Buffer3.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer3.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
|
|
6632
|
+
}
|
|
6633
|
+
previousChunk = buf;
|
|
6634
|
+
};
|
|
6635
|
+
socket.prependListener("close", onSocketClose);
|
|
6636
|
+
socket.on("data", onData);
|
|
6637
|
+
request.on("close", () => {
|
|
6638
|
+
socket.removeListener("close", onSocketClose);
|
|
6639
|
+
socket.removeListener("data", onData);
|
|
6657
6640
|
});
|
|
6658
|
-
}
|
|
6641
|
+
});
|
|
6659
6642
|
}
|
|
6643
|
+
|
|
6660
6644
|
// src/functions/endpoint/get-sonar-endpoint.ts
|
|
6661
6645
|
async function getSonarEndpoint(appEndpoint) {
|
|
6662
6646
|
let response;
|
|
6663
6647
|
try {
|
|
6664
|
-
|
|
6648
|
+
const url = `${appEndpoint}/subApps`;
|
|
6649
|
+
if (typeof Bun !== "undefined") {
|
|
6650
|
+
response = await fetch(url, {
|
|
6651
|
+
tls: {
|
|
6652
|
+
rejectUnauthorized: false
|
|
6653
|
+
}
|
|
6654
|
+
});
|
|
6655
|
+
} else {
|
|
6656
|
+
response = await fetch2(url, {
|
|
6657
|
+
agent: new https2.Agent({
|
|
6658
|
+
rejectUnauthorized: false
|
|
6659
|
+
})
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6665
6662
|
} catch (error) {
|
|
6666
6663
|
throw new SonarInitializationException({
|
|
6667
6664
|
reason: "Not Responding" /* NotResponding */,
|
|
@@ -6767,7 +6764,7 @@ function convertProfileChannelToUser(channel) {
|
|
|
6767
6764
|
async function requestConfigs(sonarAddress, channel) {
|
|
6768
6765
|
let response;
|
|
6769
6766
|
try {
|
|
6770
|
-
response = await
|
|
6767
|
+
response = await fetch(`${sonarAddress}/configs?vad=${channel}`);
|
|
6771
6768
|
} catch (error) {
|
|
6772
6769
|
throw new SonarRequestException({ innerException: error });
|
|
6773
6770
|
}
|
|
@@ -6803,7 +6800,7 @@ async function getChannelProfiles(sonarAddress, channel, favoritesOnly) {
|
|
|
6803
6800
|
async function requestSelectedConfigs(sonarAddress) {
|
|
6804
6801
|
let response;
|
|
6805
6802
|
try {
|
|
6806
|
-
response = await
|
|
6803
|
+
response = await fetch(`${sonarAddress}/configs/selected`);
|
|
6807
6804
|
} catch (error) {
|
|
6808
6805
|
throw new SonarRequestException({ innerException: error });
|
|
6809
6806
|
}
|
|
@@ -6837,7 +6834,7 @@ async function getSelectedProfiles(sonarAddress) {
|
|
|
6837
6834
|
async function changeSelectedConfig(sonarAddress, configId) {
|
|
6838
6835
|
let response;
|
|
6839
6836
|
try {
|
|
6840
|
-
response = await
|
|
6837
|
+
response = await fetch(`${sonarAddress}/configs/${configId}/select`, {
|
|
6841
6838
|
method: "PUT"
|
|
6842
6839
|
});
|
|
6843
6840
|
} catch (error) {
|