@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,463 +1,629 @@
1
- import * as yup from "yup";
2
- import { KnownErrors } from ".";
3
- import { isBase64 } from "./utils/bytes";
4
- import { StackAssertionError, throwErr } from "./utils/errors";
5
- import { decodeBasicAuthorizationHeader } from "./utils/http";
6
- import { allProviders } from "./utils/oauth";
7
- import { deepPlainClone, omit } from "./utils/objects";
8
- import { isValidUrl } from "./utils/urls";
9
- import { isUuid } from "./utils/uuids";
10
- // eslint-disable-next-line no-restricted-syntax
11
- yup.addMethod(yup.string, "nonEmpty", function (message) {
12
- return this.test("non-empty", message ?? (({ path }) => `${path} must not be empty`), (value) => {
13
- return value !== "";
14
- });
15
- });
16
- yup.addMethod(yup.Schema, "getNested", function (path) {
17
- if (!path.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/))
18
- throw new StackAssertionError(`yupSchema.getNested can currently only be used with alphanumeric keys. Fix this in the future. Provided key: ${path}`);
19
- return yup.reach(this, path);
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/schema-fields.ts
31
+ var schema_fields_exports = {};
32
+ __export(schema_fields_exports, {
33
+ ReplaceFieldWithOwnUserId: () => ReplaceFieldWithOwnUserId,
34
+ accessTokenResponseSchema: () => accessTokenResponseSchema,
35
+ adaptSchema: () => adaptSchema,
36
+ adminAuthTypeSchema: () => adminAuthTypeSchema,
37
+ base64Schema: () => base64Schema,
38
+ basicAuthorizationHeaderSchema: () => basicAuthorizationHeaderSchema,
39
+ clientOrHigherAuthTypeSchema: () => clientOrHigherAuthTypeSchema,
40
+ contactChannelIdSchema: () => contactChannelIdSchema,
41
+ contactChannelIsPrimarySchema: () => contactChannelIsPrimarySchema,
42
+ contactChannelIsVerifiedSchema: () => contactChannelIsVerifiedSchema,
43
+ contactChannelTypeSchema: () => contactChannelTypeSchema,
44
+ contactChannelUsedForAuthSchema: () => contactChannelUsedForAuthSchema,
45
+ contactChannelValueSchema: () => contactChannelValueSchema,
46
+ containedPermissionIdsSchema: () => containedPermissionIdsSchema,
47
+ customPermissionDefinitionIdSchema: () => customPermissionDefinitionIdSchema,
48
+ emailHostSchema: () => emailHostSchema,
49
+ emailOtpSignInCallbackUrlSchema: () => emailOtpSignInCallbackUrlSchema,
50
+ emailPasswordSchema: () => emailPasswordSchema,
51
+ emailPortSchema: () => emailPortSchema,
52
+ emailSchema: () => emailSchema,
53
+ emailSenderEmailSchema: () => emailSenderEmailSchema,
54
+ emailSenderNameSchema: () => emailSenderNameSchema,
55
+ emailTypeSchema: () => emailTypeSchema,
56
+ emailUsernameSchema: () => emailUsernameSchema,
57
+ emailVerificationCallbackUrlSchema: () => emailVerificationCallbackUrlSchema,
58
+ ensureObjectSchema: () => ensureObjectSchema,
59
+ handlerPathSchema: () => handlerPathSchema,
60
+ jsonSchema: () => jsonSchema,
61
+ jsonStringOrEmptySchema: () => jsonStringOrEmptySchema,
62
+ jsonStringSchema: () => jsonStringSchema,
63
+ neonAuthorizationHeaderSchema: () => neonAuthorizationHeaderSchema,
64
+ oauthAccountMergeStrategySchema: () => oauthAccountMergeStrategySchema,
65
+ oauthClientIdSchema: () => oauthClientIdSchema,
66
+ oauthClientSecretSchema: () => oauthClientSecretSchema,
67
+ oauthEnabledSchema: () => oauthEnabledSchema,
68
+ oauthFacebookConfigIdSchema: () => oauthFacebookConfigIdSchema,
69
+ oauthIdSchema: () => oauthIdSchema,
70
+ oauthMicrosoftTenantIdSchema: () => oauthMicrosoftTenantIdSchema,
71
+ oauthTypeSchema: () => oauthTypeSchema,
72
+ passwordSchema: () => passwordSchema,
73
+ permissionDefinitionIdSchema: () => permissionDefinitionIdSchema,
74
+ primaryEmailAuthEnabledSchema: () => primaryEmailAuthEnabledSchema,
75
+ primaryEmailSchema: () => primaryEmailSchema,
76
+ primaryEmailVerifiedSchema: () => primaryEmailVerifiedSchema,
77
+ profileImageUrlSchema: () => profileImageUrlSchema,
78
+ projectAllowLocalhostSchema: () => projectAllowLocalhostSchema,
79
+ projectClientTeamCreationEnabledSchema: () => projectClientTeamCreationEnabledSchema,
80
+ projectClientUserDeletionEnabledSchema: () => projectClientUserDeletionEnabledSchema,
81
+ projectConfigIdSchema: () => projectConfigIdSchema,
82
+ projectCreateTeamOnSignUpSchema: () => projectCreateTeamOnSignUpSchema,
83
+ projectCreatedAtMillisSchema: () => projectCreatedAtMillisSchema,
84
+ projectCredentialEnabledSchema: () => projectCredentialEnabledSchema,
85
+ projectDescriptionSchema: () => projectDescriptionSchema,
86
+ projectDisplayNameSchema: () => projectDisplayNameSchema,
87
+ projectIdSchema: () => projectIdSchema,
88
+ projectIsProductionModeSchema: () => projectIsProductionModeSchema,
89
+ projectMagicLinkEnabledSchema: () => projectMagicLinkEnabledSchema,
90
+ projectPasskeyEnabledSchema: () => projectPasskeyEnabledSchema,
91
+ projectSignUpEnabledSchema: () => projectSignUpEnabledSchema,
92
+ projectUserCountSchema: () => projectUserCountSchema,
93
+ refreshTokenResponseSchema: () => refreshTokenResponseSchema,
94
+ selectedTeamIdSchema: () => selectedTeamIdSchema,
95
+ serverOrHigherAuthTypeSchema: () => serverOrHigherAuthTypeSchema,
96
+ signInEmailSchema: () => signInEmailSchema,
97
+ signInResponseSchema: () => signInResponseSchema,
98
+ signedUpAtMillisSchema: () => signedUpAtMillisSchema,
99
+ strictEmailSchema: () => strictEmailSchema,
100
+ teamClientMetadataSchema: () => teamClientMetadataSchema,
101
+ teamClientReadOnlyMetadataSchema: () => teamClientReadOnlyMetadataSchema,
102
+ teamCreatedAtMillisSchema: () => teamCreatedAtMillisSchema,
103
+ teamCreatorUserIdSchema: () => teamCreatorUserIdSchema,
104
+ teamDisplayNameSchema: () => teamDisplayNameSchema,
105
+ teamIdSchema: () => teamIdSchema,
106
+ teamInvitationCallbackUrlSchema: () => teamInvitationCallbackUrlSchema,
107
+ teamInvitationEmailSchema: () => teamInvitationEmailSchema,
108
+ teamMemberDisplayNameSchema: () => teamMemberDisplayNameSchema,
109
+ teamMemberProfileImageUrlSchema: () => teamMemberProfileImageUrlSchema,
110
+ teamPermissionDescriptionSchema: () => teamPermissionDescriptionSchema,
111
+ teamProfileImageUrlSchema: () => teamProfileImageUrlSchema,
112
+ teamServerMetadataSchema: () => teamServerMetadataSchema,
113
+ teamSystemPermissions: () => teamSystemPermissions,
114
+ urlSchema: () => urlSchema,
115
+ userClientMetadataSchema: () => userClientMetadataSchema,
116
+ userClientReadOnlyMetadataSchema: () => userClientReadOnlyMetadataSchema,
117
+ userDisplayNameSchema: () => userDisplayNameSchema,
118
+ userHasPasswordSchema: () => userHasPasswordSchema,
119
+ userIdOrMeSchema: () => userIdOrMeSchema,
120
+ userIdSchema: () => userIdSchema,
121
+ userLastActiveAtMillisSchema: () => userLastActiveAtMillisSchema,
122
+ userOAuthProviderSchema: () => userOAuthProviderSchema,
123
+ userOtpAuthEnabledMutationSchema: () => userOtpAuthEnabledMutationSchema,
124
+ userOtpAuthEnabledSchema: () => userOtpAuthEnabledSchema,
125
+ userPasskeyAuthEnabledSchema: () => userPasskeyAuthEnabledSchema,
126
+ userPasswordHashMutationSchema: () => userPasswordHashMutationSchema,
127
+ userPasswordMutationSchema: () => userPasswordMutationSchema,
128
+ userServerMetadataSchema: () => userServerMetadataSchema,
129
+ userTotpSecretMutationSchema: () => userTotpSecretMutationSchema,
130
+ yupArray: () => yupArray,
131
+ yupBoolean: () => yupBoolean,
132
+ yupDate: () => yupDate,
133
+ yupDefinedAndNonEmptyWhen: () => yupDefinedAndNonEmptyWhen,
134
+ yupDefinedWhen: () => yupDefinedWhen,
135
+ yupMixed: () => yupMixed,
136
+ yupNever: () => yupNever,
137
+ yupNumber: () => yupNumber,
138
+ yupObject: () => yupObject,
139
+ yupRecord: () => yupRecord,
140
+ yupString: () => yupString,
141
+ yupTuple: () => yupTuple,
142
+ yupUnion: () => yupUnion,
143
+ yupValidate: () => yupValidate
20
144
  });
21
- export async function yupValidate(schema, obj, options) {
22
- try {
23
- return await schema.validate(obj, {
24
- ...omit(options ?? {}, ['currentUserId']),
25
- context: {
26
- ...options?.context,
27
- stackAllowUserIdMe: options?.currentUserId !== undefined,
28
- },
29
- });
145
+ module.exports = __toCommonJS(schema_fields_exports);
146
+ var yup = __toESM(require("yup"), 1);
147
+ var import__ = require(".");
148
+ var import_bytes = require("./utils/bytes");
149
+ var import_errors = require("./utils/errors");
150
+ var import_http = require("./utils/http");
151
+ var import_oauth = require("./utils/oauth");
152
+ var import_objects = require("./utils/objects");
153
+ var import_urls = require("./utils/urls");
154
+ var import_uuids = require("./utils/uuids");
155
+ yup.addMethod(yup.string, "nonEmpty", function(message) {
156
+ return this.test(
157
+ "non-empty",
158
+ message ?? (({ path }) => `${path} must not be empty`),
159
+ (value) => {
160
+ return value !== "";
30
161
  }
31
- catch (error) {
32
- if (error instanceof ReplaceFieldWithOwnUserId) {
33
- const currentUserId = options?.currentUserId;
34
- if (!currentUserId)
35
- throw new KnownErrors.CannotGetOwnUserWithoutUser();
36
- // parse yup path
37
- let pathRemaining = error.path;
38
- const fieldPath = [];
39
- while (pathRemaining.length > 0) {
40
- if (pathRemaining.startsWith("[")) {
41
- const index = pathRemaining.indexOf("]");
42
- if (index < 0)
43
- throw new StackAssertionError("Invalid path");
44
- fieldPath.push(JSON.parse(pathRemaining.slice(1, index)));
45
- pathRemaining = pathRemaining.slice(index + 1);
46
- }
47
- else {
48
- let dotIndex = pathRemaining.indexOf(".");
49
- if (dotIndex === -1)
50
- dotIndex = pathRemaining.length;
51
- fieldPath.push(pathRemaining.slice(0, dotIndex));
52
- pathRemaining = pathRemaining.slice(dotIndex + 1);
53
- }
54
- }
55
- const newObj = deepPlainClone(obj);
56
- let it = newObj;
57
- for (const field of fieldPath.slice(0, -1)) {
58
- if (!Object.prototype.hasOwnProperty.call(it, field)) {
59
- throw new StackAssertionError(`Segment ${field} of path ${error.path} not found in object`);
60
- }
61
- it = it[field];
62
- }
63
- it[fieldPath[fieldPath.length - 1]] = currentUserId;
64
- return await yupValidate(schema, newObj, options);
162
+ );
163
+ });
164
+ yup.addMethod(yup.Schema, "getNested", function(path) {
165
+ if (!path.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)) throw new import_errors.StackAssertionError(`yupSchema.getNested can currently only be used with alphanumeric keys. Fix this in the future. Provided key: ${path}`);
166
+ return yup.reach(this, path);
167
+ });
168
+ async function yupValidate(schema, obj, options) {
169
+ try {
170
+ return await schema.validate(obj, {
171
+ ...(0, import_objects.omit)(options ?? {}, ["currentUserId"]),
172
+ context: {
173
+ ...options?.context,
174
+ stackAllowUserIdMe: options?.currentUserId !== void 0
175
+ }
176
+ });
177
+ } catch (error) {
178
+ if (error instanceof ReplaceFieldWithOwnUserId) {
179
+ const currentUserId = options?.currentUserId;
180
+ if (!currentUserId) throw new import__.KnownErrors.CannotGetOwnUserWithoutUser();
181
+ let pathRemaining = error.path;
182
+ const fieldPath = [];
183
+ while (pathRemaining.length > 0) {
184
+ if (pathRemaining.startsWith("[")) {
185
+ const index = pathRemaining.indexOf("]");
186
+ if (index < 0) throw new import_errors.StackAssertionError("Invalid path");
187
+ fieldPath.push(JSON.parse(pathRemaining.slice(1, index)));
188
+ pathRemaining = pathRemaining.slice(index + 1);
189
+ } else {
190
+ let dotIndex = pathRemaining.indexOf(".");
191
+ if (dotIndex === -1) dotIndex = pathRemaining.length;
192
+ fieldPath.push(pathRemaining.slice(0, dotIndex));
193
+ pathRemaining = pathRemaining.slice(dotIndex + 1);
194
+ }
195
+ }
196
+ const newObj = (0, import_objects.deepPlainClone)(obj);
197
+ let it = newObj;
198
+ for (const field of fieldPath.slice(0, -1)) {
199
+ if (!Object.prototype.hasOwnProperty.call(it, field)) {
200
+ throw new import_errors.StackAssertionError(`Segment ${field} of path ${error.path} not found in object`);
65
201
  }
66
- throw error;
202
+ it = it[field];
203
+ }
204
+ it[fieldPath[fieldPath.length - 1]] = currentUserId;
205
+ return await yupValidate(schema, newObj, options);
67
206
  }
207
+ throw error;
208
+ }
68
209
  }
69
- const _idDescription = (identify) => `The unique identifier of the ${identify}`;
70
- const _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
71
- const _clientMetaDataDescription = (identify) => `Client metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client.`;
72
- const _clientReadOnlyMetaDataDescription = (identify) => `Client read-only, server-writable metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client. The client can read this data, but cannot modify it. This is useful for things like subscription status.`;
73
- const _profileImageUrlDescription = (identify) => `URL of the profile image for ${identify}. Can be a Base64 encoded image. Must be smaller than 100KB. Please compress and crop to a square before passing in.`;
74
- const _serverMetaDataDescription = (identify) => `Server metadata. Used as a data store, only accessible from the server side. You can store secret information related to the ${identify} here.`;
75
- const _atMillisDescription = (identify) => `(the number of milliseconds since epoch, January 1, 1970, UTC)`;
76
- const _createdAtMillisDescription = (identify) => `The time the ${identify} was created ${_atMillisDescription(identify)}`;
77
- const _signedUpAtMillisDescription = `The time the user signed up ${_atMillisDescription}`;
78
- const _lastActiveAtMillisDescription = `The time the user was last active ${_atMillisDescription}`;
79
- // Built-in replacements
80
- export function yupString(...args) {
81
- // eslint-disable-next-line no-restricted-syntax
82
- return yup.string(...args);
210
+ var _idDescription = (identify) => `The unique identifier of the ${identify}`;
211
+ var _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
212
+ var _clientMetaDataDescription = (identify) => `Client metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client.`;
213
+ var _clientReadOnlyMetaDataDescription = (identify) => `Client read-only, server-writable metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client. The client can read this data, but cannot modify it. This is useful for things like subscription status.`;
214
+ var _profileImageUrlDescription = (identify) => `URL of the profile image for ${identify}. Can be a Base64 encoded image. Must be smaller than 100KB. Please compress and crop to a square before passing in.`;
215
+ var _serverMetaDataDescription = (identify) => `Server metadata. Used as a data store, only accessible from the server side. You can store secret information related to the ${identify} here.`;
216
+ var _atMillisDescription = (identify) => `(the number of milliseconds since epoch, January 1, 1970, UTC)`;
217
+ var _createdAtMillisDescription = (identify) => `The time the ${identify} was created ${_atMillisDescription(identify)}`;
218
+ var _signedUpAtMillisDescription = `The time the user signed up ${_atMillisDescription}`;
219
+ var _lastActiveAtMillisDescription = `The time the user was last active ${_atMillisDescription}`;
220
+ function yupString(...args) {
221
+ return yup.string(...args);
83
222
  }
84
- export function yupNumber(...args) {
85
- // eslint-disable-next-line no-restricted-syntax
86
- return yup.number(...args);
223
+ function yupNumber(...args) {
224
+ return yup.number(...args);
87
225
  }
88
- export function yupBoolean(...args) {
89
- // eslint-disable-next-line no-restricted-syntax
90
- return yup.boolean(...args);
226
+ function yupBoolean(...args) {
227
+ return yup.boolean(...args);
91
228
  }
92
- /**
93
- * @deprecated, use number of milliseconds since epoch instead
94
- */
95
- export function yupDate(...args) {
96
- // eslint-disable-next-line no-restricted-syntax
97
- return yup.date(...args);
229
+ function yupDate(...args) {
230
+ return yup.date(...args);
98
231
  }
99
- export function yupMixed(...args) {
100
- // eslint-disable-next-line no-restricted-syntax
101
- return yup.mixed(...args);
232
+ function yupMixed(...args) {
233
+ return yup.mixed(...args);
102
234
  }
103
- export function yupArray(...args) {
104
- // eslint-disable-next-line no-restricted-syntax
105
- return yup.array(...args);
235
+ function yupArray(...args) {
236
+ return yup.array(...args);
106
237
  }
107
- export function yupTuple(...args) {
108
- // eslint-disable-next-line no-restricted-syntax
109
- return yup.tuple(...args);
238
+ function yupTuple(...args) {
239
+ return yup.tuple(...args);
110
240
  }
111
- export function yupObject(...args) {
112
- // eslint-disable-next-line no-restricted-syntax
113
- const object = yup.object(...args).test('no-unknown-object-properties', ({ path }) => `${path} contains unknown properties`, (value, context) => {
114
- if (context.options.context?.noUnknownPathPrefixes?.some((prefix) => context.path.startsWith(prefix))) {
115
- if (context.schema.spec.noUnknown !== false) {
116
- const availableKeys = new Set(Object.keys(context.schema.fields));
117
- const unknownKeys = Object.keys(value ?? {}).filter(key => !availableKeys.has(key));
118
- if (unknownKeys.length > 0) {
119
- // TODO "did you mean XYZ"
120
- return context.createError({
121
- message: `${context.path || "Object"} contains unknown properties: ${unknownKeys.join(', ')}`,
122
- path: context.path,
123
- params: { unknownKeys, availableKeys },
124
- });
125
- }
126
- }
241
+ function yupObject(...args) {
242
+ const object2 = yup.object(...args).test(
243
+ "no-unknown-object-properties",
244
+ ({ path }) => `${path} contains unknown properties`,
245
+ (value, context) => {
246
+ if (context.options.context?.noUnknownPathPrefixes?.some((prefix) => context.path.startsWith(prefix))) {
247
+ if (context.schema.spec.noUnknown !== false) {
248
+ const availableKeys = new Set(Object.keys(context.schema.fields));
249
+ const unknownKeys = Object.keys(value ?? {}).filter((key) => !availableKeys.has(key));
250
+ if (unknownKeys.length > 0) {
251
+ return context.createError({
252
+ message: `${context.path || "Object"} contains unknown properties: ${unknownKeys.join(", ")}`,
253
+ path: context.path,
254
+ params: { unknownKeys, availableKeys }
255
+ });
256
+ }
127
257
  }
128
- return true;
129
- });
130
- // we don't want to update the type of `object` to have a default flag
131
- return object.default(undefined);
258
+ }
259
+ return true;
260
+ }
261
+ );
262
+ return object2.default(void 0);
132
263
  }
133
- export function yupNever() {
134
- return yupMixed().test('never', 'This value should never be reached', () => false);
264
+ function yupNever() {
265
+ return yupMixed().test("never", "This value should never be reached", () => false);
135
266
  }
136
- export function yupUnion(...args) {
137
- if (args.length === 0)
138
- throw new Error('yupUnion must have at least one schema');
139
- const [first] = args;
140
- const firstDesc = first.describe();
267
+ function yupUnion(...args) {
268
+ if (args.length === 0) throw new Error("yupUnion must have at least one schema");
269
+ const [first] = args;
270
+ const firstDesc = first.describe();
271
+ for (const schema of args) {
272
+ const desc = schema.describe();
273
+ if (desc.type !== firstDesc.type) throw new import_errors.StackAssertionError(`yupUnion must have schemas of the same type (got: ${firstDesc.type} and ${desc.type})`, { first, schema, firstDesc, desc });
274
+ }
275
+ return yupMixed().test("is-one-of", "Invalid value", async (value, context) => {
276
+ const errors = [];
141
277
  for (const schema of args) {
142
- const desc = schema.describe();
143
- if (desc.type !== firstDesc.type)
144
- throw new StackAssertionError(`yupUnion must have schemas of the same type (got: ${firstDesc.type} and ${desc.type})`, { first, schema, firstDesc, desc });
278
+ try {
279
+ await yupValidate(schema, value, context.options);
280
+ return true;
281
+ } catch (e) {
282
+ errors.push(e);
283
+ }
145
284
  }
146
- return yupMixed().test('is-one-of', 'Invalid value', async (value, context) => {
147
- const errors = [];
148
- for (const schema of args) {
149
- try {
150
- await yupValidate(schema, value, context.options);
151
- return true;
152
- }
153
- catch (e) {
154
- errors.push(e);
155
- }
156
- }
157
- return context.createError({
158
- message: `${context.path} is not matched by any of the provided schemas:\n${errors.map((e, i) => '\tSchema ' + i + ": \n\t\t" + e.errors.join('\n\t\t')).join('\n')}`,
159
- path: context.path,
160
- });
285
+ return context.createError({
286
+ message: `${context.path} is not matched by any of the provided schemas:
287
+ ${errors.map((e, i) => " Schema " + i + ": \n " + e.errors.join("\n ")).join("\n")}`,
288
+ path: context.path
161
289
  });
290
+ });
162
291
  }
163
- export function yupRecord(keySchema, valueSchema) {
164
- return yupObject().unknown(true).test('record', '${path} must be a record of valid values', async function (value, context) {
165
- if (value == null)
166
- return true;
167
- const { path, createError } = this;
168
- if (typeof value !== 'object') {
169
- return createError({ message: `${path} must be an object` });
170
- }
171
- // Validate each property using the provided valueSchema
172
- for (const key of Object.keys(value)) {
173
- // Validate the key
174
- await yupValidate(keySchema, key, context.options);
175
- // Validate the value
176
- try {
177
- await yupValidate(valueSchema, value[key], {
178
- ...context.options,
179
- context: {
180
- ...context.options.context,
181
- path: path ? `${path}.${key}` : key,
182
- },
183
- });
184
- }
185
- catch (e) {
186
- return createError({
187
- path: path ? `${path}.${key}` : key,
188
- message: e.message,
189
- });
292
+ function yupRecord(keySchema, valueSchema) {
293
+ return yupObject().unknown(true).test(
294
+ "record",
295
+ "${path} must be a record of valid values",
296
+ async function(value, context) {
297
+ if (value == null) return true;
298
+ const { path, createError } = this;
299
+ if (typeof value !== "object") {
300
+ return createError({ message: `${path} must be an object` });
301
+ }
302
+ for (const key of Object.keys(value)) {
303
+ await yupValidate(keySchema, key, context.options);
304
+ try {
305
+ await yupValidate(valueSchema, value[key], {
306
+ ...context.options,
307
+ context: {
308
+ ...context.options.context,
309
+ path: path ? `${path}.${key}` : key
190
310
  }
311
+ });
312
+ } catch (e) {
313
+ return createError({
314
+ path: path ? `${path}.${key}` : key,
315
+ message: e.message
316
+ });
191
317
  }
192
- return true;
193
- });
318
+ }
319
+ return true;
320
+ }
321
+ );
194
322
  }
195
- export function ensureObjectSchema(schema) {
196
- if (!(schema instanceof yup.ObjectSchema))
197
- throw new StackAssertionError(`assertObjectSchema: schema is not an ObjectSchema: ${schema.describe().type}`);
198
- return schema;
323
+ function ensureObjectSchema(schema) {
324
+ if (!(schema instanceof yup.ObjectSchema)) throw new import_errors.StackAssertionError(`assertObjectSchema: schema is not an ObjectSchema: ${schema.describe().type}`);
325
+ return schema;
199
326
  }
200
- // Common
201
- export const adaptSchema = yupMixed();
202
- /**
203
- * Yup's URL schema does not recognize some URLs (including `http://localhost`) as a valid URL. This schema is a workaround for that.
204
- */
205
- export const urlSchema = yupString().test({
206
- name: 'no-spaces',
207
- message: (params) => `${params.path} contains spaces`,
208
- test: (value) => value == null || !value.includes(' ')
327
+ var adaptSchema = yupMixed();
328
+ var urlSchema = yupString().test({
329
+ name: "no-spaces",
330
+ message: (params) => `${params.path} contains spaces`,
331
+ test: (value) => value == null || !value.includes(" ")
209
332
  }).test({
210
- name: 'url',
211
- message: (params) => `${params.path} is not a valid URL`,
212
- test: (value) => value == null || isValidUrl(value)
213
- });
214
- export const jsonSchema = yupMixed().nullable().defined().transform((value) => JSON.parse(JSON.stringify(value)));
215
- export const jsonStringSchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
216
- if (value == null)
217
- return true;
218
- try {
219
- JSON.parse(value);
220
- return true;
221
- }
222
- catch (error) {
223
- return false;
224
- }
333
+ name: "url",
334
+ message: (params) => `${params.path} is not a valid URL`,
335
+ test: (value) => value == null || (0, import_urls.isValidUrl)(value)
225
336
  });
226
- export const jsonStringOrEmptySchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
227
- if (!value)
228
- return true;
229
- try {
230
- JSON.parse(value);
231
- return true;
232
- }
233
- catch (error) {
234
- return false;
235
- }
337
+ var jsonSchema = yupMixed().nullable().defined().transform((value) => JSON.parse(JSON.stringify(value)));
338
+ var jsonStringSchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
339
+ if (value == null) return true;
340
+ try {
341
+ JSON.parse(value);
342
+ return true;
343
+ } catch (error) {
344
+ return false;
345
+ }
236
346
  });
237
- export const base64Schema = yupString().test("is-base64", (params) => `${params.path} is not valid base64`, (value) => {
238
- if (value == null)
239
- return true;
240
- return isBase64(value);
347
+ var jsonStringOrEmptySchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
348
+ if (!value) return true;
349
+ try {
350
+ JSON.parse(value);
351
+ return true;
352
+ } catch (error) {
353
+ return false;
354
+ }
241
355
  });
242
- export const passwordSchema = yupString().max(70);
243
- /**
244
- * A stricter email schema that does some additional checks for UX input. (Some emails are allowed by the spec, for
245
- * example `test@localhost` or `abc@gmail`, but almost certainly a user input error.)
246
- *
247
- * Note that some users in the DB have an email that doesn't match this regex, so most of the time you should use
248
- * `emailSchema` instead until we do the DB migration.
249
- */
250
- // eslint-disable-next-line no-restricted-syntax
251
- export const strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
252
- // eslint-disable-next-line no-restricted-syntax
253
- export const emailSchema = yupString().email();
254
- import.meta.vitest?.test('strictEmailSchema', ({ expect }) => {
255
- const validEmails = [
256
- "a@example.com",
257
- "abc@example.com",
258
- "a.b@example.com",
259
- "throwaway.mail+token@example.com",
260
- "email-alt-dash@demo-mail.com",
261
- "test-account@weird-domain.net",
262
- "%!~&+{}=|`#@domain.test",
263
- "admin@a.longtldexample",
264
- ];
265
- for (const email of validEmails) {
266
- expect(strictEmailSchema(undefined).validateSync(email)).toBe(email);
267
- }
268
- const invalidEmails = [
269
- "test@localhost",
270
- "test@gmail",
271
- "test@gmail.com.a",
272
- "test@gmail.a",
273
- "test.@example.com",
274
- "test..test@example.com",
275
- ".test@example.com",
276
- ];
277
- for (const email of invalidEmails) {
278
- expect(() => strictEmailSchema(undefined).validateSync(email)).toThrow();
279
- }
356
+ var base64Schema = yupString().test("is-base64", (params) => `${params.path} is not valid base64`, (value) => {
357
+ if (value == null) return true;
358
+ return (0, import_bytes.isBase64)(value);
280
359
  });
281
- // Request auth
282
- export const clientOrHigherAuthTypeSchema = yupString().oneOf(['client', 'server', 'admin']).defined();
283
- export const serverOrHigherAuthTypeSchema = yupString().oneOf(['server', 'admin']).defined();
284
- export const adminAuthTypeSchema = yupString().oneOf(['admin']).defined();
285
- // Projects
286
- export const projectIdSchema = yupString().test((v) => v === undefined || v === "internal" || isUuid(v)).meta({ openapiField: { description: _idDescription('project'), exampleValue: 'e0b52f4d-dece-408c-af49-d23061bb0f8d' } });
287
- export const projectDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('project'), exampleValue: 'MyMusic' } });
288
- export const projectDescriptionSchema = yupString().nullable().meta({ openapiField: { description: 'A human readable description of the project', exampleValue: 'A music streaming service' } });
289
- export const projectCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription('project'), exampleValue: 1630000000000 } });
290
- export const projectUserCountSchema = yupNumber().meta({ openapiField: { description: 'The number of users in this project', exampleValue: 10 } });
291
- export const projectIsProductionModeSchema = yupBoolean().meta({ openapiField: { description: 'Whether the project is in production mode', exampleValue: true } });
292
- // Project config
293
- export const projectConfigIdSchema = yupString().meta({ openapiField: { description: _idDescription('project config'), exampleValue: 'd09201f0-54f5-40bd-89ff-6d1815ddad24' } });
294
- export const projectAllowLocalhostSchema = yupBoolean().meta({ openapiField: { description: 'Whether localhost is allowed as a domain for this project. Should only be allowed in development mode', exampleValue: true } });
295
- export const projectCreateTeamOnSignUpSchema = yupBoolean().meta({ openapiField: { description: 'Whether a team should be created for each user that signs up', exampleValue: true } });
296
- export const projectMagicLinkEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether magic link authentication is enabled for this project', exampleValue: true } });
297
- export const projectPasskeyEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether passkey authentication is enabled for this project', exampleValue: true } });
298
- export const projectClientTeamCreationEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether client users can create teams', exampleValue: true } });
299
- export const projectClientUserDeletionEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether client users can delete their own account from the client', exampleValue: true } });
300
- export const projectSignUpEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether users can sign up new accounts, or whether they are only allowed to sign in to existing accounts. Regardless of this option, the server API can always create new users with the `POST /users` endpoint.', exampleValue: true } });
301
- export const projectCredentialEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether email password authentication is enabled for this project', exampleValue: true } });
302
- // Project OAuth config
303
- export const oauthIdSchema = yupString().oneOf(allProviders).meta({ openapiField: { description: `OAuth provider ID, one of ${allProviders.map(x => `\`${x}\``).join(', ')}`, exampleValue: 'google' } });
304
- export const oauthEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether the OAuth provider is enabled. If an provider is first enabled, then disabled, it will be shown in the list but with enabled=false', exampleValue: true } });
305
- export const oauthTypeSchema = yupString().oneOf(['shared', 'standard']).meta({ openapiField: { description: 'OAuth provider type, one of shared, standard. "shared" uses Stack shared OAuth keys and it is only meant for development. "standard" uses your own OAuth keys and will show your logo and company name when signing in with the provider.', exampleValue: 'standard' } });
306
- export const oauthClientIdSchema = yupString().meta({ openapiField: { description: 'OAuth client ID. Needs to be specified when using type="standard"', exampleValue: 'google-oauth-client-id' } });
307
- export const oauthClientSecretSchema = yupString().meta({ openapiField: { description: 'OAuth client secret. Needs to be specified when using type="standard"', exampleValue: 'google-oauth-client-secret' } });
308
- export const oauthFacebookConfigIdSchema = yupString().meta({ openapiField: { description: 'The configuration id for Facebook business login (for things like ads and marketing). This is only required if you are using the standard OAuth with Facebook and you are using Facebook business login.' } });
309
- export const oauthMicrosoftTenantIdSchema = yupString().meta({ openapiField: { description: 'The Microsoft tenant id for Microsoft directory. This is only required if you are using the standard OAuth with Microsoft and you have an Azure AD tenant.' } });
310
- export const oauthAccountMergeStrategySchema = yupString().oneOf(['link_method', 'raise_error', 'allow_duplicates']).meta({ openapiField: { description: 'Determines how to handle OAuth logins that match an existing user by email. `link_method` adds the OAuth method to the existing user. `raise_error` rejects the login with an error. `allow_duplicates` creates a new user.', exampleValue: 'link_method' } });
311
- // Project email config
312
- export const emailTypeSchema = yupString().oneOf(['shared', 'standard']).meta({ openapiField: { description: 'Email provider type, one of shared, standard. "shared" uses Stack shared email provider and it is only meant for development. "standard" uses your own email server and will have your email address as the sender.', exampleValue: 'standard' } });
313
- export const emailSenderNameSchema = yupString().meta({ openapiField: { description: 'Email sender name. Needs to be specified when using type="standard"', exampleValue: 'Stack' } });
314
- export const emailHostSchema = yupString().meta({ openapiField: { description: 'Email host. Needs to be specified when using type="standard"', exampleValue: 'smtp.your-domain.com' } });
315
- export const emailPortSchema = yupNumber().min(0).max(65535).meta({ openapiField: { description: 'Email port. Needs to be specified when using type="standard"', exampleValue: 587 } });
316
- export const emailUsernameSchema = yupString().meta({ openapiField: { description: 'Email username. Needs to be specified when using type="standard"', exampleValue: 'smtp-email' } });
317
- export const emailSenderEmailSchema = emailSchema.meta({ openapiField: { description: 'Email sender email. Needs to be specified when using type="standard"', exampleValue: 'example@your-domain.com' } });
318
- export const emailPasswordSchema = passwordSchema.meta({ openapiField: { description: 'Email password. Needs to be specified when using type="standard"', exampleValue: 'your-email-password' } });
319
- // Project domain config
320
- export const handlerPathSchema = yupString().test('is-handler-path', 'Handler path must start with /', (value) => value?.startsWith('/')).meta({ openapiField: { description: 'Handler path. If you did not setup a custom handler path, it should be "/handler" by default. It needs to start with /', exampleValue: '/handler' } });
321
- // Users
322
- export class ReplaceFieldWithOwnUserId extends Error {
323
- constructor(path) {
324
- super(`This error should be caught by whoever validated the schema, and the field in the path '${path}' should be replaced with the current user's id. This is a workaround to yup not providing access to the context inside the transform function.`);
325
- this.path = path;
326
- }
327
- }
328
- const userIdMeSentinelUuid = "cad564fd-f81b-43f4-b390-98abf3fcc17e";
329
- export const userIdOrMeSchema = yupString().uuid().transform(v => {
330
- if (v === "me")
331
- return userIdMeSentinelUuid;
332
- else
333
- return v;
360
+ var passwordSchema = yupString().max(70);
361
+ var strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
362
+ var emailSchema = yupString().email();
363
+ var clientOrHigherAuthTypeSchema = yupString().oneOf(["client", "server", "admin"]).defined();
364
+ var serverOrHigherAuthTypeSchema = yupString().oneOf(["server", "admin"]).defined();
365
+ var adminAuthTypeSchema = yupString().oneOf(["admin"]).defined();
366
+ var projectIdSchema = yupString().test((v) => v === void 0 || v === "internal" || (0, import_uuids.isUuid)(v)).meta({ openapiField: { description: _idDescription("project"), exampleValue: "e0b52f4d-dece-408c-af49-d23061bb0f8d" } });
367
+ var projectDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("project"), exampleValue: "MyMusic" } });
368
+ var projectDescriptionSchema = yupString().nullable().meta({ openapiField: { description: "A human readable description of the project", exampleValue: "A music streaming service" } });
369
+ var projectCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription("project"), exampleValue: 163e10 } });
370
+ var projectUserCountSchema = yupNumber().meta({ openapiField: { description: "The number of users in this project", exampleValue: 10 } });
371
+ var projectIsProductionModeSchema = yupBoolean().meta({ openapiField: { description: "Whether the project is in production mode", exampleValue: true } });
372
+ var projectConfigIdSchema = yupString().meta({ openapiField: { description: _idDescription("project config"), exampleValue: "d09201f0-54f5-40bd-89ff-6d1815ddad24" } });
373
+ var projectAllowLocalhostSchema = yupBoolean().meta({ openapiField: { description: "Whether localhost is allowed as a domain for this project. Should only be allowed in development mode", exampleValue: true } });
374
+ var projectCreateTeamOnSignUpSchema = yupBoolean().meta({ openapiField: { description: "Whether a team should be created for each user that signs up", exampleValue: true } });
375
+ var projectMagicLinkEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether magic link authentication is enabled for this project", exampleValue: true } });
376
+ var projectPasskeyEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether passkey authentication is enabled for this project", exampleValue: true } });
377
+ var projectClientTeamCreationEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether client users can create teams", exampleValue: true } });
378
+ var projectClientUserDeletionEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether client users can delete their own account from the client", exampleValue: true } });
379
+ var projectSignUpEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether users can sign up new accounts, or whether they are only allowed to sign in to existing accounts. Regardless of this option, the server API can always create new users with the `POST /users` endpoint.", exampleValue: true } });
380
+ var projectCredentialEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether email password authentication is enabled for this project", exampleValue: true } });
381
+ var oauthIdSchema = yupString().oneOf(import_oauth.allProviders).meta({ openapiField: { description: `OAuth provider ID, one of ${import_oauth.allProviders.map((x) => `\`${x}\``).join(", ")}`, exampleValue: "google" } });
382
+ var oauthEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether the OAuth provider is enabled. If an provider is first enabled, then disabled, it will be shown in the list but with enabled=false", exampleValue: true } });
383
+ var oauthTypeSchema = yupString().oneOf(["shared", "standard"]).meta({ openapiField: { description: 'OAuth provider type, one of shared, standard. "shared" uses Stack shared OAuth keys and it is only meant for development. "standard" uses your own OAuth keys and will show your logo and company name when signing in with the provider.', exampleValue: "standard" } });
384
+ var oauthClientIdSchema = yupString().meta({ openapiField: { description: 'OAuth client ID. Needs to be specified when using type="standard"', exampleValue: "google-oauth-client-id" } });
385
+ var oauthClientSecretSchema = yupString().meta({ openapiField: { description: 'OAuth client secret. Needs to be specified when using type="standard"', exampleValue: "google-oauth-client-secret" } });
386
+ var oauthFacebookConfigIdSchema = yupString().meta({ openapiField: { description: "The configuration id for Facebook business login (for things like ads and marketing). This is only required if you are using the standard OAuth with Facebook and you are using Facebook business login." } });
387
+ var oauthMicrosoftTenantIdSchema = yupString().meta({ openapiField: { description: "The Microsoft tenant id for Microsoft directory. This is only required if you are using the standard OAuth with Microsoft and you have an Azure AD tenant." } });
388
+ var oauthAccountMergeStrategySchema = yupString().oneOf(["link_method", "raise_error", "allow_duplicates"]).meta({ openapiField: { description: "Determines how to handle OAuth logins that match an existing user by email. `link_method` adds the OAuth method to the existing user. `raise_error` rejects the login with an error. `allow_duplicates` creates a new user.", exampleValue: "link_method" } });
389
+ var emailTypeSchema = yupString().oneOf(["shared", "standard"]).meta({ openapiField: { description: 'Email provider type, one of shared, standard. "shared" uses Stack shared email provider and it is only meant for development. "standard" uses your own email server and will have your email address as the sender.', exampleValue: "standard" } });
390
+ var emailSenderNameSchema = yupString().meta({ openapiField: { description: 'Email sender name. Needs to be specified when using type="standard"', exampleValue: "Stack" } });
391
+ var emailHostSchema = yupString().meta({ openapiField: { description: 'Email host. Needs to be specified when using type="standard"', exampleValue: "smtp.your-domain.com" } });
392
+ var emailPortSchema = yupNumber().min(0).max(65535).meta({ openapiField: { description: 'Email port. Needs to be specified when using type="standard"', exampleValue: 587 } });
393
+ var emailUsernameSchema = yupString().meta({ openapiField: { description: 'Email username. Needs to be specified when using type="standard"', exampleValue: "smtp-email" } });
394
+ var emailSenderEmailSchema = emailSchema.meta({ openapiField: { description: 'Email sender email. Needs to be specified when using type="standard"', exampleValue: "example@your-domain.com" } });
395
+ var emailPasswordSchema = passwordSchema.meta({ openapiField: { description: 'Email password. Needs to be specified when using type="standard"', exampleValue: "your-email-password" } });
396
+ var handlerPathSchema = yupString().test("is-handler-path", "Handler path must start with /", (value) => value?.startsWith("/")).meta({ openapiField: { description: 'Handler path. If you did not setup a custom handler path, it should be "/handler" by default. It needs to start with /', exampleValue: "/handler" } });
397
+ var ReplaceFieldWithOwnUserId = class extends Error {
398
+ constructor(path) {
399
+ super(`This error should be caught by whoever validated the schema, and the field in the path '${path}' should be replaced with the current user's id. This is a workaround to yup not providing access to the context inside the transform function.`);
400
+ this.path = path;
401
+ }
402
+ };
403
+ var userIdMeSentinelUuid = "cad564fd-f81b-43f4-b390-98abf3fcc17e";
404
+ var userIdOrMeSchema = yupString().uuid().transform((v) => {
405
+ if (v === "me") return userIdMeSentinelUuid;
406
+ else return v;
334
407
  }).test((v, context) => {
335
- if (!("stackAllowUserIdMe" in (context.options.context ?? {})))
336
- throw new StackAssertionError('userIdOrMeSchema is not allowed in this context. Make sure you\'re using yupValidate from schema-fields.ts to validate, instead of schema.validate(...).');
337
- if (!context.options.context?.stackAllowUserIdMe)
338
- throw new StackAssertionError('userIdOrMeSchema is not allowed in this context. Make sure you\'re passing in the currentUserId option in yupValidate.');
339
- if (v === userIdMeSentinelUuid)
340
- throw new ReplaceFieldWithOwnUserId(context.path);
341
- return true;
342
- }).meta({ openapiField: { description: 'The ID of the user, or the special value `me` for the currently authenticated user', exampleValue: '3241a285-8329-4d69-8f3d-316e08cf140c' } });
343
- export const userIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('user'), exampleValue: '3241a285-8329-4d69-8f3d-316e08cf140c' } });
344
- export const primaryEmailSchema = emailSchema.meta({ openapiField: { description: 'Primary email', exampleValue: 'johndoe@example.com' } });
345
- export const primaryEmailAuthEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether the primary email is used for authentication. If this is set to `false`, the user will not be able to sign in with the primary email with password or OTP', exampleValue: true } });
346
- export const primaryEmailVerifiedSchema = yupBoolean().meta({ openapiField: { description: 'Whether the primary email has been verified to belong to this user', exampleValue: true } });
347
- export const userDisplayNameSchema = yupString().nullable().meta({ openapiField: { description: _displayNameDescription('user'), exampleValue: 'John Doe' } });
348
- export const selectedTeamIdSchema = yupString().uuid().meta({ openapiField: { description: 'ID of the team currently selected by the user', exampleValue: 'team-id' } });
349
- export const profileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('user'), exampleValue: 'https://example.com/image.jpg' } });
350
- export const signedUpAtMillisSchema = yupNumber().meta({ openapiField: { description: _signedUpAtMillisDescription, exampleValue: 1630000000000 } });
351
- export const userClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription('user'), exampleValue: { key: 'value' } } });
352
- export const userClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription('user'), exampleValue: { key: 'value' } } });
353
- export const userServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription('user'), exampleValue: { key: 'value' } } });
354
- export const userOAuthProviderSchema = yupObject({
355
- id: yupString().defined(),
356
- type: yupString().oneOf(allProviders).defined(),
357
- provider_user_id: yupString().defined(),
408
+ if (!("stackAllowUserIdMe" in (context.options.context ?? {}))) throw new import_errors.StackAssertionError("userIdOrMeSchema is not allowed in this context. Make sure you're using yupValidate from schema-fields.ts to validate, instead of schema.validate(...).");
409
+ if (!context.options.context?.stackAllowUserIdMe) throw new import_errors.StackAssertionError("userIdOrMeSchema is not allowed in this context. Make sure you're passing in the currentUserId option in yupValidate.");
410
+ if (v === userIdMeSentinelUuid) throw new ReplaceFieldWithOwnUserId(context.path);
411
+ return true;
412
+ }).meta({ openapiField: { description: "The ID of the user, or the special value `me` for the currently authenticated user", exampleValue: "3241a285-8329-4d69-8f3d-316e08cf140c" } });
413
+ var userIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("user"), exampleValue: "3241a285-8329-4d69-8f3d-316e08cf140c" } });
414
+ var primaryEmailSchema = emailSchema.meta({ openapiField: { description: "Primary email", exampleValue: "johndoe@example.com" } });
415
+ var primaryEmailAuthEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether the primary email is used for authentication. If this is set to `false`, the user will not be able to sign in with the primary email with password or OTP", exampleValue: true } });
416
+ var primaryEmailVerifiedSchema = yupBoolean().meta({ openapiField: { description: "Whether the primary email has been verified to belong to this user", exampleValue: true } });
417
+ var userDisplayNameSchema = yupString().nullable().meta({ openapiField: { description: _displayNameDescription("user"), exampleValue: "John Doe" } });
418
+ var selectedTeamIdSchema = yupString().uuid().meta({ openapiField: { description: "ID of the team currently selected by the user", exampleValue: "team-id" } });
419
+ var profileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("user"), exampleValue: "https://example.com/image.jpg" } });
420
+ var signedUpAtMillisSchema = yupNumber().meta({ openapiField: { description: _signedUpAtMillisDescription, exampleValue: 163e10 } });
421
+ var userClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription("user"), exampleValue: { key: "value" } } });
422
+ var userClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription("user"), exampleValue: { key: "value" } } });
423
+ var userServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription("user"), exampleValue: { key: "value" } } });
424
+ var userOAuthProviderSchema = yupObject({
425
+ id: yupString().defined(),
426
+ type: yupString().oneOf(import_oauth.allProviders).defined(),
427
+ provider_user_id: yupString().defined()
358
428
  });
