@stackframe/stack-shared 2.8.7 → 2.8.10

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 +10 -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 +724 -0
  7. package/dist/config/schema.d.ts +51 -48
  8. package/dist/config/schema.js +230 -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 +199 -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 +188 -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 +1223 -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 +153 -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 +294 -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 +18 -10
  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 +640 -0
  245. package/dist/interface/crud/projects.d.ts +36 -31
  246. package/dist/interface/crud/projects.js +218 -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 +444 -0
  293. package/dist/known-errors.d.ts +12 -9
  294. package/dist/known-errors.js +1088 -561
  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 +65 -0
  421. package/dist/utils/objects.d.ts +31 -30
  422. package/dist/utils/objects.js +196 -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 +299 -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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/unicode.tsx"],"sourcesContent":["import { StackAssertionError } from \"./errors\";\n\nexport function getFlagEmoji(twoLetterCountryCode: string) {\n if (!/^[a-zA-Z][a-zA-Z]$/.test(twoLetterCountryCode)) throw new StackAssertionError(\"Country code must be two alphabetical letters\");\n const codePoints = twoLetterCountryCode\n .toUpperCase()\n .split('')\n .map(char => 127397 + char.charCodeAt(0));\n return String.fromCodePoint(...codePoints);\n}\nundefined?.test(\"getFlagEmoji\", ({ expect }) => {\n // Test with valid country codes\n expect(getFlagEmoji(\"US\")).toBe(\"🇺🇸\");\n expect(getFlagEmoji(\"us\")).toBe(\"🇺🇸\");\n expect(getFlagEmoji(\"GB\")).toBe(\"🇬🇧\");\n expect(getFlagEmoji(\"JP\")).toBe(\"🇯🇵\");\n\n // Test with invalid country codes\n expect(() => getFlagEmoji(\"\")).toThrow(\"Country code must be two alphabetical letters\");\n expect(() => getFlagEmoji(\"A\")).toThrow(\"Country code must be two alphabetical letters\");\n expect(() => getFlagEmoji(\"ABC\")).toThrow(\"Country code must be two alphabetical letters\");\n expect(() => getFlagEmoji(\"12\")).toThrow(\"Country code must be two alphabetical letters\");\n expect(() => getFlagEmoji(\"A1\")).toThrow(\"Country code must be two alphabetical letters\");\n});\n"],"mappings":";AAAA,SAAS,2BAA2B;AAE7B,SAAS,aAAa,sBAA8B;AACzD,MAAI,CAAC,qBAAqB,KAAK,oBAAoB,EAAG,OAAM,IAAI,oBAAoB,+CAA+C;AACnI,QAAM,aAAa,qBAChB,YAAY,EACZ,MAAM,EAAE,EACR,IAAI,UAAQ,SAAS,KAAK,WAAW,CAAC,CAAC;AAC1C,SAAO,OAAO,cAAc,GAAG,UAAU;AAC3C;","names":[]}
