mulguard 1.1.7 → 1.1.8

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 (546) hide show
  1. package/README.md +21 -582
  2. package/adapters.d.ts +2 -0
  3. package/adapters.d.ts.map +1 -0
  4. package/adapters.js +1 -0
  5. package/index.d.ts +329 -0
  6. package/index.d.ts.map +1 -0
  7. package/index.js +145 -0
  8. package/jwt.d.ts +9 -0
  9. package/jwt.d.ts.map +1 -0
  10. package/jwt.js +8 -0
  11. package/lib/actions.d.ts +13 -0
  12. package/lib/actions.d.ts.map +1 -0
  13. package/lib/actions.js +86 -0
  14. package/lib/client.d.ts +104 -0
  15. package/lib/client.d.ts.map +1 -0
  16. package/lib/client.js +95 -0
  17. package/lib/env.d.ts +12 -0
  18. package/lib/env.d.ts.map +1 -0
  19. package/lib/env.js +38 -0
  20. package/lib/index.d.ts +56 -0
  21. package/lib/index.d.ts.map +1 -0
  22. package/lib/index.js +187 -0
  23. package/lib/types.d.ts +24 -0
  24. package/lib/types.d.ts.map +1 -0
  25. package/lib/types.js +1 -0
  26. package/middleware.d.ts +9 -0
  27. package/middleware.d.ts.map +1 -0
  28. package/middleware.js +12 -0
  29. package/next.d.ts +9 -0
  30. package/next.d.ts.map +1 -0
  31. package/next.js +12 -0
  32. package/package.json +117 -126
  33. package/providers/42-school.d.ts +3 -0
  34. package/providers/42-school.d.ts.map +1 -0
  35. package/providers/42-school.js +2 -0
  36. package/providers/apple.d.ts +3 -0
  37. package/providers/apple.d.ts.map +1 -0
  38. package/providers/apple.js +2 -0
  39. package/providers/asgardeo.d.ts +3 -0
  40. package/providers/asgardeo.d.ts.map +1 -0
  41. package/providers/asgardeo.js +2 -0
  42. package/providers/atlassian.d.ts +3 -0
  43. package/providers/atlassian.d.ts.map +1 -0
  44. package/providers/atlassian.js +2 -0
  45. package/providers/auth0.d.ts +3 -0
  46. package/providers/auth0.d.ts.map +1 -0
  47. package/providers/auth0.js +2 -0
  48. package/providers/authentik.d.ts +3 -0
  49. package/providers/authentik.d.ts.map +1 -0
  50. package/providers/authentik.js +2 -0
  51. package/providers/azure-ad-b2c.d.ts +3 -0
  52. package/providers/azure-ad-b2c.d.ts.map +1 -0
  53. package/providers/azure-ad-b2c.js +2 -0
  54. package/providers/azure-ad.d.ts +3 -0
  55. package/providers/azure-ad.d.ts.map +1 -0
  56. package/providers/azure-ad.js +2 -0
  57. package/providers/azure-devops.d.ts +3 -0
  58. package/providers/azure-devops.d.ts.map +1 -0
  59. package/providers/azure-devops.js +2 -0
  60. package/providers/bankid-no.d.ts +3 -0
  61. package/providers/bankid-no.d.ts.map +1 -0
  62. package/providers/bankid-no.js +2 -0
  63. package/providers/battlenet.d.ts +3 -0
  64. package/providers/battlenet.d.ts.map +1 -0
  65. package/providers/battlenet.js +2 -0
  66. package/providers/beyondidentity.d.ts +3 -0
  67. package/providers/beyondidentity.d.ts.map +1 -0
  68. package/providers/beyondidentity.js +2 -0
  69. package/providers/bitbucket.d.ts +3 -0
  70. package/providers/bitbucket.d.ts.map +1 -0
  71. package/providers/bitbucket.js +2 -0
  72. package/providers/box.d.ts +3 -0
  73. package/providers/box.d.ts.map +1 -0
  74. package/providers/box.js +2 -0
  75. package/providers/boxyhq-saml.d.ts +3 -0
  76. package/providers/boxyhq-saml.d.ts.map +1 -0
  77. package/providers/boxyhq-saml.js +2 -0
  78. package/providers/bungie.d.ts +3 -0
  79. package/providers/bungie.d.ts.map +1 -0
  80. package/providers/bungie.js +2 -0
  81. package/providers/click-up.d.ts +3 -0
  82. package/providers/click-up.d.ts.map +1 -0
  83. package/providers/click-up.js +2 -0
  84. package/providers/cognito.d.ts +3 -0
  85. package/providers/cognito.d.ts.map +1 -0
  86. package/providers/cognito.js +2 -0
  87. package/providers/coinbase.d.ts +3 -0
  88. package/providers/coinbase.d.ts.map +1 -0
  89. package/providers/coinbase.js +2 -0
  90. package/providers/concept2.d.ts +3 -0
  91. package/providers/concept2.d.ts.map +1 -0
  92. package/providers/concept2.js +2 -0
  93. package/providers/credentials.d.ts +3 -0
  94. package/providers/credentials.d.ts.map +1 -0
  95. package/providers/credentials.js +2 -0
  96. package/providers/descope.d.ts +3 -0
  97. package/providers/descope.d.ts.map +1 -0
  98. package/providers/descope.js +2 -0
  99. package/providers/discord.d.ts +3 -0
  100. package/providers/discord.d.ts.map +1 -0
  101. package/providers/discord.js +2 -0
  102. package/providers/dribbble.d.ts +3 -0
  103. package/providers/dribbble.d.ts.map +1 -0
  104. package/providers/dribbble.js +2 -0
  105. package/providers/dropbox.d.ts +3 -0
  106. package/providers/dropbox.d.ts.map +1 -0
  107. package/providers/dropbox.js +2 -0
  108. package/providers/duende-identity-server6.d.ts +3 -0
  109. package/providers/duende-identity-server6.d.ts.map +1 -0
  110. package/providers/duende-identity-server6.js +2 -0
  111. package/providers/email.d.ts +3 -0
  112. package/providers/email.d.ts.map +1 -0
  113. package/providers/email.js +2 -0
  114. package/providers/eventbrite.d.ts +3 -0
  115. package/providers/eventbrite.d.ts.map +1 -0
  116. package/providers/eventbrite.js +2 -0
  117. package/providers/eveonline.d.ts +3 -0
  118. package/providers/eveonline.d.ts.map +1 -0
  119. package/providers/eveonline.js +2 -0
  120. package/providers/facebook.d.ts +3 -0
  121. package/providers/facebook.d.ts.map +1 -0
  122. package/providers/facebook.js +2 -0
  123. package/providers/faceit.d.ts +3 -0
  124. package/providers/faceit.d.ts.map +1 -0
  125. package/providers/faceit.js +2 -0
  126. package/providers/figma.d.ts +3 -0
  127. package/providers/figma.d.ts.map +1 -0
  128. package/providers/figma.js +2 -0
  129. package/providers/forwardemail.d.ts +3 -0
  130. package/providers/forwardemail.d.ts.map +1 -0
  131. package/providers/forwardemail.js +2 -0
  132. package/providers/foursquare.d.ts +3 -0
  133. package/providers/foursquare.d.ts.map +1 -0
  134. package/providers/foursquare.js +2 -0
  135. package/providers/freshbooks.d.ts +3 -0
  136. package/providers/freshbooks.d.ts.map +1 -0
  137. package/providers/freshbooks.js +2 -0
  138. package/providers/frontegg.d.ts +3 -0
  139. package/providers/frontegg.d.ts.map +1 -0
  140. package/providers/frontegg.js +2 -0
  141. package/providers/fusionauth.d.ts +3 -0
  142. package/providers/fusionauth.d.ts.map +1 -0
  143. package/providers/fusionauth.js +2 -0
  144. package/providers/github.d.ts +3 -0
  145. package/providers/github.d.ts.map +1 -0
  146. package/providers/github.js +2 -0
  147. package/providers/gitlab.d.ts +3 -0
  148. package/providers/gitlab.d.ts.map +1 -0
  149. package/providers/gitlab.js +2 -0
  150. package/providers/google.d.ts +3 -0
  151. package/providers/google.d.ts.map +1 -0
  152. package/providers/google.js +2 -0
  153. package/providers/hubspot.d.ts +3 -0
  154. package/providers/hubspot.d.ts.map +1 -0
  155. package/providers/hubspot.js +2 -0
  156. package/providers/huggingface.d.ts +3 -0
  157. package/providers/huggingface.d.ts.map +1 -0
  158. package/providers/huggingface.js +2 -0
  159. package/providers/identity-server4.d.ts +3 -0
  160. package/providers/identity-server4.d.ts.map +1 -0
  161. package/providers/identity-server4.js +2 -0
  162. package/providers/index.d.ts +2 -0
  163. package/providers/index.d.ts.map +1 -0
  164. package/providers/index.js +1 -0
  165. package/providers/instagram.d.ts +3 -0
  166. package/providers/instagram.d.ts.map +1 -0
  167. package/providers/instagram.js +2 -0
  168. package/providers/kakao.d.ts +3 -0
  169. package/providers/kakao.d.ts.map +1 -0
  170. package/providers/kakao.js +2 -0
  171. package/providers/keycloak.d.ts +3 -0
  172. package/providers/keycloak.d.ts.map +1 -0
  173. package/providers/keycloak.js +2 -0
  174. package/providers/kinde.d.ts +3 -0
  175. package/providers/kinde.d.ts.map +1 -0
  176. package/providers/kinde.js +2 -0
  177. package/providers/line.d.ts +3 -0
  178. package/providers/line.d.ts.map +1 -0
  179. package/providers/line.js +2 -0
  180. package/providers/linkedin.d.ts +3 -0
  181. package/providers/linkedin.d.ts.map +1 -0
  182. package/providers/linkedin.js +2 -0
  183. package/providers/logto.d.ts +3 -0
  184. package/providers/logto.d.ts.map +1 -0
  185. package/providers/logto.js +2 -0
  186. package/providers/loops.d.ts +3 -0
  187. package/providers/loops.d.ts.map +1 -0
  188. package/providers/loops.js +2 -0
  189. package/providers/mailchimp.d.ts +3 -0
  190. package/providers/mailchimp.d.ts.map +1 -0
  191. package/providers/mailchimp.js +2 -0
  192. package/providers/mailgun.d.ts +3 -0
  193. package/providers/mailgun.d.ts.map +1 -0
  194. package/providers/mailgun.js +2 -0
  195. package/providers/mailru.d.ts +3 -0
  196. package/providers/mailru.d.ts.map +1 -0
  197. package/providers/mailru.js +2 -0
  198. package/providers/mastodon.d.ts +3 -0
  199. package/providers/mastodon.d.ts.map +1 -0
  200. package/providers/mastodon.js +2 -0
  201. package/providers/mattermost.d.ts +3 -0
  202. package/providers/mattermost.d.ts.map +1 -0
  203. package/providers/mattermost.js +2 -0
  204. package/providers/medium.d.ts +3 -0
  205. package/providers/medium.d.ts.map +1 -0
  206. package/providers/medium.js +2 -0
  207. package/providers/microsoft-entra-id.d.ts +3 -0
  208. package/providers/microsoft-entra-id.d.ts.map +1 -0
  209. package/providers/microsoft-entra-id.js +2 -0
  210. package/providers/naver.d.ts +3 -0
  211. package/providers/naver.d.ts.map +1 -0
  212. package/providers/naver.js +2 -0
  213. package/providers/netlify.d.ts +3 -0
  214. package/providers/netlify.d.ts.map +1 -0
  215. package/providers/netlify.js +2 -0
  216. package/providers/netsuite.d.ts +3 -0
  217. package/providers/netsuite.d.ts.map +1 -0
  218. package/providers/netsuite.js +2 -0
  219. package/providers/nextcloud.d.ts +3 -0
  220. package/providers/nextcloud.d.ts.map +1 -0
  221. package/providers/nextcloud.js +2 -0
  222. package/providers/nodemailer.d.ts +3 -0
  223. package/providers/nodemailer.d.ts.map +1 -0
  224. package/providers/nodemailer.js +2 -0
  225. package/providers/notion.d.ts +3 -0
  226. package/providers/notion.d.ts.map +1 -0
  227. package/providers/notion.js +2 -0
  228. package/providers/okta.d.ts +3 -0
  229. package/providers/okta.d.ts.map +1 -0
  230. package/providers/okta.js +2 -0
  231. package/providers/onelogin.d.ts +3 -0
  232. package/providers/onelogin.d.ts.map +1 -0
  233. package/providers/onelogin.js +2 -0
  234. package/providers/ory-hydra.d.ts +3 -0
  235. package/providers/ory-hydra.d.ts.map +1 -0
  236. package/providers/ory-hydra.js +2 -0
  237. package/providers/osso.d.ts +3 -0
  238. package/providers/osso.d.ts.map +1 -0
  239. package/providers/osso.js +2 -0
  240. package/providers/osu.d.ts +3 -0
  241. package/providers/osu.d.ts.map +1 -0
  242. package/providers/osu.js +2 -0
  243. package/providers/passage.d.ts +3 -0
  244. package/providers/passage.d.ts.map +1 -0
  245. package/providers/passage.js +2 -0
  246. package/providers/passkey.d.ts +3 -0
  247. package/providers/passkey.d.ts.map +1 -0
  248. package/providers/passkey.js +2 -0
  249. package/providers/patreon.d.ts +3 -0
  250. package/providers/patreon.d.ts.map +1 -0
  251. package/providers/patreon.js +2 -0
  252. package/providers/ping-id.d.ts +3 -0
  253. package/providers/ping-id.d.ts.map +1 -0
  254. package/providers/ping-id.js +2 -0
  255. package/providers/pinterest.d.ts +3 -0
  256. package/providers/pinterest.d.ts.map +1 -0
  257. package/providers/pinterest.js +2 -0
  258. package/providers/pipedrive.d.ts +3 -0
  259. package/providers/pipedrive.d.ts.map +1 -0
  260. package/providers/pipedrive.js +2 -0
  261. package/providers/postmark.d.ts +3 -0
  262. package/providers/postmark.d.ts.map +1 -0
  263. package/providers/postmark.js +2 -0
  264. package/providers/reddit.d.ts +3 -0
  265. package/providers/reddit.d.ts.map +1 -0
  266. package/providers/reddit.js +2 -0
  267. package/providers/resend.d.ts +3 -0
  268. package/providers/resend.d.ts.map +1 -0
  269. package/providers/resend.js +2 -0
  270. package/providers/roblox.d.ts +3 -0
  271. package/providers/roblox.d.ts.map +1 -0
  272. package/providers/roblox.js +2 -0
  273. package/providers/salesforce.d.ts +3 -0
  274. package/providers/salesforce.d.ts.map +1 -0
  275. package/providers/salesforce.js +2 -0
  276. package/providers/sendgrid.d.ts +3 -0
  277. package/providers/sendgrid.d.ts.map +1 -0
  278. package/providers/sendgrid.js +2 -0
  279. package/providers/simplelogin.d.ts +3 -0
  280. package/providers/simplelogin.d.ts.map +1 -0
  281. package/providers/simplelogin.js +2 -0
  282. package/providers/slack.d.ts +3 -0
  283. package/providers/slack.d.ts.map +1 -0
  284. package/providers/slack.js +2 -0
  285. package/providers/spotify.d.ts +3 -0
  286. package/providers/spotify.d.ts.map +1 -0
  287. package/providers/spotify.js +2 -0
  288. package/providers/strava.d.ts +3 -0
  289. package/providers/strava.d.ts.map +1 -0
  290. package/providers/strava.js +2 -0
  291. package/providers/threads.d.ts +3 -0
  292. package/providers/threads.d.ts.map +1 -0
  293. package/providers/threads.js +2 -0
  294. package/providers/tiktok.d.ts +3 -0
  295. package/providers/tiktok.d.ts.map +1 -0
  296. package/providers/tiktok.js +2 -0
  297. package/providers/todoist.d.ts +3 -0
  298. package/providers/todoist.d.ts.map +1 -0
  299. package/providers/todoist.js +2 -0
  300. package/providers/trakt.d.ts +3 -0
  301. package/providers/trakt.d.ts.map +1 -0
  302. package/providers/trakt.js +2 -0
  303. package/providers/twitch.d.ts +3 -0
  304. package/providers/twitch.d.ts.map +1 -0
  305. package/providers/twitch.js +2 -0
  306. package/providers/twitter.d.ts +3 -0
  307. package/providers/twitter.d.ts.map +1 -0
  308. package/providers/twitter.js +2 -0
  309. package/providers/united-effects.d.ts +3 -0
  310. package/providers/united-effects.d.ts.map +1 -0
  311. package/providers/united-effects.js +2 -0
  312. package/providers/vipps.d.ts +3 -0
  313. package/providers/vipps.d.ts.map +1 -0
  314. package/providers/vipps.js +2 -0
  315. package/providers/vk.d.ts +3 -0
  316. package/providers/vk.d.ts.map +1 -0
  317. package/providers/vk.js +2 -0
  318. package/providers/webauthn.d.ts +3 -0
  319. package/providers/webauthn.d.ts.map +1 -0
  320. package/providers/webauthn.js +2 -0
  321. package/providers/webex.d.ts +3 -0
  322. package/providers/webex.d.ts.map +1 -0
  323. package/providers/webex.js +2 -0
  324. package/providers/wechat.d.ts +3 -0
  325. package/providers/wechat.d.ts.map +1 -0
  326. package/providers/wechat.js +2 -0
  327. package/providers/wikimedia.d.ts +3 -0
  328. package/providers/wikimedia.d.ts.map +1 -0
  329. package/providers/wikimedia.js +2 -0
  330. package/providers/wordpress.d.ts +3 -0
  331. package/providers/wordpress.d.ts.map +1 -0
  332. package/providers/wordpress.js +2 -0
  333. package/providers/workos.d.ts +3 -0
  334. package/providers/workos.d.ts.map +1 -0
  335. package/providers/workos.js +2 -0
  336. package/providers/yandex.d.ts +3 -0
  337. package/providers/yandex.d.ts.map +1 -0
  338. package/providers/yandex.js +2 -0
  339. package/providers/zitadel.d.ts +3 -0
  340. package/providers/zitadel.d.ts.map +1 -0
  341. package/providers/zitadel.js +2 -0
  342. package/providers/zoho.d.ts +3 -0
  343. package/providers/zoho.d.ts.map +1 -0
  344. package/providers/zoho.js +2 -0
  345. package/providers/zoom.d.ts +3 -0
  346. package/providers/zoom.d.ts.map +1 -0
  347. package/providers/zoom.js +2 -0
  348. package/react.d.ts +102 -0
  349. package/react.d.ts.map +1 -0
  350. package/react.js +361 -0
  351. package/src/adapters.ts +1 -0
  352. package/src/index.ts +430 -0
  353. package/src/jwt.ts +9 -0
  354. package/src/lib/actions.ts +144 -0
  355. package/src/lib/client.ts +245 -0
  356. package/src/lib/env.ts +36 -0
  357. package/src/lib/index.ts +313 -0
  358. package/src/lib/types.ts +30 -0
  359. package/src/middleware.ts +16 -0
  360. package/src/next.ts +16 -0
  361. package/src/providers/42-school.ts +2 -0
  362. package/src/providers/apple.ts +2 -0
  363. package/src/providers/asgardeo.ts +2 -0
  364. package/src/providers/atlassian.ts +2 -0
  365. package/src/providers/auth0.ts +2 -0
  366. package/src/providers/authentik.ts +2 -0
  367. package/src/providers/azure-ad-b2c.ts +2 -0
  368. package/src/providers/azure-ad.ts +2 -0
  369. package/src/providers/azure-devops.ts +2 -0
  370. package/src/providers/bankid-no.ts +2 -0
  371. package/src/providers/battlenet.ts +2 -0
  372. package/src/providers/beyondidentity.ts +2 -0
  373. package/src/providers/bitbucket.ts +2 -0
  374. package/src/providers/box.ts +2 -0
  375. package/src/providers/boxyhq-saml.ts +2 -0
  376. package/src/providers/bungie.ts +2 -0
  377. package/src/providers/click-up.ts +2 -0
  378. package/src/providers/cognito.ts +2 -0
  379. package/src/providers/coinbase.ts +2 -0
  380. package/src/providers/concept2.ts +2 -0
  381. package/src/providers/credentials.ts +2 -0
  382. package/src/providers/descope.ts +2 -0
  383. package/src/providers/discord.ts +2 -0
  384. package/src/providers/dribbble.ts +2 -0
  385. package/src/providers/dropbox.ts +2 -0
  386. package/src/providers/duende-identity-server6.ts +2 -0
  387. package/src/providers/email.ts +2 -0
  388. package/src/providers/eventbrite.ts +2 -0
  389. package/src/providers/eveonline.ts +2 -0
  390. package/src/providers/facebook.ts +2 -0
  391. package/src/providers/faceit.ts +2 -0
  392. package/src/providers/figma.ts +2 -0
  393. package/src/providers/forwardemail.ts +2 -0
  394. package/src/providers/foursquare.ts +2 -0
  395. package/src/providers/freshbooks.ts +2 -0
  396. package/src/providers/frontegg.ts +2 -0
  397. package/src/providers/fusionauth.ts +2 -0
  398. package/src/providers/github.ts +2 -0
  399. package/src/providers/gitlab.ts +2 -0
  400. package/src/providers/google.ts +2 -0
  401. package/src/providers/hubspot.ts +2 -0
  402. package/src/providers/huggingface.ts +2 -0
  403. package/src/providers/identity-server4.ts +2 -0
  404. package/src/providers/index.ts +1 -0
  405. package/src/providers/instagram.ts +2 -0
  406. package/src/providers/kakao.ts +2 -0
  407. package/src/providers/keycloak.ts +2 -0
  408. package/src/providers/kinde.ts +2 -0
  409. package/src/providers/line.ts +2 -0
  410. package/src/providers/linkedin.ts +2 -0
  411. package/src/providers/logto.ts +2 -0
  412. package/src/providers/loops.ts +2 -0
  413. package/src/providers/mailchimp.ts +2 -0
  414. package/src/providers/mailgun.ts +2 -0
  415. package/src/providers/mailru.ts +2 -0
  416. package/src/providers/mastodon.ts +2 -0
  417. package/src/providers/mattermost.ts +2 -0
  418. package/src/providers/medium.ts +2 -0
  419. package/src/providers/microsoft-entra-id.ts +2 -0
  420. package/src/providers/naver.ts +2 -0
  421. package/src/providers/netlify.ts +2 -0
  422. package/src/providers/netsuite.ts +2 -0
  423. package/src/providers/nextcloud.ts +2 -0
  424. package/src/providers/nodemailer.ts +2 -0
  425. package/src/providers/notion.ts +2 -0
  426. package/src/providers/okta.ts +2 -0
  427. package/src/providers/onelogin.ts +2 -0
  428. package/src/providers/ory-hydra.ts +2 -0
  429. package/src/providers/osso.ts +2 -0
  430. package/src/providers/osu.ts +2 -0
  431. package/src/providers/passage.ts +2 -0
  432. package/src/providers/passkey.ts +2 -0
  433. package/src/providers/patreon.ts +2 -0
  434. package/src/providers/ping-id.ts +2 -0
  435. package/src/providers/pinterest.ts +2 -0
  436. package/src/providers/pipedrive.ts +2 -0
  437. package/src/providers/postmark.ts +2 -0
  438. package/src/providers/reddit.ts +2 -0
  439. package/src/providers/resend.ts +2 -0
  440. package/src/providers/roblox.ts +2 -0
  441. package/src/providers/salesforce.ts +2 -0
  442. package/src/providers/sendgrid.ts +2 -0
  443. package/src/providers/simplelogin.ts +2 -0
  444. package/src/providers/slack.ts +2 -0
  445. package/src/providers/spotify.ts +2 -0
  446. package/src/providers/strava.ts +2 -0
  447. package/src/providers/threads.ts +2 -0
  448. package/src/providers/tiktok.ts +2 -0
  449. package/src/providers/todoist.ts +2 -0
  450. package/src/providers/trakt.ts +2 -0
  451. package/src/providers/twitch.ts +2 -0
  452. package/src/providers/twitter.ts +2 -0
  453. package/src/providers/united-effects.ts +2 -0
  454. package/src/providers/vipps.ts +2 -0
  455. package/src/providers/vk.ts +2 -0
  456. package/src/providers/webauthn.ts +2 -0
  457. package/src/providers/webex.ts +2 -0
  458. package/src/providers/wechat.ts +2 -0
  459. package/src/providers/wikimedia.ts +2 -0
  460. package/src/providers/wordpress.ts +2 -0
  461. package/src/providers/workos.ts +2 -0
  462. package/src/providers/yandex.ts +2 -0
  463. package/src/providers/zitadel.ts +2 -0
  464. package/src/providers/zoho.ts +2 -0
  465. package/src/providers/zoom.ts +2 -0
  466. package/src/react.tsx +546 -0
  467. package/src/webauthn.ts +152 -0
  468. package/webauthn.d.ts +9 -0
  469. package/webauthn.d.ts.map +1 -0
  470. package/webauthn.js +92 -0
  471. package/LICENSE +0 -70
  472. package/dist/actions-CMtg7FGv.js +0 -1
  473. package/dist/actions-CjQUKaXF.mjs +0 -200
  474. package/dist/client/index.js +0 -1
  475. package/dist/client/index.mjs +0 -484
  476. package/dist/components/AccountPicker.d.ts +0 -11
  477. package/dist/components/OAuthButton.d.ts +0 -11
  478. package/dist/components/PassKeyButton.d.ts +0 -11
  479. package/dist/components/PassKeyRegister.d.ts +0 -10
  480. package/dist/components/TwoFactorSetup.d.ts +0 -8
  481. package/dist/components/TwoFactorVerify.d.ts +0 -9
  482. package/dist/core/account-picker/encryption.d.ts +0 -22
  483. package/dist/core/account-picker/index.d.ts +0 -22
  484. package/dist/core/auth/email-password.d.ts +0 -145
  485. package/dist/core/auth/oauth/index.d.ts +0 -14
  486. package/dist/core/auth/oauth/oauth-handler.d.ts +0 -172
  487. package/dist/core/auth/oauth/pkce.d.ts +0 -168
  488. package/dist/core/auth/oauth/providers.d.ts +0 -198
  489. package/dist/core/auth/oauth/state-store-cookie.d.ts +0 -83
  490. package/dist/core/auth/oauth/state-store-redis.d.ts +0 -25
  491. package/dist/core/auth/oauth/state-store.d.ts +0 -48
  492. package/dist/core/auth/otp.d.ts +0 -184
  493. package/dist/core/auth/passkey.d.ts +0 -35
  494. package/dist/core/auth/password.d.ts +0 -22
  495. package/dist/core/auth/signin-unified.d.ts +0 -33
  496. package/dist/core/auth/two-factor.d.ts +0 -28
  497. package/dist/core/client/index.d.ts +0 -132
  498. package/dist/core/client/token-refresh-manager.d.ts +0 -48
  499. package/dist/core/errors/index.d.ts +0 -269
  500. package/dist/core/index.d.ts +0 -9
  501. package/dist/core/logger/index.d.ts +0 -147
  502. package/dist/core/mulguard/auth-handlers.d.ts +0 -100
  503. package/dist/core/mulguard/defaults.d.ts +0 -58
  504. package/dist/core/mulguard/index.d.ts +0 -9
  505. package/dist/core/mulguard/integration.d.ts +0 -104
  506. package/dist/core/mulguard/oauth-handler.d.ts +0 -93
  507. package/dist/core/mulguard/session-manager.d.ts +0 -94
  508. package/dist/core/security/csrf.d.ts +0 -46
  509. package/dist/core/security/headers.d.ts +0 -24
  510. package/dist/core/security/index.d.ts +0 -132
  511. package/dist/core/security/rate-limit.d.ts +0 -39
  512. package/dist/core/security/security-manager.d.ts +0 -236
  513. package/dist/core/security/validation.d.ts +0 -251
  514. package/dist/core/security/xss.d.ts +0 -20
  515. package/dist/core/session/index.d.ts +0 -35
  516. package/dist/core/session/session-manager.d.ts +0 -235
  517. package/dist/core/types/auth.d.ts +0 -290
  518. package/dist/core/types/errors.d.ts +0 -200
  519. package/dist/core/types/index.d.ts +0 -484
  520. package/dist/core/utils/auth-helpers.d.ts +0 -136
  521. package/dist/core/utils/logger.d.ts +0 -121
  522. package/dist/index/index.js +0 -1
  523. package/dist/index/index.mjs +0 -2736
  524. package/dist/index.d.ts +0 -18
  525. package/dist/mulguard.d.ts +0 -373
  526. package/dist/nextjs/client/hooks.d.ts +0 -122
  527. package/dist/nextjs/client/index.d.ts +0 -13
  528. package/dist/nextjs/client/provider.d.ts +0 -69
  529. package/dist/nextjs/client/server-actions-helper.d.ts +0 -22
  530. package/dist/nextjs/handlers/api.d.ts +0 -10
  531. package/dist/nextjs/handlers/index.d.ts +0 -9
  532. package/dist/nextjs/handlers/route.d.ts +0 -76
  533. package/dist/nextjs/index.d.ts +0 -15
  534. package/dist/nextjs/proxy/index.d.ts +0 -149
  535. package/dist/nextjs/proxy/security.d.ts +0 -9
  536. package/dist/nextjs/server/actions.d.ts +0 -30
  537. package/dist/nextjs/server/auth.d.ts +0 -65
  538. package/dist/nextjs/server/cookies.d.ts +0 -41
  539. package/dist/nextjs/server/index.d.ts +0 -18
  540. package/dist/nextjs/server/oauth-state.d.ts +0 -32
  541. package/dist/nextjs/server/session-helpers.d.ts +0 -24
  542. package/dist/nextjs/server/session.d.ts +0 -144
  543. package/dist/oauth-state-Drwz6fES.js +0 -1
  544. package/dist/oauth-state-pdypStuS.mjs +0 -210
  545. package/dist/server/index.js +0 -1
  546. package/dist/server/index.mjs +0 -29