359
- export const userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 1630000000000 } });
360
- export const userPasskeyAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has passkeys enabled', exampleValue: false } });
361
- export const userOtpAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has OTP/magic link enabled. ', exampleValue: true } });
362
- export const userOtpAuthEnabledMutationSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has OTP/magic link enabled. Note that only accounts with verified emails can sign-in with OTP.', exampleValue: true } });
363
- export const userHasPasswordSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has a password set. If the user does not have a password set, they will not be able to sign in with email/password.', exampleValue: true } });
364
- export const userPasswordMutationSchema = passwordSchema.nullable().meta({ openapiField: { description: 'Sets the user\'s password. Doing so revokes all current sessions.', exampleValue: 'my-new-password' } }).max(70);
365
- export const userPasswordHashMutationSchema = yupString()
366
- .nonEmpty()
367
- .meta({ openapiField: { description: 'If `password` is not given, sets the user\'s password hash to the given string in Modular Crypt Format (ex.: `$2a$10$VIhIOofSMqGdGlL4wzE//e.77dAQGqNtF/1dT7bqCrVtQuInWy2qi`). Doing so revokes all current sessions.' } }); // we don't set an exampleValue here because it's exclusive with the password field and having both would break the generated example
368
- export const userTotpSecretMutationSchema = base64Schema.nullable().meta({ openapiField: { description: 'Enables 2FA and sets a TOTP secret for the user. Set to null to disable 2FA.', exampleValue: 'dG90cC1zZWNyZXQ=' } });
369
- // Auth
370
- export const signInEmailSchema = strictEmailSchema(undefined).meta({ openapiField: { description: 'The email to sign in with.', exampleValue: 'johndoe@example.com' } });
371
- export const emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct the magic link from. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/auth/otp/sign-in` endpoint.', exampleValue: 'https://example.com/handler/magic-link-callback' } });
372
- export const emailVerificationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct a verification link for the verification e-mail. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/contact-channels/verify` endpoint.', exampleValue: 'https://example.com/handler/email-verification' } });
373
- export const accessTokenResponseSchema = yupString().meta({ openapiField: { description: 'Short-lived access token that can be used to authenticate the user', exampleValue: 'eyJhmMiJB2TO...diI4QT' } });
374
- export const refreshTokenResponseSchema = yupString().meta({ openapiField: { description: 'Long-lived refresh token that can be used to obtain a new access token', exampleValue: 'i8ns3aq2...14y' } });
375
- export const signInResponseSchema = yupObject({
376
- refresh_token: refreshTokenResponseSchema.defined(),
377
- access_token: accessTokenResponseSchema.defined(),
378
- is_new_user: yupBoolean().meta({ openapiField: { description: 'Whether the user is a new user', exampleValue: true } }).defined(),
379
- user_id: userIdSchema.defined(),
429
+ var userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 163e10 } });
430
+ var userPasskeyAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has passkeys enabled", exampleValue: false } });
431
+ var userOtpAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has OTP/magic link enabled. ", exampleValue: true } });
432
+ var userOtpAuthEnabledMutationSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has OTP/magic link enabled. Note that only accounts with verified emails can sign-in with OTP.", exampleValue: true } });
433
+ var userHasPasswordSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has a password set. If the user does not have a password set, they will not be able to sign in with email/password.", exampleValue: true } });
434
+ var userPasswordMutationSchema = passwordSchema.nullable().meta({ openapiField: { description: "Sets the user's password. Doing so revokes all current sessions.", exampleValue: "my-new-password" } }).max(70);
435
+ var userPasswordHashMutationSchema = yupString().nonEmpty().meta({ openapiField: { description: "If `password` is not given, sets the user's password hash to the given string in Modular Crypt Format (ex.: `$2a$10$VIhIOofSMqGdGlL4wzE//e.77dAQGqNtF/1dT7bqCrVtQuInWy2qi`). Doing so revokes all current sessions." } });
436
+ var userTotpSecretMutationSchema = base64Schema.nullable().meta({ openapiField: { description: "Enables 2FA and sets a TOTP secret for the user. Set to null to disable 2FA.", exampleValue: "dG90cC1zZWNyZXQ=" } });
437
+ var signInEmailSchema = strictEmailSchema(void 0).meta({ openapiField: { description: "The email to sign in with.", exampleValue: "johndoe@example.com" } });
438
+ var emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct the magic link from. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/auth/otp/sign-in` endpoint.", exampleValue: "https://example.com/handler/magic-link-callback" } });
439
+ var emailVerificationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct a verification link for the verification e-mail. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/contact-channels/verify` endpoint.", exampleValue: "https://example.com/handler/email-verification" } });
440
+ var accessTokenResponseSchema = yupString().meta({ openapiField: { description: "Short-lived access token that can be used to authenticate the user", exampleValue: "eyJhmMiJB2TO...diI4QT" } });
441
+ var refreshTokenResponseSchema = yupString().meta({ openapiField: { description: "Long-lived refresh token that can be used to obtain a new access token", exampleValue: "i8ns3aq2...14y" } });
442
+ var signInResponseSchema = yupObject({
443
+ refresh_token: refreshTokenResponseSchema.defined(),
444
+ access_token: accessTokenResponseSchema.defined(),
445
+ is_new_user: yupBoolean().meta({ openapiField: { description: "Whether the user is a new user", exampleValue: true } }).defined(),
446
+ user_id: userIdSchema.defined()
380
447
  });
