@v3finance/core-sdk 0.1.0 → 0.2.1

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 (217) hide show
  1. package/CHANGELOG.md +441 -7
  2. package/README.md +219 -73
  3. package/dist/cjs/client.d.ts +67 -22
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +38 -2
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/errors.d.ts +30 -10
  8. package/dist/cjs/core/errors.d.ts.map +1 -1
  9. package/dist/cjs/core/errors.js +47 -15
  10. package/dist/cjs/core/errors.js.map +1 -1
  11. package/dist/cjs/core/gated.d.ts +30 -6
  12. package/dist/cjs/core/gated.d.ts.map +1 -1
  13. package/dist/cjs/core/gated.js +21 -6
  14. package/dist/cjs/core/gated.js.map +1 -1
  15. package/dist/cjs/core/http.d.ts +12 -8
  16. package/dist/cjs/core/http.d.ts.map +1 -1
  17. package/dist/cjs/core/http.js +147 -43
  18. package/dist/cjs/core/http.js.map +1 -1
  19. package/dist/cjs/core/pagination.d.ts +28 -1
  20. package/dist/cjs/core/pagination.d.ts.map +1 -1
  21. package/dist/cjs/core/pagination.js +36 -1
  22. package/dist/cjs/core/pagination.js.map +1 -1
  23. package/dist/cjs/generated/operations.js +1 -1
  24. package/dist/cjs/generated/types.d.ts +965 -179
  25. package/dist/cjs/generated/types.d.ts.map +1 -1
  26. package/dist/cjs/index.d.ts +32 -8
  27. package/dist/cjs/index.d.ts.map +1 -1
  28. package/dist/cjs/index.js +12 -0
  29. package/dist/cjs/index.js.map +1 -1
  30. package/dist/cjs/resources/addresses.d.ts +23 -8
  31. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  32. package/dist/cjs/resources/addresses.js +8 -1
  33. package/dist/cjs/resources/addresses.js.map +1 -1
  34. package/dist/cjs/resources/admin.d.ts +150 -25
  35. package/dist/cjs/resources/admin.d.ts.map +1 -1
  36. package/dist/cjs/resources/admin.js +94 -23
  37. package/dist/cjs/resources/admin.js.map +1 -1
  38. package/dist/cjs/resources/approvals.d.ts +46 -5
  39. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  40. package/dist/cjs/resources/approvals.js +27 -4
  41. package/dist/cjs/resources/approvals.js.map +1 -1
  42. package/dist/cjs/resources/balances.d.ts +152 -16
  43. package/dist/cjs/resources/balances.d.ts.map +1 -1
  44. package/dist/cjs/resources/balances.js +9 -5
  45. package/dist/cjs/resources/balances.js.map +1 -1
  46. package/dist/cjs/resources/categories.d.ts +93 -21
  47. package/dist/cjs/resources/categories.d.ts.map +1 -1
  48. package/dist/cjs/resources/categories.js +65 -18
  49. package/dist/cjs/resources/categories.js.map +1 -1
  50. package/dist/cjs/resources/counterparties.d.ts +26 -3
  51. package/dist/cjs/resources/counterparties.d.ts.map +1 -1
  52. package/dist/cjs/resources/counterparties.js +17 -0
  53. package/dist/cjs/resources/counterparties.js.map +1 -1
  54. package/dist/cjs/resources/folders.d.ts +51 -10
  55. package/dist/cjs/resources/folders.d.ts.map +1 -1
  56. package/dist/cjs/resources/folders.js +36 -5
  57. package/dist/cjs/resources/folders.js.map +1 -1
  58. package/dist/cjs/resources/history.d.ts +20 -2
  59. package/dist/cjs/resources/history.d.ts.map +1 -1
  60. package/dist/cjs/resources/history.js.map +1 -1
  61. package/dist/cjs/resources/me.d.ts +27 -4
  62. package/dist/cjs/resources/me.d.ts.map +1 -1
  63. package/dist/cjs/resources/me.js +22 -1
  64. package/dist/cjs/resources/me.js.map +1 -1
  65. package/dist/cjs/resources/members.d.ts +19 -4
  66. package/dist/cjs/resources/members.d.ts.map +1 -1
  67. package/dist/cjs/resources/members.js +15 -6
  68. package/dist/cjs/resources/members.js.map +1 -1
  69. package/dist/cjs/resources/operations.d.ts +64 -8
  70. package/dist/cjs/resources/operations.d.ts.map +1 -1
  71. package/dist/cjs/resources/operations.js +26 -2
  72. package/dist/cjs/resources/operations.js.map +1 -1
  73. package/dist/cjs/resources/registries.d.ts +87 -9
  74. package/dist/cjs/resources/registries.d.ts.map +1 -1
  75. package/dist/cjs/resources/registries.js +54 -11
  76. package/dist/cjs/resources/registries.js.map +1 -1
  77. package/dist/cjs/resources/reports.d.ts +300 -41
  78. package/dist/cjs/resources/reports.d.ts.map +1 -1
  79. package/dist/cjs/resources/reports.js +135 -7
  80. package/dist/cjs/resources/reports.js.map +1 -1
  81. package/dist/cjs/resources/sharing.d.ts +61 -10
  82. package/dist/cjs/resources/sharing.d.ts.map +1 -1
  83. package/dist/cjs/resources/sharing.js +51 -4
  84. package/dist/cjs/resources/sharing.js.map +1 -1
  85. package/dist/cjs/resources/transfers.d.ts +44 -6
  86. package/dist/cjs/resources/transfers.d.ts.map +1 -1
  87. package/dist/cjs/resources/transfers.js +41 -3
  88. package/dist/cjs/resources/transfers.js.map +1 -1
  89. package/dist/cjs/resources/types.d.ts +16 -0
  90. package/dist/cjs/resources/types.d.ts.map +1 -1
  91. package/dist/cjs/units.d.ts.map +1 -1
  92. package/dist/cjs/units.js +18 -2
  93. package/dist/cjs/units.js.map +1 -1
  94. package/dist/cjs/version.d.ts +1 -1
  95. package/dist/cjs/version.js +1 -1
  96. package/dist/esm/client.d.ts +67 -22
  97. package/dist/esm/client.d.ts.map +1 -1
  98. package/dist/esm/client.js +38 -2
  99. package/dist/esm/client.js.map +1 -1
  100. package/dist/esm/core/errors.d.ts +30 -10
  101. package/dist/esm/core/errors.d.ts.map +1 -1
  102. package/dist/esm/core/errors.js +47 -15
  103. package/dist/esm/core/errors.js.map +1 -1
  104. package/dist/esm/core/gated.d.ts +30 -6
  105. package/dist/esm/core/gated.d.ts.map +1 -1
  106. package/dist/esm/core/gated.js +21 -6
  107. package/dist/esm/core/gated.js.map +1 -1
  108. package/dist/esm/core/http.d.ts +12 -8
  109. package/dist/esm/core/http.d.ts.map +1 -1
  110. package/dist/esm/core/http.js +148 -44
  111. package/dist/esm/core/http.js.map +1 -1
  112. package/dist/esm/core/pagination.d.ts +28 -1
  113. package/dist/esm/core/pagination.d.ts.map +1 -1
  114. package/dist/esm/core/pagination.js +36 -1
  115. package/dist/esm/core/pagination.js.map +1 -1
  116. package/dist/esm/generated/operations.js +1 -1
  117. package/dist/esm/generated/types.d.ts +965 -179
  118. package/dist/esm/generated/types.d.ts.map +1 -1
  119. package/dist/esm/index.d.ts +32 -8
  120. package/dist/esm/index.d.ts.map +1 -1
  121. package/dist/esm/index.js +17 -5
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/resources/addresses.d.ts +23 -8
  124. package/dist/esm/resources/addresses.d.ts.map +1 -1
  125. package/dist/esm/resources/addresses.js +8 -1
  126. package/dist/esm/resources/addresses.js.map +1 -1
  127. package/dist/esm/resources/admin.d.ts +150 -25
  128. package/dist/esm/resources/admin.d.ts.map +1 -1
  129. package/dist/esm/resources/admin.js +94 -23
  130. package/dist/esm/resources/admin.js.map +1 -1
  131. package/dist/esm/resources/approvals.d.ts +46 -5
  132. package/dist/esm/resources/approvals.d.ts.map +1 -1
  133. package/dist/esm/resources/approvals.js +27 -4
  134. package/dist/esm/resources/approvals.js.map +1 -1
  135. package/dist/esm/resources/balances.d.ts +152 -16
  136. package/dist/esm/resources/balances.d.ts.map +1 -1
  137. package/dist/esm/resources/balances.js +9 -5
  138. package/dist/esm/resources/balances.js.map +1 -1
  139. package/dist/esm/resources/categories.d.ts +93 -21
  140. package/dist/esm/resources/categories.d.ts.map +1 -1
  141. package/dist/esm/resources/categories.js +65 -18
  142. package/dist/esm/resources/categories.js.map +1 -1
  143. package/dist/esm/resources/counterparties.d.ts +26 -3
  144. package/dist/esm/resources/counterparties.d.ts.map +1 -1
  145. package/dist/esm/resources/counterparties.js +17 -0
  146. package/dist/esm/resources/counterparties.js.map +1 -1
  147. package/dist/esm/resources/folders.d.ts +51 -10
  148. package/dist/esm/resources/folders.d.ts.map +1 -1
  149. package/dist/esm/resources/folders.js +36 -5
  150. package/dist/esm/resources/folders.js.map +1 -1
  151. package/dist/esm/resources/history.d.ts +20 -2
  152. package/dist/esm/resources/history.d.ts.map +1 -1
  153. package/dist/esm/resources/history.js.map +1 -1
  154. package/dist/esm/resources/me.d.ts +27 -4
  155. package/dist/esm/resources/me.d.ts.map +1 -1
  156. package/dist/esm/resources/me.js +22 -1
  157. package/dist/esm/resources/me.js.map +1 -1
  158. package/dist/esm/resources/members.d.ts +19 -4
  159. package/dist/esm/resources/members.d.ts.map +1 -1
  160. package/dist/esm/resources/members.js +15 -6
  161. package/dist/esm/resources/members.js.map +1 -1
  162. package/dist/esm/resources/operations.d.ts +64 -8
  163. package/dist/esm/resources/operations.d.ts.map +1 -1
  164. package/dist/esm/resources/operations.js +26 -2
  165. package/dist/esm/resources/operations.js.map +1 -1
  166. package/dist/esm/resources/registries.d.ts +87 -9
  167. package/dist/esm/resources/registries.d.ts.map +1 -1
  168. package/dist/esm/resources/registries.js +54 -11
  169. package/dist/esm/resources/registries.js.map +1 -1
  170. package/dist/esm/resources/reports.d.ts +300 -41
  171. package/dist/esm/resources/reports.d.ts.map +1 -1
  172. package/dist/esm/resources/reports.js +135 -7
  173. package/dist/esm/resources/reports.js.map +1 -1
  174. package/dist/esm/resources/sharing.d.ts +61 -10
  175. package/dist/esm/resources/sharing.d.ts.map +1 -1
  176. package/dist/esm/resources/sharing.js +51 -4
  177. package/dist/esm/resources/sharing.js.map +1 -1
  178. package/dist/esm/resources/transfers.d.ts +44 -6
  179. package/dist/esm/resources/transfers.d.ts.map +1 -1
  180. package/dist/esm/resources/transfers.js +41 -3
  181. package/dist/esm/resources/transfers.js.map +1 -1
  182. package/dist/esm/resources/types.d.ts +16 -0
  183. package/dist/esm/resources/types.d.ts.map +1 -1
  184. package/dist/esm/units.d.ts.map +1 -1
  185. package/dist/esm/units.js +18 -2
  186. package/dist/esm/units.js.map +1 -1
  187. package/dist/esm/version.d.ts +1 -1
  188. package/dist/esm/version.js +1 -1
  189. package/docs/concepts.md +193 -0
  190. package/docs/errors.md +491 -0
  191. package/package.json +7 -6
  192. package/src/client.ts +89 -25
  193. package/src/core/errors.ts +49 -15
  194. package/src/core/gated.ts +31 -7
  195. package/src/core/http.ts +173 -49
  196. package/src/core/pagination.ts +38 -1
  197. package/src/generated/operations.ts +1 -1
  198. package/src/generated/types.ts +1001 -180
  199. package/src/index.ts +64 -7
  200. package/src/resources/addresses.ts +24 -8
  201. package/src/resources/admin.ts +186 -33
  202. package/src/resources/approvals.ts +55 -9
  203. package/src/resources/balances.ts +186 -14
  204. package/src/resources/categories.ts +125 -30
  205. package/src/resources/counterparties.ts +23 -6
  206. package/src/resources/folders.ts +74 -18
  207. package/src/resources/history.ts +27 -2
  208. package/src/resources/me.ts +30 -5
  209. package/src/resources/members.ts +26 -7
  210. package/src/resources/operations.ts +73 -8
  211. package/src/resources/registries.ts +90 -11
  212. package/src/resources/reports.ts +348 -67
  213. package/src/resources/sharing.ts +71 -18
  214. package/src/resources/transfers.ts +51 -7
  215. package/src/resources/types.ts +16 -0
  216. package/src/units.ts +19 -2
  217. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,aAAa;AACvB,oFAAoF;AAClF,MAAM;AACR,uFAAuF;GACrF,SAAS;AACX,sFAAsF;GACpF,SAAS;AACX,gEAAgE;GAC9D,SAAS;AACX,yEAAyE;GACvE,OAAO,CAAA;AAEX,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,SAAU,SAAQ,KAAK;I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AAQ,MAAM,aAAa,MAAM,KAAG,SAYzD,CAAA;AAEJ,eAAO,MAAM,YAAY,cAAe,MAAM,KAAG,SAO7C,CAAA;AAEJ,eAAO,MAAM,UAAU,UAAW,OAAO,aAAa,MAAM,KAAG,SAQ3D,CAAA"}
