@elsoul/erpc-sdk 0.2.0 → 0.3.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.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1205,6 +1205,7 @@ var HttpJsonRpcTransport = class {
|
|
|
1205
1205
|
}
|
|
1206
1206
|
throw new ErpcInvalidResponseError("ERPC returned a non-array batch response");
|
|
1207
1207
|
}
|
|
1208
|
+
const expectedIds = new Set(requests.map((request) => request.id));
|
|
1208
1209
|
const byId = /* @__PURE__ */ new Map();
|
|
1209
1210
|
for (const response of raw) {
|
|
1210
1211
|
if (!isObject2(response) || !("id" in response)) {
|
|
@@ -1214,6 +1215,16 @@ var HttpJsonRpcTransport = class {
|
|
|
1214
1215
|
if (typeof id !== "number" && typeof id !== "string") {
|
|
1215
1216
|
throw new ErpcInvalidResponseError("ERPC returned an invalid batch id");
|
|
1216
1217
|
}
|
|
1218
|
+
if (!expectedIds.has(id)) {
|
|
1219
|
+
throw new ErpcInvalidResponseError(
|
|
1220
|
+
"ERPC returned an unexpected batch response id"
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
if (byId.has(id)) {
|
|
1224
|
+
throw new ErpcInvalidResponseError(
|
|
1225
|
+
`ERPC returned duplicate batch response id ${String(id)}`
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1217
1228
|
byId.set(id, response);
|
|
1218
1229
|
}
|
|
1219
1230
|
const results = requests.map((request) => {
|