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