@@ -1,93 +0,0 @@
1
- import { AuthResult, OAuthUserInfo, User, Session, OAuthProviderConfig, OAuthProvidersConfig, CallbacksConfig } from '../types';
2
- import { exchangeOAuthCode } from '../auth/oauth/providers';
3
- /**
4
- * OAuth handler configuration.
5
- */
6
- export interface OAuthHandlerConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
7
- readonly oauthProviders: OAuthProvidersConfig;
8
- readonly baseUrl: string;
9
- readonly callbacks: CallbacksConfig;
10
- readonly createSession: (user: TUser, userInfo: OAuthUserInfo, tokens: Awaited<ReturnType<typeof exchangeOAuthCode>>) => TSession;
11
- readonly saveSession: (session: TSession) => Promise<void>;
12
- readonly onError?: (error: Error, context: string) => Promise<void> | void;
13
- }
14
- /**
15
- * OAuth state validation function.
16
- */
17
- export type ValidateOAuthState = (state: string, provider: string) => Promise<boolean>;
18
- /**
19
- * Creates OAuth callback handler.
20
- *
21
- * Automatically handles:
22
- * 1. Code exchange for tokens
23
- * 2. User profile retrieval
24
- * 3. User creation/lookup via callback
25
- * 4. Session creation and storage
26
- *
27
- * @template TUser - User type
28
- * @template TSession - Session type
29
- * @param config - OAuth handler configuration
30
- * @param validateState - Function to validate OAuth state
31
- * @returns OAuth callback handler
32
- *
33
- * @example
34
- * ```typescript
35
- * const handler = createOAuthCallbackHandler(config, validateState)
36
- * const result = await handler('google', 'code123', 'state456')
37
- * ```
38
- */
39
- export declare function createOAuthCallbackHandler<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(config: OAuthHandlerConfig<TUser, TSession>, _validateState: ValidateOAuthState): (provider: string, code: string, _state: string) => Promise<AuthResult<TUser, TSession>>;
40
- /**
41
- * Creates OAuth initiation action if providers are configured.
42
- *
43
- * @param oauthProviders - OAuth providers configuration
44
- * @param baseUrl - Base URL for redirects
45
- * @param generateState - Function to generate CSRF state
46
- * @param buildAuthUrl - Function to build authorization URL
47
- * @returns OAuth initiation action or undefined
48
- */
49
- export declare function createOAuthInitiationAction(oauthProviders: OAuthProvidersConfig, baseUrl: string, generateState: () => string, buildAuthUrl: (provider: string, config: OAuthProviderConfig, baseUrl: string, state: string) => string): ((provider: string) => Promise<{
50
- url: string;
51
- state: string;
52
- }>) | undefined;
53
- /**
54
- * TODO: Performance
55
- * - [ ] Add token exchange result caching
56
- * - [ ] Implement request retry logic
57
- * - [ ] Add connection pooling for OAuth API calls
58
- * - [ ] Cache user profile data
59
- *
60
- * TODO: Features
61
- * - [ ] Add PKCE support
62
- * - [ ] Implement token refresh flow
63
- * - [ ] Add OAuth 2.1 compliance
64
- * - [ ] Support for OpenID Connect
65
- * - [ ] Add account linking
66
- *
67
- * TODO: Type Safety
68
- * - [ ] Add type-safe provider configuration
69
- * - [ ] Create type-level endpoint validation
70
- * - [ ] Implement compile-time provider validation
71
- *
72
- * TODO: Security
73
- * - [ ] Add token validation before use
74
- * - [ ] Implement token encryption
75
- * - [ ] Add request signing
76
- * - [ ] Create security audit logging
77
- *
78
- * TODO: Testing
79
- * - [ ] Add comprehensive OAuth handler tests
80
- * - [ ] Test all provider flows
81
- * - [ ] Test error handling
82
- * - [ ] Add integration tests
83
- *
84
- * TODO: Documentation
85
- * - [ ] Document OAuth flow
86
- * - [ ] Add provider setup guides
87
- * - [ ] Create troubleshooting guide
88
- *
89
- * TODO: Limitations
90
- * - [ ] No support for OAuth 1.0
91
- * - [ ] Token refresh not implemented
92
- * - [ ] No PKCE support yet
93
- */
@@ -1,94 +0,0 @@
1
- import { Session, SessionConfig } from '../types';
2
- /**
3
- * Session cache entry.
4
- */
5
- interface SessionCacheEntry {
6
- readonly session: Session | null;
7
- readonly timestamp: number;
8
- }
9
- /**
10
- * Session manager configuration.
11
- */
12
- export interface SessionManagerConfig {
13
- readonly sessionConfig: SessionConfig;
14
- readonly cacheTtl: number;
15
- readonly getSessionAction?: () => Promise<Session | null>;
16
- readonly onSessionExpired?: (session: Session) => Promise<void> | void;
17
- readonly onError?: (error: Error, context: string) => Promise<void> | void;
18
- }
19
- /**
20
- * Session operation result.
21
- */
22
- export interface SessionResult {
23
- readonly success: boolean;
24
- readonly error?: string;
25
- readonly warning?: string;
26
- }
27
- /**
28
- * Creates a session manager instance.
29
- *
30
- * @param config - Session manager configuration
31
- * @returns Session manager functions
32
- */
33
- export declare function createSessionManager(config: SessionManagerConfig): {
34
- getSession: () => Promise<Session | null>;
35
- setSession: (session: Session) => Promise<SessionResult>;
36
- clearSessionCookie: () => Promise<void>;
37
- getAccessToken: () => Promise<string | null>;
38
- getRefreshToken: () => Promise<string | null>;
39
- hasValidTokens: () => Promise<boolean>;
40
- clearCache: () => void;
41
- getSessionConfig: () => {
42
- cookieName: string;
43
- config: SessionConfig;
44
- };
45
- };
46
- /**
47
- * Type predicate to check if a value is a valid session cache entry.
48
- *
49
- * @param value - Value to check
50
- * @returns True if value is a valid cache entry
51
- */
52
- export declare function isSessionCacheEntry(value: unknown): value is SessionCacheEntry;
53
- export {};
54
- /**
55
- * TODO: Performance
56
- * - [ ] Add session compression for large sessions
57
- * - [ ] Implement session chunking for very large sessions
58
- * - [ ] Add session cache invalidation strategies
59
- * - [ ] Consider using WeakMap for session references
60
- *
61
- * TODO: Features
62
- * - [ ] Add session encryption at rest
63
- * - [ ] Implement session rotation
64
- * - [ ] Add session fingerprinting
65
- * - [ ] Create session analytics
66
- * - [ ] Add session migration support
67
- *
68
- * TODO: Type Safety
69
- * - [ ] Add type-level session validation
70
- * - [ ] Create type-safe session builders
71
- * - [ ] Implement session schema validation
72
- *
73
- * TODO: Security
74
- * - [ ] Add session hijacking detection
75
- * - [ ] Implement session timeout warnings
76
- * - [ ] Add session audit logging
77
- * - [ ] Create session security monitoring
78
- *
79
- * TODO: Testing
80
- * - [ ] Add comprehensive session manager tests
81
- * - [ ] Test cache invalidation
82
- * - [ ] Test session expiration
83
- * - [ ] Test error handling
84
- *
85
- * TODO: Documentation
86
- * - [ ] Document session lifecycle
87
- * - [ ] Add session best practices guide
88
- * - [ ] Create troubleshooting guide
89
- *
90
- * TODO: Limitations
91
- * - [ ] Session cache is in-memory (not shared across instances)
92
- * - [ ] No session persistence (consider database-backed sessions)
93
- * - [ ] Session validation is basic (consider schema validation)
94
- */
@@ -1,46 +0,0 @@
1
- /**
2
- * CSRF Protection utilities
3
- */
4
- export interface CSRFTokenStore {
5
- get(key: string): string | null;
6
- set(key: string, value: string, expiresIn?: number): void;
7
- delete(key: string): void;
8
- }
9
- /**
10
- * In-memory CSRF token store (for server-side)
11
- */
12
- export declare class MemoryCSRFStore implements CSRFTokenStore {
13
- private tokens;
14
- get(key: string): string | null;
15
- set(key: string, value: string, expiresIn?: number): void;
16
- delete(key: string): void;
17
- clear(): void;
18
- }
19
- /**
20
- * CSRF Protection manager
21
- */
22
- export declare class CSRFProtection {
23
- private store;
24
- private tokenLength;
25
- constructor(store?: CSRFTokenStore, tokenLength?: number);
26
- /**
27
- * Generate CSRF token
28
- */
29
- generateToken(key: string, expiresIn?: number): string;
30
- /**
31
- * Validate CSRF token
32
- */
33
- validateToken(key: string, token: string): boolean;
34
- /**
35
- * Get stored token without validating
36
- */
37
- getToken(key: string): string | null;
38
- /**
39
- * Delete token
40
- */
41
- deleteToken(key: string): void;
42
- }
43
- /**
44
- * Create CSRF protection instance
45
- */
46
- export declare function createCSRFProtection(store?: CSRFTokenStore): CSRFProtection;
@@ -1,24 +0,0 @@
1
- /**
2
- * Security Headers utilities
3
- */
4
- export interface SecurityHeaders {
5
- 'X-Content-Type-Options'?: string;
6
- 'X-Frame-Options'?: string;
7
- 'X-XSS-Protection'?: string;
8
- 'Strict-Transport-Security'?: string;
9
- 'Content-Security-Policy'?: string;
10
- 'Referrer-Policy'?: string;
11
- 'Permissions-Policy'?: string;
12
- }
13
- /**
14
- * Default security headers
15
- */
16
- export declare const DEFAULT_SECURITY_HEADERS: SecurityHeaders;
17
- /**
18
- * Get security headers
19
- */
20
- export declare function getSecurityHeaders(custom?: Partial<SecurityHeaders>): SecurityHeaders;
21
- /**
22
- * Apply security headers to response
23
- */
24
- export declare function applySecurityHeaders(headers: Headers, custom?: Partial<SecurityHeaders>): void;
@@ -1,132 +0,0 @@
1
- /**
2
- * Security utilities for Mulguard Authentication Library.
3
- *
4
- * Provides token generation, CSRF protection, input sanitization, and validation.
5
- *
6
- * @module @mulguard/core/security
7
- */
8
- /**
9
- * Generates a cryptographically secure random token.
10
- *
11
- * @param length - Token length in bytes (default: 32)
12
- * @returns Base64url-encoded token
13
- *
14
- * @example
15
- * ```typescript
16
- * const token = generateToken(32)
17
- * // Returns: 'abc123xyz...' (base64url encoded)
18
- * ```
19
- */
20
- export declare function generateToken(length?: number): string;
21
- /**
22
- * Generates a CSRF token for state validation.
23
- *
24
- * @returns Base64url-encoded CSRF token
25
- *
26
- * @example
27
- * ```typescript
28
- * const state = generateCSRFToken()
29
- * // Store state for validation
30
- * ```
31
- */
32
- export declare function generateCSRFToken(): string;
33
- /**
34
- * Validates a CSRF token using constant-time comparison.
35
- *
36
- * Uses constant-time comparison to prevent timing attacks.
37
- *
38
- * @param token - Token to validate
39
- * @param expected - Expected token value
40
- * @returns True if tokens match
41
- *
42
- * @example
43
- * ```typescript
44
- * const isValid = validateCSRFToken(receivedToken, storedToken)
45
- * if (!isValid) {
46
- * throw new Error('Invalid CSRF token')
47
- * }
48
- * ```
49
- */
50
- export declare function validateCSRFToken(token: unknown, expected: unknown): boolean;
51
- /**
52
- * Type predicate to check if CSRF token is valid.
53
- *
54
- * @param token - Token to check
55
- * @param expected - Expected token
56
- * @returns True if token is valid
57
- */
58
- export declare function isValidCSRFToken(token: unknown, expected: unknown): token is string;
59
- /**
60
- * Sanitizes string input by trimming and removing dangerous characters.
61
- *
62
- * @param input - Input to sanitize
63
- * @returns Sanitized string
64
- *
65
- * @example
66
- * ```typescript
67
- * const sanitized = sanitizeInput(' <script>alert("xss")</script> ')
68
- * // Returns: 'scriptalert("xss")script'
69
- * ```
70
- */
71
- export declare function sanitizeInput(input: unknown): string;
72
- /**
73
- * Validates email format.
74
- *
75
- * @param email - Email to validate
76
- * @returns True if email is valid
77
- *
78
- * @example
79
- * ```typescript
80
- * if (isValidEmail('user@example.com')) {
81
- * // Email is valid
82
- * }
83
- * ```
84
- */
85
- export declare function isValidEmail(email: unknown): email is string;
86
- export * from './rate-limit';
87
- export * from './headers';
88
- export * from './validation';
89
- export * from './csrf';
90
- export * from './xss';
91
- /**
92
- * TODO: Performance
93
- * - [ ] Add token generation caching for high-frequency operations
94
- * - [ ] Optimize constant-time comparison for very long tokens
95
- * - [ ] Consider using Web Crypto API for token generation
96
- * - [ ] Add input sanitization result caching
97
- *
98
- * TODO: Features
99
- * - [ ] Add token expiration validation
100
- * - [ ] Implement token rotation support
101
- * - [ ] Add rate limiting for token generation
102
- * - [ ] Create token strength scoring
103
- * - [ ] Add token format validation helpers
104
- *
105
- * TODO: Type Safety
106
- * - [ ] Add branded types for tokens
107
- * - [ ] Create type-safe token validation
108
- * - [ ] Add type guards for all security functions
109
- * - [ ] Implement type-level security constraints
110
- *
111
- * TODO: Security
112
- * - [ ] Add token generation logging (with masking)
113
- * - [ ] Implement token blacklisting
114
- * - [ ] Add security event monitoring
115
- * - [ ] Create security audit logging
116
- *
117
- * TODO: Testing
118
- * - [ ] Add comprehensive security tests
119
- * - [ ] Test timing attack resistance
120
- * - [ ] Test token generation randomness
121
- * - [ ] Add fuzzing tests
122
- *
123
- * TODO: Documentation
124
- * - [ ] Document security best practices
125
- * - [ ] Add security considerations guide
126
- * - [ ] Document token lifecycle
127
- *
128
- * TODO: Limitations
129
- * - [ ] Token generation uses Node.js Buffer (consider Web Crypto API for browsers)
130
- * - [ ] Constant-time comparison may have micro-optimizations
131
- * - [ ] Email validation is basic (use validation.ts for comprehensive validation)
132
- */
@@ -1,39 +0,0 @@
1
- /**
2
- * Rate Limiting utilities
3
- * Client-side rate limiting helpers (actual rate limiting should be on backend)
4
- */
5
- export interface RateLimitConfig {
6
- maxAttempts: number;
7
- windowMs: number;
8
- keyPrefix?: string;
9
- }
10
- export interface RateLimitResult {
11
- allowed: boolean;
12
- remaining: number;
13
- resetAt: Date;
14
- }
15
- /**
16
- * Client-side rate limit tracker
17
- * Note: This is just a helper. Real rate limiting must be enforced on the backend.
18
- */
19
- export declare class RateLimiter {
20
- private attempts;
21
- private config;
22
- constructor(config: RateLimitConfig);
23
- /**
24
- * Check if request is allowed
25
- */
26
- check(key: string): RateLimitResult;
27
- /**
28
- * Reset rate limit for a key
29
- */
30
- reset(key: string): void;
31
- /**
32
- * Clear all rate limits
33
- */
34
- clear(): void;
35
- }
36
- /**
37
- * Create rate limiter instance
38
- */
39
- export declare function createRateLimiter(config: RateLimitConfig): RateLimiter;
@@ -1,236 +0,0 @@
1
- import { CSRFTokenStore } from './csrf';
2
- import { ValidationResult } from './validation';
3
- import { Logger } from '../logger';
4
- /**
5
- * Comprehensive security configuration.
6
- */
7
- export interface SecurityConfig {
8
- readonly csrfProtection?: {
9
- readonly enabled: boolean;
10
- readonly tokenLength?: number;
11
- readonly expiresIn?: number;
12
- readonly store?: CSRFTokenStore;
13
- };
14
- readonly rateLimiting?: {
15
- readonly enabled: boolean;
16
- readonly maxAttempts?: number;
17
- readonly windowMs?: number;
18
- readonly strategy?: 'ip' | 'user' | 'email';
19
- };
20
- readonly validation?: {
21
- readonly strictEmail?: boolean;
22
- readonly minPasswordLength?: number;
23
- readonly requireStrongPassword?: boolean;
24
- };
25
- readonly xssProtection?: {
26
- readonly enabled: boolean;
27
- readonly sanitizeHtml?: boolean;
28
- };
29
- readonly logger?: Logger;
30
- }
31
- /**
32
- * Comprehensive security manager for authentication operations.
33
- *
34
- * Provides unified access to all security utilities with centralized configuration.
35
- *
36
- * @example
37
- * ```typescript
38
- * const security = new SecurityManager({
39
- * csrfProtection: { enabled: true },
40
- * rateLimiting: { enabled: true, maxAttempts: 5 },
41
- * })
42
- *
43
- * // Validate email
44
- * const emailResult = security.validateEmail('user@example.com')
45
- *
46
- * // Check rate limit
47
- * const rateLimitResult = security.checkRateLimit('user@example.com')
48
- * ```
49
- */
50
- export declare class SecurityManager {
51
- private readonly config;
52
- private readonly csrfProtection;
53
- private readonly rateLimiter;
54
- constructor(config?: SecurityConfig);
55
- /**
56
- * Validates and sanitizes an email address.
57
- *
58
- * @param email - Email address to validate
59
- * @returns Validation result with sanitized email if valid
60
- * @throws ValidationError if validation fails and strict mode is enabled
61
- *
62
- * @example
63
- * ```typescript
64
- * const result = security.validateEmail('user@example.com')
65
- * if (result.valid) {
66
- * console.log(result.sanitized) // 'user@example.com'
67
- * }
68
- * ```
69
- */
70
- validateEmail(email: unknown): ValidationResult<string>;
71
- /**
72
- * Validates and sanitizes a password with strength assessment.
73
- *
74
- * @param password - Password to validate
75
- * @returns Validation result with strength indicator if valid
76
- * @throws ValidationError if validation fails and strict mode is enabled
77
- *
78
- * @example
79
- * ```typescript
80
- * const result = security.validatePassword('MyP@ssw0rd!')
81
- * if (result.valid) {
82
- * console.log(result.strength) // 'strong'
83
- * }
84
- * ```
85
- */
86
- validatePassword(password: unknown): ValidationResult<string>;
87
- /**
88
- * Validates and sanitizes a name.
89
- *
90
- * @param name - Name to validate
91
- * @returns Validation result with sanitized name if valid
92
- */
93
- validateName(name: unknown): ValidationResult<string>;
94
- /**
95
- * Validates a token format.
96
- *
97
- * @param token - Token to validate
98
- * @returns Validation result
99
- */
100
- validateToken(token: unknown): ValidationResult<string>;
101
- /**
102
- * Validates a URL.
103
- *
104
- * @param url - URL to validate
105
- * @returns Validation result
106
- */
107
- validateURL(url: unknown): ValidationResult<string>;
108
- /**
109
- * Validates and sanitizes generic input with XSS prevention.
110
- *
111
- * @param input - Input to validate and sanitize
112
- * @param options - Sanitization options
113
- * @returns Validation result with sanitized input if valid
114
- */
115
- sanitizeInput(input: unknown, options?: {
116
- maxLength?: number;
117
- allowHtml?: boolean;
118
- required?: boolean;
119
- }): ValidationResult<string>;
120
- /**
121
- * Escapes HTML to prevent XSS.
122
- *
123
- * @param str - String to escape
124
- * @returns Escaped string
125
- */
126
- escapeHTML(str: string): string;
127
- /**
128
- * Sanitizes user input with XSS prevention.
129
- *
130
- * @param input - Input to sanitize
131
- * @returns Sanitized string
132
- */
133
- sanitizeUserInput(input: unknown): string;
134
- /**
135
- * Generates a CSRF token.
136
- *
137
- * @param key - Token key (e.g., session ID)
138
- * @param expiresIn - Expiration time in milliseconds (optional)
139
- * @returns CSRF token
140
- * @throws Error if CSRF protection is disabled
141
- */
142
- generateCSRFToken(key: string, expiresIn?: number): string;
143
- /**
144
- * Validates a CSRF token.
145
- *
146
- * @param key - Token key (e.g., session ID)
147
- * @param token - Token to validate
148
- * @returns True if token is valid
149
- */
150
- validateCSRFToken(key: string, token: string): boolean;
151
- /**
152
- * Checks rate limit for a given key.
153
- *
154
- * @param key - Rate limit key (IP, user ID, email, etc.)
155
- * @returns Rate limit result
156
- * @throws RateLimitError if rate limit is exceeded
157
- */
158
- checkRateLimit(key: string): {
159
- allowed: boolean;
160
- remaining: number;
161
- resetAt: Date;
162
- };
163
- /**
164
- * Resets rate limit for a given key.
165
- *
166
- * @param key - Rate limit key
167
- */
168
- resetRateLimit(key: string): void;
169
- /**
170
- * Gets current security configuration.
171
- *
172
- * @returns Security configuration
173
- */
174
- getConfig(): Readonly<SecurityConfig>;
175
- }
176
- /**
177
- * Creates a security manager instance.
178
- *
179
- * @param config - Security configuration
180
- * @returns Security manager instance
181
- *
182
- * @example
183
- * ```typescript
184
- * const security = createSecurityManager({
185
- * csrfProtection: { enabled: true },
186
- * rateLimiting: { enabled: true, maxAttempts: 5 },
187
- * })
188
- * ```
189
- */
190
- export declare function createSecurityManager(config?: SecurityConfig): SecurityManager;
191
- export * from './validation';
192
- export * from './csrf';
193
- export * from './rate-limit';
194
- export * from './xss';
195
- /**
196
- * TODO: Performance
197
- * - [ ] Add validation result caching (with TTL)
198
- * - [ ] Optimize rate limiting with sliding window algorithm
199
- * - [ ] Add batch validation support
200
- * - [ ] Implement async validation for heavy operations
201
- *
202
- * TODO: Features
203
- * - [ ] Add Redis-based rate limiting support
204
- * - [ ] Implement distributed CSRF token storage
205
- * - [ ] Add security event logging
206
- * - [ ] Create security metrics collection
207
- * - [ ] Add IP whitelist/blacklist support
208
- * - [ ] Implement CAPTCHA integration
209
- *
210
- * TODO: Type Safety
211
- * - [ ] Add branded types for validated inputs
212
- * - [ ] Create type-safe security configuration
213
- * - [ ] Implement compile-time validation rules
214
- *
215
- * TODO: Security
216
- * - [ ] Add security headers management
217
- * - [ ] Implement content security policy (CSP) helpers
218
- * - [ ] Add security audit logging
219
- * - [ ] Create security incident reporting
220
- *
221
- * TODO: Testing
222
- * - [ ] Add comprehensive unit tests
223
- * - [ ] Test rate limiting edge cases
224
- * - [ ] Test CSRF token expiration
225
- * - [ ] Add security fuzzing tests
226
- *
227
- * TODO: Documentation
228
- * - [ ] Document security best practices
229
- * - [ ] Add security configuration guide
230
- * - [ ] Create security troubleshooting guide
231
- *
232
- * TODO: Limitations
233
- * - [ ] Rate limiting is in-memory (consider Redis for distributed systems)
234
- * - [ ] CSRF tokens are in-memory (consider persistent storage)
235
- * - [ ] HTML sanitization is basic (consider DOMPurify for complex cases)
236
- */