mulguard 1.1.7 → 1.1.9

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/LICENSE +3 -3
  2. package/README.md +21 -582
  3. package/adapters.d.ts +2 -0
  4. package/adapters.d.ts.map +1 -0
  5. package/adapters.js +1 -0
  6. package/index.d.ts +329 -0
  7. package/index.d.ts.map +1 -0
  8. package/index.js +145 -0
  9. package/jwt.d.ts +9 -0
  10. package/jwt.d.ts.map +1 -0
  11. package/jwt.js +8 -0
  12. package/lib/actions.d.ts +13 -0
  13. package/lib/actions.d.ts.map +1 -0
  14. package/lib/actions.js +86 -0
  15. package/lib/client.d.ts +104 -0
  16. package/lib/client.d.ts.map +1 -0
  17. package/lib/client.js +95 -0
  18. package/lib/env.d.ts +12 -0
  19. package/lib/env.d.ts.map +1 -0
  20. package/lib/env.js +38 -0
  21. package/lib/index.d.ts +56 -0
  22. package/lib/index.d.ts.map +1 -0
  23. package/lib/index.js +187 -0
  24. package/lib/types.d.ts +24 -0
  25. package/lib/types.d.ts.map +1 -0
  26. package/lib/types.js +1 -0
  27. package/middleware.d.ts +9 -0
  28. package/middleware.d.ts.map +1 -0
  29. package/middleware.js +12 -0
  30. package/next.d.ts +9 -0
  31. package/next.d.ts.map +1 -0
  32. package/next.js +12 -0
  33. package/package.json +93 -102
  34. package/providers/42-school.d.ts +3 -0
  35. package/providers/42-school.d.ts.map +1 -0
  36. package/providers/42-school.js +2 -0
  37. package/providers/apple.d.ts +3 -0
  38. package/providers/apple.d.ts.map +1 -0
  39. package/providers/apple.js +2 -0
  40. package/providers/asgardeo.d.ts +3 -0
  41. package/providers/asgardeo.d.ts.map +1 -0
  42. package/providers/asgardeo.js +2 -0
  43. package/providers/atlassian.d.ts +3 -0
  44. package/providers/atlassian.d.ts.map +1 -0
  45. package/providers/atlassian.js +2 -0
  46. package/providers/auth0.d.ts +3 -0
  47. package/providers/auth0.d.ts.map +1 -0
  48. package/providers/auth0.js +2 -0
  49. package/providers/authentik.d.ts +3 -0
  50. package/providers/authentik.d.ts.map +1 -0
  51. package/providers/authentik.js +2 -0
  52. package/providers/azure-ad-b2c.d.ts +3 -0
  53. package/providers/azure-ad-b2c.d.ts.map +1 -0
  54. package/providers/azure-ad-b2c.js +2 -0
  55. package/providers/azure-ad.d.ts +3 -0
  56. package/providers/azure-ad.d.ts.map +1 -0
  57. package/providers/azure-ad.js +2 -0
  58. package/providers/azure-devops.d.ts +3 -0
  59. package/providers/azure-devops.d.ts.map +1 -0
  60. package/providers/azure-devops.js +2 -0
  61. package/providers/bankid-no.d.ts +3 -0
  62. package/providers/bankid-no.d.ts.map +1 -0
  63. package/providers/bankid-no.js +2 -0
  64. package/providers/battlenet.d.ts +3 -0
  65. package/providers/battlenet.d.ts.map +1 -0
  66. package/providers/battlenet.js +2 -0
  67. package/providers/beyondidentity.d.ts +3 -0
  68. package/providers/beyondidentity.d.ts.map +1 -0
  69. package/providers/beyondidentity.js +2 -0
  70. package/providers/bitbucket.d.ts +3 -0
  71. package/providers/bitbucket.d.ts.map +1 -0
  72. package/providers/bitbucket.js +2 -0
  73. package/providers/box.d.ts +3 -0
  74. package/providers/box.d.ts.map +1 -0
  75. package/providers/box.js +2 -0
  76. package/providers/boxyhq-saml.d.ts +3 -0
  77. package/providers/boxyhq-saml.d.ts.map +1 -0
  78. package/providers/boxyhq-saml.js +2 -0
  79. package/providers/bungie.d.ts +3 -0
  80. package/providers/bungie.d.ts.map +1 -0
  81. package/providers/bungie.js +2 -0
  82. package/providers/click-up.d.ts +3 -0
  83. package/providers/click-up.d.ts.map +1 -0
  84. package/providers/click-up.js +2 -0
  85. package/providers/cognito.d.ts +3 -0
  86. package/providers/cognito.d.ts.map +1 -0
  87. package/providers/cognito.js +2 -0
  88. package/providers/coinbase.d.ts +3 -0
  89. package/providers/coinbase.d.ts.map +1 -0
  90. package/providers/coinbase.js +2 -0
  91. package/providers/concept2.d.ts +3 -0
  92. package/providers/concept2.d.ts.map +1 -0
  93. package/providers/concept2.js +2 -0
  94. package/providers/credentials.d.ts +3 -0
  95. package/providers/credentials.d.ts.map +1 -0
  96. package/providers/credentials.js +2 -0
  97. package/providers/descope.d.ts +3 -0
  98. package/providers/descope.d.ts.map +1 -0
  99. package/providers/descope.js +2 -0
  100. package/providers/discord.d.ts +3 -0
  101. package/providers/discord.d.ts.map +1 -0
  102. package/providers/discord.js +2 -0
  103. package/providers/dribbble.d.ts +3 -0
  104. package/providers/dribbble.d.ts.map +1 -0
  105. package/providers/dribbble.js +2 -0
  106. package/providers/dropbox.d.ts +3 -0
  107. package/providers/dropbox.d.ts.map +1 -0
  108. package/providers/dropbox.js +2 -0
  109. package/providers/duende-identity-server6.d.ts +3 -0
  110. package/providers/duende-identity-server6.d.ts.map +1 -0
  111. package/providers/duende-identity-server6.js +2 -0
  112. package/providers/email.d.ts +3 -0
  113. package/providers/email.d.ts.map +1 -0
  114. package/providers/email.js +2 -0
  115. package/providers/eventbrite.d.ts +3 -0
  116. package/providers/eventbrite.d.ts.map +1 -0
  117. package/providers/eventbrite.js +2 -0
  118. package/providers/eveonline.d.ts +3 -0
  119. package/providers/eveonline.d.ts.map +1 -0
  120. package/providers/eveonline.js +2 -0
  121. package/providers/facebook.d.ts +3 -0
  122. package/providers/facebook.d.ts.map +1 -0
  123. package/providers/facebook.js +2 -0
  124. package/providers/faceit.d.ts +3 -0
  125. package/providers/faceit.d.ts.map +1 -0
  126. package/providers/faceit.js +2 -0
  127. package/providers/figma.d.ts +3 -0
  128. package/providers/figma.d.ts.map +1 -0
  129. package/providers/figma.js +2 -0
  130. package/providers/forwardemail.d.ts +3 -0
  131. package/providers/forwardemail.d.ts.map +1 -0
  132. package/providers/forwardemail.js +2 -0
  133. package/providers/foursquare.d.ts +3 -0
  134. package/providers/foursquare.d.ts.map +1 -0
  135. package/providers/foursquare.js +2 -0
  136. package/providers/freshbooks.d.ts +3 -0
  137. package/providers/freshbooks.d.ts.map +1 -0
  138. package/providers/freshbooks.js +2 -0
  139. package/providers/frontegg.d.ts +3 -0
  140. package/providers/frontegg.d.ts.map +1 -0
  141. package/providers/frontegg.js +2 -0
  142. package/providers/fusionauth.d.ts +3 -0
  143. package/providers/fusionauth.d.ts.map +1 -0
  144. package/providers/fusionauth.js +2 -0
  145. package/providers/github.d.ts +3 -0
  146. package/providers/github.d.ts.map +1 -0
  147. package/providers/github.js +2 -0
  148. package/providers/gitlab.d.ts +3 -0
  149. package/providers/gitlab.d.ts.map +1 -0
  150. package/providers/gitlab.js +2 -0
  151. package/providers/google.d.ts +3 -0
  152. package/providers/google.d.ts.map +1 -0
  153. package/providers/google.js +2 -0
  154. package/providers/hubspot.d.ts +3 -0
  155. package/providers/hubspot.d.ts.map +1 -0
  156. package/providers/hubspot.js +2 -0
  157. package/providers/huggingface.d.ts +3 -0
  158. package/providers/huggingface.d.ts.map +1 -0
  159. package/providers/huggingface.js +2 -0
  160. package/providers/identity-server4.d.ts +3 -0
  161. package/providers/identity-server4.d.ts.map +1 -0
  162. package/providers/identity-server4.js +2 -0
  163. package/providers/index.d.ts +2 -0
  164. package/providers/index.d.ts.map +1 -0
  165. package/providers/index.js +1 -0
  166. package/providers/instagram.d.ts +3 -0
  167. package/providers/instagram.d.ts.map +1 -0
  168. package/providers/instagram.js +2 -0
  169. package/providers/kakao.d.ts +3 -0
  170. package/providers/kakao.d.ts.map +1 -0
  171. package/providers/kakao.js +2 -0
  172. package/providers/keycloak.d.ts +3 -0
  173. package/providers/keycloak.d.ts.map +1 -0
  174. package/providers/keycloak.js +2 -0
  175. package/providers/kinde.d.ts +3 -0
  176. package/providers/kinde.d.ts.map +1 -0
  177. package/providers/kinde.js +2 -0
  178. package/providers/line.d.ts +3 -0
  179. package/providers/line.d.ts.map +1 -0
  180. package/providers/line.js +2 -0
  181. package/providers/linkedin.d.ts +3 -0
  182. package/providers/linkedin.d.ts.map +1 -0
  183. package/providers/linkedin.js +2 -0
  184. package/providers/logto.d.ts +3 -0
  185. package/providers/logto.d.ts.map +1 -0
  186. package/providers/logto.js +2 -0
  187. package/providers/loops.d.ts +3 -0
  188. package/providers/loops.d.ts.map +1 -0
  189. package/providers/loops.js +2 -0
  190. package/providers/mailchimp.d.ts +3 -0
  191. package/providers/mailchimp.d.ts.map +1 -0
  192. package/providers/mailchimp.js +2 -0
  193. package/providers/mailgun.d.ts +3 -0
  194. package/providers/mailgun.d.ts.map +1 -0
  195. package/providers/mailgun.js +2 -0
  196. package/providers/mailru.d.ts +3 -0
  197. package/providers/mailru.d.ts.map +1 -0
  198. package/providers/mailru.js +2 -0
  199. package/providers/mastodon.d.ts +3 -0
  200. package/providers/mastodon.d.ts.map +1 -0
  201. package/providers/mastodon.js +2 -0
  202. package/providers/mattermost.d.ts +3 -0
  203. package/providers/mattermost.d.ts.map +1 -0
  204. package/providers/mattermost.js +2 -0
  205. package/providers/medium.d.ts +3 -0
  206. package/providers/medium.d.ts.map +1 -0
  207. package/providers/medium.js +2 -0
  208. package/providers/microsoft-entra-id.d.ts +3 -0
  209. package/providers/microsoft-entra-id.d.ts.map +1 -0
  210. package/providers/microsoft-entra-id.js +2 -0
  211. package/providers/naver.d.ts +3 -0
  212. package/providers/naver.d.ts.map +1 -0
  213. package/providers/naver.js +2 -0
  214. package/providers/netlify.d.ts +3 -0
  215. package/providers/netlify.d.ts.map +1 -0
  216. package/providers/netlify.js +2 -0
  217. package/providers/netsuite.d.ts +3 -0
  218. package/providers/netsuite.d.ts.map +1 -0
  219. package/providers/netsuite.js +2 -0
  220. package/providers/nextcloud.d.ts +3 -0
  221. package/providers/nextcloud.d.ts.map +1 -0
  222. package/providers/nextcloud.js +2 -0
  223. package/providers/nodemailer.d.ts +3 -0
  224. package/providers/nodemailer.d.ts.map +1 -0
  225. package/providers/nodemailer.js +2 -0
  226. package/providers/notion.d.ts +3 -0
  227. package/providers/notion.d.ts.map +1 -0
  228. package/providers/notion.js +2 -0
  229. package/providers/okta.d.ts +3 -0
  230. package/providers/okta.d.ts.map +1 -0
  231. package/providers/okta.js +2 -0
  232. package/providers/onelogin.d.ts +3 -0
  233. package/providers/onelogin.d.ts.map +1 -0
  234. package/providers/onelogin.js +2 -0
  235. package/providers/ory-hydra.d.ts +3 -0
  236. package/providers/ory-hydra.d.ts.map +1 -0
  237. package/providers/ory-hydra.js +2 -0
  238. package/providers/osso.d.ts +3 -0
  239. package/providers/osso.d.ts.map +1 -0
  240. package/providers/osso.js +2 -0
  241. package/providers/osu.d.ts +3 -0
  242. package/providers/osu.d.ts.map +1 -0
  243. package/providers/osu.js +2 -0
  244. package/providers/passage.d.ts +3 -0
  245. package/providers/passage.d.ts.map +1 -0
  246. package/providers/passage.js +2 -0
  247. package/providers/passkey.d.ts +3 -0
  248. package/providers/passkey.d.ts.map +1 -0
  249. package/providers/passkey.js +2 -0
  250. package/providers/patreon.d.ts +3 -0
  251. package/providers/patreon.d.ts.map +1 -0
  252. package/providers/patreon.js +2 -0
  253. package/providers/ping-id.d.ts +3 -0
  254. package/providers/ping-id.d.ts.map +1 -0
  255. package/providers/ping-id.js +2 -0
  256. package/providers/pinterest.d.ts +3 -0
  257. package/providers/pinterest.d.ts.map +1 -0
  258. package/providers/pinterest.js +2 -0
  259. package/providers/pipedrive.d.ts +3 -0
  260. package/providers/pipedrive.d.ts.map +1 -0
  261. package/providers/pipedrive.js +2 -0
  262. package/providers/postmark.d.ts +3 -0
  263. package/providers/postmark.d.ts.map +1 -0
  264. package/providers/postmark.js +2 -0
  265. package/providers/reddit.d.ts +3 -0
  266. package/providers/reddit.d.ts.map +1 -0
  267. package/providers/reddit.js +2 -0
  268. package/providers/resend.d.ts +3 -0
  269. package/providers/resend.d.ts.map +1 -0
  270. package/providers/resend.js +2 -0
  271. package/providers/roblox.d.ts +3 -0
  272. package/providers/roblox.d.ts.map +1 -0
  273. package/providers/roblox.js +2 -0
  274. package/providers/salesforce.d.ts +3 -0
  275. package/providers/salesforce.d.ts.map +1 -0
  276. package/providers/salesforce.js +2 -0
  277. package/providers/sendgrid.d.ts +3 -0
  278. package/providers/sendgrid.d.ts.map +1 -0
  279. package/providers/sendgrid.js +2 -0
  280. package/providers/simplelogin.d.ts +3 -0
  281. package/providers/simplelogin.d.ts.map +1 -0
  282. package/providers/simplelogin.js +2 -0
  283. package/providers/slack.d.ts +3 -0
  284. package/providers/slack.d.ts.map +1 -0
  285. package/providers/slack.js +2 -0
  286. package/providers/spotify.d.ts +3 -0
  287. package/providers/spotify.d.ts.map +1 -0
  288. package/providers/spotify.js +2 -0
  289. package/providers/strava.d.ts +3 -0
  290. package/providers/strava.d.ts.map +1 -0
  291. package/providers/strava.js +2 -0
  292. package/providers/threads.d.ts +3 -0
  293. package/providers/threads.d.ts.map +1 -0
  294. package/providers/threads.js +2 -0
  295. package/providers/tiktok.d.ts +3 -0
  296. package/providers/tiktok.d.ts.map +1 -0
  297. package/providers/tiktok.js +2 -0
  298. package/providers/todoist.d.ts +3 -0
  299. package/providers/todoist.d.ts.map +1 -0
  300. package/providers/todoist.js +2 -0
  301. package/providers/trakt.d.ts +3 -0
  302. package/providers/trakt.d.ts.map +1 -0
  303. package/providers/trakt.js +2 -0
  304. package/providers/twitch.d.ts +3 -0
  305. package/providers/twitch.d.ts.map +1 -0
  306. package/providers/twitch.js +2 -0
  307. package/providers/twitter.d.ts +3 -0
  308. package/providers/twitter.d.ts.map +1 -0
  309. package/providers/twitter.js +2 -0
  310. package/providers/united-effects.d.ts +3 -0
  311. package/providers/united-effects.d.ts.map +1 -0
  312. package/providers/united-effects.js +2 -0
  313. package/providers/vipps.d.ts +3 -0
  314. package/providers/vipps.d.ts.map +1 -0
  315. package/providers/vipps.js +2 -0
  316. package/providers/vk.d.ts +3 -0
  317. package/providers/vk.d.ts.map +1 -0
  318. package/providers/vk.js +2 -0
  319. package/providers/webauthn.d.ts +3 -0
  320. package/providers/webauthn.d.ts.map +1 -0
  321. package/providers/webauthn.js +2 -0
  322. package/providers/webex.d.ts +3 -0
  323. package/providers/webex.d.ts.map +1 -0
  324. package/providers/webex.js +2 -0
  325. package/providers/wechat.d.ts +3 -0
  326. package/providers/wechat.d.ts.map +1 -0
  327. package/providers/wechat.js +2 -0
  328. package/providers/wikimedia.d.ts +3 -0
  329. package/providers/wikimedia.d.ts.map +1 -0
  330. package/providers/wikimedia.js +2 -0
  331. package/providers/wordpress.d.ts +3 -0
  332. package/providers/wordpress.d.ts.map +1 -0
  333. package/providers/wordpress.js +2 -0
  334. package/providers/workos.d.ts +3 -0
  335. package/providers/workos.d.ts.map +1 -0
  336. package/providers/workos.js +2 -0
  337. package/providers/yandex.d.ts +3 -0
  338. package/providers/yandex.d.ts.map +1 -0
  339. package/providers/yandex.js +2 -0
  340. package/providers/zitadel.d.ts +3 -0
  341. package/providers/zitadel.d.ts.map +1 -0
  342. package/providers/zitadel.js +2 -0
  343. package/providers/zoho.d.ts +3 -0
  344. package/providers/zoho.d.ts.map +1 -0
  345. package/providers/zoho.js +2 -0
  346. package/providers/zoom.d.ts +3 -0
  347. package/providers/zoom.d.ts.map +1 -0
  348. package/providers/zoom.js +2 -0
  349. package/react.d.ts +102 -0
  350. package/react.d.ts.map +1 -0
  351. package/react.js +361 -0
  352. package/src/adapters.ts +1 -0
  353. package/src/index.ts +430 -0
  354. package/src/jwt.ts +9 -0
  355. package/src/lib/actions.ts +144 -0
  356. package/src/lib/client.ts +245 -0
  357. package/src/lib/env.ts +36 -0
  358. package/src/lib/index.ts +313 -0
  359. package/src/lib/types.ts +30 -0
  360. package/src/middleware.ts +16 -0
  361. package/src/next.ts +16 -0
  362. package/src/providers/42-school.ts +2 -0
  363. package/src/providers/apple.ts +2 -0
  364. package/src/providers/asgardeo.ts +2 -0
  365. package/src/providers/atlassian.ts +2 -0
  366. package/src/providers/auth0.ts +2 -0
  367. package/src/providers/authentik.ts +2 -0
  368. package/src/providers/azure-ad-b2c.ts +2 -0
  369. package/src/providers/azure-ad.ts +2 -0
  370. package/src/providers/azure-devops.ts +2 -0
  371. package/src/providers/bankid-no.ts +2 -0
  372. package/src/providers/battlenet.ts +2 -0
  373. package/src/providers/beyondidentity.ts +2 -0
  374. package/src/providers/bitbucket.ts +2 -0
  375. package/src/providers/box.ts +2 -0
  376. package/src/providers/boxyhq-saml.ts +2 -0
  377. package/src/providers/bungie.ts +2 -0
  378. package/src/providers/click-up.ts +2 -0
  379. package/src/providers/cognito.ts +2 -0
  380. package/src/providers/coinbase.ts +2 -0
  381. package/src/providers/concept2.ts +2 -0
  382. package/src/providers/credentials.ts +2 -0
  383. package/src/providers/descope.ts +2 -0
  384. package/src/providers/discord.ts +2 -0
  385. package/src/providers/dribbble.ts +2 -0
  386. package/src/providers/dropbox.ts +2 -0
  387. package/src/providers/duende-identity-server6.ts +2 -0
  388. package/src/providers/email.ts +2 -0
  389. package/src/providers/eventbrite.ts +2 -0
  390. package/src/providers/eveonline.ts +2 -0
  391. package/src/providers/facebook.ts +2 -0
  392. package/src/providers/faceit.ts +2 -0
  393. package/src/providers/figma.ts +2 -0
  394. package/src/providers/forwardemail.ts +2 -0
  395. package/src/providers/foursquare.ts +2 -0
  396. package/src/providers/freshbooks.ts +2 -0
  397. package/src/providers/frontegg.ts +2 -0
  398. package/src/providers/fusionauth.ts +2 -0
  399. package/src/providers/github.ts +2 -0
  400. package/src/providers/gitlab.ts +2 -0
  401. package/src/providers/google.ts +2 -0
  402. package/src/providers/hubspot.ts +2 -0
  403. package/src/providers/huggingface.ts +2 -0
  404. package/src/providers/identity-server4.ts +2 -0
  405. package/src/providers/index.ts +1 -0
  406. package/src/providers/instagram.ts +2 -0
  407. package/src/providers/kakao.ts +2 -0
  408. package/src/providers/keycloak.ts +2 -0
  409. package/src/providers/kinde.ts +2 -0
  410. package/src/providers/line.ts +2 -0
  411. package/src/providers/linkedin.ts +2 -0
  412. package/src/providers/logto.ts +2 -0
  413. package/src/providers/loops.ts +2 -0
  414. package/src/providers/mailchimp.ts +2 -0
  415. package/src/providers/mailgun.ts +2 -0
  416. package/src/providers/mailru.ts +2 -0
  417. package/src/providers/mastodon.ts +2 -0
  418. package/src/providers/mattermost.ts +2 -0
  419. package/src/providers/medium.ts +2 -0
  420. package/src/providers/microsoft-entra-id.ts +2 -0
  421. package/src/providers/naver.ts +2 -0
  422. package/src/providers/netlify.ts +2 -0
  423. package/src/providers/netsuite.ts +2 -0
  424. package/src/providers/nextcloud.ts +2 -0
  425. package/src/providers/nodemailer.ts +2 -0
  426. package/src/providers/notion.ts +2 -0
  427. package/src/providers/okta.ts +2 -0
  428. package/src/providers/onelogin.ts +2 -0
  429. package/src/providers/ory-hydra.ts +2 -0
  430. package/src/providers/osso.ts +2 -0
  431. package/src/providers/osu.ts +2 -0
  432. package/src/providers/passage.ts +2 -0
  433. package/src/providers/passkey.ts +2 -0
  434. package/src/providers/patreon.ts +2 -0
  435. package/src/providers/ping-id.ts +2 -0
  436. package/src/providers/pinterest.ts +2 -0
  437. package/src/providers/pipedrive.ts +2 -0
  438. package/src/providers/postmark.ts +2 -0
  439. package/src/providers/reddit.ts +2 -0
  440. package/src/providers/resend.ts +2 -0
  441. package/src/providers/roblox.ts +2 -0
  442. package/src/providers/salesforce.ts +2 -0
  443. package/src/providers/sendgrid.ts +2 -0
  444. package/src/providers/simplelogin.ts +2 -0
  445. package/src/providers/slack.ts +2 -0
  446. package/src/providers/spotify.ts +2 -0
  447. package/src/providers/strava.ts +2 -0
  448. package/src/providers/threads.ts +2 -0
  449. package/src/providers/tiktok.ts +2 -0
  450. package/src/providers/todoist.ts +2 -0
  451. package/src/providers/trakt.ts +2 -0
  452. package/src/providers/twitch.ts +2 -0
  453. package/src/providers/twitter.ts +2 -0
  454. package/src/providers/united-effects.ts +2 -0
  455. package/src/providers/vipps.ts +2 -0
  456. package/src/providers/vk.ts +2 -0
  457. package/src/providers/webauthn.ts +2 -0
  458. package/src/providers/webex.ts +2 -0
  459. package/src/providers/wechat.ts +2 -0
  460. package/src/providers/wikimedia.ts +2 -0
  461. package/src/providers/wordpress.ts +2 -0
  462. package/src/providers/workos.ts +2 -0
  463. package/src/providers/yandex.ts +2 -0
  464. package/src/providers/zitadel.ts +2 -0
  465. package/src/providers/zoho.ts +2 -0
  466. package/src/providers/zoom.ts +2 -0
  467. package/src/react.tsx +546 -0
  468. package/src/webauthn.ts +152 -0
  469. package/webauthn.d.ts +9 -0
  470. package/webauthn.d.ts.map +1 -0
  471. package/webauthn.js +92 -0
  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,484 +0,0 @@