@@ -6,14 +6,30 @@
6
6
  * wrapper has three gaps the client has to close itself — otherwise a precise
7
7
  * error turns into "something went wrong":
8
8
  *
9
- * 1. Bodies without an `error` key pass through untouched. Batch sharing
10
- * endpoints answer 400 with `{results:[…]}`, which is not a failure of
11
- * the whole call but "some subjects were rejected", and has to be read
12
- * item by item.
13
- * 2. Validation failures arrive as a plain string — `{error: "path: msg"}`
14
- * — with no code and no details.
15
- * 3. Inside a batch result `message` equals the code (`{code:"X",
16
- * message:"X"}`), so it must never be shown to a person as-is.
9
+ * 1. Bodies without an `error` key pass through untouched — the wrapper
10
+ * keys off that one field. Batch sharing endpoints answer 400 with
11
+ * `{results:[…]}`, which is not a failure of the whole call but "some
12
+ * subjects were rejected", and has to be read item by item.
13
+ * 2. Non-JSON bodies have no wrapper at all: the layer leaves by
14
+ * content-type, and a thrown `HTTPException` carries its own response
15
+ * past it. So a 502 from the edge, a WAF 403 or a platform 429 arrive as
16
+ * text. `core/http.ts` reduces a short one to a flat `{error: "…"}`
17
+ * (dropping HTML pages) before it reaches this parser, which is why the
18
+ * flat string shape below is still read — and why the per-status
19
+ * fallback wording here is what a person ends up seeing.
20
+ * 3. `message` sometimes IS the code. Handlers answer `{error: "<CODE>",
21
+ * code: "<CODE>"}` and batch items carry `{code:"X", message:"X"}`; the
22
+ * wrapper copies the former into `message` faithfully. A code is not a
23
+ * sentence, so it must never be shown to a person as-is.
24
+ *
25
+ * What is NOT a gap any more: zod validation failures. The route hook does
26
+ * build a flat `{error: "amount: Required; …"}` (backend
27
+ * `openapi/common.ts`), but that is an intermediate form.
28
+ * `middleware/errorEnvelope` rewraps every JSON body carrying a string
29
+ * `error` into the canonical envelope, `code` derived from the status —
30
+ * `BAD_REQUEST` here, because the hook sets none of its own. The same layer
31
+ * answers an unmatched path and an uncaught throw. Reading `body.error` as a
32
+ * string against today's API therefore hands you an object.
17
33
  *
