@stackframe/stack-shared 2.8.8 → 2.8.11

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 (476) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/config/format.d.cts +39 -0
  3. package/dist/config/format.d.ts +14 -13
  4. package/dist/config/format.js +147 -206
  5. package/dist/config/format.js.map +1 -0
  6. package/dist/config/schema.d.cts +729 -0
  7. package/dist/config/schema.d.ts +59 -51
  8. package/dist/config/schema.js +232 -172
  9. package/dist/config/schema.js.map +1 -0
  10. package/dist/crud.d.cts +102 -0
  11. package/dist/crud.d.ts +15 -13
  12. package/dist/crud.js +83 -128
  13. package/dist/crud.js.map +1 -0
  14. package/dist/esm/config/format.js +135 -0
  15. package/dist/esm/config/format.js.map +1 -0
  16. package/dist/esm/config/schema.js +201 -0
  17. package/dist/esm/config/schema.js.map +1 -0
  18. package/dist/esm/crud.js +60 -0
  19. package/dist/esm/crud.js.map +1 -0
  20. package/dist/esm/global.d.js +1 -0
  21. package/dist/esm/global.d.js.map +1 -0
  22. package/dist/esm/helpers/password.js +17 -0
  23. package/dist/esm/helpers/password.js.map +1 -0
  24. package/dist/esm/helpers/production-mode.js +50 -0
  25. package/dist/esm/helpers/production-mode.js.map +1 -0
  26. package/dist/esm/hooks/use-async-callback.js +38 -0
  27. package/dist/esm/hooks/use-async-callback.js.map +1 -0
  28. package/dist/esm/hooks/use-async-external-store.js +23 -0
  29. package/dist/esm/hooks/use-async-external-store.js.map +1 -0
  30. package/dist/esm/hooks/use-hash.js +17 -0
  31. package/dist/esm/hooks/use-hash.js.map +1 -0
  32. package/dist/esm/hooks/use-strict-memo.js +61 -0
  33. package/dist/esm/hooks/use-strict-memo.js.map +1 -0
  34. package/dist/esm/index.js +22 -0
  35. package/dist/esm/index.js.map +1 -0
  36. package/dist/esm/interface/adminInterface.js +244 -0
  37. package/dist/esm/interface/adminInterface.js.map +1 -0
  38. package/dist/esm/interface/clientInterface.js +2041 -0
  39. package/dist/esm/interface/clientInterface.js.map +1 -0
  40. package/dist/esm/interface/crud/contact-channels.js +77 -0
  41. package/dist/esm/interface/crud/contact-channels.js.map +1 -0
  42. package/dist/esm/interface/crud/current-user.js +65 -0
  43. package/dist/esm/interface/crud/current-user.js.map +1 -0
  44. package/dist/esm/interface/crud/email-templates.js +52 -0
  45. package/dist/esm/interface/crud/email-templates.js.map +1 -0
  46. package/dist/esm/interface/crud/emails.js +20 -0
  47. package/dist/esm/interface/crud/emails.js.map +1 -0
  48. package/dist/esm/interface/crud/internal-api-keys.js +69 -0
  49. package/dist/esm/interface/crud/internal-api-keys.js.map +1 -0
  50. package/dist/esm/interface/crud/oauth.js +24 -0
  51. package/dist/esm/interface/crud/oauth.js.map +1 -0
  52. package/dist/esm/interface/crud/project-api-keys.js +93 -0
  53. package/dist/esm/interface/crud/project-api-keys.js.map +1 -0
  54. package/dist/esm/interface/crud/project-permissions.js +113 -0
  55. package/dist/esm/interface/crud/project-permissions.js.map +1 -0
  56. package/dist/esm/interface/crud/projects.js +180 -0
  57. package/dist/esm/interface/crud/projects.js.map +1 -0
  58. package/dist/esm/interface/crud/sessions.js +62 -0
  59. package/dist/esm/interface/crud/sessions.js.map +1 -0
  60. package/dist/esm/interface/crud/svix-token.js +22 -0
  61. package/dist/esm/interface/crud/svix-token.js.map +1 -0
  62. package/dist/esm/interface/crud/team-invitation-details.js +23 -0
  63. package/dist/esm/interface/crud/team-invitation-details.js.map +1 -0
  64. package/dist/esm/interface/crud/team-invitation.js +36 -0
  65. package/dist/esm/interface/crud/team-invitation.js.map +1 -0
  66. package/dist/esm/interface/crud/team-member-profiles.js +62 -0
  67. package/dist/esm/interface/crud/team-member-profiles.js.map +1 -0
  68. package/dist/esm/interface/crud/team-memberships.js +60 -0
  69. package/dist/esm/interface/crud/team-memberships.js.map +1 -0
  70. package/dist/esm/interface/crud/team-permissions.js +114 -0
  71. package/dist/esm/interface/crud/team-permissions.js.map +1 -0
  72. package/dist/esm/interface/crud/teams.js +143 -0
  73. package/dist/esm/interface/crud/teams.js.map +1 -0
  74. package/dist/esm/interface/crud/users.js +139 -0
  75. package/dist/esm/interface/crud/users.js.map +1 -0
  76. package/dist/esm/interface/serverInterface.js +485 -0
  77. package/dist/esm/interface/serverInterface.js.map +1 -0
  78. package/dist/esm/interface/webhooks.js +21 -0
  79. package/dist/esm/interface/webhooks.js.map +1 -0
  80. package/dist/esm/known-errors.js +1238 -0
  81. package/dist/esm/known-errors.js.map +1 -0
  82. package/dist/esm/schema-fields.js +484 -0
  83. package/dist/esm/schema-fields.js.map +1 -0
  84. package/dist/esm/sessions.js +168 -0
  85. package/dist/esm/sessions.js.map +1 -0
  86. package/dist/esm/utils/api-keys.js +79 -0
  87. package/dist/esm/utils/api-keys.js.map +1 -0
  88. package/dist/esm/utils/arrays.js +78 -0
  89. package/dist/esm/utils/arrays.js.map +1 -0
  90. package/dist/esm/utils/base64.js +18 -0
  91. package/dist/esm/utils/base64.js.map +1 -0
  92. package/dist/esm/utils/booleans.js +12 -0
  93. package/dist/esm/utils/booleans.js.map +1 -0
  94. package/dist/esm/utils/browser-compat.js +21 -0
  95. package/dist/esm/utils/browser-compat.js.map +1 -0
  96. package/dist/esm/utils/bytes.js +160 -0
  97. package/dist/esm/utils/bytes.js.map +1 -0
  98. package/dist/esm/utils/caches.js +167 -0
  99. package/dist/esm/utils/caches.js.map +1 -0
  100. package/dist/esm/utils/compile-time.js +11 -0
  101. package/dist/esm/utils/compile-time.js.map +1 -0
  102. package/dist/esm/utils/crypto.js +25 -0
  103. package/dist/esm/utils/crypto.js.map +1 -0
  104. package/dist/esm/utils/dates.js +64 -0
  105. package/dist/esm/utils/dates.js.map +1 -0
  106. package/dist/esm/utils/dom.js +11 -0
  107. package/dist/esm/utils/dom.js.map +1 -0
  108. package/dist/esm/utils/env.js +58 -0
  109. package/dist/esm/utils/env.js.map +1 -0
  110. package/dist/esm/utils/errors.js +174 -0
  111. package/dist/esm/utils/errors.js.map +1 -0
  112. package/dist/esm/utils/fs.js +37 -0
  113. package/dist/esm/utils/fs.js.map +1 -0
  114. package/dist/esm/utils/functions.js +12 -0
  115. package/dist/esm/utils/functions.js.map +1 -0
  116. package/dist/esm/utils/geo.js +15 -0
  117. package/dist/esm/utils/geo.js.map +1 -0
  118. package/dist/esm/utils/globals.js +18 -0
  119. package/dist/esm/utils/globals.js.map +1 -0
  120. package/dist/esm/utils/hashes.js +55 -0
  121. package/dist/esm/utils/hashes.js.map +1 -0
  122. package/dist/esm/utils/html.js +13 -0
  123. package/dist/esm/utils/html.js.map +1 -0
  124. package/dist/esm/utils/http.js +60 -0
  125. package/dist/esm/utils/http.js.map +1 -0
  126. package/dist/esm/utils/ips.js +15 -0
  127. package/dist/esm/utils/ips.js.map +1 -0
  128. package/dist/esm/utils/json.js +31 -0
  129. package/dist/esm/utils/json.js.map +1 -0
  130. package/dist/esm/utils/jwt.js +87 -0
  131. package/dist/esm/utils/jwt.js.map +1 -0
  132. package/dist/esm/utils/locks.js +57 -0
  133. package/dist/esm/utils/locks.js.map +1 -0
  134. package/dist/esm/utils/maps.js +181 -0
  135. package/dist/esm/utils/maps.js.map +1 -0
  136. package/dist/esm/utils/math.js +8 -0
  137. package/dist/esm/utils/math.js.map +1 -0
  138. package/dist/esm/utils/node-http.js +42 -0
  139. package/dist/esm/utils/node-http.js.map +1 -0
  140. package/dist/esm/utils/numbers.js +32 -0
  141. package/dist/esm/utils/numbers.js.map +1 -0
  142. package/dist/esm/utils/oauth.js +10 -0
  143. package/dist/esm/utils/oauth.js.map +1 -0
  144. package/dist/esm/utils/objects.js +177 -0
  145. package/dist/esm/utils/objects.js.map +1 -0
  146. package/dist/esm/utils/passkey.js +1 -0
  147. package/dist/esm/utils/passkey.js.map +1 -0
  148. package/dist/esm/utils/promises.js +233 -0
  149. package/dist/esm/utils/promises.js.map +1 -0
  150. package/dist/esm/utils/proxies.js +128 -0
  151. package/dist/esm/utils/proxies.js.map +1 -0
  152. package/dist/esm/utils/react.js +78 -0
  153. package/dist/esm/utils/react.js.map +1 -0
  154. package/dist/esm/utils/results.js +141 -0
  155. package/dist/esm/utils/results.js.map +1 -0
  156. package/dist/esm/utils/sentry.js +20 -0
  157. package/dist/esm/utils/sentry.js.map +1 -0
  158. package/dist/esm/utils/stores.js +195 -0
  159. package/dist/esm/utils/stores.js.map +1 -0
  160. package/dist/esm/utils/strings.js +295 -0
  161. package/dist/esm/utils/strings.js.map +1 -0
  162. package/dist/esm/utils/strings.nicify.test.js +222 -0
  163. package/dist/esm/utils/strings.nicify.test.js.map +1 -0
  164. package/dist/esm/utils/types.js +1 -0
  165. package/dist/esm/utils/types.js.map +1 -0
  166. package/dist/esm/utils/unicode.js +11 -0
  167. package/dist/esm/utils/unicode.js.map +1 -0
  168. package/dist/esm/utils/urls.js +53 -0
  169. package/dist/esm/utils/urls.js.map +1 -0
  170. package/dist/esm/utils/uuids.js +16 -0
  171. package/dist/esm/utils/uuids.js.map +1 -0
  172. package/dist/global.d.d.cts +1 -0
  173. package/dist/global.d.d.ts +1 -0
  174. package/dist/global.d.js +2 -0
  175. package/dist/global.d.js.map +1 -0
  176. package/dist/helpers/password.d.cts +11 -0
  177. package/dist/helpers/password.d.ts +11 -2
  178. package/dist/helpers/password.js +41 -11
  179. package/dist/helpers/password.js.map +1 -0
  180. package/dist/helpers/production-mode.d.cts +12 -0
  181. package/dist/helpers/production-mode.d.ts +9 -3
  182. package/dist/helpers/production-mode.js +72 -45
  183. package/dist/helpers/production-mode.js.map +1 -0
  184. package/dist/hooks/use-async-callback.d.cts +6 -0
  185. package/dist/hooks/use-async-callback.d.ts +6 -3
  186. package/dist/hooks/use-async-callback.js +72 -30
  187. package/dist/hooks/use-async-callback.js.map +1 -0
  188. package/dist/hooks/use-async-external-store.d.cts +7 -0
  189. package/dist/hooks/use-async-external-store.d.ts +5 -2
  190. package/dist/hooks/use-async-external-store.js +47 -19
  191. package/dist/hooks/use-async-external-store.js.map +1 -0
  192. package/dist/hooks/use-hash.d.cts +3 -0
  193. package/dist/hooks/use-hash.d.ts +3 -1
  194. package/dist/hooks/use-hash.js +41 -8
  195. package/dist/hooks/use-hash.js.map +1 -0
  196. package/dist/hooks/use-strict-memo.d.cts +8 -0
  197. package/dist/hooks/use-strict-memo.d.ts +3 -1
  198. package/dist/hooks/use-strict-memo.js +78 -131
  199. package/dist/hooks/use-strict-memo.js.map +1 -0
  200. package/dist/index.d.cts +30 -0
  201. package/dist/index.d.ts +30 -4
  202. package/dist/index.js +42 -4
  203. package/dist/index.js.map +1 -0
  204. package/dist/interface/adminInterface.d.cts +94 -0
  205. package/dist/interface/adminInterface.d.ts +38 -15
  206. package/dist/interface/adminInterface.js +269 -174
  207. package/dist/interface/adminInterface.js.map +1 -0
  208. package/dist/interface/clientInterface.d.cts +260 -0
  209. package/dist/interface/clientInterface.d.ts +25 -18
  210. package/dist/interface/clientInterface.js +2054 -995
  211. package/dist/interface/clientInterface.js.map +1 -0
  212. package/dist/interface/crud/contact-channels.d.cts +180 -0
  213. package/dist/interface/crud/contact-channels.d.ts +30 -25
  214. package/dist/interface/crud/contact-channels.js +101 -59
  215. package/dist/interface/crud/contact-channels.js.map +1 -0
  216. package/dist/interface/crud/current-user.d.cts +205 -0
  217. package/dist/interface/crud/current-user.d.ts +17 -12
  218. package/dist/interface/crud/current-user.js +86 -56
  219. package/dist/interface/crud/current-user.js.map +1 -0
  220. package/dist/interface/crud/email-templates.d.cts +84 -0
  221. package/dist/interface/crud/email-templates.d.ts +24 -19
  222. package/dist/interface/crud/email-templates.js +77 -37
  223. package/dist/interface/crud/email-templates.js.map +1 -0
  224. package/dist/interface/crud/emails.d.cts +69 -0
  225. package/dist/interface/crud/emails.d.ts +12 -7
  226. package/dist/interface/crud/emails.js +54 -12
  227. package/dist/interface/crud/emails.js.map +1 -0
  228. package/dist/interface/crud/internal-api-keys.d.cts +139 -0
  229. package/dist/interface/crud/internal-api-keys.d.ts +22 -17
  230. package/dist/interface/crud/internal-api-keys.js +92 -54
  231. package/dist/interface/crud/internal-api-keys.js.map +1 -0
  232. package/dist/interface/crud/oauth.d.cts +34 -0
  233. package/dist/interface/crud/oauth.d.ts +16 -11
  234. package/dist/interface/crud/oauth.js +48 -14
  235. package/dist/interface/crud/oauth.js.map +1 -0
  236. package/dist/interface/crud/project-api-keys.d.cts +196 -0
  237. package/dist/interface/crud/project-api-keys.d.ts +20 -12
  238. package/dist/interface/crud/project-api-keys.js +121 -74
  239. package/dist/interface/crud/project-api-keys.js.map +1 -0
  240. package/dist/interface/crud/project-permissions.d.cts +160 -0
  241. package/dist/interface/crud/project-permissions.d.ts +38 -33
  242. package/dist/interface/crud/project-permissions.js +148 -90
  243. package/dist/interface/crud/project-permissions.js.map +1 -0
  244. package/dist/interface/crud/projects.d.cts +627 -0
  245. package/dist/interface/crud/projects.d.ts +43 -51
  246. package/dist/interface/crud/projects.js +210 -156
  247. package/dist/interface/crud/projects.js.map +1 -0
  248. package/dist/interface/crud/sessions.d.cts +149 -0
  249. package/dist/interface/crud/sessions.d.ts +21 -16
  250. package/dist/interface/crud/sessions.js +86 -50
  251. package/dist/interface/crud/sessions.js.map +1 -0
  252. package/dist/interface/crud/svix-token.d.cts +26 -0
  253. package/dist/interface/crud/svix-token.d.ts +14 -9
  254. package/dist/interface/crud/svix-token.js +46 -12
  255. package/dist/interface/crud/svix-token.js.map +1 -0
  256. package/dist/interface/crud/team-invitation-details.d.cts +30 -0
  257. package/dist/interface/crud/team-invitation-details.d.ts +12 -7
  258. package/dist/interface/crud/team-invitation-details.js +57 -15
  259. package/dist/interface/crud/team-invitation-details.js.map +1 -0
  260. package/dist/interface/crud/team-invitation.d.cts +49 -0
  261. package/dist/interface/crud/team-invitation.d.ts +13 -8
  262. package/dist/interface/crud/team-invitation.js +69 -27
  263. package/dist/interface/crud/team-invitation.js.map +1 -0
  264. package/dist/interface/crud/team-member-profiles.d.cts +229 -0
  265. package/dist/interface/crud/team-member-profiles.d.ts +20 -15
  266. package/dist/interface/crud/team-member-profiles.js +95 -49
  267. package/dist/interface/crud/team-member-profiles.js.map +1 -0
  268. package/dist/interface/crud/team-memberships.d.cts +74 -0
  269. package/dist/interface/crud/team-memberships.d.ts +22 -17
  270. package/dist/interface/crud/team-memberships.js +85 -45
  271. package/dist/interface/crud/team-memberships.js.map +1 -0
  272. package/dist/interface/crud/team-permissions.d.cts +168 -0
  273. package/dist/interface/crud/team-permissions.d.ts +38 -33
  274. package/dist/interface/crud/team-permissions.js +149 -91
  275. package/dist/interface/crud/team-permissions.js.map +1 -0
  276. package/dist/interface/crud/teams.d.cts +298 -0
  277. package/dist/interface/crud/teams.d.ts +45 -40
  278. package/dist/interface/crud/teams.js +177 -119
  279. package/dist/interface/crud/teams.js.map +1 -0
  280. package/dist/interface/crud/users.d.cts +469 -0
  281. package/dist/interface/crud/users.d.ts +31 -26
  282. package/dist/interface/crud/users.js +172 -118
  283. package/dist/interface/crud/users.js.map +1 -0
  284. package/dist/interface/serverInterface.d.cts +128 -0
  285. package/dist/interface/serverInterface.d.ts +29 -17
  286. package/dist/interface/serverInterface.js +506 -339
  287. package/dist/interface/serverInterface.js.map +1 -0
  288. package/dist/interface/webhooks.d.cts +292 -0
  289. package/dist/interface/webhooks.d.ts +6 -3
  290. package/dist/interface/webhooks.js +45 -15
  291. package/dist/interface/webhooks.js.map +1 -0
  292. package/dist/known-errors.d.cts +447 -0
  293. package/dist/known-errors.d.ts +15 -9
  294. package/dist/known-errors.js +1104 -562
  295. package/dist/known-errors.js.map +1 -0
  296. package/dist/schema-fields.d.cts +163 -0
  297. package/dist/schema-fields.d.ts +116 -114
  298. package/dist/schema-fields.js +593 -427
  299. package/dist/schema-fields.js.map +1 -0
  300. package/dist/sessions.d.cts +109 -0
  301. package/dist/sessions.d.ts +6 -3
  302. package/dist/sessions.js +201 -172
  303. package/dist/sessions.js.map +1 -0
  304. package/dist/utils/api-keys.d.cts +24 -0
  305. package/dist/utils/api-keys.d.ts +5 -4
  306. package/dist/utils/api-keys.js +106 -66
  307. package/dist/utils/api-keys.js.map +1 -0
  308. package/dist/utils/arrays.d.cts +18 -0
  309. package/dist/utils/arrays.d.ts +15 -13
  310. package/dist/utils/arrays.js +101 -168
  311. package/dist/utils/arrays.js.map +1 -0
  312. package/dist/utils/base64.d.cts +4 -0
  313. package/dist/utils/base64.d.ts +4 -2
  314. package/dist/utils/base64.js +41 -20
  315. package/dist/utils/base64.js.map +1 -0
  316. package/dist/utils/booleans.d.cts +6 -0
  317. package/dist/utils/booleans.d.ts +6 -4
  318. package/dist/utils/booleans.js +35 -27
  319. package/dist/utils/booleans.js.map +1 -0
  320. package/dist/utils/browser-compat.d.cts +8 -0
  321. package/dist/utils/browser-compat.d.ts +3 -1
  322. package/dist/utils/browser-compat.js +45 -16
  323. package/dist/utils/browser-compat.js.map +1 -0
  324. package/dist/utils/bytes.d.cts +15 -0
  325. package/dist/utils/bytes.d.ts +15 -13
  326. package/dist/utils/bytes.js +182 -270
  327. package/dist/utils/bytes.js.map +1 -0
  328. package/dist/utils/caches.d.cts +98 -0
  329. package/dist/utils/caches.d.ts +17 -14
  330. package/dist/utils/caches.js +188 -193
  331. package/dist/utils/caches.js.map +1 -0
  332. package/dist/utils/compile-time.d.cts +8 -0
  333. package/dist/utils/compile-time.d.ts +3 -1
  334. package/dist/utils/compile-time.js +35 -10
  335. package/dist/utils/compile-time.js.map +1 -0
  336. package/dist/utils/crypto.d.cts +8 -0
  337. package/dist/utils/crypto.d.ts +4 -2
  338. package/dist/utils/crypto.js +49 -21
  339. package/dist/utils/crypto.js.map +1 -0
  340. package/dist/utils/dates.d.cts +15 -0
  341. package/dist/utils/dates.d.ts +6 -4
  342. package/dist/utils/dates.js +83 -105
  343. package/dist/utils/dates.js.map +1 -0
  344. package/dist/utils/dom.d.cts +3 -0
  345. package/dist/utils/dom.d.ts +3 -1
  346. package/dist/utils/dom.js +35 -7
  347. package/dist/utils/dom.js.map +1 -0
  348. package/dist/utils/env.d.cts +9 -0
  349. package/dist/utils/env.d.ts +6 -4
  350. package/dist/utils/env.js +70 -43
  351. package/dist/utils/env.js.map +1 -0
  352. package/dist/utils/errors.d.cts +223 -0
  353. package/dist/utils/errors.d.ts +14 -11
  354. package/dist/utils/errors.js +148 -126
  355. package/dist/utils/errors.js.map +1 -0
  356. package/dist/utils/fs.d.cts +7 -0
  357. package/dist/utils/fs.d.ts +5 -3
  358. package/dist/utils/fs.js +70 -27
  359. package/dist/utils/fs.js.map +1 -0
  360. package/dist/utils/functions.d.cts +4 -0
  361. package/dist/utils/functions.d.ts +4 -2
  362. package/dist/utils/functions.js +35 -18
  363. package/dist/utils/functions.js.map +1 -0
  364. package/dist/utils/geo.d.cts +22 -0
  365. package/dist/utils/geo.d.ts +6 -3
  366. package/dist/utils/geo.js +39 -9
  367. package/dist/utils/geo.js.map +1 -0
  368. package/dist/utils/globals.d.cts +5 -0
  369. package/dist/utils/globals.d.ts +4 -2
  370. package/dist/utils/globals.js +41 -14
  371. package/dist/utils/globals.js.map +1 -0
  372. package/dist/utils/hashes.d.cts +7 -0
  373. package/dist/utils/hashes.d.ts +7 -5
  374. package/dist/utils/hashes.js +87 -41
  375. package/dist/utils/hashes.js.map +1 -0
  376. package/dist/utils/html.d.cts +4 -0
  377. package/dist/utils/html.d.ts +4 -2
  378. package/dist/utils/html.js +36 -37
  379. package/dist/utils/html.js.map +1 -0
  380. package/dist/utils/http.d.cts +43 -0
  381. package/dist/utils/http.d.ts +6 -4
  382. package/dist/utils/http.js +83 -83
  383. package/dist/utils/http.js.map +1 -0
  384. package/dist/utils/ips.d.cts +6 -0
  385. package/dist/utils/ips.d.ts +6 -4
  386. package/dist/utils/ips.js +48 -35
  387. package/dist/utils/ips.js.map +1 -0
  388. package/dist/utils/json.d.cts +13 -0
  389. package/dist/utils/json.d.ts +9 -6
  390. package/dist/utils/json.js +54 -157
  391. package/dist/utils/json.js.map +1 -0
  392. package/dist/utils/jwt.d.cts +44 -0
  393. package/dist/utils/jwt.d.ts +14 -11
  394. package/dist/utils/jwt.js +119 -84
  395. package/dist/utils/jwt.js.map +1 -0
  396. package/dist/utils/locks.d.cts +15 -0
  397. package/dist/utils/locks.d.ts +3 -2
  398. package/dist/utils/locks.js +76 -56
  399. package/dist/utils/locks.js.map +1 -0
  400. package/dist/utils/maps.d.cts +59 -0
  401. package/dist/utils/maps.d.ts +6 -4
  402. package/dist/utils/maps.js +207 -343
  403. package/dist/utils/maps.js.map +1 -0
  404. package/dist/utils/math.d.cts +6 -0
  405. package/dist/utils/math.d.ts +3 -1
  406. package/dist/utils/math.js +31 -16
  407. package/dist/utils/math.js.map +1 -0
  408. package/dist/utils/node-http.d.cts +15 -0
  409. package/dist/utils/node-http.d.ts +5 -5
  410. package/dist/utils/node-http.js +65 -36
  411. package/dist/utils/node-http.js.map +1 -0
  412. package/dist/utils/numbers.d.cts +5 -0
  413. package/dist/utils/numbers.d.ts +5 -3
  414. package/dist/utils/numbers.js +53 -66
  415. package/dist/utils/numbers.js.map +1 -0
  416. package/dist/utils/oauth.d.cts +8 -0
  417. package/dist/utils/oauth.d.ts +8 -6
  418. package/dist/utils/oauth.js +37 -4
  419. package/dist/utils/oauth.js.map +1 -0
  420. package/dist/utils/objects.d.cts +69 -0
  421. package/dist/utils/objects.d.ts +37 -32
  422. package/dist/utils/objects.js +224 -374
  423. package/dist/utils/objects.js.map +1 -0
  424. package/dist/utils/passkey.d.cts +1 -0
  425. package/dist/utils/passkey.d.ts +1 -1
  426. package/dist/utils/passkey.js +19 -1
  427. package/dist/utils/passkey.js.map +1 -0
  428. package/dist/utils/promises.d.cts +74 -0
  429. package/dist/utils/promises.d.ts +20 -18
  430. package/dist/utils/promises.js +252 -393
  431. package/dist/utils/promises.js.map +1 -0
  432. package/dist/utils/proxies.d.cts +4 -0
  433. package/dist/utils/proxies.d.ts +4 -2
  434. package/dist/utils/proxies.js +150 -161
  435. package/dist/utils/proxies.js.map +1 -0
  436. package/dist/utils/react.d.cts +25 -0
  437. package/dist/utils/react.d.ts +9 -6
  438. package/dist/utils/react.js +88 -134
  439. package/dist/utils/react.js.map +1 -0
  440. package/dist/utils/results.d.cts +78 -0
  441. package/dist/utils/results.d.ts +10 -9
  442. package/dist/utils/results.js +143 -324
  443. package/dist/utils/results.js.map +1 -0
  444. package/dist/utils/sentry.d.cts +5 -0
  445. package/dist/utils/sentry.d.ts +5 -2
  446. package/dist/utils/sentry.js +44 -14
  447. package/dist/utils/sentry.js.map +1 -0
  448. package/dist/utils/stores.d.cts +102 -0
  449. package/dist/utils/stores.d.ts +12 -9
  450. package/dist/utils/stores.js +219 -189
  451. package/dist/utils/stores.js.map +1 -0
  452. package/dist/utils/strings.d.cts +72 -0
  453. package/dist/utils/strings.d.ts +22 -20
  454. package/dist/utils/strings.js +300 -580
  455. package/dist/utils/strings.js.map +1 -0
  456. package/dist/utils/strings.nicify.test.d.cts +2 -0
  457. package/dist/utils/strings.nicify.test.d.ts +2 -1
  458. package/dist/utils/strings.nicify.test.js +168 -158
  459. package/dist/utils/strings.nicify.test.js.map +1 -0
  460. package/dist/utils/types.d.cts +23 -0
  461. package/dist/utils/types.d.ts +8 -6
  462. package/dist/utils/types.js +19 -1
  463. package/dist/utils/types.js.map +1 -0
  464. package/dist/utils/unicode.d.cts +3 -0
  465. package/dist/utils/unicode.d.ts +3 -1
  466. package/dist/utils/unicode.js +34 -21
  467. package/dist/utils/unicode.js.map +1 -0
  468. package/dist/utils/urls.d.cts +20 -0
  469. package/dist/utils/urls.d.ts +10 -8
  470. package/dist/utils/urls.js +76 -165
  471. package/dist/utils/urls.js.map +1 -0
  472. package/dist/utils/uuids.d.cts +4 -0
  473. package/dist/utils/uuids.d.ts +4 -2
  474. package/dist/utils/uuids.js +39 -35
  475. package/dist/utils/uuids.js.map +1 -0
  476. package/package.json +5 -5