381
- // Permissions
382
- export const teamSystemPermissions = [
383
- '$update_team',
384
- '$delete_team',
385
- '$read_members',
386
- '$remove_members',
387
- '$invite_members',
388
- '$manage_api_keys',
448
+ var teamSystemPermissions = [
449
+ "$update_team",
450
+ "$delete_team",
451
+ "$read_members",
452
+ "$remove_members",
453
+ "$invite_members",
454
+ "$manage_api_keys"
389
455
  ];
390
- export const permissionDefinitionIdSchema = yupString()
391
- .matches(/^\$?[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" and optional "$" at the beginning are allowed')
392
- .test('is-system-permission', 'System permissions must start with a dollar sign', (value, ctx) => {
393
- if (!value)
394
- return true;
395
- if (value.startsWith('$') && !teamSystemPermissions.includes(value)) {
396
- return ctx.createError({ message: 'Invalid system permission' });
397
- }
398
- return true;
399
- })
400
- .meta({ openapiField: { description: `The permission ID used to uniquely identify a permission. Can either be a custom permission with lowercase letters, numbers, \`:\`, and \`_\` characters, or one of the system permissions: ${teamSystemPermissions.map(x => `\`${x}\``).join(', ')}`, exampleValue: 'read_secret_info' } });
401
- export const customPermissionDefinitionIdSchema = yupString()
402
- .matches(/^[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" are allowed')
403
- .meta({ openapiField: { description: 'The permission ID used to uniquely identify a permission. Can only contain lowercase letters, numbers, ":", and "_" characters', exampleValue: 'read_secret_info' } });
404
- export const teamPermissionDescriptionSchema = yupString().meta({ openapiField: { description: 'A human-readable description of the permission', exampleValue: 'Read secret information' } });
405
- export const containedPermissionIdsSchema = yupArray(permissionDefinitionIdSchema.defined()).meta({ openapiField: { description: 'The IDs of the permissions that are contained in this permission', exampleValue: ['read_public_info'] } });
406
- // Teams
407
- export const teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('team'), exampleValue: 'ad962777-8244-496a-b6a2-e0c6a449c79e' } });
408
- export const teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team'), exampleValue: 'My Team' } });
409
- export const teamProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team'), exampleValue: 'https://example.com/image.jpg' } });
410
- export const teamClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription('team'), exampleValue: { key: 'value' } } });
411
- export const teamClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription('team'), exampleValue: { key: 'value' } } });
412
- export const teamServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription('team'), exampleValue: { key: 'value' } } });
413
- export const teamCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription('team'), exampleValue: 1630000000000 } });
414
- export const teamInvitationEmailSchema = emailSchema.meta({ openapiField: { description: 'The email of the user to invite.', exampleValue: 'johndoe@example.com' } });
415
- export const teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct an invite link with. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/team-invitations/accept` endpoint.', exampleValue: 'https://example.com/handler/team-invitation' } });
416
- export const teamCreatorUserIdSchema = userIdOrMeSchema.meta({ openapiField: { description: 'The ID of the creator of the team. If not specified, the user will not be added to the team. Can be either "me" or the ID of the user. Only used on the client side.', exampleValue: 'me' } });
417
- // Team member profiles
418
- export const teamMemberDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team member') + ' Note that this is separate from the display_name of the user.', exampleValue: 'John Doe' } });
419
- export const teamMemberProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team member'), exampleValue: 'https://example.com/image.jpg' } });
420
- // Contact channels
421
- export const contactChannelIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('contact channel'), exampleValue: 'b3d396b8-c574-4c80-97b3-50031675ceb2' } });
422
- export const contactChannelTypeSchema = yupString().oneOf(['email']).meta({ openapiField: { description: `The type of the contact channel. Currently only "email" is supported.`, exampleValue: 'email' } });
423
- export const contactChannelValueSchema = yupString().when('type', {
424
- is: 'email',
425
- then: (schema) => schema.email(),
426
- }).meta({ openapiField: { description: 'The value of the contact channel. For email, this should be a valid email address.', exampleValue: 'johndoe@example.com' } });
427
- export const contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.', exampleValue: true } });
428
- export const contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.', exampleValue: true } });
429
- export const contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.', exampleValue: true } });
430
- // Headers
431
- export const basicAuthorizationHeaderSchema = yupString().test('is-basic-authorization-header', 'Authorization header must be in the format "Basic <base64>"', (value) => {
432
- if (!value)
433
- return true;
434
- return decodeBasicAuthorizationHeader(value) !== null;
456
+ var permissionDefinitionIdSchema = yupString().matches(/^\$?[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" and optional "$" at the beginning are allowed').test("is-system-permission", "System permissions must start with a dollar sign", (value, ctx) => {
457
+ if (!value) return true;
458
+ if (value.startsWith("$") && !teamSystemPermissions.includes(value)) {
459
+ return ctx.createError({ message: "Invalid system permission" });
460
+ }
461
+ return true;
462
+ }).meta({ openapiField: { description: `The permission ID used to uniquely identify a permission. Can either be a custom permission with lowercase letters, numbers, \`:\`, and \`_\` characters, or one of the system permissions: ${teamSystemPermissions.map((x) => `\`${x}\``).join(", ")}`, exampleValue: "read_secret_info" } });
463
+ var customPermissionDefinitionIdSchema = yupString().matches(/^[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" are allowed').meta({ openapiField: { description: 'The permission ID used to uniquely identify a permission. Can only contain lowercase letters, numbers, ":", and "_" characters', exampleValue: "read_secret_info" } });
464
+ var teamPermissionDescriptionSchema = yupString().meta({ openapiField: { description: "A human-readable description of the permission", exampleValue: "Read secret information" } });
465
+ var containedPermissionIdsSchema = yupArray(permissionDefinitionIdSchema.defined()).meta({ openapiField: { description: "The IDs of the permissions that are contained in this permission", exampleValue: ["read_public_info"] } });
466
+ var teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("team"), exampleValue: "ad962777-8244-496a-b6a2-e0c6a449c79e" } });
467
+ var teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("team"), exampleValue: "My Team" } });
468
+ var teamProfileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("team"), exampleValue: "https://example.com/image.jpg" } });
469
+ var teamClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription("team"), exampleValue: { key: "value" } } });
470
+ var teamClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription("team"), exampleValue: { key: "value" } } });
471
+ var teamServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription("team"), exampleValue: { key: "value" } } });
472
+ var teamCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription("team"), exampleValue: 163e10 } });
473
+ var teamInvitationEmailSchema = emailSchema.meta({ openapiField: { description: "The email of the user to invite.", exampleValue: "johndoe@example.com" } });
474
+ var teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct an invite link with. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/team-invitations/accept` endpoint.", exampleValue: "https://example.com/handler/team-invitation" } });
475
+ var teamCreatorUserIdSchema = userIdOrMeSchema.meta({ openapiField: { description: 'The ID of the creator of the team. If not specified, the user will not be added to the team. Can be either "me" or the ID of the user. Only used on the client side.', exampleValue: "me" } });
476
+ var teamMemberDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("team member") + " Note that this is separate from the display_name of the user.", exampleValue: "John Doe" } });
477
+ var teamMemberProfileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("team member"), exampleValue: "https://example.com/image.jpg" } });
478
+ var contactChannelIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("contact channel"), exampleValue: "b3d396b8-c574-4c80-97b3-50031675ceb2" } });
479
+ var contactChannelTypeSchema = yupString().oneOf(["email"]).meta({ openapiField: { description: `The type of the contact channel. Currently only "email" is supported.`, exampleValue: "email" } });
480
+ var contactChannelValueSchema = yupString().when("type", {
481
+ is: "email",
482
+ then: (schema) => schema.email()
483
+ }).meta({ openapiField: { description: "The value of the contact channel. For email, this should be a valid email address.", exampleValue: "johndoe@example.com" } });
484
+ var contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.", exampleValue: true } });
485
+ var contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.", exampleValue: true } });
486
+ var contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.", exampleValue: true } });
487
+ var basicAuthorizationHeaderSchema = yupString().test("is-basic-authorization-header", 'Authorization header must be in the format "Basic <base64>"', (value) => {
488
+ if (!value) return true;
489
+ return (0, import_http.decodeBasicAuthorizationHeader)(value) !== null;
435
490
  });