@@ -0,0 +1,53 @@
1
+ // src/utils/urls.tsx
2
+ import { generateSecureRandomString } from "./crypto";
3
+ import { templateIdentity } from "./strings";
4
+ function createUrlIfValid(...args) {
5
+ try {
6
+ return new URL(...args);
7
+ } catch (e) {
8
+ return null;
9
+ }
10
+ }
11
+ function isValidUrl(url2) {
12
+ return !!createUrlIfValid(url2);
13
+ }
14
+ function isValidHostname(hostname) {
15
+ const url2 = createUrlIfValid(`https://${hostname}`);
16
+ if (!url2) return false;
17
+ return url2.hostname === hostname;
18
+ }
19
+ function isLocalhost(urlOrString) {
20
+ const url2 = createUrlIfValid(urlOrString);
21
+ if (!url2) return false;
22
+ if (url2.hostname === "localhost" || url2.hostname.endsWith(".localhost")) return true;
23
+ if (url2.hostname.match(/^127\.\d+\.\d+\.\d+$/)) return true;
24
+ return false;
25
+ }
26
+ function isRelative(url2) {
27
+ const randomDomain = `${generateSecureRandomString()}.stack-auth.example.com`;
28
+ const u = createUrlIfValid(url2, `https://${randomDomain}`);
29
+ if (!u) return false;
30
+ if (u.host !== randomDomain) return false;
31
+ if (u.protocol !== "https:") return false;
32
+ return true;
33
+ }
34
+ function getRelativePart(url2) {
35
+ return url2.pathname + url2.search + url2.hash;
36
+ }
37
+ function url(strings, ...values) {
38
+ return new URL(urlString(strings, ...values));
39
+ }
40
+ function urlString(strings, ...values) {
41
+ return templateIdentity(strings, ...values.map(encodeURIComponent));
42
+ }
43
+ export {
44
+ createUrlIfValid,
45
+ getRelativePart,
46
+ isLocalhost,
47
+ isRelative,
48
+ isValidHostname,
49
+ isValidUrl,
50
+ url,
51
+ urlString
52
+ };
53
+ //# sourceMappingURL=urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/urls.tsx"],"sourcesContent":["import { generateSecureRandomString } from \"./crypto\";\nimport { templateIdentity } from \"./strings\";\n\nexport function createUrlIfValid(...args: ConstructorParameters<typeof URL>) {\n try {\n return new URL(...args);\n } catch (e) {\n return null;\n }\n}\nundefined?.test(\"createUrlIfValid\", ({ expect }) => {\n // Test with valid URLs\n expect(createUrlIfValid(\"https://example.com\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"https://example.com/path?query=value#hash\")).toBeInstanceOf(URL);\n expect(createUrlIfValid(\"/path\", \"https://example.com\")).toBeInstanceOf(URL);\n\n // Test with invalid URLs\n expect(createUrlIfValid(\"\")).toBeNull();\n expect(createUrlIfValid(\"not a url\")).toBeNull();\n expect(createUrlIfValid(\"http://\")).toBeNull();\n});\n\nexport function isValidUrl(url: string) {\n return !!createUrlIfValid(url);\n}\nundefined?.test(\"isValidUrl\", ({ expect }) => {\n // Test with valid URLs\n expect(isValidUrl(\"https://example.com\")).toBe(true);\n expect(isValidUrl(\"http://localhost:3000\")).toBe(true);\n expect(isValidUrl(\"ftp://example.com\")).toBe(true);\n\n // Test with invalid URLs\n expect(isValidUrl(\"\")).toBe(false);\n expect(isValidUrl(\"not a url\")).toBe(false);\n expect(isValidUrl(\"http://\")).toBe(false);\n});\n\nexport function isValidHostname(hostname: string) {\n const url = createUrlIfValid(`https://${hostname}`);\n if (!url) return false;\n return url.hostname === hostname;\n}\nundefined?.test(\"isValidHostname\", ({ expect }) => {\n // Test with valid hostnames\n expect(isValidHostname(\"example.com\")).toBe(true);\n expect(isValidHostname(\"localhost\")).toBe(true);\n expect(isValidHostname(\"sub.domain.example.com\")).toBe(true);\n expect(isValidHostname(\"127.0.0.1\")).toBe(true);\n\n // Test with invalid hostnames\n expect(isValidHostname(\"\")).toBe(false);\n expect(isValidHostname(\"example.com/path\")).toBe(false);\n expect(isValidHostname(\"https://example.com\")).toBe(false);\n expect(isValidHostname(\"example com\")).toBe(false);\n});\n\nexport function isLocalhost(urlOrString: string | URL) {\n const url = createUrlIfValid(urlOrString);\n if (!url) return false;\n if (url.hostname === \"localhost\" || url.hostname.endsWith(\".localhost\")) return true;\n if (url.hostname.match(/^127\\.\\d+\\.\\d+\\.\\d+$/)) return true;\n return false;\n}\nundefined?.test(\"isLocalhost\", ({ expect }) => {\n // Test with localhost URLs\n expect(isLocalhost(\"http://localhost\")).toBe(true);\n expect(isLocalhost(\"https://localhost:8080\")).toBe(true);\n expect(isLocalhost(\"http://sub.localhost\")).toBe(true);\n expect(isLocalhost(\"http://127.0.0.1\")).toBe(true);\n expect(isLocalhost(\"http://127.1.2.3\")).toBe(true);\n\n // Test with non-localhost URLs\n expect(isLocalhost(\"https://example.com\")).toBe(false);\n expect(isLocalhost(\"http://192.168.1.1\")).toBe(false);\n expect(isLocalhost(\"http://10.0.0.1\")).toBe(false);\n\n // Test with URL objects\n expect(isLocalhost(new URL(\"http://localhost\"))).toBe(true);\n expect(isLocalhost(new URL(\"https://example.com\"))).toBe(false);\n\n // Test with invalid URLs\n expect(isLocalhost(\"not a url\")).toBe(false);\n expect(isLocalhost(\"\")).toBe(false);\n});\n\nexport function isRelative(url: string) {\n const randomDomain = `${generateSecureRandomString()}.stack-auth.example.com`;\n const u = createUrlIfValid(url, `https://${randomDomain}`);\n if (!u) return false;\n if (u.host !== randomDomain) return false;\n if (u.protocol !== \"https:\") return false;\n return true;\n}\nundefined?.test(\"isRelative\", ({ expect }) => {\n // We can't easily mock generateSecureRandomString in this context\n // but we can still test the function's behavior\n\n // Test with relative URLs\n expect(isRelative(\"/\")).toBe(true);\n expect(isRelative(\"/path\")).toBe(true);\n expect(isRelative(\"/path?query=value#hash\")).toBe(true);\n\n // Test with absolute URLs\n expect(isRelative(\"https://example.com\")).toBe(false);\n expect(isRelative(\"http://example.com\")).toBe(false);\n expect(isRelative(\"//example.com\")).toBe(false);\n\n // Note: The implementation treats empty strings and invalid URLs as relative\n // This is because they can be resolved against a base URL\n expect(isRelative(\"\")).toBe(true);\n expect(isRelative(\"not a url\")).toBe(true);\n});\n\nexport function getRelativePart(url: URL) {\n return url.pathname + url.search + url.hash;\n}\nundefined?.test(\"getRelativePart\", ({ expect }) => {\n // Test with various URLs\n expect(getRelativePart(new URL(\"https://example.com\"))).toBe(\"/\");\n expect(getRelativePart(new URL(\"https://example.com/path\"))).toBe(\"/path\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value\"))).toBe(\"/path?query=value\");\n expect(getRelativePart(new URL(\"https://example.com/path#hash\"))).toBe(\"/path#hash\");\n expect(getRelativePart(new URL(\"https://example.com/path?query=value#hash\"))).toBe(\"/path?query=value#hash\");\n\n // Test with different domains but same paths\n const url1 = new URL(\"https://example.com/path?query=value#hash\");\n const url2 = new URL(\"https://different.com/path?query=value#hash\");\n expect(getRelativePart(url1)).toBe(getRelativePart(url2));\n});\n\n/**\n * A template literal tag that returns a URL.\n *\n * Any values passed are encoded.\n */\nexport function url(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): URL {\n return new URL(urlString(strings, ...values));\n}\nundefined?.test(\"url\", ({ expect }) => {\n // Test with no interpolation\n expect(url`https://example.com`).toBeInstanceOf(URL);\n expect(url`https://example.com`.href).toBe(\"https://example.com/\");\n\n // Test with string interpolation\n expect(url`https://example.com/${\"path\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}`.pathname).toBe(\"/path\");\n\n // Test with number interpolation\n expect(url`https://example.com/${42}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${42}`.pathname).toBe(\"/42\");\n\n // Test with boolean interpolation\n expect(url`https://example.com/${true}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${true}`.pathname).toBe(\"/true\");\n\n // Test with special characters in interpolation\n expect(url`https://example.com/${\"path with spaces\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path with spaces\"}`.pathname).toBe(\"/path%20with%20spaces\");\n\n // Test with multiple interpolations\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`).toBeInstanceOf(URL);\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.pathname).toBe(\"/path\");\n expect(url`https://example.com/${\"path\"}?query=${\"value\"}`.search).toBe(\"?query=value\");\n});\n\n\n/**\n * A template literal tag that returns a URL string.\n *\n * Any values passed are encoded.\n */\nexport function urlString(strings: TemplateStringsArray | readonly string[], ...values: (string|number|boolean)[]): string {\n return templateIdentity(strings, ...values.map(encodeURIComponent));\n}\nundefined?.test(\"urlString\", ({ expect }) => {\n // Test with no interpolation\n expect(urlString`https://example.com`).toBe(\"https://example.com\");\n\n // Test with string interpolation\n expect(urlString`https://example.com/${\"path\"}`).toBe(\"https://example.com/path\");\n\n // Test with number interpolation\n expect(urlString`https://example.com/${42}`).toBe(\"https://example.com/42\");\n\n // Test with boolean interpolation\n expect(urlString`https://example.com/${true}`).toBe(\"https://example.com/true\");\n\n // Test with special characters in interpolation\n expect(urlString`https://example.com/${\"path with spaces\"}`).toBe(\"https://example.com/path%20with%20spaces\");\n expect(urlString`https://example.com/${\"?&=\"}`).toBe(\"https://example.com/%3F%26%3D\");\n\n // Test with multiple interpolations\n expect(urlString`https://example.com/${\"path\"}?query=${\"value\"}`).toBe(\"https://example.com/path?query=value\");\n expect(urlString`https://example.com/${\"path\"}?query=${\"value with spaces\"}`).toBe(\"https://example.com/path?query=value%20with%20spaces\");\n});\n\n\n"],"mappings":";AAAA,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAE1B,SAAS,oBAAoB,MAAyC;AAC3E,MAAI;AACF,WAAO,IAAI,IAAI,GAAG,IAAI;AAAA,EACxB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAaO,SAAS,WAAWA,MAAa;AACtC,SAAO,CAAC,CAAC,iBAAiBA,IAAG;AAC/B;AAaO,SAAS,gBAAgB,UAAkB;AAChD,QAAMA,OAAM,iBAAiB,WAAW,QAAQ,EAAE;AAClD,MAAI,CAACA,KAAK,QAAO;AACjB,SAAOA,KAAI,aAAa;AAC1B;AAeO,SAAS,YAAY,aAA2B;AACrD,QAAMA,OAAM,iBAAiB,WAAW;AACxC,MAAI,CAACA,KAAK,QAAO;AACjB,MAAIA,KAAI,aAAa,eAAeA,KAAI,SAAS,SAAS,YAAY,EAAG,QAAO;AAChF,MAAIA,KAAI,SAAS,MAAM,sBAAsB,EAAG,QAAO;AACvD,SAAO;AACT;AAuBO,SAAS,WAAWA,MAAa;AACtC,QAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,QAAM,IAAI,iBAAiBA,MAAK,WAAW,YAAY,EAAE;AACzD,MAAI,CAAC,EAAG,QAAO;AACf,MAAI,EAAE,SAAS,aAAc,QAAO;AACpC,MAAI,EAAE,aAAa,SAAU,QAAO;AACpC,SAAO;AACT;AAqBO,SAAS,gBAAgBA,MAAU;AACxC,SAAOA,KAAI,WAAWA,KAAI,SAASA,KAAI;AACzC;AAoBO,SAAS,IAAI,YAAsD,QAAwC;AAChH,SAAO,IAAI,IAAI,UAAU,SAAS,GAAG,MAAM,CAAC;AAC9C;AAkCO,SAAS,UAAU,YAAsD,QAA2C;AACzH,SAAO,iBAAiB,SAAS,GAAG,OAAO,IAAI,kBAAkB,CAAC;AACpE;","names":["url"]}
@@ -0,0 +1,16 @@
1
+ // src/utils/uuids.tsx
2
+ import { generateRandomValues } from "./crypto";
3
+ function generateUuid() {
4
+ return "10000000-1000-4000-8000-100000000000".replace(
5
+ /[018]/g,
6
+ (c) => (+c ^ generateRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
7
+ );
8
+ }
9
+ function isUuid(str) {
10
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(str);
11
+ }
12
+ export {
13
+ generateUuid,
14
+ isUuid
15
+ };
16
+ //# sourceMappingURL=uuids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/uuids.tsx"],"sourcesContent":["import { generateRandomValues } from \"./crypto\";\n\nexport function generateUuid() {\n // crypto.randomUuid is not supported in all browsers, so this is a polyfill\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (+c ^ generateRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)\n );\n}\nundefined?.test(\"generateUuid\", ({ expect }) => {\n // Test that the function returns a valid UUID\n const uuid = generateUuid();\n expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);\n\n // Test that multiple calls generate different UUIDs\n const uuid2 = generateUuid();\n expect(uuid).not.toBe(uuid2);\n\n // Test that the UUID is version 4 (random)\n expect(uuid.charAt(14)).toBe('4');\n\n // Test that the UUID has the correct variant (8, 9, a, or b in position 19)\n expect('89ab').toContain(uuid.charAt(19));\n});\n\nexport function isUuid(str: string) {\n return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(str);\n}\nundefined?.test(\"isUuid\", ({ expect }) => {\n // Test with valid UUIDs\n expect(isUuid(\"123e4567-e89b-42d3-a456-426614174000\")).toBe(true);\n expect(isUuid(\"123e4567-e89b-42d3-8456-426614174000\")).toBe(true);\n expect(isUuid(\"123e4567-e89b-42d3-9456-426614174000\")).toBe(true);\n expect(isUuid(\"123e4567-e89b-42d3-a456-426614174000\")).toBe(true);\n expect(isUuid(\"123e4567-e89b-42d3-b456-426614174000\")).toBe(true);\n\n // Test with invalid UUIDs\n expect(isUuid(\"\")).toBe(false);\n expect(isUuid(\"not-a-uuid\")).toBe(false);\n expect(isUuid(\"123e4567-e89b-12d3-a456-426614174000\")).toBe(false); // Wrong version (not 4)\n expect(isUuid(\"123e4567-e89b-42d3-c456-426614174000\")).toBe(false); // Wrong variant (not 8, 9, a, or b)\n expect(isUuid(\"123e4567-e89b-42d3-a456-42661417400\")).toBe(false); // Too short\n expect(isUuid(\"123e4567-e89b-42d3-a456-4266141740000\")).toBe(false); // Too long\n expect(isUuid(\"123e4567-e89b-42d3-a456_426614174000\")).toBe(false); // Wrong format (underscore instead of dash)\n\n // Test with uppercase letters (should fail as UUID should be lowercase)\n expect(isUuid(\"123E4567-E89B-42D3-A456-426614174000\")).toBe(false);\n});\n"],"mappings":";AAAA,SAAS,4BAA4B;AAE9B,SAAS,eAAe;AAE7B,SAAO,uCAAuC;AAAA,IAAQ;AAAA,IAAU,QAC7D,CAAC,IAAI,qBAAqB,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,SAAS,EAAE;AAAA,EAC9E;AACF;AAiBO,SAAS,OAAO,KAAa;AAClC,SAAO,wEAAwE,KAAK,GAAG;AACzF;","names":[]}
@@ -0,0 +1 @@
1
+ import '@simplewebauthn/types';
@@ -0,0 +1 @@
1
+ import '@simplewebauthn/types';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=global.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ import '../crud.cjs';
2
+ import { KnownErrors } from '../known-errors.cjs';
3
+ import 'yup';
4
+ import '../utils/types.cjs';
5
+ import '../utils/errors.cjs';
6
+ import '../utils/json.cjs';
7
+ import '../utils/results.cjs';
8
+
9
+ declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
10
+
11
+ export { getPasswordError };
@@ -1,2 +1,11 @@
1
- import { KnownErrors } from "..";
2
- export declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
1
+ import '../crud.js';
2
+ import { KnownErrors } from '../known-errors.js';
3
+ import 'yup';
4
+ import '../utils/types.js';
5
+ import '../utils/errors.js';
6
+ import '../utils/json.js';
7
+ import '../utils/results.js';
8
+
9
+ declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
10
+
11
+ export { getPasswordError };
@@ -1,12 +1,42 @@
1
- import { KnownErrors } from "..";
2
- const minLength = 8;
3
- const maxLength = 70;
4
- export function getPasswordError(password) {
5
- if (password.length < minLength) {
6
- return new KnownErrors.PasswordTooShort(minLength);
7
- }
8
- if (password.length > maxLength) {
9
- return new KnownErrors.PasswordTooLong(maxLength);
10
- }
11
- return undefined;
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/helpers/password.ts
21
+ var password_exports = {};
22
+ __export(password_exports, {
23
+ getPasswordError: () => getPasswordError
24
+ });
25
+ module.exports = __toCommonJS(password_exports);
26
+ var import__ = require("..");
27
+ var minLength = 8;
28
+ var maxLength = 70;
29
+ function getPasswordError(password) {
30
+ if (password.length < minLength) {
31
+ return new import__.KnownErrors.PasswordTooShort(minLength);
32
+ }
33
+ if (password.length > maxLength) {
34
+ return new import__.KnownErrors.PasswordTooLong(maxLength);
35
+ }
36
+ return void 0;
12
37
  }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ getPasswordError
41
+ });
42
+ //# sourceMappingURL=password.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/helpers/password.ts"],"sourcesContent":["import { KnownErrors } from \"..\";\n\nconst minLength = 8;\nconst maxLength = 70;\n\nexport function getPasswordError(password: string): KnownErrors[\"PasswordRequirementsNotMet\"] | undefined {\n if (password.length < minLength) {\n return new KnownErrors.PasswordTooShort(minLength);\n }\n\n if (password.length > maxLength) {\n return new KnownErrors.PasswordTooLong(maxLength);\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAA4B;AAE5B,IAAM,YAAY;AAClB,IAAM,YAAY;AAEX,SAAS,iBAAiB,UAAyE;AACxG,MAAI,SAAS,SAAS,WAAW;AAC/B,WAAO,IAAI,qBAAY,iBAAiB,SAAS;AAAA,EACnD;AAEA,MAAI,SAAS,SAAS,WAAW;AAC/B,WAAO,IAAI,qBAAY,gBAAgB,SAAS;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { ProjectsCrud } from '../interface/crud/projects.cjs';
2
+ import '../crud.cjs';
3
+ import 'yup';
4
+ import '../utils/types.cjs';
5
+
6
+ type ProductionModeError = {
7
+ message: string;
8
+ relativeFixUrl: `/${string}`;
9
+ };
10
+ declare function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]): ProductionModeError[];
11
+
12
+ export { type ProductionModeError, getProductionModeErrors };
@@ -1,6 +1,12 @@
1
- import { ProjectsCrud } from "../interface/crud/projects";
2
- export type ProductionModeError = {
1
+ import { ProjectsCrud } from '../interface/crud/projects.js';
2
+ import '../crud.js';
3
+ import 'yup';
4
+ import '../utils/types.js';
5
+
6
+ type ProductionModeError = {
3
7
  message: string;
4
8
  relativeFixUrl: `/${string}`;
5
9
  };
6
- export declare function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]): ProductionModeError[];
10
+ declare function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]): ProductionModeError[];
11
+
12
+ export { type ProductionModeError, getProductionModeErrors };
@@ -1,48 +1,75 @@
1
- import { StackAssertionError, captureError } from "../utils/errors";
2
- import { isLocalhost } from "../utils/urls";
3
- export function getProductionModeErrors(project) {
4
- const errors = [];
5
- const domainsFixUrl = `/projects/${project.id}/domains`;
6
- if (project.config.allow_localhost) {
7
- errors.push({
8
- message: "Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings",
9
- relativeFixUrl: domainsFixUrl,
10
- });
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/helpers/production-mode.ts
21
+ var production_mode_exports = {};
22
+ __export(production_mode_exports, {
23
+ getProductionModeErrors: () => getProductionModeErrors
24
+ });
25
+ module.exports = __toCommonJS(production_mode_exports);
26
+ var import_errors = require("../utils/errors");
27
+ var import_urls = require("../utils/urls");
28
+ function getProductionModeErrors(project) {
29
+ const errors = [];
30
+ const domainsFixUrl = `/projects/${project.id}/domains`;
31
+ if (project.config.allow_localhost) {
32
+ errors.push({
33
+ message: "Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings",
34
+ relativeFixUrl: domainsFixUrl
35
+ });
36
+ }
37
+ for (const { domain } of project.config.domains) {
38
+ let url;
39
+ try {
40
+ url = new URL(domain);
41
+ } catch (e) {
42
+ (0, import_errors.captureError)("production-mode-domain-not-valid", new import_errors.StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", {
43
+ domain,
44
+ projectId: project
45
+ }));
46
+ errors.push({
47
+ message: "Trusted domain is not a valid URL: " + domain,
48
+ relativeFixUrl: domainsFixUrl
49
+ });
50
+ continue;
11
51
  }
12
- for (const { domain } of project.config.domains) {
13
- let url;
14
- try {
15
- url = new URL(domain);
16
- }
17
- catch (e) {
18
- captureError("production-mode-domain-not-valid", new StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", {
19
- domain,
20
- projectId: project
21
- }));
22
- errors.push({
23
- message: "Trusted domain is not a valid URL: " + domain,
24
- relativeFixUrl: domainsFixUrl,
25
- });
26
- continue;
27
- }
28
- if (isLocalhost(url)) {
29
- errors.push({
30
- message: "Localhost domains are not allowed to be trusted in production mode: " + domain,
31
- relativeFixUrl: domainsFixUrl,
32
- });
33
- }
34
- else if (url.hostname.match(/^\d+(\.\d+)*$/)) {
35
- errors.push({
36
- message: "Direct IPs are not valid for trusted domains in production mode: " + domain,
37
- relativeFixUrl: domainsFixUrl,
38
- });
39
- }
40
- else if (url.protocol !== "https:") {
41
- errors.push({
42
- message: "Trusted domains should be HTTPS: " + domain,
43
- relativeFixUrl: domainsFixUrl,
44
- });
45
- }
52
+ if ((0, import_urls.isLocalhost)(url)) {
53
+ errors.push({
54
+ message: "Localhost domains are not allowed to be trusted in production mode: " + domain,
55
+ relativeFixUrl: domainsFixUrl
56
+ });
57
+ } else if (url.hostname.match(/^\d+(\.\d+)*$/)) {
58
+ errors.push({
59
+ message: "Direct IPs are not valid for trusted domains in production mode: " + domain,
60
+ relativeFixUrl: domainsFixUrl
61
+ });
62
+ } else if (url.protocol !== "https:") {
63
+ errors.push({
64
+ message: "Trusted domains should be HTTPS: " + domain,
65
+ relativeFixUrl: domainsFixUrl
66
+ });
46
67
  }
47
- return errors;
68
+ }
69
+ return errors;
48
70
  }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ getProductionModeErrors