@@ -1,341 +1,508 @@
1
- import { KnownErrors } from "../known-errors";
2
- import { StackAssertionError } from "../utils/errors";
3
- import { filterUndefined } from "../utils/objects";
4
- import { Result } from "../utils/results";
5
- import { urlString } from "../utils/urls";
6
- import { StackClientInterface } from "./clientInterface";
7
- export class StackServerInterface extends StackClientInterface {
8
- constructor(options) {
9
- super(options);
10
- this.options = options;
11
- }
12
- async sendServerRequest(path, options, session, requestType = "server") {
13
- return await this.sendClientRequest(path, {
14
- ...options,
15
- headers: {
16
- "x-stack-secret-server-key": "secretServerKey" in this.options ? this.options.secretServerKey : "",
17
- ...options.headers,
18
- },
19
- }, session, requestType);
20
- }
21
- async sendServerRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorsToCatch) {
22
- try {
23
- return Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));
24
- }
25
- catch (e) {
26
- for (const errorType of errorsToCatch) {
27
- if (e instanceof errorType) {
28
- return Result.error(e);
29
- }
30
- }
31
- throw e;
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/interface/serverInterface.ts
21
+ var serverInterface_exports = {};
22
+ __export(serverInterface_exports, {
23
+ StackServerInterface: () => StackServerInterface
24
+ });
25
+ module.exports = __toCommonJS(serverInterface_exports);
26
+ var import_known_errors = require("../known-errors");
27
+ var import_errors = require("../utils/errors");
28
+ var import_objects = require("../utils/objects");
29
+ var import_results = require("../utils/results");
30
+ var import_urls = require("../utils/urls");
31
+ var import_clientInterface = require("./clientInterface");
32
+ var StackServerInterface = class extends import_clientInterface.StackClientInterface {
33
+ constructor(options) {
34
+ super(options);
35
+ this.options = options;
36
+ }
37
+ async sendServerRequest(path, options, session, requestType = "server") {
38
+ return await this.sendClientRequest(
39
+ path,
40
+ {
41
+ ...options,
42
+ headers: {
43
+ "x-stack-secret-server-key": "secretServerKey" in this.options ? this.options.secretServerKey : "",
44
+ ...options.headers
32
45
  }
33
- }
34
- async createServerUser(data) {
35
- const response = await this.sendServerRequest("/users", {
36
- method: "POST",
37
- headers: {
38
- "content-type": "application/json",
39
- },
40
- body: JSON.stringify(data),
41
- }, null);
42
- return await response.json();
43
- }
44
- async getServerUserByToken(session) {
45
- const responseOrError = await this.sendServerRequestAndCatchKnownError("/users/me", {}, session, [KnownErrors.CannotGetOwnUserWithoutUser]);
46
- if (responseOrError.status === "error") {
47
- if (responseOrError.error instanceof KnownErrors.CannotGetOwnUserWithoutUser) {
48
- return null;
49
- }
50
- else {
51
- throw new StackAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
52
- }
46
+ },
47
+ session,
48
+ requestType
49
+ );
50
+ }
51
+ async sendServerRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorsToCatch) {
52
+ try {
53
+ return import_results.Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));
54
+ } catch (e) {
55
+ for (const errorType of errorsToCatch) {
56
+ if (e instanceof errorType) {
57
+ return import_results.Result.error(e);
53
58
  }
54
- const response = responseOrError.data;
55
- const user = await response.json();
56
- if (!user)
57
- throw new StackAssertionError("User endpoint returned null; this should never happen");
58
- return user;
59
- }
60
- async getServerUserById(userId) {
61
- const responseOrError = await this.sendServerRequestAndCatchKnownError(urlString `/users/${userId}`, {}, null, [KnownErrors.UserNotFound]);
62
- if (responseOrError.status === "error") {
63
- return Result.error(responseOrError.error);
64
- }
65
- const user = await responseOrError.data.json();
66
- return Result.ok(user);
67
- }
68
- async listServerTeamInvitations(options) {
69
- const response = await this.sendServerRequest(urlString `/team-invitations?team_id=${options.teamId}`, {}, null);
70
- const result = await response.json();
71
- return result.items;
72
- }
73
- async revokeServerTeamInvitation(invitationId, teamId) {
74
- await this.sendServerRequest(urlString `/team-invitations/${invitationId}?team_id=${teamId}`, { method: "DELETE" }, null);
75
- }
76
- async listServerTeamMemberProfiles(options) {
77
- const response = await this.sendServerRequest(urlString `/team-member-profiles?team_id=${options.teamId}`, {}, null);
78
- const result = await response.json();
79
- return result.items;
80
- }
81
- async getServerTeamMemberProfile(options) {
82
- const response = await this.sendServerRequest(urlString `/team-member-profiles/${options.teamId}/${options.userId}`, {}, null);
83
- return await response.json();
84
- }
85
- async listServerTeamPermissions(options, session) {
86
- const response = await this.sendServerRequest(`/team-permissions?${new URLSearchParams(filterUndefined({
87
- user_id: options.userId,
88
- team_id: options.teamId,
89
- recursive: options.recursive.toString(),
90
- }))}`, {}, session);
91
- const result = await response.json();
92
- return result.items;
93
- }
94
- async listServerProjectPermissions(options, session) {
95
- const response = await this.sendServerRequest(`/project-permissions?${new URLSearchParams(filterUndefined({
96
- user_id: options.userId,
97
- recursive: options.recursive.toString(),
98
- }))}`, {}, session);
99
- const result = await response.json();
100
- return result.items;
101
- }
102
- async listServerUsers(options) {
103
- const searchParams = new URLSearchParams(filterUndefined({
104
- cursor: options.cursor,
105
- limit: options.limit?.toString(),
106
- desc: options.desc?.toString(),
107
- ...options.orderBy ? {
108
- order_by: {
109
- signedUpAt: "signed_up_at",
110
- }[options.orderBy],
111
- } : {},
112
- ...options.query ? {
113
- query: options.query,
114
- } : {},
115
- }));
116
- const response = await this.sendServerRequest("/users?" + searchParams.toString(), {}, null);
117
- return await response.json();
118
- }
119
- async listServerTeams(options) {
120
- const response = await this.sendServerRequest(`/teams?${new URLSearchParams(filterUndefined({
121
- user_id: options?.userId,
122
- }))}`, {}, null);
123
- const result = await response.json();
124
- return result.items;
125
- }
126
- async getServerTeam(teamId) {
127
- const response = await this.sendServerRequest(`/teams/${teamId}`, {}, null);
128
- return await response.json();
129
- }
130
- async listServerTeamUsers(teamId) {
131
- const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);
132
- const result = await response.json();
133
- return result.items;
134
- }
135
- /* when passing a session, the user will be added to the team */
136
- async createServerTeam(data) {
137
- const response = await this.sendServerRequest("/teams", {
138
- method: "POST",
139
- headers: {
140
- "content-type": "application/json",
141
- },
142
- body: JSON.stringify(data),
143
- }, null);
144
- return await response.json();
145
- }
146
- async updateServerTeam(teamId, data) {
147
- const response = await this.sendServerRequest(urlString `/teams/${teamId}`, {
148
- method: "PATCH",
149
- headers: {
150
- "content-type": "application/json",
151
- },
152
- body: JSON.stringify(data),
153
- }, null);
154
- return await response.json();
155
- }
156
- async deleteServerTeam(teamId) {
157
- await this.sendServerRequest(urlString `/teams/${teamId}`, { method: "DELETE" }, null);
158
- }
159
- async addServerUserToTeam(options) {
160
- const response = await this.sendServerRequest(urlString `/team-memberships/${options.teamId}/${options.userId}`, {
161
- method: "POST",
162
- headers: {
163
- "content-type": "application/json",
164
- },
165
- body: JSON.stringify({}),
166
- }, null);
167
- return await response.json();
168
- }
169
- async removeServerUserFromTeam(options) {
170
- await this.sendServerRequest(urlString `/team-memberships/${options.teamId}/${options.userId}`, {
171
- method: "DELETE",
172
- headers: {
173
- "content-type": "application/json",
174
- },
175
- body: JSON.stringify({}),
176
- }, null);
177
- }
178
- async updateServerUser(userId, update) {
179
- const response = await this.sendServerRequest(urlString `/users/${userId}`, {
180
- method: "PATCH",
181
- headers: {
182
- "content-type": "application/json",
183
- },
184
- body: JSON.stringify(update),
185
- }, null);
186
- return await response.json();
187
- }
188
- async createServerProviderAccessToken(userId, provider, scope) {
189
- const response = await this.sendServerRequest(urlString `/connected-accounts/${userId}/${provider}/access-token`, {
190
- method: "POST",
191
- headers: {
192
- "content-type": "application/json",
193
- },
194
- body: JSON.stringify({ scope }),
195
- }, null);
196
- return await response.json();
197
- }
198
- async createServerUserSession(userId, expiresInMillis, isImpersonation) {
199
- const response = await this.sendServerRequest("/auth/sessions", {
200
- method: "POST",
201
- headers: {
202
- "content-type": "application/json",
203
- },
204
- body: JSON.stringify({
205
- user_id: userId,
206
- expires_in_millis: expiresInMillis,
207
- is_impersonation: isImpersonation,
208
- }),
209
- }, null);
210
- const result = await response.json();
211
- return {
212
- accessToken: result.access_token,
213
- refreshToken: result.refresh_token,
214
- };
215
- }
216
- async leaveServerTeam(options) {
217
- await this.sendClientRequest(urlString `/team-memberships/${options.teamId}/${options.userId}`, {
218
- method: "DELETE",
219
- headers: {
220
- "content-type": "application/json",
221
- },
222
- body: JSON.stringify({}),
223
- }, null);
224
- }
225
- async updateServerTeamMemberProfile(options) {
226
- await this.sendServerRequest(urlString `/team-member-profiles/${options.teamId}/${options.userId}`, {
227
- method: "PATCH",
228
- headers: {
229
- "content-type": "application/json",
230
- },
231
- body: JSON.stringify(options.profile),
232
- }, null);
233
- }
234
- async grantServerTeamUserPermission(teamId, userId, permissionId) {
235
- await this.sendServerRequest(urlString `/team-permissions/${teamId}/${userId}/${permissionId}`, {
236
- method: "POST",
237
- headers: {
238
- "content-type": "application/json",
239
- },
240
- body: JSON.stringify({}),
241
- }, null);
242
- }
243
- async revokeServerTeamUserPermission(teamId, userId, permissionId) {
244
- await this.sendServerRequest(urlString `/team-permissions/${teamId}/${userId}/${permissionId}`, {
245
- method: "DELETE",
246
- headers: {
247
- "content-type": "application/json",
248
- },
249
- body: JSON.stringify({}),
250
- }, null);
251
- }
252
- async deleteServerUser(userId) {
253
- await this.sendServerRequest(urlString `/users/${userId}`, {
254
- method: "DELETE",
255
- headers: {
256
- "content-type": "application/json",
257
- },
258
- body: JSON.stringify({}),
259
- }, null);
260
- }
261
- async createServerContactChannel(data) {
262
- const response = await this.sendServerRequest("/contact-channels", {
263
- method: "POST",
264
- headers: {
265
- "content-type": "application/json",
266
- },
267
- body: JSON.stringify(data),
268
- }, null);
269
- return await response.json();
270
- }
271
- async updateServerContactChannel(userId, contactChannelId, data) {
272
- const response = await this.sendServerRequest(urlString `/contact-channels/${userId}/${contactChannelId}`, {
273
- method: "PATCH",
274
- headers: {
275
- "content-type": "application/json",
276
- },
277
- body: JSON.stringify(data),
278
- }, null);
279
- return await response.json();
280
- }
281
- async deleteServerContactChannel(userId, contactChannelId) {
282
- await this.sendServerRequest(urlString `/contact-channels/${userId}/${contactChannelId}`, {
283
- method: "DELETE",
284
- }, null);
285
- }
286
- async listServerContactChannels(userId) {
287
- const response = await this.sendServerRequest(urlString `/contact-channels?user_id=${userId}`, {
288
- method: "GET",
289
- }, null);
290
- const json = await response.json();
291
- return json.items;
292
- }
293
- async sendServerContactChannelVerificationEmail(userId, contactChannelId, callbackUrl) {
294
- await this.sendServerRequest(urlString `/contact-channels/${userId}/${contactChannelId}/send-verification-code`, {
295
- method: "POST",
296
- headers: {
297
- "content-type": "application/json",
298
- },
299
- body: JSON.stringify({ callback_url: callbackUrl }),
300
- }, null);
301
- }
302
- async listServerSessions(userId) {
303
- const response = await this.sendServerRequest(urlString `/auth/sessions?user_id=${userId}`, {
304
- method: "GET",
305
- }, null);
306
- return await response.json();
307
- }
308
- async deleteServerSession(sessionId) {
309
- await this.sendServerRequest(urlString `/auth/sessions/${sessionId}`, {
310
- method: "DELETE",
311
- }, null);
312
- }
313
- async sendServerTeamInvitation(options) {
314
- await this.sendServerRequest("/team-invitations/send-code", {
315
- method: "POST",
316
- headers: {
317
- "Content-Type": "application/json"
318
- },
319
- body: JSON.stringify({
320
- email: options.email,
321
- team_id: options.teamId,
322
- callback_url: options.callbackUrl,
323
- }),
324
- }, null);
325
- }
326
- async updatePassword(options) {
327
- const res = await this.sendServerRequestAndCatchKnownError("/auth/password/update", {
328
- method: "POST",
329
- headers: {
330
- "Content-Type": "application/json"
331
- },
332
- body: JSON.stringify({
333
- old_password: options.oldPassword,
334
- new_password: options.newPassword,
335
- }),
336
- }, null, [KnownErrors.PasswordConfirmationMismatch, KnownErrors.PasswordRequirementsNotMet]);
337
- if (res.status === "error") {
338
- return res.error;
339
- }
340
- }
341
- }
59
+ }
60
+ throw e;
61
+ }
62
+ }
63
+ async createServerUser(data) {
64
+ const response = await this.sendServerRequest(
65
+ "/users",
66
+ {
67
+ method: "POST",
68
+ headers: {
69
+ "content-type": "application/json"
70
+ },
71
+ body: JSON.stringify(data)
72
+ },
73
+ null
74
+ );
75
+ return await response.json();
76
+ }
77
+ async getServerUserByToken(session) {
78
+ const responseOrError = await this.sendServerRequestAndCatchKnownError(
79
+ "/users/me",
80
+ {},
81
+ session,
82
+ [import_known_errors.KnownErrors.CannotGetOwnUserWithoutUser]
83
+ );
84
+ if (responseOrError.status === "error") {
85
+ if (responseOrError.error instanceof import_known_errors.KnownErrors.CannotGetOwnUserWithoutUser) {
86
+ return null;
87
+ } else {
88
+ throw new import_errors.StackAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
89
+ }
90
+ }
91
+ const response = responseOrError.data;
92
+ const user = await response.json();
93
+ if (!user) throw new import_errors.StackAssertionError("User endpoint returned null; this should never happen");
94
+ return user;
95
+ }
96
+ async getServerUserById(userId) {
97
+ const responseOrError = await this.sendServerRequestAndCatchKnownError(
98
+ import_urls.urlString`/users/${userId}`,
99
+ {},
100
+ null,
101
+ [import_known_errors.KnownErrors.UserNotFound]
102
+ );
103
+ if (responseOrError.status === "error") {
104
+ return import_results.Result.error(responseOrError.error);
105
+ }
106
+ const user = await responseOrError.data.json();
107
+ return import_results.Result.ok(user);
108
+ }
109
+ async listServerTeamInvitations(options) {
110
+ const response = await this.sendServerRequest(
111
+ import_urls.urlString`/team-invitations?team_id=${options.teamId}`,
112
+ {},
113
+ null
114
+ );
115
+ const result = await response.json();
116
+ return result.items;
117
+ }
118
+ async revokeServerTeamInvitation(invitationId, teamId) {
119
+ await this.sendServerRequest(
120
+ import_urls.urlString`/team-invitations/${invitationId}?team_id=${teamId}`,
121
+ { method: "DELETE" },
122
+ null
123
+ );
124
+ }
125
+ async listServerTeamMemberProfiles(options) {
126
+ const response = await this.sendServerRequest(
127
+ import_urls.urlString`/team-member-profiles?team_id=${options.teamId}`,
128
+ {},
129
+ null
130
+ );
131
+ const result = await response.json();
132
+ return result.items;
133
+ }
134
+ async getServerTeamMemberProfile(options) {
135
+ const response = await this.sendServerRequest(
136
+ import_urls.urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
137
+ {},
138
+ null
139
+ );
140
+ return await response.json();
141
+ }
142
+ async listServerTeamPermissions(options, session) {
143
+ const response = await this.sendServerRequest(
144
+ `/team-permissions?${new URLSearchParams((0, import_objects.filterUndefined)({
145
+ user_id: options.userId,
146
+ team_id: options.teamId,
147
+ recursive: options.recursive.toString()
148
+ }))}`,
149
+ {},
150
+ session
151
+ );
152
+ const result = await response.json();
153
+ return result.items;
154
+ }
155
+ async listServerProjectPermissions(options, session) {
156
+ const response = await this.sendServerRequest(
157
+ `/project-permissions?${new URLSearchParams((0, import_objects.filterUndefined)({
158
+ user_id: options.userId,
159
+ recursive: options.recursive.toString()
160
+ }))}`,
161
+ {},
162
+ session
163
+ );
164
+ const result = await response.json();
165
+ return result.items;
166
+ }
167
+ async listServerUsers(options) {
168
+ const searchParams = new URLSearchParams((0, import_objects.filterUndefined)({
169
+ cursor: options.cursor,
170
+ limit: options.limit?.toString(),
171
+ desc: options.desc?.toString(),
172
+ ...options.orderBy ? {
173
+ order_by: {
174
+ signedUpAt: "signed_up_at"
175
+ }[options.orderBy]
176
+ } : {},
177
+ ...options.query ? {
178
+ query: options.query
179
+ } : {}
180
+ }));
181
+ const response = await this.sendServerRequest("/users?" + searchParams.toString(), {}, null);
182
+ return await response.json();
183
+ }
184
+ async listServerTeams(options) {
185
+ const response = await this.sendServerRequest(
186
+ `/teams?${new URLSearchParams((0, import_objects.filterUndefined)({
187
+ user_id: options?.userId
188
+ }))}`,
189
+ {},
190
+ null
191
+ );
192
+ const result = await response.json();
193
+ return result.items;
194
+ }
195
+ async getServerTeam(teamId) {
196
+ const response = await this.sendServerRequest(
197
+ `/teams/${teamId}`,
198
+ {},
199
+ null
200
+ );
201
+ return await response.json();
202
+ }
203
+ async listServerTeamUsers(teamId) {
204
+ const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);
205
+ const result = await response.json();
206
+ return result.items;
207
+ }
208
+ /* when passing a session, the user will be added to the team */
209
+ async createServerTeam(data) {
210
+ const response = await this.sendServerRequest(
211
+ "/teams",
212
+ {
213
+ method: "POST",
214
+ headers: {
215
+ "content-type": "application/json"
216
+ },
217
+ body: JSON.stringify(data)
218
+ },
219
+ null
220
+ );
221
+ return await response.json();
222
+ }
223
+ async updateServerTeam(teamId, data) {
224
+ const response = await this.sendServerRequest(
225
+ import_urls.urlString`/teams/${teamId}`,
226
+ {
227
+ method: "PATCH",
228
+ headers: {
229
+ "content-type": "application/json"
230
+ },
231
+ body: JSON.stringify(data)
232
+ },
233
+ null
234
+ );
235
+ return await response.json();
236
+ }
237
+ async deleteServerTeam(teamId) {
238
+ await this.sendServerRequest(
239
+ import_urls.urlString`/teams/${teamId}`,
240
+ { method: "DELETE" },
241
+ null
242
+ );
243
+ }
244
+ async addServerUserToTeam(options) {
245
+ const response = await this.sendServerRequest(
246
+ import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
247
+ {
248
+ method: "POST",
249
+ headers: {
250
+ "content-type": "application/json"
251
+ },
252
+ body: JSON.stringify({})
253
+ },
254
+ null
255
+ );
256
+ return await response.json();
257
+ }
258
+ async removeServerUserFromTeam(options) {
259
+ await this.sendServerRequest(
260
+ import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
261
+ {
262
+ method: "DELETE",
263
+ headers: {
264
+ "content-type": "application/json"
265
+ },
266
+ body: JSON.stringify({})
267
+ },
268
+ null
269
+ );
270
+ }
271
+ async updateServerUser(userId, update) {
272
+ const response = await this.sendServerRequest(
273
+ import_urls.urlString`/users/${userId}`,
274
+ {
275
+ method: "PATCH",
276
+ headers: {
277
+ "content-type": "application/json"
278
+ },
279
+ body: JSON.stringify(update)
280
+ },
281
+ null
282
+ );
283
+ return await response.json();
284
+ }
285
+ async createServerProviderAccessToken(userId, provider, scope) {
286
+ const response = await this.sendServerRequest(
287
+ import_urls.urlString`/connected-accounts/${userId}/${provider}/access-token`,
288
+ {
289
+ method: "POST",
290
+ headers: {
291
+ "content-type": "application/json"
292
+ },
293
+ body: JSON.stringify({ scope })
294
+ },
295
+ null
296
+ );
297
+ return await response.json();
298
+ }
299
+ async createServerUserSession(userId, expiresInMillis, isImpersonation) {
300
+ const response = await this.sendServerRequest(
301
+ "/auth/sessions",
302
+ {
303
+ method: "POST",
304
+ headers: {
305
+ "content-type": "application/json"
306
+ },
307
+ body: JSON.stringify({
308
+ user_id: userId,
309
+ expires_in_millis: expiresInMillis,
310
+ is_impersonation: isImpersonation
311
+ })
312
+ },
313
+ null
314
+ );
315
+ const result = await response.json();
316
+ return {
317
+ accessToken: result.access_token,
318
+ refreshToken: result.refresh_token
319
+ };
320
+ }
321
+ async leaveServerTeam(options) {
322
+ await this.sendClientRequest(
323
+ import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
324
+ {
325
+ method: "DELETE",
326
+ headers: {
327
+ "content-type": "application/json"
328
+ },
329
+ body: JSON.stringify({})
330
+ },
331
+ null
332
+ );
333
+ }
334
+ async updateServerTeamMemberProfile(options) {
335
+ await this.sendServerRequest(
336
+ import_urls.urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
337
+ {
338
+ method: "PATCH",
339
+ headers: {
340
+ "content-type": "application/json"
341
+ },
342
+ body: JSON.stringify(options.profile)
343
+ },
344
+ null
345
+ );
346
+ }
347
+ async grantServerTeamUserPermission(teamId, userId, permissionId) {
348
+ await this.sendServerRequest(
349
+ import_urls.urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
350
+ {
351
+ method: "POST",
352
+ headers: {
353
+ "content-type": "application/json"
354
+ },
355
+ body: JSON.stringify({})
356
+ },
357
+ null
358
+ );
359
+ }
360
+ async revokeServerTeamUserPermission(teamId, userId, permissionId) {
361
+ await this.sendServerRequest(
362
+ import_urls.urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
363
+ {
364
+ method: "DELETE",
365
+ headers: {
366
+ "content-type": "application/json"
367
+ },
368
+ body: JSON.stringify({})
369
+ },
370
+ null
371
+ );
372
+ }
373
+ async deleteServerUser(userId) {
374
+ await this.sendServerRequest(
375
+ import_urls.urlString`/users/${userId}`,
376
+ {
377
+ method: "DELETE",
378
+ headers: {
379
+ "content-type": "application/json"
380
+ },
381
+ body: JSON.stringify({})
382
+ },
383
+ null
384
+ );
385
+ }
386
+ async createServerContactChannel(data) {
387
+ const response = await this.sendServerRequest(
388
+ "/contact-channels",
389
+ {
390
+ method: "POST",
391
+ headers: {
392
+ "content-type": "application/json"
393
+ },
394
+ body: JSON.stringify(data)
395
+ },
396
+ null
397
+ );
398
+ return await response.json();
399
+ }
400
+ async updateServerContactChannel(userId, contactChannelId, data) {
401
+ const response = await this.sendServerRequest(
402
+ import_urls.urlString`/contact-channels/${userId}/${contactChannelId}`,
403
+ {
404
+ method: "PATCH",
405
+ headers: {
406
+ "content-type": "application/json"
407
+ },
408
+ body: JSON.stringify(data)
409
+ },
410
+ null
411
+ );
412
+ return await response.json();
413
+ }
414
+ async deleteServerContactChannel(userId, contactChannelId) {
415
+ await this.sendServerRequest(
416
+ import_urls.urlString`/contact-channels/${userId}/${contactChannelId}`,
417
+ {
418
+ method: "DELETE"
419
+ },
420
+ null
421
+ );
422
+ }
423
+ async listServerContactChannels(userId) {
424
+ const response = await this.sendServerRequest(
425
+ import_urls.urlString`/contact-channels?user_id=${userId}`,
426
+ {
427
+ method: "GET"
428
+ },
429
+ null
430
+ );
431
+ const json = await response.json();
432
+ return json.items;
433
+ }
434
+ async sendServerContactChannelVerificationEmail(userId, contactChannelId, callbackUrl) {
435
+ await this.sendServerRequest(
436
+ import_urls.urlString`/contact-channels/${userId}/${contactChannelId}/send-verification-code`,
437
+ {
438
+ method: "POST",
439
+ headers: {
440
+ "content-type": "application/json"
441
+ },
442
+ body: JSON.stringify({ callback_url: callbackUrl })
443
+ },
444
+ null
445
+ );
446
+ }
447
+ async listServerSessions(userId) {
448
+ const response = await this.sendServerRequest(
449
+ import_urls.urlString`/auth/sessions?user_id=${userId}`,
450
+ {
451
+ method: "GET"
452
+ },
453
+ null
454
+ );
455
+ return await response.json();
456
+ }
457
+ async deleteServerSession(sessionId) {
458
+ await this.sendServerRequest(
459
+ import_urls.urlString`/auth/sessions/${sessionId}`,
460
+ {
461
+ method: "DELETE"
462
+ },
463
+ null
464
+ );
465
+ }
466
+ async sendServerTeamInvitation(options) {
467
+ await this.sendServerRequest(
468
+ "/team-invitations/send-code",
469
+ {
470
+ method: "POST",
471
+ headers: {
472
+ "Content-Type": "application/json"
473
+ },
474
+ body: JSON.stringify({
475
+ email: options.email,
476
+ team_id: options.teamId,
477
+ callback_url: options.callbackUrl
478
+ })
479
+ },
480
+ null
481
+ );
482
+ }
483
+ async updatePassword(options) {
484
+ const res = await this.sendServerRequestAndCatchKnownError(
485
+ "/auth/password/update",
486
+ {
487
+ method: "POST",
488
+ headers: {
489
+ "Content-Type": "application/json"
490
+ },
491
+ body: JSON.stringify({
492
+ old_password: options.oldPassword,
493
+ new_password: options.newPassword
494
+ })
495
+ },
496
+ null,
497
+ [import_known_errors.KnownErrors.PasswordConfirmationMismatch, import_known_errors.KnownErrors.PasswordRequirementsNotMet]
498
+ );
499
+ if (res.status === "error") {
500
+ return res.error;
501
+ }
502
+ }
503
+ };
504
+ // Annotate the CommonJS export names for ESM import in node:
505
+ 0 && (module.exports = {
506
+ StackServerInterface
507
+ });
508
+ //# sourceMappingURL=serverInterface.js.map