@celestia-island/plana-rpc-client 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.ts +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/plana-rpc-client",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/celestia-island/plana"
package/src/client.ts CHANGED
@@ -565,7 +565,14 @@ export class RpcClient {
565
565
  clearTimeout(entry.timer);
566
566
  if (data.error) {
567
567
  const msg: string = data.error.message || "unknown rpc error";
568
- const kind: RpcErrorKind = data.error.code === -32003 ? "forbidden" : "rpc";
568
+ // Authorization denials only: -32002 is chest's dedicated
569
+ // admin/workspace-role gate code, -32005 its platform-proxy
570
+ // grant gate. -32003 is chest's GENERIC internal/upstream
571
+ // error code — classifying it as "forbidden" (the old
572
+ // mapping) made upstream faults render as permission
573
+ // problems in every consumer webui.
574
+ const kind: RpcErrorKind =
575
+ data.error.code === -32002 || data.error.code === -32005 ? "forbidden" : "rpc";
569
576
  entry.reject(new RpcError(kind, entry.method, msg));
570
577
  } else {
571
578
  entry.resolve(data.result);
@@ -832,7 +839,10 @@ export class RpcClient {
832
839
  const body = await resp.json() as any;
833
840
  if (body.error) {
834
841
  const msg: string = body.error.message || "unknown rpc error";
835
- const kind: RpcErrorKind = body.error.code === -32003 ? "forbidden" : "rpc";
842
+ // Same classification as the WS path: -32002/-32005 are chest's
843
+ // authorization-denial codes; -32003 is generic upstream/internal.
844
+ const kind: RpcErrorKind =
845
+ body.error.code === -32002 || body.error.code === -32005 ? "forbidden" : "rpc";
836
846
  throw new RpcError(kind, method, msg);
837
847
  }
838
848
  return body.result as T;