1
- import { User, Session, AuthResult, SuccessfulAuthResult, FailedAuthResult, TwoFactorAuthResult, EmailCredentials, RegisterData, Verify2FAData } from './auth';
2
- /**
3
- * Core type definitions for Mulguard Authentication Library
4
- *
5
- * @module @mulguard/core/types
6
- * @see {@link https://github.com/mulguard/mulguard} for documentation
7
- */
8
- export * from './auth';
9
- export * from './errors';
10
- /**
11
- * Generic HTTP client interface for making API requests.
12
- *
13
- * @template TResponse - Response data type
14
- * @template TRequest - Request data type (optional)
15
- *
16
- * @example
17
- * ```typescript
18
- * const client: ApiClient = {
19
- * get: async <T>(url: string) => ({ data: await fetch(url).then(r => r.json()) as T }),
20
- * post: async <T>(url: string, data?: unknown) => ({ data: await fetch(url, { method: 'POST', body: JSON.stringify(data) }).then(r => r.json()) as T }),
21
- * // ...
22
- * }
23
- * ```
24
- */
25
- export interface ApiClient {
26
- /** GET request */
27
- get: <TResponse = unknown>(url: string, config?: unknown) => Promise<{
28
- data: TResponse;
29
- }>;
30
- /** POST request */
31
- post: <TResponse = unknown, TRequest = unknown>(url: string, data?: TRequest, config?: unknown) => Promise<{
32
- data: TResponse;
33
- }>;
34
- /** PUT request */
35
- put: <TResponse = unknown, TRequest = unknown>(url: string, data?: TRequest, config?: unknown) => Promise<{
36
- data: TResponse;
37
- }>;
38
- /** DELETE request */
39
- delete: <TResponse = unknown>(url: string, config?: unknown) => Promise<{
40
- data: TResponse;
41
- }>;
42
- }
43
- /**
44
- * Authentication provider type.
45
- */
46
- export type AuthProvider = 'email' | 'oauth' | 'passkey';
47
- /**
48
- * Remembered user information for account picker functionality.
49
- *
50
- * @property userId - Unique user identifier
51
- * @property email - User email address
52
- * @property name - User display name
53
- * @property avatar - Optional avatar URL
54
- * @property provider - Authentication provider used
55
- * @property lastLoginAt - Timestamp of last login
56
- */
57
- export interface RememberedUser {
58
- readonly userId: string;
59
- readonly email: string;
60
- readonly name: string;
61
- readonly avatar?: string;
62
- readonly provider: AuthProvider;
63
- readonly lastLoginAt: Date;
64
- }
65
- /**
66
- * OAuth provider configuration.
67
- *
68
- * @property clientId - OAuth client identifier (required)
69
- * @property clientSecret - OAuth client secret (server-side only, optional)
70
- * @property redirectUri - Custom redirect URI (auto-generated if not provided)
71
- * @property scopes - OAuth scopes (defaults provided per provider)
72
- * @property params - Additional OAuth parameters
73
- */
74
- export interface OAuthProviderConfig {
75
- readonly clientId: string;
76
- readonly clientSecret?: string;
77
- readonly redirectUri?: string;
78
- readonly scopes?: readonly string[];
79
- readonly params?: Readonly<Record<string, string>>;
80
- }
81
- /**
82
- * OAuth providers configuration map.
83
- *
84
- * Supports built-in providers (google, github, apple, facebook) and custom providers.
85
- *
86
- * @example
87
- * ```typescript
88
- * const providers: OAuthProvidersConfig = {
89
- * google: { clientId: '...', clientSecret: '...' },
90
- * custom: { clientId: '...', scopes: ['read', 'write'] }
91
- * }
92
- * ```
93
- */
94
- export interface OAuthProvidersConfig {
95
- readonly google?: OAuthProviderConfig;
96
- readonly github?: OAuthProviderConfig;
97
- readonly apple?: OAuthProviderConfig;
98
- readonly facebook?: OAuthProviderConfig;
99
- readonly [key: string]: OAuthProviderConfig | undefined;
100
- }
101
- /**
102
- * OAuth token response from provider.
103
- *
104
- * @property access_token - Access token (required)
105
- * @property refresh_token - Refresh token (optional)
106
- * @property expires_in - Token expiration in seconds (optional)
107
- * @property token_type - Token type, typically 'Bearer' (optional)
108
- * @property id_token - ID token for OpenID Connect (optional)
109
- * @property scope - Granted scopes (optional)
110
- */
111
- export interface OAuthTokens {
112
- readonly access_token: string;
113
- readonly refresh_token?: string;
114
- readonly expires_in?: number;
115
- readonly token_type?: string;
116
- readonly id_token?: string;
117
- readonly scope?: string;
118
- }
119
- /**
120
- * Enhanced OAuth user information with tokens and provider metadata.
121
- *
122
- * This interface extends basic user info with OAuth-specific data required for
123
- * backend API integration and advanced use cases.
124
- *
125
- * @property id - User ID from OAuth provider
126
- * @property email - User email from OAuth provider
127
- * @property name - User display name
128
- * @property avatar - User avatar URL (optional)
129
- * @property emailVerified - Email verification status (optional)
130
- * @property provider - OAuth provider identifier (e.g., 'google', 'github')
131
- * @property accessToken - OAuth access token (required for backend API)
132
- * @property refreshToken - OAuth refresh token (optional)
133
- * @property tokens - Complete OAuth tokens object
134
- * @property rawProfile - Raw profile data from provider (for advanced use)
135
- *
136
- * @example
137
- * ```typescript
138
- * callbacks: {
139
- * onOAuthUser: async (userInfo) => {
140
- * // userInfo.accessToken available for backend API calls
141
- * // userInfo.rawProfile available for provider-specific data
142
- * return await createOrUpdateUser(userInfo)
143
- * }
144
- * }
145
- * ```
146
- */
147
- export interface OAuthUserInfo {
148
- readonly id: string;
149
- readonly email: string;
150
- readonly name: string;
151
- readonly avatar?: string;
152
- readonly emailVerified?: boolean;
153
- readonly provider: string;
154
- readonly accessToken: string;
155
- readonly refreshToken?: string;
156
- readonly tokens: OAuthTokens;
157
- readonly rawProfile?: Readonly<Record<string, unknown>>;
158
- readonly [key: string]: unknown;
159
- }
160
- /**
161
- * Session cookie configuration.
162
- *
163
- * @property cookieName - Cookie name (default: '__mulguard_session')
164
- * @property expiresIn - Session expiration in seconds (default: 7 days)
165
- * @property httpOnly - HttpOnly flag (default: true)
166
- * @property secure - Secure flag (default: true in production)
167
- * @property sameSite - SameSite policy (default: 'lax')
168
- * @property path - Cookie path (default: '/')
169
- * @property domain - Cookie domain (optional)
170
- * @property cacheTtl - Session cache TTL in milliseconds (default: 5000)
171
- */
172
- export interface SessionConfig {
173
- readonly cookieName?: string;
174
- readonly expiresIn?: number;
175
- readonly httpOnly?: boolean;
176
- readonly secure?: boolean;
177
- readonly sameSite?: 'strict' | 'lax' | 'none';
178
- readonly path?: string;
179
- readonly domain?: string;
180
- readonly cacheTtl?: number;
181
- }
182
- /**
183
- * Security configuration options.
184
- *
185
- * Enhanced with comprehensive security settings from SecurityManager.
186
- *
187
- * @property csrfProtection - CSRF protection configuration
188
- * @property rateLimiting - Rate limiting configuration
189
- * @property validation - Input validation configuration
190
- * @property xssProtection - XSS protection configuration
191
- * @property requireHttps - Require HTTPS (default: true in production)
192
- * @property allowedOrigins - Allowed origins for CORS
193
- */
194
- export interface SecurityConfig {
195
- readonly csrfProtection?: {
196
- readonly enabled?: boolean;
197
- readonly tokenLength?: number;
198
- readonly expiresIn?: number;
199
- };
200
- readonly rateLimiting?: {
201
- readonly enabled?: boolean;
202
- readonly maxAttempts?: number;
203
- readonly windowMs?: number;
204
- readonly strategy?: 'ip' | 'user' | 'email';
205
- };
206
- readonly validation?: {
207
- readonly strictEmail?: boolean;
208
- readonly minPasswordLength?: number;
209
- readonly requireStrongPassword?: boolean;
210
- };
211
- readonly xssProtection?: {
212
- readonly enabled?: boolean;
213
- readonly sanitizeHtml?: boolean;
214
- };
215
- readonly requireHttps?: boolean;
216
- readonly allowedOrigins?: readonly string[];
217
- }
218
- /**
219
- * OAuth provider identifier.
220
- */
221
- export type OAuthProviderId = 'google' | 'github' | 'apple' | 'facebook' | string;
222
- /**
223
- * Sign-in provider type.
224
- */
225
- export type SignInProvider = OAuthProviderId | 'credentials' | 'passkey' | 'otp';
226
- /**
227
- * Sign-in options for unified interface.
228
- *
229
- * @property provider - Authentication provider
230
- * @property credentials - Email/password credentials (for 'credentials' provider)
231
- * @property formData - Form data (alternative to credentials)
232
- * @property options - Additional options (for 'otp' or 'passkey' providers)
233
- */
234
- export interface SignInOptions {
235
- readonly provider: SignInProvider;
236
- readonly credentials?: Readonly<EmailCredentials>;
237
- readonly formData?: FormData;
238
- readonly options?: Readonly<{
239
- userId?: string;
240
- email?: string;
241
- code?: string;
242
- }>;
243
- }
244
- /**
245
- * Lifecycle callbacks configuration.
246
- *
247
- * All callbacks are optional and can be used to hook into authentication events.
248
- *
249
- * @property onSignIn - Called after successful sign-in
250
- * @property onSignOut - Called after sign-out
251
- * @property onSessionUpdate - Called when session is updated (can modify session)
252
- * @property onError - Called on authentication errors
253
- * @property onTokenRefresh - Called when tokens are refreshed
254
- * @property onSessionExpired - Called when session expires
255
- * @property onOAuthUser - Called when OAuth user is received (for user creation/lookup)
256
- */
257
- export interface CallbacksConfig {
258
- readonly onSignIn?: (user: User, session: Session) => Promise<void> | void;
259
- readonly onSignOut?: (user: User) => Promise<void> | void;
260
- readonly onSessionUpdate?: (session: Session) => Promise<Session> | Session;
261
- readonly onError?: (error: Error, context?: string) => Promise<void> | void;
262
- readonly onTokenRefresh?: (oldSession: Session, newSession: Session) => Promise<void> | void;
263
- readonly onSessionExpired?: (session: Session) => Promise<void> | void;
264
- readonly onOAuthUser?: (userInfo: OAuthUserInfo, provider: string) => Promise<User>;
265
- }
266
- /**
267
- * Request context for Server Actions.
268
- *
269
- * Provides access to request metadata for authentication operations.
270
- *
271
- * @property headers - Request headers
272
- * @property cookies - Request cookies map
273
- * @property ip - Client IP address (optional)
274
- * @property userAgent - User agent string (optional)
275
- */
276
- export interface RequestContext {
277
- readonly headers: Headers;
278
- readonly cookies: ReadonlyMap<string, string>;
279
- readonly ip?: string;
280
- readonly userAgent?: string;
281
- }
282
- /**
283
- * Main Mulguard configuration interface.
284
- *
285
- * @template TUser - User type (extends base User)
286
- * @template TSession - Session type (extends base Session)
287
- *
288
- * @property session - Session configuration
289
- * @property actions - Custom authentication actions (required)
290
- * @property callbacks - Lifecycle callbacks (optional)
291
- * @property security - Security configuration (optional)
292
- * @property tokenRefresh - Token refresh configuration (optional)
293
- * @property providers - OAuth providers configuration (optional)
294
- * @property oauthStateStore - OAuth state store (optional, uses in-memory by default)
295
- * @property sessionCacheTtl - Session cache TTL in milliseconds (optional)
296
- */
297
- export interface MulguardConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
298
- readonly session?: SessionConfig;
299
- readonly actions: AuthActions<TUser, TSession>;
300
- readonly callbacks?: CallbacksConfig;
301
- readonly security?: SecurityConfig;
302
- readonly tokenRefresh?: import('../client/token-refresh-manager').TokenRefreshConfig;
303
- readonly providers?: {
304
- readonly oauth?: OAuthProvidersConfig;
305
- };
306
- readonly oauthStateStore?: import('../auth/oauth/state-store').OAuthStateStore;
307
- readonly sessionCacheTtl?: number;
308
- }
309
- export type { User, Session, AuthResult, SuccessfulAuthResult, FailedAuthResult, TwoFactorAuthResult, EmailCredentials, RegisterData, Verify2FAData, };
310
- export { isAuthSuccess, isAuthFailure, isTwoFactorRequired } from './auth';
311
- /**
312
- * Custom authentication actions interface.
313
- *
314
- * Users implement these actions to provide custom authentication logic.
315
- * All actions are Server Actions that run on the server.
316
- *
317
- * @template TUser - User type
318
- * @template TSession - Session type
319
- */
320
- export interface AuthActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
321
- readonly signIn: SignInActions<TUser, TSession>;
322
- readonly signUp?: (data: RegisterData) => Promise<AuthResult<TUser, TSession>>;
323
- readonly signOut?: () => Promise<{
324
- success: boolean;
325
- error?: string;
326
- }>;
327
- readonly resetPassword?: (email: string) => Promise<{
328
- success: boolean;
329
- error?: string;
330
- }>;
331
- readonly verifyEmail?: (token: string) => Promise<{
332
- success: boolean;
333
- error?: string;
334
- }>;
335
- readonly getSession?: () => Promise<TSession | null>;
336
- readonly refreshSession?: () => Promise<TSession | null>;
337
- readonly oauthCallback?: (provider: string, code: string, state: string) => Promise<AuthResult<TUser, TSession>>;
338
- readonly passkey?: PasskeyActions<TUser, TSession>;
339
- readonly twoFactor?: TwoFactorActions<TUser, TSession>;
340
- readonly verify2FA?: (data: Verify2FAData) => Promise<AuthResult<TUser, TSession>>;
341
- }
342
- /**
343
- * Sign-in actions interface.
344
- *
345
- * @template TUser - User type
346
- * @template TSession - Session type
347
- */
348
- export interface SignInActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
349
- readonly email: (credentials: EmailCredentials) => Promise<AuthResult<TUser, TSession>>;
350
- readonly oauth?: (provider: string) => Promise<{
351
- url: string;
352
- state: string;
353
- }>;
354
- readonly passkey?: (options?: {
355
- userId?: string;
356
- }) => Promise<AuthResult<TUser, TSession>>;
357
- readonly otp?: (email: string, code?: string) => Promise<AuthResult<TUser, TSession>>;
358
- }
359
- /**
360
- * Passkey actions interface.
361
- *
362
- * @template TUser - User type
363
- * @template TSession - Session type
364
- */
365
- export interface PasskeyActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
366
- readonly register?: (options?: {
367
- name?: string;
368
- userId?: string;
369
- }) => Promise<{
370
- success: boolean;
371
- passkeyId?: string;
372
- error?: string;
373
- }>;
374
- readonly authenticate?: (options?: {
375
- userId?: string;
376
- }) => Promise<AuthResult<TUser, TSession>>;
377
- readonly list?: () => Promise<ReadonlyArray<{
378
- id: string;
379
- name: string;
380
- createdAt: Date;
381
- lastUsedAt?: Date;
382
- }>>;
383
- readonly remove?: (passKeyId: string) => Promise<{
384
- success: boolean;
385
- error?: string;
386
- }>;
387
- }
388
- /**
389
- * Two-factor authentication actions interface.
390
- *
391
- * @template TUser - User type
392
- * @template TSession - Session type
393
- */
394
- export interface TwoFactorActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
395
- readonly enable?: () => Promise<{
396
- success: boolean;
397
- qrCode?: string;
398
- secret?: string;
399
- error?: string;
400
- }>;
401
- readonly verify?: (code: string) => Promise<{
402
- success: boolean;
403
- backupCodes?: string[];
404
- error?: string;
405
- }>;
406
- readonly disable?: () => Promise<{
407
- success: boolean;
408
- error?: string;
409
- }>;
410
- readonly generateBackupCodes?: () => Promise<{
411
- success: boolean;
412
- backupCodes?: string[];
413
- error?: string;
414
- }>;
415
- readonly isEnabled?: () => Promise<boolean>;
416
- readonly verify2FA?: (data: Verify2FAData) => Promise<AuthResult<TUser, TSession>>;
417
- }
418
- /**
419
- * Type predicate to check if a value is a valid User object.
420
- *
421
- * @param value - Value to check
422
- * @returns True if value is a valid User
423
- *
424
- * @example
425
- * ```typescript
426
- * if (isUser(data)) {
427
- * // TypeScript knows data is User here
428
- * console.log(data.email)
429
- * }
430
- * ```
431
- */
432
- export declare function isUser(value: unknown): value is User;
433
- /**
434
- * Type predicate to check if a value is a valid Session object.
435
- *
436
- * @template TUser - User type
437
- * @param value - Value to check
438
- * @returns True if value is a valid Session
439
- *
440
- * @example
441
- * ```typescript
442
- * if (isSession(data)) {
443
- * // TypeScript knows data is Session here
444
- * console.log(data.user.email)
445
- * }
446
- * ```
447
- */
448
- export declare function isSession<TUser extends User = User>(value: unknown): value is Session<TUser>;
449
- /**
450
- * TODO: Performance
451
- * - [ ] Add type-level optimizations for large union types
452
- * - [ ] Consider using branded types for IDs to prevent mixing
453
- * - [ ] Add type-level validation for configuration objects
454
- * - [ ] Implement type-safe builder pattern for complex configurations
455
- *
456
- * TODO: Features
457
- * - [ ] Add conditional types for provider-specific OAuth configs
458
- * - [ ] Implement discriminated unions for AuthResult variants
459
- * - [ ] Add type-level session expiration checking
460
- * - [ ] Create type-safe middleware chain types
461
- * - [ ] Add generic constraints for custom User/Session extensions
462
- *
463
- * TODO: Type Safety
464
- * - [ ] Add branded types for sensitive data (tokens, passwords)
465
- * - [ ] Implement type-level validation for email formats
466
- * - [ ] Add type guards for all public interfaces
467
- * - [ ] Create type-safe error handling with exhaustiveness checking
468
- *
469
- * TODO: Testing
470
- * - [ ] Add type-level tests using ts-expect
471
- * - [ ] Test type inference in various scenarios
472
- * - [ ] Verify type narrowing with type predicates
473
- * - [ ] Test generic constraints and conditional types
474
- *
475
- * TODO: Documentation
476
- * - [ ] Add more JSDoc examples for complex types
477
- * - [ ] Document type-level patterns and best practices
478
- * - [ ] Create type usage guides
479
- *
480
- * TODO: Limitations
481
- * - [ ] Type inference may be limited with very complex generic chains
482
- * - [ ] Branded types add runtime overhead (consider compile-time only)
483
- * - [ ] Deep readonly types may impact performance with large objects
484
- */
@@ -1,136 +0,0 @@
1
- import { AuthResult, TwoFactorAuthResult } from '../types/auth';
2
- import { AuthErrorCode } from '../types/errors';
3
- /**
4
- * Check if an authentication result indicates an error
5
- *
6
- * @param result - Authentication result to check
7
- * @returns True if the result indicates an error
8
- *
9
- * @example
10
- * ```typescript
11
- * const result = await auth.signIn.email(credentials)
12
- * if (isAuthError(result)) {
13
- * console.error('Authentication failed:', result.error)
14
- * }
15
- * ```
16
- */
17
- export declare function isAuthError(result: AuthResult): boolean;
18
- /**
19
- * Type guard to check if 2FA is required
20
- *
21
- * This function narrows the type to TwoFactorAuthResult when true,
22
- * making it easier to work with 2FA flows in TypeScript.
23
- *
24
- * @param result - Authentication result to check
25
- * @returns True if 2FA is required (type guard)
26
- *
27
- * @example
28
- * ```typescript
29
- * const result = await auth.signIn.email(credentials)
30
- * if (isTwoFactorRequired(result)) {
31
- * // TypeScript knows result is TwoFactorAuthResult here
32
- * console.log('2FA required for:', result.email)
33
- * // Can safely access result.email, result.userId, result.twoFactorMethod
34
- * }
35
- * ```
36
- */
37
- export declare function isTwoFactorRequired(result: AuthResult): result is TwoFactorAuthResult;
38
- /**
39
- * Get error message from authentication result
40
- *
41
- * @param result - Authentication result
42
- * @param defaultMessage - Default message if no error is present
43
- * @returns Error message or default message
44
- *
45
- * @example
46
- * ```typescript
47
- * const result = await auth.signIn.email(credentials)
48
- * if (!result.success) {
49
- * const message = getErrorMessage(result, 'Authentication failed')
50
- * showToast(message)
51
- * }
52
- * ```
53
- */
54
- export declare function getErrorMessage(result: AuthResult, defaultMessage?: string): string;
55
- /**
56
- * Get error code from authentication result
57
- *
58
- * @param result - Authentication result
59
- * @returns Error code or undefined
60
- *
61
- * @example
62
- * ```typescript
63
- * const result = await auth.signIn.email(credentials)
64
- * const errorCode = getErrorCode(result)
65
- * if (errorCode === AuthErrorCode.ACCOUNT_LOCKED) {
66
- * showAccountLockedMessage()
67
- * }
68
- * ```
69
- */
70
- export declare function getErrorCode(result: AuthResult): AuthErrorCode | undefined;
71
- /**
72
- * Check if authentication was successful
73
- *
74
- * @param result - Authentication result to check
75
- * @returns True if authentication was successful
76
- *
77
- * @example
78
- * ```typescript
79
- * const result = await auth.signIn.email(credentials)
80
- * if (isAuthSuccess(result)) {
81
- * console.log('Welcome,', result.user?.name)
82
- * }
83
- * ```
84
- */
85
- export declare function isAuthSuccess(result: AuthResult): boolean;
86
- /**
87
- * Check if a specific error code matches
88
- *
89
- * @param result - Authentication result
90
- * @param code - Error code to check for
91
- * @returns True if the error code matches
92
- *
93
- * @example
94
- * ```typescript
95
- * const result = await auth.signIn.email(credentials)
96
- * if (hasErrorCode(result, AuthErrorCode.ACCOUNT_LOCKED)) {
97
- * showAccountLockedMessage()
98
- * }
99
- * ```
100
- */
101
- export declare function hasErrorCode(result: AuthResult, code: AuthErrorCode): boolean;
102
- /**
103
- * Check if the error is retryable
104
- *
105
- * Some errors (like network errors or rate limits) may be retryable,
106
- * while others (like invalid credentials) should not be retried.
107
- *
108
- * @param result - Authentication result
109
- * @returns True if the error is retryable
110
- *
111
- * @example
112
- * ```typescript
113
- * const result = await auth.signIn.email(credentials)
114
- * if (isAuthError(result) && isRetryableError(result)) {
115
- * // Show retry button
116
- * showRetryButton()
117
- * }
118
- * ```
119
- */
120
- export declare function isRetryableError(result: AuthResult): boolean;
121
- /**
122
- * Get user-friendly error message based on error code
123
- *
124
- * @param result - Authentication result
125
- * @returns User-friendly error message
126
- *
127
- * @example
128
- * ```typescript
129
- * const result = await auth.signIn.email(credentials)
130
- * if (!result.success) {
131
- * const message = getUserFriendlyError(result)
132
- * showToast(message)
133
- * }
134
- * ```
135
- */
136
- export declare function getUserFriendlyError(result: AuthResult): string;