436
- // Neon integration
437
- export const neonAuthorizationHeaderSchema = basicAuthorizationHeaderSchema.test('is-neon-authorization-header', 'Invalid client_id:client_secret values; did you use the correct values for the Neon integration?', (value) => {
438
- if (!value)
439
- return true;
440
- const [clientId, clientSecret] = decodeBasicAuthorizationHeader(value) ?? throwErr(`Neon authz header invalid? This should've been validated by basicAuthorizationHeaderSchema: ${value}`);
441
- for (const neonClientConfig of JSON.parse(process.env.STACK_NEON_INTEGRATION_CLIENTS_CONFIG || '[]')) {
442
- if (clientId === neonClientConfig.client_id && clientSecret === neonClientConfig.client_secret)
443
- return true;
444
- }
445
- return false;
491
+ var neonAuthorizationHeaderSchema = basicAuthorizationHeaderSchema.test("is-neon-authorization-header", "Invalid client_id:client_secret values; did you use the correct values for the Neon integration?", (value) => {
492
+ if (!value) return true;
493
+ const [clientId, clientSecret] = (0, import_http.decodeBasicAuthorizationHeader)(value) ?? (0, import_errors.throwErr)(`Neon authz header invalid? This should've been validated by basicAuthorizationHeaderSchema: ${value}`);
494
+ for (const neonClientConfig of JSON.parse(process.env.STACK_NEON_INTEGRATION_CLIENTS_CONFIG || "[]")) {
495
+ if (clientId === neonClientConfig.client_id && clientSecret === neonClientConfig.client_secret) return true;
496
+ }
497
+ return false;
446
498
  });
447
- // Utils
448
- export function yupDefinedWhen(schema, triggers) {
449
- const entries = Object.entries(triggers);
450
- return schema.when(entries.map(([key]) => key), {
451
- is: (...values) => entries.every(([key, value], index) => value === values[index]),
452
- then: (schema) => schema.defined(),
453
- otherwise: (schema) => schema.optional()
454
- });
499
+ function yupDefinedWhen(schema, triggers) {
500
+ const entries = Object.entries(triggers);
501
+ return schema.when(entries.map(([key]) => key), {
502
+ is: (...values) => entries.every(([key, value], index) => value === values[index]),
503
+ then: (schema2) => schema2.defined(),
504
+ otherwise: (schema2) => schema2.optional()
505
+ });
455
506
  }
456
- export function yupDefinedAndNonEmptyWhen(schema, triggers) {
457
- const entries = Object.entries(triggers);
458
- return schema.when(entries.map(([key]) => key), {
459
- is: (...values) => entries.every(([key, value], index) => value === values[index]),
460
- then: (schema) => schema.defined().nonEmpty(),
461
- otherwise: (schema) => schema.optional()
462
- });
507
+ function yupDefinedAndNonEmptyWhen(schema, triggers) {
508
+ const entries = Object.entries(triggers);
509
+ return schema.when(entries.map(([key]) => key), {
510
+ is: (...values) => entries.every(([key, value], index) => value === values[index]),
511
+ then: (schema2) => schema2.defined().nonEmpty(),
512
+ otherwise: (schema2) => schema2.optional()
513
+ });
463
514
  }
515
+ // Annotate the CommonJS export names for ESM import in node:
516
+ 0 && (module.exports = {
517
+ ReplaceFieldWithOwnUserId,
518
+ accessTokenResponseSchema,
519
+ adaptSchema,
520
+ adminAuthTypeSchema,
521
+ base64Schema,
522
+ basicAuthorizationHeaderSchema,
523
+ clientOrHigherAuthTypeSchema,
524
+ contactChannelIdSchema,
525
+ contactChannelIsPrimarySchema,
526
+ contactChannelIsVerifiedSchema,
527
+ contactChannelTypeSchema,
528
+ contactChannelUsedForAuthSchema,
529
+ contactChannelValueSchema,
530
+ containedPermissionIdsSchema,
531
+ customPermissionDefinitionIdSchema,
532
+ emailHostSchema,
533
+ emailOtpSignInCallbackUrlSchema,
534
+ emailPasswordSchema,
535
+ emailPortSchema,
536
+ emailSchema,
537
+ emailSenderEmailSchema,
538
+ emailSenderNameSchema,
539
+ emailTypeSchema,
540
+ emailUsernameSchema,
541
+ emailVerificationCallbackUrlSchema,
542
+ ensureObjectSchema,
543
+ handlerPathSchema,
544
+ jsonSchema,
545
+ jsonStringOrEmptySchema,
546
+ jsonStringSchema,
547
+ neonAuthorizationHeaderSchema,
548
+ oauthAccountMergeStrategySchema,
549
+ oauthClientIdSchema,
550
+ oauthClientSecretSchema,
551
+ oauthEnabledSchema,
552
+ oauthFacebookConfigIdSchema,
553
+ oauthIdSchema,
554
+ oauthMicrosoftTenantIdSchema,
555
+ oauthTypeSchema,
556
+ passwordSchema,
557
+ permissionDefinitionIdSchema,
558
+ primaryEmailAuthEnabledSchema,
559
+ primaryEmailSchema,
560
+ primaryEmailVerifiedSchema,
561
+ profileImageUrlSchema,
562
+ projectAllowLocalhostSchema,
563
+ projectClientTeamCreationEnabledSchema,
564
+ projectClientUserDeletionEnabledSchema,
565
+ projectConfigIdSchema,
566
+ projectCreateTeamOnSignUpSchema,
567
+ projectCreatedAtMillisSchema,
568
+ projectCredentialEnabledSchema,
569
+ projectDescriptionSchema,
570
+ projectDisplayNameSchema,
571
+ projectIdSchema,
572
+ projectIsProductionModeSchema,
573
+ projectMagicLinkEnabledSchema,
574
+ projectPasskeyEnabledSchema,
575
+ projectSignUpEnabledSchema,
576
+ projectUserCountSchema,
577
+ refreshTokenResponseSchema,
578
+ selectedTeamIdSchema,
579
+ serverOrHigherAuthTypeSchema,
580
+ signInEmailSchema,
581
+ signInResponseSchema,
582
+ signedUpAtMillisSchema,
583
+ strictEmailSchema,
584
+ teamClientMetadataSchema,
585
+ teamClientReadOnlyMetadataSchema,
586
+ teamCreatedAtMillisSchema,
587
+ teamCreatorUserIdSchema,
588
+ teamDisplayNameSchema,
589
+ teamIdSchema,
590
+ teamInvitationCallbackUrlSchema,
591
+ teamInvitationEmailSchema,
592
+ teamMemberDisplayNameSchema,
593
+ teamMemberProfileImageUrlSchema,
594
+ teamPermissionDescriptionSchema,
595
+ teamProfileImageUrlSchema,
596
+ teamServerMetadataSchema,
597
+ teamSystemPermissions,
598
+ urlSchema,
599
+ userClientMetadataSchema,
600
+ userClientReadOnlyMetadataSchema,
601
+ userDisplayNameSchema,
602
+ userHasPasswordSchema,
603
+ userIdOrMeSchema,
604
+ userIdSchema,
605
+ userLastActiveAtMillisSchema,
606
+ userOAuthProviderSchema,
607
+ userOtpAuthEnabledMutationSchema,
608
+ userOtpAuthEnabledSchema,
609
+ userPasskeyAuthEnabledSchema,
610
+ userPasswordHashMutationSchema,
611
+ userPasswordMutationSchema,
612
+ userServerMetadataSchema,
613
+ userTotpSecretMutationSchema,
614
+ yupArray,
615
+ yupBoolean,
616
+ yupDate,
617
+ yupDefinedAndNonEmptyWhen,
618
+ yupDefinedWhen,
619
+ yupMixed,
620
+ yupNever,
621
+ yupNumber,
622
+ yupObject,
623
+ yupRecord,
624
+ yupString,
625
+ yupTuple,
626
+ yupUnion,
627
+ yupValidate
628
+ });
629
+ //# sourceMappingURL=schema-fields.js.map