@stadar/sdk 0.1.7

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 (357) hide show
  1. package/README.md +62 -0
  2. package/dist/apis/AccountApi.d.ts +248 -0
  3. package/dist/apis/AccountApi.d.ts.map +1 -0
  4. package/dist/apis/AccountApi.js +228 -0
  5. package/dist/apis/AccountApi.js.map +1 -0
  6. package/dist/apis/AuthApi.d.ts +232 -0
  7. package/dist/apis/AuthApi.d.ts.map +1 -0
  8. package/dist/apis/AuthApi.js +213 -0
  9. package/dist/apis/AuthApi.js.map +1 -0
  10. package/dist/apis/BillingApi.d.ts +103 -0
  11. package/dist/apis/BillingApi.d.ts.map +1 -0
  12. package/dist/apis/BillingApi.js +92 -0
  13. package/dist/apis/BillingApi.js.map +1 -0
  14. package/dist/apis/GamesApi.d.ts +96 -0
  15. package/dist/apis/GamesApi.d.ts.map +1 -0
  16. package/dist/apis/GamesApi.js +100 -0
  17. package/dist/apis/GamesApi.js.map +1 -0
  18. package/dist/apis/LeaguesApi.d.ts +214 -0
  19. package/dist/apis/LeaguesApi.d.ts.map +1 -0
  20. package/dist/apis/LeaguesApi.js +225 -0
  21. package/dist/apis/LeaguesApi.js.map +1 -0
  22. package/dist/apis/MatchesApi.d.ts +178 -0
  23. package/dist/apis/MatchesApi.d.ts.map +1 -0
  24. package/dist/apis/MatchesApi.js +183 -0
  25. package/dist/apis/MatchesApi.js.map +1 -0
  26. package/dist/apis/MetaApi.d.ts +160 -0
  27. package/dist/apis/MetaApi.d.ts.map +1 -0
  28. package/dist/apis/MetaApi.js +151 -0
  29. package/dist/apis/MetaApi.js.map +1 -0
  30. package/dist/apis/SeriesApi.d.ts +211 -0
  31. package/dist/apis/SeriesApi.d.ts.map +1 -0
  32. package/dist/apis/SeriesApi.js +223 -0
  33. package/dist/apis/SeriesApi.js.map +1 -0
  34. package/dist/apis/TournamentsApi.d.ts +149 -0
  35. package/dist/apis/TournamentsApi.d.ts.map +1 -0
  36. package/dist/apis/TournamentsApi.js +149 -0
  37. package/dist/apis/TournamentsApi.js.map +1 -0
  38. package/dist/apis/WebhooksApi.d.ts +173 -0
  39. package/dist/apis/WebhooksApi.d.ts.map +1 -0
  40. package/dist/apis/WebhooksApi.js +157 -0
  41. package/dist/apis/WebhooksApi.js.map +1 -0
  42. package/dist/apis/index.d.ts +11 -0
  43. package/dist/apis/index.d.ts.map +1 -0
  44. package/dist/apis/index.js +13 -0
  45. package/dist/apis/index.js.map +1 -0
  46. package/dist/from_env.d.ts +22 -0
  47. package/dist/from_env.d.ts.map +1 -0
  48. package/dist/from_env.js +57 -0
  49. package/dist/from_env.js.map +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +6 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/models/APIKeySummary.d.ts +57 -0
  55. package/dist/models/APIKeySummary.d.ts.map +1 -0
  56. package/dist/models/APIKeySummary.js +58 -0
  57. package/dist/models/APIKeySummary.js.map +1 -0
  58. package/dist/models/AccountCreateKey201Response.d.ts +77 -0
  59. package/dist/models/AccountCreateKey201Response.d.ts.map +1 -0
  60. package/dist/models/AccountCreateKey201Response.js +69 -0
  61. package/dist/models/AccountCreateKey201Response.js.map +1 -0
  62. package/dist/models/AccountCreateKeyRequest.d.ts +33 -0
  63. package/dist/models/AccountCreateKeyRequest.d.ts.map +1 -0
  64. package/dist/models/AccountCreateKeyRequest.js +44 -0
  65. package/dist/models/AccountCreateKeyRequest.js.map +1 -0
  66. package/dist/models/AccountListKeys200Response.d.ts +34 -0
  67. package/dist/models/AccountListKeys200Response.d.ts.map +1 -0
  68. package/dist/models/AccountListKeys200Response.js +43 -0
  69. package/dist/models/AccountListKeys200Response.js.map +1 -0
  70. package/dist/models/AccountMeCapabilities200Response.d.ts +41 -0
  71. package/dist/models/AccountMeCapabilities200Response.d.ts.map +1 -0
  72. package/dist/models/AccountMeCapabilities200Response.js +46 -0
  73. package/dist/models/AccountMeCapabilities200Response.js.map +1 -0
  74. package/dist/models/AccountUsageRecent200Response.d.ts +34 -0
  75. package/dist/models/AccountUsageRecent200Response.d.ts.map +1 -0
  76. package/dist/models/AccountUsageRecent200Response.js +43 -0
  77. package/dist/models/AccountUsageRecent200Response.js.map +1 -0
  78. package/dist/models/AuthMeResponse.d.ts +41 -0
  79. package/dist/models/AuthMeResponse.d.ts.map +1 -0
  80. package/dist/models/AuthMeResponse.js +46 -0
  81. package/dist/models/AuthMeResponse.js.map +1 -0
  82. package/dist/models/AuthMeResponseData.d.ts +45 -0
  83. package/dist/models/AuthMeResponseData.d.ts.map +1 -0
  84. package/dist/models/AuthMeResponseData.js +46 -0
  85. package/dist/models/AuthMeResponseData.js.map +1 -0
  86. package/dist/models/CS2PreviewExtras.d.ts +44 -0
  87. package/dist/models/CS2PreviewExtras.d.ts.map +1 -0
  88. package/dist/models/CS2PreviewExtras.js +47 -0
  89. package/dist/models/CS2PreviewExtras.js.map +1 -0
  90. package/dist/models/CS2PreviewExtrasMapVetoHistory.d.ts +51 -0
  91. package/dist/models/CS2PreviewExtrasMapVetoHistory.d.ts.map +1 -0
  92. package/dist/models/CS2PreviewExtrasMapVetoHistory.js +48 -0
  93. package/dist/models/CS2PreviewExtrasMapVetoHistory.js.map +1 -0
  94. package/dist/models/CS2PreviewExtrasMapWinRateValue.d.ts +39 -0
  95. package/dist/models/CS2PreviewExtrasMapWinRateValue.d.ts.map +1 -0
  96. package/dist/models/CS2PreviewExtrasMapWinRateValue.js +44 -0
  97. package/dist/models/CS2PreviewExtrasMapWinRateValue.js.map +1 -0
  98. package/dist/models/CapabilitySet.d.ts +72 -0
  99. package/dist/models/CapabilitySet.d.ts.map +1 -0
  100. package/dist/models/CapabilitySet.js +75 -0
  101. package/dist/models/CapabilitySet.js.map +1 -0
  102. package/dist/models/ErrorBody.d.ts +53 -0
  103. package/dist/models/ErrorBody.d.ts.map +1 -0
  104. package/dist/models/ErrorBody.js +52 -0
  105. package/dist/models/ErrorBody.js.map +1 -0
  106. package/dist/models/ErrorEnvelope.d.ts +34 -0
  107. package/dist/models/ErrorEnvelope.d.ts.map +1 -0
  108. package/dist/models/ErrorEnvelope.js +45 -0
  109. package/dist/models/ErrorEnvelope.js.map +1 -0
  110. package/dist/models/Game.d.ts +78 -0
  111. package/dist/models/Game.d.ts.map +1 -0
  112. package/dist/models/Game.js +62 -0
  113. package/dist/models/Game.js.map +1 -0
  114. package/dist/models/GameEnvelope.d.ts +41 -0
  115. package/dist/models/GameEnvelope.d.ts.map +1 -0
  116. package/dist/models/GameEnvelope.js +46 -0
  117. package/dist/models/GameEnvelope.js.map +1 -0
  118. package/dist/models/GamesListResponse.d.ts +41 -0
  119. package/dist/models/GamesListResponse.d.ts.map +1 -0
  120. package/dist/models/GamesListResponse.js +46 -0
  121. package/dist/models/GamesListResponse.js.map +1 -0
  122. package/dist/models/HeadToHead.d.ts +51 -0
  123. package/dist/models/HeadToHead.d.ts.map +1 -0
  124. package/dist/models/HeadToHead.js +54 -0
  125. package/dist/models/HeadToHead.js.map +1 -0
  126. package/dist/models/Healthz200Response.d.ts +40 -0
  127. package/dist/models/Healthz200Response.d.ts.map +1 -0
  128. package/dist/models/Healthz200Response.js +48 -0
  129. package/dist/models/Healthz200Response.js.map +1 -0
  130. package/dist/models/Last5Result.d.ts +65 -0
  131. package/dist/models/Last5Result.d.ts.map +1 -0
  132. package/dist/models/Last5Result.js +67 -0
  133. package/dist/models/Last5Result.js.map +1 -0
  134. package/dist/models/League.d.ts +81 -0
  135. package/dist/models/League.d.ts.map +1 -0
  136. package/dist/models/League.js +58 -0
  137. package/dist/models/League.js.map +1 -0
  138. package/dist/models/LeagueEnvelope.d.ts +41 -0
  139. package/dist/models/LeagueEnvelope.d.ts.map +1 -0
  140. package/dist/models/LeagueEnvelope.js +46 -0
  141. package/dist/models/LeagueEnvelope.js.map +1 -0
  142. package/dist/models/LeagueSummary.d.ts +45 -0
  143. package/dist/models/LeagueSummary.d.ts.map +1 -0
  144. package/dist/models/LeagueSummary.js +46 -0
  145. package/dist/models/LeagueSummary.js.map +1 -0
  146. package/dist/models/LeaguesListResponse.d.ts +41 -0
  147. package/dist/models/LeaguesListResponse.d.ts.map +1 -0
  148. package/dist/models/LeaguesListResponse.js +46 -0
  149. package/dist/models/LeaguesListResponse.js.map +1 -0
  150. package/dist/models/Match.d.ts +145 -0
  151. package/dist/models/Match.d.ts.map +1 -0
  152. package/dist/models/Match.js +89 -0
  153. package/dist/models/Match.js.map +1 -0
  154. package/dist/models/MatchEnvelope.d.ts +41 -0
  155. package/dist/models/MatchEnvelope.d.ts.map +1 -0
  156. package/dist/models/MatchEnvelope.js +46 -0
  157. package/dist/models/MatchEnvelope.js.map +1 -0
  158. package/dist/models/MatchParticipant.d.ts +57 -0
  159. package/dist/models/MatchParticipant.d.ts.map +1 -0
  160. package/dist/models/MatchParticipant.js +50 -0
  161. package/dist/models/MatchParticipant.js.map +1 -0
  162. package/dist/models/MatchPreview.d.ts +62 -0
  163. package/dist/models/MatchPreview.d.ts.map +1 -0
  164. package/dist/models/MatchPreview.js +63 -0
  165. package/dist/models/MatchPreview.js.map +1 -0
  166. package/dist/models/MatchPreviewEnvelope.d.ts +41 -0
  167. package/dist/models/MatchPreviewEnvelope.d.ts.map +1 -0
  168. package/dist/models/MatchPreviewEnvelope.js +46 -0
  169. package/dist/models/MatchPreviewEnvelope.js.map +1 -0
  170. package/dist/models/MatchPreviewForm.d.ts +40 -0
  171. package/dist/models/MatchPreviewForm.d.ts.map +1 -0
  172. package/dist/models/MatchPreviewForm.js +49 -0
  173. package/dist/models/MatchPreviewForm.js.map +1 -0
  174. package/dist/models/MatchPreviewLast5.d.ts +40 -0
  175. package/dist/models/MatchPreviewLast5.d.ts.map +1 -0
  176. package/dist/models/MatchPreviewLast5.js +49 -0
  177. package/dist/models/MatchPreviewLast5.js.map +1 -0
  178. package/dist/models/MatchesListResponse.d.ts +41 -0
  179. package/dist/models/MatchesListResponse.d.ts.map +1 -0
  180. package/dist/models/MatchesListResponse.js +46 -0
  181. package/dist/models/MatchesListResponse.js.map +1 -0
  182. package/dist/models/Meta.d.ts +59 -0
  183. package/dist/models/Meta.d.ts.map +1 -0
  184. package/dist/models/Meta.js +52 -0
  185. package/dist/models/Meta.js.map +1 -0
  186. package/dist/models/Paging.d.ts +45 -0
  187. package/dist/models/Paging.d.ts.map +1 -0
  188. package/dist/models/Paging.js +46 -0
  189. package/dist/models/Paging.js.map +1 -0
  190. package/dist/models/RootVersion200Response.d.ts +45 -0
  191. package/dist/models/RootVersion200Response.d.ts.map +1 -0
  192. package/dist/models/RootVersion200Response.js +46 -0
  193. package/dist/models/RootVersion200Response.js.map +1 -0
  194. package/dist/models/Series.d.ts +89 -0
  195. package/dist/models/Series.d.ts.map +1 -0
  196. package/dist/models/Series.js +62 -0
  197. package/dist/models/Series.js.map +1 -0
  198. package/dist/models/SeriesEnvelope.d.ts +41 -0
  199. package/dist/models/SeriesEnvelope.d.ts.map +1 -0
  200. package/dist/models/SeriesEnvelope.js +46 -0
  201. package/dist/models/SeriesEnvelope.js.map +1 -0
  202. package/dist/models/SeriesListResponse.d.ts +41 -0
  203. package/dist/models/SeriesListResponse.d.ts.map +1 -0
  204. package/dist/models/SeriesListResponse.js +46 -0
  205. package/dist/models/SeriesListResponse.js.map +1 -0
  206. package/dist/models/SeriesSummary.d.ts +45 -0
  207. package/dist/models/SeriesSummary.d.ts.map +1 -0
  208. package/dist/models/SeriesSummary.js +46 -0
  209. package/dist/models/SeriesSummary.js.map +1 -0
  210. package/dist/models/SeriesWinner.d.ts +39 -0
  211. package/dist/models/SeriesWinner.d.ts.map +1 -0
  212. package/dist/models/SeriesWinner.js +44 -0
  213. package/dist/models/SeriesWinner.js.map +1 -0
  214. package/dist/models/SignupRequest.d.ts +39 -0
  215. package/dist/models/SignupRequest.d.ts.map +1 -0
  216. package/dist/models/SignupRequest.js +48 -0
  217. package/dist/models/SignupRequest.js.map +1 -0
  218. package/dist/models/SourceCredit.d.ts +45 -0
  219. package/dist/models/SourceCredit.d.ts.map +1 -0
  220. package/dist/models/SourceCredit.js +52 -0
  221. package/dist/models/SourceCredit.js.map +1 -0
  222. package/dist/models/Stream.d.ts +57 -0
  223. package/dist/models/Stream.d.ts.map +1 -0
  224. package/dist/models/Stream.js +50 -0
  225. package/dist/models/Stream.js.map +1 -0
  226. package/dist/models/TeamForm.d.ts +59 -0
  227. package/dist/models/TeamForm.d.ts.map +1 -0
  228. package/dist/models/TeamForm.js +63 -0
  229. package/dist/models/TeamForm.js.map +1 -0
  230. package/dist/models/Tournament.d.ts +148 -0
  231. package/dist/models/Tournament.d.ts.map +1 -0
  232. package/dist/models/Tournament.js +88 -0
  233. package/dist/models/Tournament.js.map +1 -0
  234. package/dist/models/TournamentEnvelope.d.ts +41 -0
  235. package/dist/models/TournamentEnvelope.d.ts.map +1 -0
  236. package/dist/models/TournamentEnvelope.js +46 -0
  237. package/dist/models/TournamentEnvelope.js.map +1 -0
  238. package/dist/models/TournamentPrizePool.d.ts +39 -0
  239. package/dist/models/TournamentPrizePool.d.ts.map +1 -0
  240. package/dist/models/TournamentPrizePool.js +44 -0
  241. package/dist/models/TournamentPrizePool.js.map +1 -0
  242. package/dist/models/TournamentSummary.d.ts +57 -0
  243. package/dist/models/TournamentSummary.d.ts.map +1 -0
  244. package/dist/models/TournamentSummary.js +50 -0
  245. package/dist/models/TournamentSummary.js.map +1 -0
  246. package/dist/models/TournamentsListResponse.d.ts +41 -0
  247. package/dist/models/TournamentsListResponse.d.ts.map +1 -0
  248. package/dist/models/TournamentsListResponse.js +46 -0
  249. package/dist/models/TournamentsListResponse.js.map +1 -0
  250. package/dist/models/UsageRow.d.ts +63 -0
  251. package/dist/models/UsageRow.d.ts.map +1 -0
  252. package/dist/models/UsageRow.js +52 -0
  253. package/dist/models/UsageRow.js.map +1 -0
  254. package/dist/models/UsageToday.d.ts +57 -0
  255. package/dist/models/UsageToday.d.ts.map +1 -0
  256. package/dist/models/UsageToday.js +50 -0
  257. package/dist/models/UsageToday.js.map +1 -0
  258. package/dist/models/WebhookSubscription.d.ts +81 -0
  259. package/dist/models/WebhookSubscription.d.ts.map +1 -0
  260. package/dist/models/WebhookSubscription.js +66 -0
  261. package/dist/models/WebhookSubscription.js.map +1 -0
  262. package/dist/models/WebhookSubscriptionRequest.d.ts +67 -0
  263. package/dist/models/WebhookSubscriptionRequest.d.ts.map +1 -0
  264. package/dist/models/WebhookSubscriptionRequest.js +63 -0
  265. package/dist/models/WebhookSubscriptionRequest.js.map +1 -0
  266. package/dist/models/WebhooksCreate201Response.d.ts +87 -0
  267. package/dist/models/WebhooksCreate201Response.d.ts.map +1 -0
  268. package/dist/models/WebhooksCreate201Response.js +68 -0
  269. package/dist/models/WebhooksCreate201Response.js.map +1 -0
  270. package/dist/models/WebhooksList200Response.d.ts +34 -0
  271. package/dist/models/WebhooksList200Response.d.ts.map +1 -0
  272. package/dist/models/WebhooksList200Response.js +43 -0
  273. package/dist/models/WebhooksList200Response.js.map +1 -0
  274. package/dist/models/index.d.ts +56 -0
  275. package/dist/models/index.d.ts.map +1 -0
  276. package/dist/models/index.js +58 -0
  277. package/dist/models/index.js.map +1 -0
  278. package/dist/runtime.d.ts +185 -0
  279. package/dist/runtime.d.ts.map +1 -0
  280. package/dist/runtime.js +338 -0
  281. package/dist/runtime.js.map +1 -0
  282. package/dist/webhooks.d.ts +29 -0
  283. package/dist/webhooks.d.ts.map +1 -0
  284. package/dist/webhooks.js +77 -0
  285. package/dist/webhooks.js.map +1 -0
  286. package/package.json +60 -0
  287. package/src/apis/AccountApi.ts +474 -0
  288. package/src/apis/AuthApi.ts +446 -0
  289. package/src/apis/BillingApi.ts +180 -0
  290. package/src/apis/GamesApi.ts +195 -0
  291. package/src/apis/LeaguesApi.ts +457 -0
  292. package/src/apis/MatchesApi.ts +368 -0
  293. package/src/apis/MetaApi.ts +289 -0
  294. package/src/apis/SeriesApi.ts +454 -0
  295. package/src/apis/TournamentsApi.ts +290 -0
  296. package/src/apis/WebhooksApi.ts +336 -0
  297. package/src/apis/index.ts +12 -0
  298. package/src/from_env.ts +68 -0
  299. package/src/index.ts +5 -0
  300. package/src/models/APIKeySummary.ts +101 -0
  301. package/src/models/AccountCreateKey201Response.ts +128 -0
  302. package/src/models/AccountCreateKeyRequest.ts +66 -0
  303. package/src/models/AccountListKeys200Response.ts +73 -0
  304. package/src/models/AccountMeCapabilities200Response.ts +88 -0
  305. package/src/models/AccountUsageRecent200Response.ts +73 -0
  306. package/src/models/AuthMeResponse.ts +88 -0
  307. package/src/models/AuthMeResponseData.ts +81 -0
  308. package/src/models/CS2PreviewExtras.ts +89 -0
  309. package/src/models/CS2PreviewExtrasMapVetoHistory.ts +89 -0
  310. package/src/models/CS2PreviewExtrasMapWinRateValue.ts +73 -0
  311. package/src/models/CapabilitySet.ts +114 -0
  312. package/src/models/ErrorBody.ts +91 -0
  313. package/src/models/ErrorEnvelope.ts +74 -0
  314. package/src/models/Game.ts +125 -0
  315. package/src/models/GameEnvelope.ts +88 -0
  316. package/src/models/GamesListResponse.ts +88 -0
  317. package/src/models/HeadToHead.ts +92 -0
  318. package/src/models/Healthz200Response.ts +75 -0
  319. package/src/models/Last5Result.ts +113 -0
  320. package/src/models/League.ts +129 -0
  321. package/src/models/LeagueEnvelope.ts +88 -0
  322. package/src/models/LeagueSummary.ts +81 -0
  323. package/src/models/LeaguesListResponse.ts +88 -0
  324. package/src/models/Match.ts +243 -0
  325. package/src/models/MatchEnvelope.ts +88 -0
  326. package/src/models/MatchParticipant.ts +97 -0
  327. package/src/models/MatchPreview.ts +137 -0
  328. package/src/models/MatchPreviewEnvelope.ts +88 -0
  329. package/src/models/MatchPreviewForm.ts +83 -0
  330. package/src/models/MatchPreviewLast5.ts +83 -0
  331. package/src/models/MatchesListResponse.ts +88 -0
  332. package/src/models/Meta.ts +112 -0
  333. package/src/models/Paging.ts +81 -0
  334. package/src/models/RootVersion200Response.ts +81 -0
  335. package/src/models/Series.ts +152 -0
  336. package/src/models/SeriesEnvelope.ts +88 -0
  337. package/src/models/SeriesListResponse.ts +88 -0
  338. package/src/models/SeriesSummary.ts +81 -0
  339. package/src/models/SeriesWinner.ts +73 -0
  340. package/src/models/SignupRequest.ts +75 -0
  341. package/src/models/SourceCredit.ts +84 -0
  342. package/src/models/Stream.ts +97 -0
  343. package/src/models/TeamForm.ts +104 -0
  344. package/src/models/Tournament.ts +236 -0
  345. package/src/models/TournamentEnvelope.ts +88 -0
  346. package/src/models/TournamentPrizePool.ts +73 -0
  347. package/src/models/TournamentSummary.ts +97 -0
  348. package/src/models/TournamentsListResponse.ts +88 -0
  349. package/src/models/UsageRow.ts +105 -0
  350. package/src/models/UsageToday.ts +97 -0
  351. package/src/models/WebhookSubscription.ts +133 -0
  352. package/src/models/WebhookSubscriptionRequest.ts +112 -0
  353. package/src/models/WebhooksCreate201Response.ts +141 -0
  354. package/src/models/WebhooksList200Response.ts +73 -0
  355. package/src/models/index.ts +57 -0
  356. package/src/runtime.ts +449 -0
  357. package/src/webhooks.ts +91 -0