18
34
  * Because of that `code` is always present here: either the server sent one,
19
35
  * or it is derived from the HTTP status. Branch on `code`, display `message`.
@@ -52,29 +68,37 @@ function hasCode(e, ...codes) {
52
68
  return isCoreError(e) && codes.includes(e.code);
53
69
  }
54
70
  /**
55
- * Status to code, mirroring the mapping the API uses, so that both sides call
56
- * the same thing by the same name.
71
+ * Status to code, used only when a body carried no code of its own: a proxy's
72
+ * HTML 502, a platform 429, an empty body.
73
+ *
74
+ * The names are the API's own names for the same statuses, so that one
75
+ * condition has one name whichever side produced it. 502 and 504 are the
76
+ * exception — the API has no envelope for them, they arrive from the edge.
57
77
  */
58
78
  function codeFromStatus(status) {
59
79
  switch (status) {
60
80
  case 400:
61
81
  return 'BAD_REQUEST';
62
82
  case 401:
63
- return 'UNAUTHORIZED';
83
+ return 'UNAUTHENTICATED';
64
84
  case 403:
65
85
  return 'FORBIDDEN';
66
86
  case 404:
67
87
  return 'NOT_FOUND';
68
88
  case 409:
69
89
  return 'CONFLICT';
90
+ case 413:
91
+ return 'PAYLOAD_TOO_LARGE';
70
92
  case 422:
71
- return 'UNPROCESSABLE';
93
+ return 'UNPROCESSABLE_ENTITY';
72
94
  case 429:
73
95
  return 'RATE_LIMITED';
96
+ case 501:
97
+ return 'NOT_IMPLEMENTED';
74
98
  case 502:
75
99
  return 'BAD_GATEWAY';
76
100
  case 503:
77
- return 'UNAVAILABLE';
101
+ return 'SERVICE_UNAVAILABLE';
78
102
  case 504:
79
103
  return 'GATEWAY_TIMEOUT';
80
104
  default:
@@ -110,7 +134,12 @@ function parseErrorBody(status, body, endpoint) {
110
134
  : fallbackMessage(status);
111
135
  return make(message, code, o.details);
112
136
  }
113
- // Shape 2 — a validation failure as a string: {error: "path: msg; …"}
137
+ // Shape 2 — a flat string `error`. No longer how validation failures reach
138
+ // a client (the envelope rewraps those into Shape 1), so the live producer
139
+ // is `core/http.ts`, which folds a short non-JSON error body into this
140
+ // shape. The sibling `code` is still read: handlers do put one next to a
141
+ // string `error`, and an older deployment without the envelope layer would
142
+ // deliver exactly that.
114
143
  if (typeof inner === 'string' && inner) {
115
144
  const flat = body.code;
116
145
  const code = typeof flat === 'string' && flat ? flat : fallbackCode;
@@ -156,7 +185,10 @@ const timeoutError = (ms, endpoint) => new CoreError({
156
185
  kind: 'timeout',
157
186
  code: 'TIMEOUT',
158
187
  status: null,
159
- message: `The server did not answer within ${Math.round(ms / 1000)}s`,
188
+ // Sub-second timeouts rounded to `0s`, which reads as "no time was
189
+ // allowed" rather than "400ms was". Below a second the unit changes
190
+ // instead of the number; a whole second keeps the shorter wording.
191
+ message: `The server did not answer within ${ms < 1000 ? `${Math.round(ms)}ms` : `${Math.round(ms / 1000)}s`}`,
160
192
  ...(endpoint === undefined ? {} : { endpoint }),
161
193
  });
162
194
  exports.timeoutError = timeoutError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;AA0BH,eAAuB,SAAQ,KAAK;IACzB,IAAI,CAAe;IAC5B,yFAAyF;IAChF,IAAI,CAAQ;IACrB,wEAAwE;IAC/D,MAAM,CAAe;IAC9B,sFAAsF;IAC7E,OAAO,CAAS;IAChB,QAAQ,CAAoB;IAErC,YAAY,IAAmB;QAC7B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACjF,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;Q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I,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,GAC9D,EAAE;IACF,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;CAChD,CAAC,CAAA;AAZS,QAAA,YAAY,GAAZ,YAAY,CAYrB;AAEG,MAAM,YAAY,GAAG,CAAC,QAAiB,EAAa,EAAE,CAC3D,IAAI,SAAS,CAAC;IACZ,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,2BAA2B;IACpC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;CAChD,CAAC,CAAA;AAPS,QAAA,YAAY,GAAZ,YAAY,CAOrB;AAEG,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,QAAiB,EAAa,EAAE,CACzE,IAAI,SAAS,CAAC;IACZ,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,qCAAqC;IAC9C,KAAK;IACL,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;CAChD,CAAC,CAAA;AARS,QAAA,UAAU,GAAV,UAAU,CAQnB"}
@@ -4,8 +4,10 @@
4
4
  *
5
5
  * 201 — applied immediately (policy allowed it without signatures);
6
6
  * 202 — queued for approval, funds are reserved, nothing has moved yet;
7
- * 200 — a replay of the same idempotency key: nothing happened now, the
8
- * existing operation came back (no second broadcast).
7
+ * 200 — on a transfer: a replay of the same idempotency key, nothing
8
+ * happened now and the existing operation came back (no second
9
+ * broadcast). Everywhere else: an ordinary applied success, because
10
+ * an edit is not a creation and answers 200 (see `replayOn200`).
9
11
  *
10
12
  * The body can be identical: a transfer returns `{transaction}` in all three.
11
13
  * A client that reads only the body will say "sent" where the truth is
@@ -13,13 +15,24 @@
13
15
  * frozen.
14
16
  *
15
17
  * `replayed` is kept separate from `applied` on purpose. A replay means the
16
- * previous attempt DID reach the server and only the answer was lost, so the
17
- * person should be told "already sent", not "sent" a second time.
18
+ * previous attempt DID reach the server and only the answer was lost — not
19
+ * that it succeeded. The body is that operation as it stands now: a replayed
20
+ * transfer may have gone out, be waiting for signatures, be still executing
21
+ * or have failed, and only its own status says which.
18
22
  */
19
23
  export type GatedOutcome = 'applied' | 'pending' | 'replayed';
24
+ /**
25
+ * `status` is the status the server ACTUALLY answered, which is why `applied`
26
+ * carries `200 | 201` rather than 201 alone: an ordinary 200 success is an
27
+ * applied operation too (updating a counterparty, editing a label — anything
28
+ * gated that is not a creation). The field used to be hard-coded to 201 for
29
+ * those, so every gated method except `transfers.send` reported a status the
30
+ * server never sent, into logs and error reports where it is the one thing
31
+ * worth trusting. Branch on `outcome`; read `status` when you need the fact.
32
+ */
20
33
  export type Gated<TApplied, TPending = TApplied> = {
21
34
  readonly outcome: 'applied';
22
- readonly status: 201;
35
+ readonly status: 200 | 201;
23
36
  readonly data: TApplied;
24
37
  } | {
25
38
  readonly outcome: 'replayed';
@@ -39,11 +52,22 @@ export type Gated<TApplied, TPending = TApplied> = {
39
52
  * success. Telling a person "already sent" after a plain edit would be as
40
53
  * wrong as telling them "done" after a replay, so each caller states which
41
54
  * of the two it is instead of the helper guessing.
55
+ *
56
+ * Which also means `outcome: 'replayed'` is UNREACHABLE for every gated
57
+ * method other than `transfers.send`: replay protection needs an idempotency
58
+ * key, and the transfer body is the only place the API takes one. The
59
+ * three-way `switch` in `docs/concepts.md` is right for a transfer; beside a
60
+ * counterparty edit its `case 'replayed'` is dead, and it is not evidence
61
+ * that such an edit can come back as a replay.
42
62
  */
43
63
  export declare function toGated<TApplied, TPending>(status: number, data: unknown, options?: {
44
64
  replayOn200?: boolean;
45
65
  }): Gated<TApplied, TPending>;
46
- /** Narrowing: the operation ran, now or earlier, and money moved. */
66
+ /**
67
+ * Narrowing: `applied` or `replayed`. For `applied` the operation ran now.
68
+ * For `replayed` it only existed already — whether money moved is in the
69
+ * body's own status, not in this check.
70
+ */
47
71
  export declare function isApplied<A, P>(r: Gated<A, P>): r is Extract<Gated<A, P>, {
48
72
  outcome: 'applied' | 'replayed';
49
73
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"gated.d.ts","sourceRoot":"","sources":["../../../src/core/gated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE7D,MAAM,MAAM,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAC3C;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAElF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAgB3B;AAED,qEAAqE;AACrE,wBAAg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AE,QAAQ,EACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAgB3B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GACb,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAAC,CAEhE;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GACb,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,CAEnD"}
@@ -5,8 +5,10 @@
5
5
  *
6
6
  * 201 — applied immediately (policy allowed it without signatures);
7
7
  * 202 — queued for approval, funds are reserved, nothing has moved yet;
8
- * 200 — a replay of the same idempotency key: nothing happened now, the
9
- * existing operation came back (no second broadcast).
8
+ * 200 — on a transfer: a replay of the same idempotency key, nothing
9
+ * happened now and the existing operation came back (no second
10
+ * broadcast). Everywhere else: an ordinary applied success, because
11
+ * an edit is not a creation and answers 200 (see `replayOn200`).
10
12
  *
11
13
  * The body can be identical: a transfer returns `{transaction}` in all three.
12
14
  * A client that reads only the body will say "sent" where the truth is
@@ -14,8 +16,10 @@
14
16
  * frozen.
15
17
  *
16
18
  * `replayed` is kept separate from `applied` on purpose. A replay means the
17
- * previous attempt DID reach the server and only the answer was lost, so the
18
- * person should be told "already sent", not "sent" a second time.
19
+ * previous attempt DID reach the server and only the answer was lost — not
20
+ * that it succeeded. The body is that operation as it stands now: a replayed
21
+ * transfer may have gone out, be waiting for signatures, be still executing
22
+ * or have failed, and only its own status says which.
19
23
  */
20
24
  Object.defineProperty(exports, "__esModule", { value: true });
21
25
  exports.toGated = toGated;
@@ -30,13 +34,20 @@ exports.isPending = isPending;
30
34
  * success. Telling a person "already sent" after a plain edit would be as
31
35
  * wrong as telling them "done" after a replay, so each caller states which
32
36
  * of the two it is instead of the helper guessing.
37
+ *
38
+ * Which also means `outcome: 'replayed'` is UNREACHABLE for every gated
39
+ * method other than `transfers.send`: replay protection needs an idempotency
40
+ * key, and the transfer body is the only place the API takes one. The
41
+ * three-way `switch` in `docs/concepts.md` is right for a transfer; beside a
42
+ * counterparty edit its `case 'replayed'` is dead, and it is not evidence
43
+ * that such an edit can come back as a replay.
33
44
  */
34
45
  function toGated(status, data, options = {}) {
35
46
  switch (status) {
36
47
  case 200:
37
48
  return options.replayOn200
38
49
  ? { outcome: 'replayed', status: 200, data: data }
39
- : { outcome: 'applied', status: 201, data: data };
50
+ : { outcome: 'applied', status: 200, data: data };
40
51
  case 201:
41
52
  return { outcome: 'applied', status: 201, data: data };
42
53
  case 202:
@@ -46,7 +57,11 @@ function toGated(status, data, options = {}) {
46
57
  'Expected 200, 201 (applied) or 202 (awaiting approval).');
47
58
  }
48
59
  }
49
- /** Narrowing: the operation ran, now or earlier, and money moved. */
60
+ /**
61
+ * Narrowing: `applied` or `replayed`. For `applied` the operation ran now.
62
+ * For `replayed` it only existed already — whether money moved is in the
63
+ * body's own status, not in this check.
64
+ */
50
65
  function isApplied(r) {
51
66
  return r.outcome === 'applied' || r.outcome === 'replayed';
52
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gated.js","sourceRoot":"","sources":["../../../src/core/gated.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;AASH;;;;;;;;;GASG;AACH,iBACE,MAAc,EACd,IAAa,EACb,OAAO,GAA8B,EAAE;IAEvC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,O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AAI,EAAE,IAAgB,EAAE,CAAA;QACjE,KAAK,GAAG;YACN,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACpE,KAAK,GAAG;YACN,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACpE;YACE,MAAM,IAAI,KAAK,CACb,kDAAkD,MAAM,IAAI;gBAC1D,yDAAyD,CAC5D,CAAA;IACL,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,mBACE,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,UAAU,CAAA;AAC5D,CAAC;AAED,yEAAyE;AACzE,mBACE,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,CAAA;AAChC,CAAC"}
@@ -39,15 +39,19 @@ export interface RequestOptions {
39
39
  signal?: AbortSignal | undefined;
40
40
  timeoutMs?: number | undefined;
41
41
  /**
42
- * Attempt key, sent as the `idempotency-key` header.
42
+ * Attempt key. ACCEPTED AND IGNORED BY THE TRANSPORT — the working place
43
+ * for it is the request BODY, the way `transfers.send` passes it.
43
44
  *
44
- * THE SERVER DOES NOT READ THIS HEADER TODAY. Replay protection on money
45
- * paths is resolved from the `idempotencyKey` FIELD OF THE BODY — that is
46
- * what `transfers.send` uses, and that is what protects it. The header is
47
- * here for the day the API starts honouring it; until then, calling a
48
- * money endpoint through the low-level client and passing the key only
49
- * here buys you nothing, and a retry after a timeout sends the money
50
- * twice. Put the key in the body.
45
+ * It used to go out as an `idempotency-key` header. The server has never
46
+ * read that header, which by itself merely bought nothing; in a browser it
47
+ * cost the whole request. The API's CORS preflight allows exactly
48
+ * `Content-Type` and `Authorization` (`allowHeaders`, backend
49
+ * `src/index.ts`), so the extra header failed the preflight and the call
50
+ * was never sent at all — a money request that could not reach the server,
51
+ * and a "network error" that no retry explains. Replay protection is
52
+ * resolved from the `idempotencyKey` FIELD of the body and nowhere else.
53
+ *
54
+ * @deprecated The transport sends this nowhere. Put the key in the body.
51
55
  */
52
56
  idempotencyKey?: string | undefined;
53
57
  headers?: Record<string, string> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,aAAa,CAAA;AAwBpB,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;AAE1C,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAE9C,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,SAAS,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAA;IAE/C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAEhC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD,8EAA8E;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3D,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAE/B,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAA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68
68
  constructor(options) {
69
69
  this.baseUrl = options.baseUrl.replace(/\/+$/, '');
70
70
  this.#options = options;
71
- const f = options.fetch ?? globalThis.fetch;
72
- if (typeof f !== 'function') {
71
+ const custom = options.fetch;
72
+ if (typeof (custom ?? globalThis.fetch) !== 'function') {
73
73
  throw new Error('@v3finance/core-sdk: fetch is unavailable in this runtime — pass one to the client options.');
74
74
  }
75
- this.#fetch = f;
75
+ // NEVER store the function and call it as `this.#fetch(…)`. A private
76
+ // field call passes the client as the receiver, and a browser's `fetch`
77
+ // checks its receiver: anything but the window is
78
+ // `TypeError: Illegal invocation`, thrown before a single byte leaves.
79
+ // Node and React Native do not check, which is how every request from a
80
+ // web page failed while the whole test suite passed — and since a
81
+ // `TypeError` out of `fetch` is what a dropped connection looks like, the
82
+ // failure surfaced as a "network error" on a perfectly good network.
83
+ //
84
+ // The wrapper calls with no receiver at all. Without a custom fetch the
85
+ // global one is looked up per call rather than captured here, so whatever
86
+ // patches it later (instrumentation, a mock server) is still honoured.
87
+ this.#fetch = custom
88
+ ? (input, init) => custom(input, init)
89
+ : (input, init) => globalThis.fetch(input, init);
76
90
  this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
77
91
  }
78
92
  /** Performs a request and returns the parsed body. Statuses >= 400 throw `CoreError`. */
@@ -86,13 +100,18 @@ class HttpClient {
86
100
  * time. Read it with `.blob()`, `.text()` or `.arrayBuffer()`.
87
101
  */
88
102
  async fetchRaw(method, path, options = {}) {
89
- const { response, endpoint } = await this.#send(method, path, options);
103
+ // The body is touched only when the call FAILED — and then by the same
104
+ // reader a JSON call uses, so one 502 from the edge produces one message
105
+ // whichever method asked for it. The two used to disagree: this one fell
106
+ // back to neutral wording while `requestRaw` put the proxy's HTML page
107
+ // into `message`.
108
+ //
109
+ // On success the response is handed over unread, which also means the
110
+ // timeout ends at the headers here: the file body is the caller's to read
111
+ // and to bound, with their own signal.
112
+ const { response, endpoint, payload } = await this.#send(method, path, options, (r, ep) => r.ok ? Promise.resolve(undefined) : readJsonBody(r, ep));
90
113
  if (!response.ok) {
91
- const body = await response
92
- .clone()
93
- .json()
94
- .catch(() => undefined);
95
- const error = (0, errors_js_1.parseErrorBody)(response.status, body, endpoint);
114
+ const error = (0, errors_js_1.parseErrorBody)(response.status, payload, endpoint);
96
115
  if (response.status === 401 && this.#options.onUnauthorized) {
97
116
  await this.#options.onUnauthorized(error);
98
117
  }
@@ -102,18 +121,28 @@ class HttpClient {
102
121
  }
103
122
  /** Same, but exposes the status — needed where 200 and 202 mean different things. */
104
123
  async requestRaw(method, path, options = {}) {
105
- const { response, endpoint } = await this.#send(method, path, options);
106
- const data = await readBody(response, endpoint);
124
+ const { response, endpoint, payload } = await this.#send(method, path, options, readJsonBody);
107
125
  if (!response.ok) {
108
- const error = (0, errors_js_1.parseErrorBody)(response.status, data, endpoint);
126
+ const error = (0, errors_js_1.parseErrorBody)(response.status, payload, endpoint);
109
127
  if (response.status === 401 && this.#options.onUnauthorized) {
110
128
  await this.#options.onUnauthorized(error);
111
129
  }
112
130
  throw error;
113
131
  }
114
- return { status: response.status, data: data, headers: response.headers };
132
+ return { status: response.status, data: payload, headers: response.headers };
115
133
  }
116
- async #send(method, path, options) {
134
+ /**
135
+ * One attempt: headers out, body in, cleanup.
136
+ *
137
+ * The body is read HERE, through `readPayload`, instead of by the caller
138
+ * afterwards — because the timeout and the caller's signal have to stay
139
+ * armed until the body is in hand. Headers arrive first and the body streams
140
+ * after; with the timer cleared at the headers, a server that answers and
141
+ * then stalls mid-body left a request hanging with nothing to end it. On a
142
+ * money path that is a transfer whose outcome is never learned, and no
143
+ * retry decision either.
144
+ */
145
+ async #send(method, path, options, readPayload) {
117
146
  const endpoint = `${method.toUpperCase()} ${path}`;
118
147
  const url = `${this.baseUrl}${path}${serializeQuery(options.query)}`;
119
148
  const timeoutMs = options.timeoutMs ?? this.#timeoutMs;
@@ -126,8 +155,14 @@ class HttpClient {
126
155
  };
127
156
  if (options.body !== undefined)
128
157
  headers['content-type'] = 'application/json';
129
- if (options.idempotencyKey)
130
- headers['idempotency-key'] = options.idempotencyKey;
158
+ // NOTHING ELSE IS ADDED BY DEFAULT, and that is a browser constraint
159
+ // rather than minimalism: the API's CORS preflight allows exactly
160
+ // `Content-Type` and `Authorization`, so any further header of ours makes
161
+ // the preflight fail and the request is never sent. These three are safe —
162
+ // `accept` is CORS-safelisted, and `user-agent` is a forbidden header name
163
+ // the browser drops before it can be preflighted (it still reaches the API
164
+ // from Node and React Native, which is where it is useful). A header
165
+ // passed in through `headers` is the caller's own risk.
131
166
  // A timer of our own on top of the caller's signal: `AbortSignal.timeout`
132
167
  // is missing in some React Native runtimes, and "the caller cancelled" has
133
168
  // to stay distinguishable from "time ran out" — on money paths those call
@@ -140,45 +175,89 @@ class HttpClient {
140
175
  }, timeoutMs);
141
176
  const onExternalAbort = () => controller.abort();
142
177
  options.signal?.addEventListener('abort', onExternalAbort, { once: true });
143
- let response;
178
+ const classify = (cause) => transportError(cause, { timedOut, timeoutMs, endpoint, signal: options.signal });
179
+ // The cleanup is an OUTER finally, so it also runs when `onTokenRotated`
180
+ // throws — a caller's storage failure should not leave our timer armed,
181
+ // ready to abort an unrelated stream seconds later.
144
182
  try {
145
- response = await this.#fetch(url, {
146
- method: method.toUpperCase(),
147
- headers,
148
- ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
149
- ...(this.#options.credentials === undefined
150
- ? {}
151
- : { credentials: this.#options.credentials }),
152
- signal: controller.signal,
153
- });
154
- }
155
- catch (cause) {
156
- if (timedOut)
157
- throw (0, errors_js_1.timeoutError)(timeoutMs, endpoint);
158
- if (options.signal?.aborted)
159
- throw (0, errors_js_1.abortedError)(endpoint);
160
- throw (0, errors_js_1.networkError)(cause, endpoint);
183
+ let response;
184
+ try {
185
+ response = await this.#fetch(url, {
186
+ method: method.toUpperCase(),
187
+ headers,
188
+ ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
189
+ ...(this.#options.credentials === undefined
190
+ ? {}
191
+ : { credentials: this.#options.credentials }),
192
+ signal: controller.signal,
193
+ });
194
+ }
195
+ catch (cause) {
196
+ throw classify(cause);
197
+ }
198
+ // Rotation arrives on successful responses too, and is taken BEFORE the
199
+ // body: the token is valid whatever the body turns out to be, and a
200
+ // rotation we drop signs the client out at the next one.
201
+ const rotated = response.headers.get(ROTATED_TOKEN_HEADER);
202
+ if (rotated && this.#options.onTokenRotated)
203
+ await this.#options.onTokenRotated(rotated);
204
+ let payload;
205
+ try {
206
+ payload = await readPayload(response, endpoint);
207
+ }
208
+ catch (cause) {
209
+ throw classify(cause);
210
+ }
211
+ return { response, endpoint, payload };
161
212
  }
162
213
  finally {
163
214
  clearTimeout(timer);
164
215
  options.signal?.removeEventListener('abort', onExternalAbort);
165
216
  }
166
- // Rotation arrives on successful responses too.
167
- const rotated = response.headers.get(ROTATED_TOKEN_HEADER);
168
- if (rotated && this.#options.onTokenRotated)
169
- await this.#options.onTokenRotated(rotated);
170
- return { response, endpoint };
171
217
  }
172
218
  }
173
219
  exports.HttpClient = HttpClient;
220
+ /**
221
+ * Names a transport failure, of the request or of the body behind it.
222
+ *
223
+ * The distinction is not cosmetic on a money path: a timeout may have been
224
+ * applied server-side (retry only with the same idempotency key), a cancel is
225
+ * the caller's own decision and must not be shown as a failure, and a network
226
+ * error never left the device. A `CoreError` arrives already named — the body
227
+ * reader raises one when a successful response is not the JSON the contract
228
+ * promises — and is passed through, so "the contract is wrong" is not reported
229
+ * as "the network is down".
230
+ *
231
+ * Our own timeout wins over the caller's signal, and both win over the cause:
232
+ * an abort mid-body surfaces as the abort that caused it, not as the opaque
233
+ * `AbortError` the stream rejects with.
234
+ */
235
+ function transportError(cause, ctx) {
236
+ if (ctx.timedOut)
237
+ return (0, errors_js_1.timeoutError)(ctx.timeoutMs, ctx.endpoint);
238
+ if (ctx.signal?.aborted)
239
+ return (0, errors_js_1.abortedError)(ctx.endpoint);
240
+ if ((0, errors_js_1.isCoreError)(cause))
241
+ return cause;
242
+ return (0, errors_js_1.networkError)(cause, ctx.endpoint);
243
+ }
244
+ /** The longest fragment of a non-JSON error body worth carrying into a message. */
245
+ const MAX_PLAIN_ERROR_CHARS = 200;
174
246
  /**
175
247
  * An empty body (204, DELETE) is `undefined`, not a parse failure. Invalid
176
248
  * JSON on a SUCCESSFUL status is a failure: the contract is not what we think
177
- * it is, and returning `undefined` quietly is worse than throwing. On an error
178
- * status the text is kept as-is for `parseErrorBody` to read.
249
+ * it is, and returning `undefined` quietly is worse than throwing.
250
+ *
251
+ * A read that fails halfway is no longer swallowed. It used to be caught into
252
+ * an empty string, which turned a truncated response — a dropped connection,
253
+ * our own timeout firing while the body streamed — into `data: undefined`
254
+ * typed as the shape the caller asked for: a failure wearing the face of a
255
+ * successful empty answer, and on a balance or a transfer the worst possible
256
+ * disguise. The rejection now travels out to `transportError`, which names it
257
+ * a timeout, a cancel or a network failure.
179
258
  */
180
- async function readBody(response, endpoint) {
181
- const text = await response.text().catch(() => '');
259
+ async function readJsonBody(response, endpoint) {
260
+ const text = await response.text();
182
261
  if (!text)
183
262
  return undefined;
184
263
  try {
@@ -187,7 +266,32 @@ async function readBody(response, endpoint) {
187
266
  catch (cause) {
188
267
  if (response.ok)
189
268
  throw (0, errors_js_1.parseError)(cause, endpoint);
190
- return { error: text };
269
+ return plainTextError(text);
191
270
  }
192
271
  }
272
+ /**
273
+ * A non-JSON error body reduced to something showable — or to nothing.
274
+ *
275
+ * Who sends these: everything in front of the API, never the API itself. A
276
+ * 502/504 while the worker is being replaced, a 403 from a WAF, a platform
277
+ * 429 — they answer with a whole HTML page (2318 bytes in one measured case).
278
+ * Passing that on as `{error: text}` put the page into `message`, which is the
279
+ * one field meant to be read by a person.
280
+ *
281
+ * Markup is therefore dropped and `parseErrorBody` falls back to its own
282
+ * wording for the status. A short line of plain text is kept instead of being
283
+ * dropped with it, because a proxy occasionally says something the status does
284
+ * not ("upstream connect error", "no healthy upstream").
285
+ */
286
+ function plainTextError(text) {
287
+ // A leading `<` catches HTML and XML error documents alike; neither is ours.
288
+ const collapsed = text.trim().replace(/\s+/g, ' ');
289
+ if (!collapsed || collapsed.startsWith('<'))
290
+ return undefined;
291
+ return {
292
+ error: collapsed.length > MAX_PLAIN_ERROR_CHARS
293
+ ? `${collapsed.slice(0, MAX_PLAIN_ERROR_CHARS)}…`
294
+ : collapsed,
295
+ };
296
+ }
193
297
  //# sourceMappingURL=http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/core/http.ts"],"names":[],"mappings":";;;;AAAA,2CAOoB;AACpB,8CAA2C;AAE3C;;;;;;;;;;;;;GAaG;AAEH,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAE7C,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAiFjC,sFAAsF;AAC/E,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAA1D,QAAA,GAAG,GAAH,GAAG,CAAuD;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAA+B,KAAwB;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAA;IACrB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAQ;QACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACvE,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MA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