74
+ });
75
+ //# sourceMappingURL=production-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/helpers/production-mode.ts"],"sourcesContent":["import { ProjectsCrud } from \"../interface/crud/projects\";\nimport { StackAssertionError, captureError } from \"../utils/errors\";\nimport { isLocalhost } from \"../utils/urls\";\n\nexport type ProductionModeError = {\n message: string,\n relativeFixUrl: `/${string}`,\n};\n\nexport function getProductionModeErrors(project: ProjectsCrud[\"Admin\"][\"Read\"]): ProductionModeError[] {\n const errors: ProductionModeError[] = [];\n const domainsFixUrl = `/projects/${project.id}/domains` as const;\n\n if (project.config.allow_localhost) {\n errors.push({\n message: \"Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings\",\n relativeFixUrl: domainsFixUrl,\n });\n }\n\n for (const { domain } of project.config.domains) {\n let url;\n try {\n url = new URL(domain);\n } catch (e) {\n captureError(\"production-mode-domain-not-valid\", new StackAssertionError(\"Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place\", {\n domain,\n projectId: project\n }));\n errors.push({\n message: \"Trusted domain is not a valid URL: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n continue;\n }\n\n if (isLocalhost(url)) {\n errors.push({\n message: \"Localhost domains are not allowed to be trusted in production mode: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n } else if (url.hostname.match(/^\\d+(\\.\\d+)*$/)) {\n errors.push({\n message: \"Direct IPs are not valid for trusted domains in production mode: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n } else if (url.protocol !== \"https:\") {\n errors.push({\n message: \"Trusted domains should be HTTPS: \" + domain,\n relativeFixUrl: domainsFixUrl,\n });\n }\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAkD;AAClD,kBAA4B;AAOrB,SAAS,wBAAwB,SAA+D;AACrG,QAAM,SAAgC,CAAC;AACvC,QAAM,gBAAgB,aAAa,QAAQ,EAAE;AAE7C,MAAI,QAAQ,OAAO,iBAAiB;AAClC,WAAO,KAAK;AAAA,MACV,SAAS;AAAA,MACT,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,aAAW,EAAE,OAAO,KAAK,QAAQ,OAAO,SAAS;AAC/C,QAAI;AACJ,QAAI;AACF,YAAM,IAAI,IAAI,MAAM;AAAA,IACtB,SAAS,GAAG;AACV,sCAAa,oCAAoC,IAAI,kCAAoB,2GAA2G;AAAA,QAClL;AAAA,QACA,WAAW;AAAA,MACb,CAAC,CAAC;AACF,aAAO,KAAK;AAAA,QACV,SAAS,wCAAwC;AAAA,QACjD,gBAAgB;AAAA,MAClB,CAAC;AACD;AAAA,IACF;AAEA,YAAI,yBAAY,GAAG,GAAG;AACpB,aAAO,KAAK;AAAA,QACV,SAAS,yEAAyE;AAAA,QAClF,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,WAAW,IAAI,SAAS,MAAM,eAAe,GAAG;AAC9C,aAAO,KAAK;AAAA,QACV,SAAS,sEAAsE;AAAA,QAC/E,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,WAAW,IAAI,aAAa,UAAU;AACpC,aAAO,KAAK;AAAA,QACV,SAAS,sCAAsC;AAAA,QAC/C,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+
3
+ declare function useAsyncCallback<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean, error: unknown | undefined];
4
+ declare function useAsyncCallbackWithLoggedError<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean];
5
+
6
+ export { useAsyncCallback, useAsyncCallbackWithLoggedError };
@@ -1,3 +1,6 @@
1
- import React from "react";
2
- export declare function useAsyncCallback<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean, error: unknown | undefined];
3
- export declare function useAsyncCallbackWithLoggedError<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean];
1
+ import React from 'react';
2
+
3
+ declare function useAsyncCallback<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean, error: unknown | undefined];
4
+ declare function useAsyncCallbackWithLoggedError<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean];
5
+
6
+ export { useAsyncCallback, useAsyncCallbackWithLoggedError };
@@ -1,32 +1,74 @@
1
- import React from "react";
2
- import { captureError } from "../utils/errors";
3
- export function useAsyncCallback(callback, deps) {
4
- const [error, setError] = React.useState(undefined);
5
- const [loadingCount, setLoadingCount] = React.useState(0);
6
- const cb = React.useCallback(async (...args) => {
7
- setLoadingCount((c) => c + 1);
8
- try {
9
- return await callback(...args);
10
- }
11
- catch (e) {
12
- setError(e);
13
- throw e;
14
- }
15
- finally {
16
- setLoadingCount((c) => c - 1);
17
- }
18
- }, deps);
19
- return [cb, loadingCount > 0, error];
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/hooks/use-async-callback.tsx
31
+ var use_async_callback_exports = {};
32
+ __export(use_async_callback_exports, {
33
+ useAsyncCallback: () => useAsyncCallback,
34
+ useAsyncCallbackWithLoggedError: () => useAsyncCallbackWithLoggedError
35
+ });
36
+ module.exports = __toCommonJS(use_async_callback_exports);
37
+ var import_react = __toESM(require("react"), 1);
38
+ var import_errors = require("../utils/errors");
39
+ function useAsyncCallback(callback, deps) {
40
+ const [error, setError] = import_react.default.useState(void 0);
41
+ const [loadingCount, setLoadingCount] = import_react.default.useState(0);
42
+ const cb = import_react.default.useCallback(
43
+ async (...args) => {
44
+ setLoadingCount((c) => c + 1);
45
+ try {
46
+ return await callback(...args);
47
+ } catch (e) {
48
+ setError(e);
49
+ throw e;
50
+ } finally {
51
+ setLoadingCount((c) => c - 1);
52
+ }
53
+ },
54
+ deps
55
+ );
56
+ return [cb, loadingCount > 0, error];
20
57
  }
21
- export function useAsyncCallbackWithLoggedError(callback, deps) {
22
- const [newCallback, loading] = useAsyncCallback(async (...args) => {
23
- try {
24
- return await callback(...args);
25
- }
26
- catch (e) {
27
- captureError("async-callback", e);
28
- throw e;
29
- }
30
- }, deps);
31
- return [newCallback, loading];
58
+ function useAsyncCallbackWithLoggedError(callback, deps) {
59
+ const [newCallback, loading] = useAsyncCallback(async (...args) => {
60
+ try {
61
+ return await callback(...args);
62
+ } catch (e) {
63
+ (0, import_errors.captureError)("async-callback", e);
64
+ throw e;
65
+ }
66
+ }, deps);
67
+ return [newCallback, loading];
32
68
  }
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ useAsyncCallback,
72
+ useAsyncCallbackWithLoggedError
73
+ });
74
+ //# sourceMappingURL=use-async-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-async-callback.tsx"],"sourcesContent":["import React from \"react\";\nimport { captureError } from \"../utils/errors\";\n\nexport function useAsyncCallback<A extends any[], R>(\n callback: (...args: A) => Promise<R>,\n deps: React.DependencyList\n): [cb: (...args: A) => Promise<R>, loading: boolean, error: unknown | undefined] {\n const [error, setError] = React.useState<unknown | undefined>(undefined);\n const [loadingCount, setLoadingCount] = React.useState(0);\n\n const cb = React.useCallback(\n async (...args: A) => {\n setLoadingCount((c) => c + 1);\n try {\n return await callback(...args);\n } catch (e) {\n setError(e);\n throw e;\n } finally {\n setLoadingCount((c) => c - 1);\n }\n },\n deps,\n );\n\n return [cb, loadingCount > 0, error];\n}\n\nexport function useAsyncCallbackWithLoggedError<A extends any[], R>(\n callback: (...args: A) => Promise<R>,\n deps: React.DependencyList\n): [cb: (...args: A) => Promise<R>, loading: boolean] {\n const [newCallback, loading] = useAsyncCallback<A, R>(async (...args) => {\n try {\n return await callback(...args);\n } catch (e) {\n captureError(\"async-callback\", e);\n throw e;\n }\n }, deps);\n\n return [newCallback, loading];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAA6B;AAEtB,SAAS,iBACd,UACA,MACgF;AAChF,QAAM,CAAC,OAAO,QAAQ,IAAI,aAAAA,QAAM,SAA8B,MAAS;AACvE,QAAM,CAAC,cAAc,eAAe,IAAI,aAAAA,QAAM,SAAS,CAAC;AAExD,QAAM,KAAK,aAAAA,QAAM;AAAA,IACf,UAAU,SAAY;AACpB,sBAAgB,CAAC,MAAM,IAAI,CAAC;AAC5B,UAAI;AACF,eAAO,MAAM,SAAS,GAAG,IAAI;AAAA,MAC/B,SAAS,GAAG;AACV,iBAAS,CAAC;AACV,cAAM;AAAA,MACR,UAAE;AACA,wBAAgB,CAAC,MAAM,IAAI,CAAC;AAAA,MAC9B;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,SAAO,CAAC,IAAI,eAAe,GAAG,KAAK;AACrC;AAEO,SAAS,gCACd,UACA,MACoD;AACpD,QAAM,CAAC,aAAa,OAAO,IAAI,iBAAuB,UAAU,SAAS;AACvE,QAAI;AACF,aAAO,MAAM,SAAS,GAAG,IAAI;AAAA,IAC/B,SAAS,GAAG;AACV,sCAAa,kBAAkB,CAAC;AAChC,YAAM;AAAA,IACR;AAAA,EACF,GAAG,IAAI;AAEP,SAAO,CAAC,aAAa,OAAO;AAC9B;","names":["React"]}
@@ -0,0 +1,7 @@
1
+ import { AsyncResult } from '../utils/results.cjs';
2
+
3
+ declare function useAsyncExternalStore<T>(subscribe: (callback: (t: T) => void) => (() => void)): AsyncResult<T, never> & {
4
+ status: "ok" | "pending";
5
+ };
6
+
7
+ export { useAsyncExternalStore };
@@ -1,4 +1,7 @@
1
- import { AsyncResult } from "../utils/results";
2
- export declare function useAsyncExternalStore<T>(subscribe: (callback: (t: T) => void) => (() => void)): AsyncResult<T, never> & {
1
+ import { AsyncResult } from '../utils/results.js';
2
+
3
+ declare function useAsyncExternalStore<T>(subscribe: (callback: (t: T) => void) => (() => void)): AsyncResult<T, never> & {
3
4
  status: "ok" | "pending";
4
5
  };
6
+
7
+ export { useAsyncExternalStore };
@@ -1,20 +1,48 @@
1
- import { useEffect, useState } from "react";
2
- import { AsyncResult } from "../utils/results";
3
- export function useAsyncExternalStore(subscribe) {
4
- // sure, the "sync" in useSyncExternalStore refers to "synchronize a store" and not "sync/async", but it's too good of a name to pass up on
5
- const [isAvailable, setIsAvailable] = useState(false);
6
- const [value, setValue] = useState();
7
- useEffect(() => {
8
- const unsubscribe = subscribe((value) => {
9
- setValue(() => value);
10
- setIsAvailable(() => true);
11
- });
12
- return unsubscribe;
13
- }, [subscribe]);
14
- if (isAvailable) {
15
- return AsyncResult.ok(value);
16
- }
17
- else {
18
- return AsyncResult.pending();
19
- }
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/hooks/use-async-external-store.tsx
21
+ var use_async_external_store_exports = {};
22
+ __export(use_async_external_store_exports, {
23
+ useAsyncExternalStore: () => useAsyncExternalStore
24
+ });
25
+ module.exports = __toCommonJS(use_async_external_store_exports);
26
+ var import_react = require("react");
27
+ var import_results = require("../utils/results");
28
+ function useAsyncExternalStore(subscribe) {
29
+ const [isAvailable, setIsAvailable] = (0, import_react.useState)(false);
30
+ const [value, setValue] = (0, import_react.useState)();
31
+ (0, import_react.useEffect)(() => {
32
+ const unsubscribe = subscribe((value2) => {
33
+ setValue(() => value2);
34
+ setIsAvailable(() => true);
35
+ });
36
+ return unsubscribe;
37
+ }, [subscribe]);
38
+ if (isAvailable) {
39
+ return import_results.AsyncResult.ok(value);
40
+ } else {
41
+ return import_results.AsyncResult.pending();
42
+ }
20
43
  }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ useAsyncExternalStore
47
+ });
48
+ //# sourceMappingURL=use-async-external-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-async-external-store.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { AsyncResult } from \"../utils/results\";\n\nexport function useAsyncExternalStore<T>(\n subscribe: (callback: (t: T) => void) => (() => void),\n): AsyncResult<T, never> & { status: \"ok\" | \"pending\" } {\n // sure, the \"sync\" in useSyncExternalStore refers to \"synchronize a store\" and not \"sync/async\", but it's too good of a name to pass up on\n\n const [isAvailable, setIsAvailable] = useState(false);\n const [value, setValue] = useState<T>();\n useEffect(() => {\n const unsubscribe = subscribe((value: T) => {\n setValue(() => value);\n setIsAvailable(() => true);\n });\n return unsubscribe;\n }, [subscribe]);\n\n if (isAvailable) {\n return AsyncResult.ok(value as T);\n } else {\n return AsyncResult.pending();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AACpC,qBAA4B;AAErB,SAAS,sBACd,WACsD;AAGtD,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAY;AACtC,8BAAU,MAAM;AACd,UAAM,cAAc,UAAU,CAACA,WAAa;AAC1C,eAAS,MAAMA,MAAK;AACpB,qBAAe,MAAM,IAAI;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,SAAS,CAAC;AAEd,MAAI,aAAa;AACf,WAAO,2BAAY,GAAG,KAAU;AAAA,EAClC,OAAO;AACL,WAAO,2BAAY,QAAQ;AAAA,EAC7B;AACF;","names":["value"]}
@@ -0,0 +1,3 @@
1
+ declare const useHash: () => string;
2
+
3
+ export { useHash };
@@ -1 +1,3 @@
1
- export declare const useHash: () => string;
1
+ declare const useHash: () => string;
2
+
3
+ export { useHash };