package/src/runtime.ts ADDED
@@ -0,0 +1,449 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Stadar Esports Data API
5
+ * Read-only, betting-friendly esports data across all major competitive titles. Flat-tier pricing (no per-game gates), Polar- billed subscriptions (Merchant of Record), sandbox keys for evaluation. See https://stadar.net for tier pricing. All endpoints under `/v1/...`. The version in `info.version` matches the URL prefix; non-breaking field additions ship in `/v1`, breaking changes get a `/v2`. We commit to 24 months of `/v1` support after `/v2` ships. Times are UTC end-to-end (RFC 3339). Localization is the client\'s problem. Cursors are opaque base64 strings; treat them as such.
6
+ *
7
+ * The version of the OpenAPI document: v1
8
+ * Contact: api@stadar.net
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ export const BASE_PATH = "https://api.stadar.net".replace(/\/+$/, "");
16
+
17
+ export interface ConfigurationParameters {
18
+ basePath?: string; // override base path
19
+ fetchApi?: FetchAPI; // override for fetch implementation
20
+ middleware?: Middleware[]; // middleware to apply before/after fetch requests
21
+ queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
22
+ username?: string; // parameter for basic security
23
+ password?: string; // parameter for basic security
24
+ apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
25
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
26
+ headers?: HTTPHeaders; //header params we want to use on every request
27
+ credentials?: RequestCredentials; //value for the credentials param we want to use on each request
28
+ }
29
+
30
+ export class Configuration {
31
+ constructor(private configuration: ConfigurationParameters = {}) {}
32
+
33
+ set config(configuration: Configuration) {
34
+ this.configuration = configuration;
35
+ }
36
+
37
+ get basePath(): string {
38
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
39
+ }
40
+
41
+ get fetchApi(): FetchAPI | undefined {
42
+ return this.configuration.fetchApi;
43
+ }
44
+
45
+ get middleware(): Middleware[] {
46
+ return this.configuration.middleware || [];
47
+ }
48
+
49
+ get queryParamsStringify(): (params: HTTPQuery) => string {
50
+ return this.configuration.queryParamsStringify || querystring;
51
+ }
52
+
53
+ get username(): string | undefined {
54
+ return this.configuration.username;
55
+ }
56
+
57
+ get password(): string | undefined {
58
+ return this.configuration.password;
59
+ }
60
+
61
+ get apiKey(): ((name: string) => string | Promise<string>) | undefined {
62
+ const apiKey = this.configuration.apiKey;
63
+ if (apiKey) {
64
+ return typeof apiKey === 'function' ? apiKey : () => apiKey;
65
+ }
66
+ return undefined;
67
+ }
68
+
69
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
70
+ const accessToken = this.configuration.accessToken;
71
+ if (accessToken) {
72
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
73
+ }
74
+ return undefined;
75
+ }
76
+
77
+ get headers(): HTTPHeaders | undefined {
78
+ return this.configuration.headers;
79
+ }
80
+
81
+ get credentials(): RequestCredentials | undefined {
82
+ return this.configuration.credentials;
83
+ }
84
+ }
85
+
86
+ export const DefaultConfig = new Configuration();
87
+
88
+ /**
89
+ * This is the base class for all generated API classes.
90
+ */
91
+ export class BaseAPI {
92
+
93
+ private static readonly jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
94
+ private middleware: Middleware[];
95
+
96
+ constructor(protected configuration = DefaultConfig) {
97
+ this.middleware = configuration.middleware;
98
+ }
99
+
100
+ withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
101
+ const next = this.clone<T>();
102
+ next.middleware = next.middleware.concat(...middlewares);
103
+ return next;
104
+ }
105
+
106
+ withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
107
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
108
+ return this.withMiddleware<T>(...middlewares);
109
+ }
110
+
111
+ withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
112
+ const middlewares = postMiddlewares.map((post) => ({ post }));
113
+ return this.withMiddleware<T>(...middlewares);
114
+ }
115
+
116
+ /**
117
+ * Check if the given MIME is a JSON MIME.
118
+ * JSON MIME examples:
119
+ * application/json
120
+ * application/json; charset=UTF8
121
+ * APPLICATION/JSON
122
+ * application/vnd.company+json
123
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
124
+ * @return True if the given MIME is JSON, false otherwise.
125
+ */
126
+ protected isJsonMime(mime: string | null | undefined): boolean {
127
+ if (!mime) {
128
+ return false;
129
+ }
130
+ return BaseAPI.jsonRegex.test(mime);
131
+ }
132
+
133
+ protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response> {
134
+ const { url, init } = await this.createFetchParams(context, initOverrides);
135
+ const response = await this.fetchApi(url, init);
136
+ if (response && (response.status >= 200 && response.status < 300)) {
137
+ return response;
138
+ }
139
+ throw new ResponseError(response, 'Response returned an error code');
140
+ }
141
+
142
+ private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) {
143
+ let url = this.configuration.basePath + context.path;
144
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
145
+ // only add the querystring to the URL if there are query parameters.
146
+ // this is done to avoid urls ending with a "?" character which buggy webservers
147
+ // do not handle correctly sometimes.
148
+ url += '?' + this.configuration.queryParamsStringify(context.query);
149
+ }
150
+
151
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
152
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
153
+
154
+ const initOverrideFn =
155
+ typeof initOverrides === "function"
156
+ ? initOverrides
157
+ : async () => initOverrides;
158
+
159
+ const initParams = {
160
+ method: context.method,
161
+ headers,
162
+ body: context.body,
163
+ credentials: this.configuration.credentials,
164
+ };
165
+
166
+ const overriddenInit: RequestInit = {
167
+ ...initParams,
168
+ ...(await initOverrideFn({
169
+ init: initParams,
170
+ context,
171
+ }))
172
+ };
173
+
174
+ let body: any;
175
+ if (isFormData(overriddenInit.body)
176
+ || (overriddenInit.body instanceof URLSearchParams)
177
+ || isBlob(overriddenInit.body)) {
178
+ body = overriddenInit.body;
179
+ } else if (this.isJsonMime(headers['Content-Type'])) {
180
+ body = JSON.stringify(overriddenInit.body);
181
+ } else {
182
+ body = overriddenInit.body;
183
+ }
184
+
185
+ const init: RequestInit = {
186
+ ...overriddenInit,
187
+ body
188
+ };
189
+
190
+ return { url, init };
191
+ }
192
+
193
+ private fetchApi = async (url: string, init: RequestInit) => {
194
+ let fetchParams = { url, init };
195
+ for (const middleware of this.middleware) {
196
+ if (middleware.pre) {
197
+ fetchParams = await middleware.pre({
198
+ fetch: this.fetchApi,
199
+ ...fetchParams,
200
+ }) || fetchParams;
201
+ }
202
+ }
203
+ let response: Response | undefined = undefined;
204
+ try {
205
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
206
+ } catch (e) {
207
+ for (const middleware of this.middleware) {
208
+ if (middleware.onError) {
209
+ response = await middleware.onError({
210
+ fetch: this.fetchApi,
211
+ url: fetchParams.url,
212
+ init: fetchParams.init,
213
+ error: e,
214
+ response: response ? response.clone() : undefined,
215
+ }) || response;
216
+ }
217
+ }
218
+ if (response === undefined) {
219
+ if (e instanceof Error) {
220
+ throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
221
+ } else {
222
+ throw e;
223
+ }
224
+ }
225
+ }
226
+ for (const middleware of this.middleware) {
227
+ if (middleware.post) {
228
+ response = await middleware.post({
229
+ fetch: this.fetchApi,
230
+ url: fetchParams.url,
231
+ init: fetchParams.init,
232
+ response: response.clone(),
233
+ }) || response;
234
+ }
235
+ }
236
+ return response;
237
+ }
238
+
239
+ /**
240
+ * Create a shallow clone of `this` by constructing a new instance
241
+ * and then shallow cloning data members.
242
+ */
243
+ private clone<T extends BaseAPI>(this: T): T {
244
+ const constructor = this.constructor as any;
245
+ const next = new constructor(this.configuration);
246
+ next.middleware = this.middleware.slice();
247
+ return next;
248
+ }
249
+ };
250
+
251
+ function isBlob(value: any): value is Blob {
252
+ return typeof Blob !== 'undefined' && value instanceof Blob;
253
+ }
254
+
255
+ function isFormData(value: any): value is FormData {
256
+ return typeof FormData !== "undefined" && value instanceof FormData;
257
+ }
258
+
259
+ export class ResponseError extends Error {
260
+ override name: "ResponseError" = "ResponseError";
261
+ constructor(public response: Response, msg?: string) {
262
+ super(msg);
263
+
264
+ // restore prototype chain
265
+ const actualProto = new.target.prototype;
266
+ if (Object.setPrototypeOf) {
267
+ Object.setPrototypeOf(this, actualProto);
268
+ }
269
+ }
270
+ }
271
+
272
+ export class FetchError extends Error {
273
+ override name: "FetchError" = "FetchError";
274
+ constructor(public cause: Error, msg?: string) {
275
+ super(msg);
276
+
277
+ // restore prototype chain
278
+ const actualProto = new.target.prototype;
279
+ if (Object.setPrototypeOf) {
280
+ Object.setPrototypeOf(this, actualProto);
281
+ }
282
+ }
283
+ }
284
+
285
+ export class RequiredError extends Error {
286
+ override name: "RequiredError" = "RequiredError";
287
+ constructor(public field: string, msg?: string) {
288
+ super(msg);
289
+
290
+ // restore prototype chain
291
+ const actualProto = new.target.prototype;
292
+ if (Object.setPrototypeOf) {
293
+ Object.setPrototypeOf(this, actualProto);
294
+ }
295
+ }
296
+ }
297
+
298
+ export const COLLECTION_FORMATS = {
299
+ csv: ",",
300
+ ssv: " ",
301
+ tsv: "\t",
302
+ pipes: "|",
303
+ };
304
+
305
+ export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
306
+
307
+ export type Json = any;
308
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
309
+ export type HTTPHeaders = { [key: string]: string };
310
+ export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery };
311
+ export type HTTPBody = Json | FormData | URLSearchParams;
312
+ export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
313
+ export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
314
+
315
+ export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise<RequestInit>
316
+
317
+ export interface FetchParams {
318
+ url: string;
319
+ init: RequestInit;
320
+ }
321
+
322
+ export interface RequestOpts {
323
+ path: string;
324
+ method: HTTPMethod;
325
+ headers: HTTPHeaders;
326
+ query?: HTTPQuery;
327
+ body?: HTTPBody;
328
+ }
329
+
330
+ export function querystring(params: HTTPQuery, prefix: string = ''): string {
331
+ return Object.keys(params)
332
+ .map(key => querystringSingleKey(key, params[key], prefix))
333
+ .filter(part => part.length > 0)
334
+ .join('&');
335
+ }
336
+
337
+ function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery, keyPrefix: string = ''): string {
338
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
339
+ if (value instanceof Array) {
340
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
341
+ .join(`&${encodeURIComponent(fullKey)}=`);
342
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
343
+ }
344
+ if (value instanceof Set) {
345
+ const valueAsArray = Array.from(value);
346
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
347
+ }
348
+ if (value instanceof Date) {
349
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
350
+ }
351
+ if (value instanceof Object) {
352
+ return querystring(value as HTTPQuery, fullKey);
353
+ }
354
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
355
+ }
356
+
357
+ export function exists(json: any, key: string) {
358
+ const value = json[key];
359
+ return value !== null && value !== undefined;
360
+ }
361
+
362
+ export function mapValues(data: any, fn: (item: any) => any) {
363
+ const result: { [key: string]: any } = {};
364
+ for (const key of Object.keys(data)) {
365
+ result[key] = fn(data[key]);
366
+ }
367
+ return result;
368
+ }
369
+
370
+ export function canConsumeForm(consumes: Consume[]): boolean {
371
+ for (const consume of consumes) {
372
+ if ('multipart/form-data' === consume.contentType) {
373
+ return true;
374
+ }
375
+ }
376
+ return false;
377
+ }
378
+
379
+ export interface Consume {
380
+ contentType: string;
381
+ }
382
+
383
+ export interface RequestContext {
384
+ fetch: FetchAPI;
385
+ url: string;
386
+ init: RequestInit;
387
+ }
388
+
389
+ export interface ResponseContext {
390
+ fetch: FetchAPI;
391
+ url: string;
392
+ init: RequestInit;
393
+ response: Response;
394
+ }
395
+
396
+ export interface ErrorContext {
397
+ fetch: FetchAPI;
398
+ url: string;
399
+ init: RequestInit;
400
+ error: unknown;
401
+ response?: Response;
402
+ }
403
+
404
+ export interface Middleware {
405
+ pre?(context: RequestContext): Promise<FetchParams | void>;
406
+ post?(context: ResponseContext): Promise<Response | void>;
407
+ onError?(context: ErrorContext): Promise<Response | void>;
408
+ }
409
+
410
+ export interface ApiResponse<T> {
411
+ raw: Response;
412
+ value(): Promise<T>;
413
+ }
414
+
415
+ export interface ResponseTransformer<T> {
416
+ (json: any): T;
417
+ }
418
+
419
+ export class JSONApiResponse<T> {
420
+ constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
421
+
422
+ async value(): Promise<T> {
423
+ return this.transformer(await this.raw.json());
424
+ }
425
+ }
426
+
427
+ export class VoidApiResponse {
428
+ constructor(public raw: Response) {}
429
+
430
+ async value(): Promise<void> {
431
+ return undefined;
432
+ }
433
+ }
434
+
435
+ export class BlobApiResponse {
436
+ constructor(public raw: Response) {}
437
+
438
+ async value(): Promise<Blob> {
439
+ return await this.raw.blob();
440
+ };
441
+ }
442
+
443
+ export class TextApiResponse {
444
+ constructor(public raw: Response) {}
445
+
446
+ async value(): Promise<string> {
447
+ return await this.raw.text();
448
+ };
449
+ }
@@ -0,0 +1,91 @@
1
+ // Hand-written webhook signature verification helper — survives
2
+ // openapi-generator regeneration (listed in
3
+ // clients/typescript/.openapi-generator-ignore).
4
+ //
5
+ // Customers receive Stadar outbound webhooks with an HMAC-SHA256
6
+ // signature in the `X-Stadar-Signature` header (mirrors Polar's
7
+ // pattern from ADR-0019). This file ships a thin `verifySignature`
8
+ // that returns Promise<boolean> using the WebCrypto API (available
9
+ // in modern Node + every browser).
10
+ //
11
+ // Constant-time comparison is enforced to prevent timing-oracle
12
+ // attacks on the signature value.
13
+
14
+ /**
15
+ * Verify an inbound Stadar webhook signature.
16
+ *
17
+ * @param body the raw HTTP request body. Pass a `Uint8Array` for
18
+ * non-UTF-8 payloads; strings are UTF-8 encoded automatically.
19
+ * @param signature the value of the `X-Stadar-Signature` header. May
20
+ * be the bare hex digest or prefixed with `sha256=`.
21
+ * @param secret the shared webhook secret (the one shown on subscription
22
+ * creation; we never re-display it).
23
+ * @returns `true` iff the signature matches.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { verifySignature } from '@stadar/sdk/webhooks';
28
+ *
29
+ * app.post('/stadar-webhook', async (req, res) => {
30
+ * const ok = await verifySignature(
31
+ * await readRawBody(req),
32
+ * req.headers['x-stadar-signature'] as string,
33
+ * process.env.STADAR_WEBHOOK_SECRET!,
34
+ * );
35
+ * if (!ok) return res.status(401).end();
36
+ * const event = JSON.parse(req.body);
37
+ * // ... handle event
38
+ * });
39
+ * ```
40
+ */
41
+ export async function verifySignature(
42
+ body: ArrayBuffer | Uint8Array | string,
43
+ signature: string,
44
+ secret: string
45
+ ): Promise<boolean> {
46
+ const enc = new TextEncoder();
47
+ const bodyBytes =
48
+ typeof body === 'string'
49
+ ? enc.encode(body)
50
+ : body instanceof Uint8Array
51
+ ? body
52
+ : new Uint8Array(body);
53
+ const cleaned = signature.startsWith('sha256=') ? signature.slice('sha256='.length) : signature;
54
+
55
+ const key = await crypto.subtle.importKey(
56
+ 'raw',
57
+ enc.encode(secret),
58
+ { name: 'HMAC', hash: 'SHA-256' },
59
+ false,
60
+ ['sign']
61
+ );
62
+ const sigBytes = await crypto.subtle.sign('HMAC', key, bodyBytes);
63
+ const expected = bytesToHex(new Uint8Array(sigBytes));
64
+ return constantTimeEqual(expected, cleaned);
65
+ }
66
+
67
+ function bytesToHex(bytes: Uint8Array): string {
68
+ let out = '';
69
+ for (const b of bytes) {
70
+ out += b.toString(16).padStart(2, '0');
71
+ }
72
+ return out;
73
+ }
74
+
75
+ /**
76
+ * Constant-time string comparison. Mismatched lengths still take the
77
+ * full loop pass to avoid a timing leak on length.
78
+ */
79
+ function constantTimeEqual(a: string, b: string): boolean {
80
+ if (a.length !== b.length) {
81
+ // Comparison itself takes constant time relative to the
82
+ // longest; still reveal "wrong length" because we already
83
+ // returned. Acceptable: real attackers know the digest length.
84
+ return false;
85
+ }
86
+ let diff = 0;
87
+ for (let i = 0; i < a.length; i++) {
88
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
89
+ }
90
+ return diff === 0;
91
+ }