mulguard 1.1.6 → 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.
- package/README.md +21 -1078
- package/adapters.d.ts +2 -0
- package/adapters.d.ts.map +1 -0
- package/adapters.js +1 -0
- package/index.d.ts +329 -0
- package/index.d.ts.map +1 -0
- package/index.js +145 -0
- package/jwt.d.ts +9 -0
- package/jwt.d.ts.map +1 -0
- package/jwt.js +8 -0
- package/lib/actions.d.ts +13 -0
- package/lib/actions.d.ts.map +1 -0
- package/lib/actions.js +86 -0
- package/lib/client.d.ts +104 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +95 -0
- package/lib/env.d.ts +12 -0
- package/lib/env.d.ts.map +1 -0
- package/lib/env.js +38 -0
- package/lib/index.d.ts +56 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +187 -0
- package/lib/types.d.ts +24 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/middleware.d.ts +9 -0
- package/middleware.d.ts.map +1 -0
- package/middleware.js +12 -0
- package/next.d.ts +9 -0
- package/next.d.ts.map +1 -0
- package/next.js +12 -0
- package/package.json +117 -73
- package/providers/42-school.d.ts +3 -0
- package/providers/42-school.d.ts.map +1 -0
- package/providers/42-school.js +2 -0
- package/providers/apple.d.ts +3 -0
- package/providers/apple.d.ts.map +1 -0
- package/providers/apple.js +2 -0
- package/providers/asgardeo.d.ts +3 -0
- package/providers/asgardeo.d.ts.map +1 -0
- package/providers/asgardeo.js +2 -0
- package/providers/atlassian.d.ts +3 -0
- package/providers/atlassian.d.ts.map +1 -0
- package/providers/atlassian.js +2 -0
- package/providers/auth0.d.ts +3 -0
- package/providers/auth0.d.ts.map +1 -0
- package/providers/auth0.js +2 -0
- package/providers/authentik.d.ts +3 -0
- package/providers/authentik.d.ts.map +1 -0
- package/providers/authentik.js +2 -0
- package/providers/azure-ad-b2c.d.ts +3 -0
- package/providers/azure-ad-b2c.d.ts.map +1 -0
- package/providers/azure-ad-b2c.js +2 -0
- package/providers/azure-ad.d.ts +3 -0
- package/providers/azure-ad.d.ts.map +1 -0
- package/providers/azure-ad.js +2 -0
- package/providers/azure-devops.d.ts +3 -0
- package/providers/azure-devops.d.ts.map +1 -0
- package/providers/azure-devops.js +2 -0
- package/providers/bankid-no.d.ts +3 -0
- package/providers/bankid-no.d.ts.map +1 -0
- package/providers/bankid-no.js +2 -0
- package/providers/battlenet.d.ts +3 -0
- package/providers/battlenet.d.ts.map +1 -0
- package/providers/battlenet.js +2 -0
- package/providers/beyondidentity.d.ts +3 -0
- package/providers/beyondidentity.d.ts.map +1 -0
- package/providers/beyondidentity.js +2 -0
- package/providers/bitbucket.d.ts +3 -0
- package/providers/bitbucket.d.ts.map +1 -0
- package/providers/bitbucket.js +2 -0
- package/providers/box.d.ts +3 -0
- package/providers/box.d.ts.map +1 -0
- package/providers/box.js +2 -0
- package/providers/boxyhq-saml.d.ts +3 -0
- package/providers/boxyhq-saml.d.ts.map +1 -0
- package/providers/boxyhq-saml.js +2 -0
- package/providers/bungie.d.ts +3 -0
- package/providers/bungie.d.ts.map +1 -0
- package/providers/bungie.js +2 -0
- package/providers/click-up.d.ts +3 -0
- package/providers/click-up.d.ts.map +1 -0
- package/providers/click-up.js +2 -0
- package/providers/cognito.d.ts +3 -0
- package/providers/cognito.d.ts.map +1 -0
- package/providers/cognito.js +2 -0
- package/providers/coinbase.d.ts +3 -0
- package/providers/coinbase.d.ts.map +1 -0
- package/providers/coinbase.js +2 -0
- package/providers/concept2.d.ts +3 -0
- package/providers/concept2.d.ts.map +1 -0
- package/providers/concept2.js +2 -0
- package/providers/credentials.d.ts +3 -0
- package/providers/credentials.d.ts.map +1 -0
- package/providers/credentials.js +2 -0
- package/providers/descope.d.ts +3 -0
- package/providers/descope.d.ts.map +1 -0
- package/providers/descope.js +2 -0
- package/providers/discord.d.ts +3 -0
- package/providers/discord.d.ts.map +1 -0
- package/providers/discord.js +2 -0
- package/providers/dribbble.d.ts +3 -0
- package/providers/dribbble.d.ts.map +1 -0
- package/providers/dribbble.js +2 -0
- package/providers/dropbox.d.ts +3 -0
- package/providers/dropbox.d.ts.map +1 -0
- package/providers/dropbox.js +2 -0
- package/providers/duende-identity-server6.d.ts +3 -0
- package/providers/duende-identity-server6.d.ts.map +1 -0
- package/providers/duende-identity-server6.js +2 -0
- package/providers/email.d.ts +3 -0
- package/providers/email.d.ts.map +1 -0
- package/providers/email.js +2 -0
- package/providers/eventbrite.d.ts +3 -0
- package/providers/eventbrite.d.ts.map +1 -0
- package/providers/eventbrite.js +2 -0
- package/providers/eveonline.d.ts +3 -0
- package/providers/eveonline.d.ts.map +1 -0
- package/providers/eveonline.js +2 -0
- package/providers/facebook.d.ts +3 -0
- package/providers/facebook.d.ts.map +1 -0
- package/providers/facebook.js +2 -0
- package/providers/faceit.d.ts +3 -0
- package/providers/faceit.d.ts.map +1 -0
- package/providers/faceit.js +2 -0
- package/providers/figma.d.ts +3 -0
- package/providers/figma.d.ts.map +1 -0
- package/providers/figma.js +2 -0
- package/providers/forwardemail.d.ts +3 -0
- package/providers/forwardemail.d.ts.map +1 -0
- package/providers/forwardemail.js +2 -0
- package/providers/foursquare.d.ts +3 -0
- package/providers/foursquare.d.ts.map +1 -0
- package/providers/foursquare.js +2 -0
- package/providers/freshbooks.d.ts +3 -0
- package/providers/freshbooks.d.ts.map +1 -0
- package/providers/freshbooks.js +2 -0
- package/providers/frontegg.d.ts +3 -0
- package/providers/frontegg.d.ts.map +1 -0
- package/providers/frontegg.js +2 -0
- package/providers/fusionauth.d.ts +3 -0
- package/providers/fusionauth.d.ts.map +1 -0
- package/providers/fusionauth.js +2 -0
- package/providers/github.d.ts +3 -0
- package/providers/github.d.ts.map +1 -0
- package/providers/github.js +2 -0
- package/providers/gitlab.d.ts +3 -0
- package/providers/gitlab.d.ts.map +1 -0
- package/providers/gitlab.js +2 -0
- package/providers/google.d.ts +3 -0
- package/providers/google.d.ts.map +1 -0
- package/providers/google.js +2 -0
- package/providers/hubspot.d.ts +3 -0
- package/providers/hubspot.d.ts.map +1 -0
- package/providers/hubspot.js +2 -0
- package/providers/huggingface.d.ts +3 -0
- package/providers/huggingface.d.ts.map +1 -0
- package/providers/huggingface.js +2 -0
- package/providers/identity-server4.d.ts +3 -0
- package/providers/identity-server4.d.ts.map +1 -0
- package/providers/identity-server4.js +2 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.d.ts.map +1 -0
- package/providers/index.js +1 -0
- package/providers/instagram.d.ts +3 -0
- package/providers/instagram.d.ts.map +1 -0
- package/providers/instagram.js +2 -0
- package/providers/kakao.d.ts +3 -0
- package/providers/kakao.d.ts.map +1 -0
- package/providers/kakao.js +2 -0
- package/providers/keycloak.d.ts +3 -0
- package/providers/keycloak.d.ts.map +1 -0
- package/providers/keycloak.js +2 -0
- package/providers/kinde.d.ts +3 -0
- package/providers/kinde.d.ts.map +1 -0
- package/providers/kinde.js +2 -0
- package/providers/line.d.ts +3 -0
- package/providers/line.d.ts.map +1 -0
- package/providers/line.js +2 -0
- package/providers/linkedin.d.ts +3 -0
- package/providers/linkedin.d.ts.map +1 -0
- package/providers/linkedin.js +2 -0
- package/providers/logto.d.ts +3 -0
- package/providers/logto.d.ts.map +1 -0
- package/providers/logto.js +2 -0
- package/providers/loops.d.ts +3 -0
- package/providers/loops.d.ts.map +1 -0
- package/providers/loops.js +2 -0
- package/providers/mailchimp.d.ts +3 -0
- package/providers/mailchimp.d.ts.map +1 -0
- package/providers/mailchimp.js +2 -0
- package/providers/mailgun.d.ts +3 -0
- package/providers/mailgun.d.ts.map +1 -0
- package/providers/mailgun.js +2 -0
- package/providers/mailru.d.ts +3 -0
- package/providers/mailru.d.ts.map +1 -0
- package/providers/mailru.js +2 -0
- package/providers/mastodon.d.ts +3 -0
- package/providers/mastodon.d.ts.map +1 -0
- package/providers/mastodon.js +2 -0
- package/providers/mattermost.d.ts +3 -0
- package/providers/mattermost.d.ts.map +1 -0
- package/providers/mattermost.js +2 -0
- package/providers/medium.d.ts +3 -0
- package/providers/medium.d.ts.map +1 -0
- package/providers/medium.js +2 -0
- package/providers/microsoft-entra-id.d.ts +3 -0
- package/providers/microsoft-entra-id.d.ts.map +1 -0
- package/providers/microsoft-entra-id.js +2 -0
- package/providers/naver.d.ts +3 -0
- package/providers/naver.d.ts.map +1 -0
- package/providers/naver.js +2 -0
- package/providers/netlify.d.ts +3 -0
- package/providers/netlify.d.ts.map +1 -0
- package/providers/netlify.js +2 -0
- package/providers/netsuite.d.ts +3 -0
- package/providers/netsuite.d.ts.map +1 -0
- package/providers/netsuite.js +2 -0
- package/providers/nextcloud.d.ts +3 -0
- package/providers/nextcloud.d.ts.map +1 -0
- package/providers/nextcloud.js +2 -0
- package/providers/nodemailer.d.ts +3 -0
- package/providers/nodemailer.d.ts.map +1 -0
- package/providers/nodemailer.js +2 -0
- package/providers/notion.d.ts +3 -0
- package/providers/notion.d.ts.map +1 -0
- package/providers/notion.js +2 -0
- package/providers/okta.d.ts +3 -0
- package/providers/okta.d.ts.map +1 -0
- package/providers/okta.js +2 -0
- package/providers/onelogin.d.ts +3 -0
- package/providers/onelogin.d.ts.map +1 -0
- package/providers/onelogin.js +2 -0
- package/providers/ory-hydra.d.ts +3 -0
- package/providers/ory-hydra.d.ts.map +1 -0
- package/providers/ory-hydra.js +2 -0
- package/providers/osso.d.ts +3 -0
- package/providers/osso.d.ts.map +1 -0
- package/providers/osso.js +2 -0
- package/providers/osu.d.ts +3 -0
- package/providers/osu.d.ts.map +1 -0
- package/providers/osu.js +2 -0
- package/providers/passage.d.ts +3 -0
- package/providers/passage.d.ts.map +1 -0
- package/providers/passage.js +2 -0
- package/providers/passkey.d.ts +3 -0
- package/providers/passkey.d.ts.map +1 -0
- package/providers/passkey.js +2 -0
- package/providers/patreon.d.ts +3 -0
- package/providers/patreon.d.ts.map +1 -0
- package/providers/patreon.js +2 -0
- package/providers/ping-id.d.ts +3 -0
- package/providers/ping-id.d.ts.map +1 -0
- package/providers/ping-id.js +2 -0
- package/providers/pinterest.d.ts +3 -0
- package/providers/pinterest.d.ts.map +1 -0
- package/providers/pinterest.js +2 -0
- package/providers/pipedrive.d.ts +3 -0
- package/providers/pipedrive.d.ts.map +1 -0
- package/providers/pipedrive.js +2 -0
- package/providers/postmark.d.ts +3 -0
- package/providers/postmark.d.ts.map +1 -0
- package/providers/postmark.js +2 -0
- package/providers/reddit.d.ts +3 -0
- package/providers/reddit.d.ts.map +1 -0
- package/providers/reddit.js +2 -0
- package/providers/resend.d.ts +3 -0
- package/providers/resend.d.ts.map +1 -0
- package/providers/resend.js +2 -0
- package/providers/roblox.d.ts +3 -0
- package/providers/roblox.d.ts.map +1 -0
- package/providers/roblox.js +2 -0
- package/providers/salesforce.d.ts +3 -0
- package/providers/salesforce.d.ts.map +1 -0
- package/providers/salesforce.js +2 -0
- package/providers/sendgrid.d.ts +3 -0
- package/providers/sendgrid.d.ts.map +1 -0
- package/providers/sendgrid.js +2 -0
- package/providers/simplelogin.d.ts +3 -0
- package/providers/simplelogin.d.ts.map +1 -0
- package/providers/simplelogin.js +2 -0
- package/providers/slack.d.ts +3 -0
- package/providers/slack.d.ts.map +1 -0
- package/providers/slack.js +2 -0
- package/providers/spotify.d.ts +3 -0
- package/providers/spotify.d.ts.map +1 -0
- package/providers/spotify.js +2 -0
- package/providers/strava.d.ts +3 -0
- package/providers/strava.d.ts.map +1 -0
- package/providers/strava.js +2 -0
- package/providers/threads.d.ts +3 -0
- package/providers/threads.d.ts.map +1 -0
- package/providers/threads.js +2 -0
- package/providers/tiktok.d.ts +3 -0
- package/providers/tiktok.d.ts.map +1 -0
- package/providers/tiktok.js +2 -0
- package/providers/todoist.d.ts +3 -0
- package/providers/todoist.d.ts.map +1 -0
- package/providers/todoist.js +2 -0
- package/providers/trakt.d.ts +3 -0
- package/providers/trakt.d.ts.map +1 -0
- package/providers/trakt.js +2 -0
- package/providers/twitch.d.ts +3 -0
- package/providers/twitch.d.ts.map +1 -0
- package/providers/twitch.js +2 -0
- package/providers/twitter.d.ts +3 -0
- package/providers/twitter.d.ts.map +1 -0
- package/providers/twitter.js +2 -0
- package/providers/united-effects.d.ts +3 -0
- package/providers/united-effects.d.ts.map +1 -0
- package/providers/united-effects.js +2 -0
- package/providers/vipps.d.ts +3 -0
- package/providers/vipps.d.ts.map +1 -0
- package/providers/vipps.js +2 -0
- package/providers/vk.d.ts +3 -0
- package/providers/vk.d.ts.map +1 -0
- package/providers/vk.js +2 -0
- package/providers/webauthn.d.ts +3 -0
- package/providers/webauthn.d.ts.map +1 -0
- package/providers/webauthn.js +2 -0
- package/providers/webex.d.ts +3 -0
- package/providers/webex.d.ts.map +1 -0
- package/providers/webex.js +2 -0
- package/providers/wechat.d.ts +3 -0
- package/providers/wechat.d.ts.map +1 -0
- package/providers/wechat.js +2 -0
- package/providers/wikimedia.d.ts +3 -0
- package/providers/wikimedia.d.ts.map +1 -0
- package/providers/wikimedia.js +2 -0
- package/providers/wordpress.d.ts +3 -0
- package/providers/wordpress.d.ts.map +1 -0
- package/providers/wordpress.js +2 -0
- package/providers/workos.d.ts +3 -0
- package/providers/workos.d.ts.map +1 -0
- package/providers/workos.js +2 -0
- package/providers/yandex.d.ts +3 -0
- package/providers/yandex.d.ts.map +1 -0
- package/providers/yandex.js +2 -0
- package/providers/zitadel.d.ts +3 -0
- package/providers/zitadel.d.ts.map +1 -0
- package/providers/zitadel.js +2 -0
- package/providers/zoho.d.ts +3 -0
- package/providers/zoho.d.ts.map +1 -0
- package/providers/zoho.js +2 -0
- package/providers/zoom.d.ts +3 -0
- package/providers/zoom.d.ts.map +1 -0
- package/providers/zoom.js +2 -0
- package/react.d.ts +102 -0
- package/react.d.ts.map +1 -0
- package/react.js +361 -0
- package/src/adapters.ts +1 -0
- package/src/index.ts +430 -0
- package/src/jwt.ts +9 -0
- package/src/lib/actions.ts +144 -0
- package/src/lib/client.ts +245 -0
- package/src/lib/env.ts +36 -0
- package/src/lib/index.ts +313 -0
- package/src/lib/types.ts +30 -0
- package/src/middleware.ts +16 -0
- package/src/next.ts +16 -0
- package/src/providers/42-school.ts +2 -0
- package/src/providers/apple.ts +2 -0
- package/src/providers/asgardeo.ts +2 -0
- package/src/providers/atlassian.ts +2 -0
- package/src/providers/auth0.ts +2 -0
- package/src/providers/authentik.ts +2 -0
- package/src/providers/azure-ad-b2c.ts +2 -0
- package/src/providers/azure-ad.ts +2 -0
- package/src/providers/azure-devops.ts +2 -0
- package/src/providers/bankid-no.ts +2 -0
- package/src/providers/battlenet.ts +2 -0
- package/src/providers/beyondidentity.ts +2 -0
- package/src/providers/bitbucket.ts +2 -0
- package/src/providers/box.ts +2 -0
- package/src/providers/boxyhq-saml.ts +2 -0
- package/src/providers/bungie.ts +2 -0
- package/src/providers/click-up.ts +2 -0
- package/src/providers/cognito.ts +2 -0
- package/src/providers/coinbase.ts +2 -0
- package/src/providers/concept2.ts +2 -0
- package/src/providers/credentials.ts +2 -0
- package/src/providers/descope.ts +2 -0
- package/src/providers/discord.ts +2 -0
- package/src/providers/dribbble.ts +2 -0
- package/src/providers/dropbox.ts +2 -0
- package/src/providers/duende-identity-server6.ts +2 -0
- package/src/providers/email.ts +2 -0
- package/src/providers/eventbrite.ts +2 -0
- package/src/providers/eveonline.ts +2 -0
- package/src/providers/facebook.ts +2 -0
- package/src/providers/faceit.ts +2 -0
- package/src/providers/figma.ts +2 -0
- package/src/providers/forwardemail.ts +2 -0
- package/src/providers/foursquare.ts +2 -0
- package/src/providers/freshbooks.ts +2 -0
- package/src/providers/frontegg.ts +2 -0
- package/src/providers/fusionauth.ts +2 -0
- package/src/providers/github.ts +2 -0
- package/src/providers/gitlab.ts +2 -0
- package/src/providers/google.ts +2 -0
- package/src/providers/hubspot.ts +2 -0
- package/src/providers/huggingface.ts +2 -0
- package/src/providers/identity-server4.ts +2 -0
- package/src/providers/index.ts +1 -0
- package/src/providers/instagram.ts +2 -0
- package/src/providers/kakao.ts +2 -0
- package/src/providers/keycloak.ts +2 -0
- package/src/providers/kinde.ts +2 -0
- package/src/providers/line.ts +2 -0
- package/src/providers/linkedin.ts +2 -0
- package/src/providers/logto.ts +2 -0
- package/src/providers/loops.ts +2 -0
- package/src/providers/mailchimp.ts +2 -0
- package/src/providers/mailgun.ts +2 -0
- package/src/providers/mailru.ts +2 -0
- package/src/providers/mastodon.ts +2 -0
- package/src/providers/mattermost.ts +2 -0
- package/src/providers/medium.ts +2 -0
- package/src/providers/microsoft-entra-id.ts +2 -0
- package/src/providers/naver.ts +2 -0
- package/src/providers/netlify.ts +2 -0
- package/src/providers/netsuite.ts +2 -0
- package/src/providers/nextcloud.ts +2 -0
- package/src/providers/nodemailer.ts +2 -0
- package/src/providers/notion.ts +2 -0
- package/src/providers/okta.ts +2 -0
- package/src/providers/onelogin.ts +2 -0
- package/src/providers/ory-hydra.ts +2 -0
- package/src/providers/osso.ts +2 -0
- package/src/providers/osu.ts +2 -0
- package/src/providers/passage.ts +2 -0
- package/src/providers/passkey.ts +2 -0
- package/src/providers/patreon.ts +2 -0
- package/src/providers/ping-id.ts +2 -0
- package/src/providers/pinterest.ts +2 -0
- package/src/providers/pipedrive.ts +2 -0
- package/src/providers/postmark.ts +2 -0
- package/src/providers/reddit.ts +2 -0
- package/src/providers/resend.ts +2 -0
- package/src/providers/roblox.ts +2 -0
- package/src/providers/salesforce.ts +2 -0
- package/src/providers/sendgrid.ts +2 -0
- package/src/providers/simplelogin.ts +2 -0
- package/src/providers/slack.ts +2 -0
- package/src/providers/spotify.ts +2 -0
- package/src/providers/strava.ts +2 -0
- package/src/providers/threads.ts +2 -0
- package/src/providers/tiktok.ts +2 -0
- package/src/providers/todoist.ts +2 -0
- package/src/providers/trakt.ts +2 -0
- package/src/providers/twitch.ts +2 -0
- package/src/providers/twitter.ts +2 -0
- package/src/providers/united-effects.ts +2 -0
- package/src/providers/vipps.ts +2 -0
- package/src/providers/vk.ts +2 -0
- package/src/providers/webauthn.ts +2 -0
- package/src/providers/webex.ts +2 -0
- package/src/providers/wechat.ts +2 -0
- package/src/providers/wikimedia.ts +2 -0
- package/src/providers/wordpress.ts +2 -0
- package/src/providers/workos.ts +2 -0
- package/src/providers/yandex.ts +2 -0
- package/src/providers/zitadel.ts +2 -0
- package/src/providers/zoho.ts +2 -0
- package/src/providers/zoom.ts +2 -0
- package/src/react.tsx +546 -0
- package/src/webauthn.ts +152 -0
- package/webauthn.d.ts +9 -0
- package/webauthn.d.ts.map +1 -0
- package/webauthn.js +92 -0
- package/LICENSE +0 -70
- package/dist/actions-CExpv_dD.js +0 -1
- package/dist/actions-DeCfLtHA.mjs +0 -184
- package/dist/client/hooks.d.ts +0 -122
- package/dist/client/index.d.ts +0 -5
- package/dist/client/index.js +0 -1
- package/dist/client/index.mjs +0 -478
- package/dist/client/provider.d.ts +0 -69
- package/dist/client/server-actions-helper.d.ts +0 -22
- package/dist/components/AccountPicker.d.ts +0 -11
- package/dist/components/OAuthButton.d.ts +0 -11
- package/dist/components/PassKeyButton.d.ts +0 -11
- package/dist/components/PassKeyRegister.d.ts +0 -10
- package/dist/components/TwoFactorSetup.d.ts +0 -8
- package/dist/components/TwoFactorVerify.d.ts +0 -9
- package/dist/core/account-picker/encryption.d.ts +0 -22
- package/dist/core/account-picker/index.d.ts +0 -22
- package/dist/core/auth/index.d.ts +0 -40
- package/dist/core/auth/oauth-providers.d.ts +0 -197
- package/dist/core/auth/oauth-state-store-cookie.d.ts +0 -83
- package/dist/core/auth/oauth-state-store-redis.d.ts +0 -25
- package/dist/core/auth/oauth-state-store.d.ts +0 -45
- package/dist/core/auth/oauth.d.ts +0 -20
- package/dist/core/auth/passkey.d.ts +0 -35
- package/dist/core/auth/password.d.ts +0 -22
- package/dist/core/auth/signin-unified.d.ts +0 -33
- package/dist/core/auth/two-factor.d.ts +0 -28
- package/dist/core/client/index.d.ts +0 -132
- package/dist/core/client/token-refresh-manager.d.ts +0 -48
- package/dist/core/index.d.ts +0 -11
- package/dist/core/mulguard/auth-handlers.d.ts +0 -100
- package/dist/core/mulguard/defaults.d.ts +0 -58
- package/dist/core/mulguard/index.d.ts +0 -9
- package/dist/core/mulguard/oauth-handler.d.ts +0 -93
- package/dist/core/mulguard/session-manager.d.ts +0 -94
- package/dist/core/security/csrf.d.ts +0 -46
- package/dist/core/security/headers.d.ts +0 -24
- package/dist/core/security/index.d.ts +0 -132
- package/dist/core/security/rate-limit.d.ts +0 -39
- package/dist/core/security/validation.d.ts +0 -251
- package/dist/core/security/xss.d.ts +0 -20
- package/dist/core/session/index.d.ts +0 -35
- package/dist/core/types/auth.d.ts +0 -290
- package/dist/core/types/errors.d.ts +0 -200
- package/dist/core/types/index.d.ts +0 -462
- package/dist/core/utils/auth-helpers.d.ts +0 -136
- package/dist/core/utils/logger.d.ts +0 -121
- package/dist/handlers/api.d.ts +0 -10
- package/dist/handlers/route.d.ts +0 -76
- package/dist/index/index.js +0 -1
- package/dist/index/index.mjs +0 -2229
- package/dist/index.d.ts +0 -21
- package/dist/middleware/index.d.ts +0 -28
- package/dist/middleware/proxy.d.ts +0 -53
- package/dist/middleware/security.d.ts +0 -9
- package/dist/mulguard.d.ts +0 -373
- package/dist/oauth-state-DKle8eCr.mjs +0 -289
- package/dist/oauth-state-DlvrCV11.js +0 -1
- package/dist/server/actions.d.ts +0 -86
- package/dist/server/auth.d.ts +0 -65
- package/dist/server/cookies.d.ts +0 -42
- package/dist/server/helpers.d.ts +0 -10
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +0 -1
- package/dist/server/index.mjs +0 -31
- package/dist/server/middleware.d.ts +0 -39
- package/dist/server/oauth-state.d.ts +0 -30
- package/dist/server/session-helpers.d.ts +0 -26
- package/dist/server/session.d.ts +0 -28
- package/dist/server/utils.d.ts +0 -10
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input validation and sanitization utilities with type safety.
|
|
3
|
-
*
|
|
4
|
-
* @module @mulguard/core/security/validation
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Validation result type.
|
|
8
|
-
*
|
|
9
|
-
* @template T - Type of sanitized value
|
|
10
|
-
*/
|
|
11
|
-
export interface ValidationResult<T = string> {
|
|
12
|
-
readonly valid: boolean;
|
|
13
|
-
readonly sanitized?: T;
|
|
14
|
-
readonly error?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Email validation result.
|
|
18
|
-
*/
|
|
19
|
-
export type EmailValidationResult = ValidationResult<string>;
|
|
20
|
-
/**
|
|
21
|
-
* Password validation result with strength indicator.
|
|
22
|
-
*/
|
|
23
|
-
export interface PasswordValidationResult extends ValidationResult<string> {
|
|
24
|
-
readonly strength?: 'weak' | 'medium' | 'strong';
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Name validation result.
|
|
28
|
-
*/
|
|
29
|
-
export type NameValidationResult = ValidationResult<string>;
|
|
30
|
-
/**
|
|
31
|
-
* Token validation result.
|
|
32
|
-
*/
|
|
33
|
-
export type TokenValidationResult = ValidationResult<string>;
|
|
34
|
-
/**
|
|
35
|
-
* URL validation result.
|
|
36
|
-
*/
|
|
37
|
-
export type URLValidationResult = ValidationResult<string>;
|
|
38
|
-
/**
|
|
39
|
-
* Input sanitization options.
|
|
40
|
-
*/
|
|
41
|
-
export interface SanitizeOptions {
|
|
42
|
-
readonly maxLength?: number;
|
|
43
|
-
readonly allowHtml?: boolean;
|
|
44
|
-
readonly required?: boolean;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Validates and sanitizes an email address.
|
|
48
|
-
*
|
|
49
|
-
* @param email - Email address to validate
|
|
50
|
-
* @returns Validation result with sanitized email if valid
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const result = validateAndSanitizeEmail(' User@Example.COM ')
|
|
55
|
-
* if (result.valid) {
|
|
56
|
-
* console.log(result.sanitized) // 'user@example.com'
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function validateAndSanitizeEmail(email: unknown): EmailValidationResult;
|
|
61
|
-
/**
|
|
62
|
-
* Type predicate to check if email validation result is valid.
|
|
63
|
-
*
|
|
64
|
-
* @param result - Validation result to check
|
|
65
|
-
* @returns True if validation is successful
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const result = validateAndSanitizeEmail(email)
|
|
70
|
-
* if (isValidEmail(result)) {
|
|
71
|
-
* // TypeScript knows result.sanitized exists
|
|
72
|
-
* console.log(result.sanitized)
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
export declare function isValidEmail(result: EmailValidationResult): result is EmailValidationResult & {
|
|
77
|
-
valid: true;
|
|
78
|
-
sanitized: string;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Validates and sanitizes a password with strength assessment.
|
|
82
|
-
*
|
|
83
|
-
* @param password - Password to validate
|
|
84
|
-
* @param minLength - Minimum password length (default: 8)
|
|
85
|
-
* @returns Validation result with strength indicator if valid
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
* const result = validateAndSanitizePassword('MyP@ssw0rd!')
|
|
90
|
-
* if (result.valid) {
|
|
91
|
-
* console.log(result.strength) // 'strong'
|
|
92
|
-
* }
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export declare function validateAndSanitizePassword(password: unknown, minLength?: number): PasswordValidationResult;
|
|
96
|
-
/**
|
|
97
|
-
* Type predicate to check if password validation result is valid.
|
|
98
|
-
*
|
|
99
|
-
* @param result - Validation result to check
|
|
100
|
-
* @returns True if validation is successful
|
|
101
|
-
*/
|
|
102
|
-
export declare function isValidPassword(result: PasswordValidationResult): result is PasswordValidationResult & {
|
|
103
|
-
valid: true;
|
|
104
|
-
sanitized: string;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Validates and sanitizes a name.
|
|
108
|
-
*
|
|
109
|
-
* @param name - Name to validate
|
|
110
|
-
* @returns Validation result with sanitized name if valid
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* const result = validateAndSanitizeName(' John Doe ')
|
|
115
|
-
* if (result.valid) {
|
|
116
|
-
* console.log(result.sanitized) // 'John Doe'
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
export declare function validateAndSanitizeName(name: unknown): NameValidationResult;
|
|
121
|
-
/**
|
|
122
|
-
* Type predicate to check if name validation result is valid.
|
|
123
|
-
*
|
|
124
|
-
* @param result - Validation result to check
|
|
125
|
-
* @returns True if validation is successful
|
|
126
|
-
*/
|
|
127
|
-
export declare function isValidName(result: NameValidationResult): result is NameValidationResult & {
|
|
128
|
-
valid: true;
|
|
129
|
-
sanitized: string;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Validates a URL.
|
|
133
|
-
*
|
|
134
|
-
* @param url - URL to validate
|
|
135
|
-
* @returns Validation result
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const result = validateURL('https://example.com')
|
|
140
|
-
* if (result.valid) {
|
|
141
|
-
* // URL is valid
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export declare function validateURL(url: unknown): URLValidationResult;
|
|
146
|
-
/**
|
|
147
|
-
* Type predicate to check if URL validation result is valid.
|
|
148
|
-
*
|
|
149
|
-
* @param result - Validation result to check
|
|
150
|
-
* @returns True if validation is successful
|
|
151
|
-
*/
|
|
152
|
-
export declare function isValidURL(result: URLValidationResult): result is URLValidationResult & {
|
|
153
|
-
valid: true;
|
|
154
|
-
sanitized: string;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Validates a token format with security checks.
|
|
158
|
-
*
|
|
159
|
-
* @param token - Token to validate
|
|
160
|
-
* @param minLength - Minimum token length (default: 16)
|
|
161
|
-
* @returns Validation result
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* const result = validateToken('abc123xyz')
|
|
166
|
-
* if (result.valid) {
|
|
167
|
-
* // Token is valid
|
|
168
|
-
* }
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
export declare function validateToken(token: unknown, minLength?: number): TokenValidationResult;
|
|
172
|
-
/**
|
|
173
|
-
* Type predicate to check if token validation result is valid.
|
|
174
|
-
*
|
|
175
|
-
* @param result - Validation result to check
|
|
176
|
-
* @returns True if validation is successful
|
|
177
|
-
*/
|
|
178
|
-
export declare function isValidToken(result: TokenValidationResult): result is TokenValidationResult & {
|
|
179
|
-
valid: true;
|
|
180
|
-
sanitized: string;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Validates and sanitizes generic input with XSS prevention.
|
|
184
|
-
*
|
|
185
|
-
* @param input - Input to validate and sanitize
|
|
186
|
-
* @param options - Sanitization options
|
|
187
|
-
* @returns Validation result with sanitized input if valid
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* const result = validateAndSanitizeInput('<script>alert("xss")</script>', { allowHtml: false })
|
|
192
|
-
* if (result.valid) {
|
|
193
|
-
* console.log(result.sanitized) // HTML escaped
|
|
194
|
-
* }
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
export declare function validateAndSanitizeInput(input: unknown, options?: SanitizeOptions): ValidationResult<string>;
|
|
198
|
-
/**
|
|
199
|
-
* Type predicate to check if input validation result is valid.
|
|
200
|
-
*
|
|
201
|
-
* @param result - Validation result to check
|
|
202
|
-
* @returns True if validation is successful
|
|
203
|
-
*/
|
|
204
|
-
export declare function isValidInput(result: ValidationResult<string>): result is ValidationResult<string> & {
|
|
205
|
-
valid: true;
|
|
206
|
-
sanitized: string;
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* TODO: Performance
|
|
210
|
-
* - [ ] Cache compiled regex patterns
|
|
211
|
-
* - [ ] Optimize password strength calculation
|
|
212
|
-
* - [ ] Add input length pre-check before full validation
|
|
213
|
-
* - [ ] Consider using Web Crypto API for token validation
|
|
214
|
-
*
|
|
215
|
-
* TODO: Features
|
|
216
|
-
* - [ ] Add internationalized email validation (IDN support)
|
|
217
|
-
* - [ ] Implement password breach checking (Have I Been Pwned API)
|
|
218
|
-
* - [ ] Add phone number validation
|
|
219
|
-
* - [ ] Create validation rule builder pattern
|
|
220
|
-
* - [ ] Add custom validation rule support
|
|
221
|
-
* - [ ] Implement validation result chaining
|
|
222
|
-
*
|
|
223
|
-
* TODO: Type Safety
|
|
224
|
-
* - [ ] Add branded types for validated inputs
|
|
225
|
-
* - [ ] Create type-level validation constraints
|
|
226
|
-
* - [ ] Implement compile-time validation rules
|
|
227
|
-
* - [ ] Add type guards for all validation results
|
|
228
|
-
*
|
|
229
|
-
* TODO: Security
|
|
230
|
-
* - [ ] Add rate limiting for validation attempts
|
|
231
|
-
* - [ ] Implement validation result caching (with TTL)
|
|
232
|
-
* - [ ] Add validation logging for security monitoring
|
|
233
|
-
* - [ ] Create validation error reporting
|
|
234
|
-
*
|
|
235
|
-
* TODO: Testing
|
|
236
|
-
* - [ ] Add comprehensive unit tests for all validators
|
|
237
|
-
* - [ ] Test edge cases (Unicode, emoji, etc.)
|
|
238
|
-
* - [ ] Test performance with large inputs
|
|
239
|
-
* - [ ] Add fuzzing tests for security
|
|
240
|
-
*
|
|
241
|
-
* TODO: Documentation
|
|
242
|
-
* - [ ] Add more JSDoc examples
|
|
243
|
-
* - [ ] Document validation rules and limits
|
|
244
|
-
* - [ ] Create validation best practices guide
|
|
245
|
-
*
|
|
246
|
-
* TODO: Limitations
|
|
247
|
-
* - [ ] Email validation is simplified (not full RFC 5322)
|
|
248
|
-
* - [ ] Password strength is basic (consider zxcvbn library)
|
|
249
|
-
* - [ ] HTML sanitization is basic (consider DOMPurify for complex cases)
|
|
250
|
-
* - [ ] No support for custom validation rules yet
|
|
251
|
-
*/
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* XSS Protection utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Escape HTML to prevent XSS
|
|
6
|
-
*/
|
|
7
|
-
export declare function escapeHTML(str: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Sanitize HTML (basic)
|
|
10
|
-
* Note: For production, use a proper HTML sanitizer library like DOMPurify
|
|
11
|
-
*/
|
|
12
|
-
export declare function sanitizeHTML(html: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Validate and sanitize user input
|
|
15
|
-
*/
|
|
16
|
-
export declare function sanitizeUserInput(input: unknown): string;
|
|
17
|
-
/**
|
|
18
|
-
* Check for potential XSS patterns
|
|
19
|
-
*/
|
|
20
|
-
export declare function containsXSSPattern(input: string): boolean;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session management utilities
|
|
3
|
-
*/
|
|
4
|
-
export interface SessionStorage {
|
|
5
|
-
get(key: string): string | null;
|
|
6
|
-
set(key: string, value: string, options?: SessionCookieOptions): void;
|
|
7
|
-
remove(key: string): void;
|
|
8
|
-
}
|
|
9
|
-
export interface SessionCookieOptions {
|
|
10
|
-
expires?: Date | number;
|
|
11
|
-
maxAge?: number;
|
|
12
|
-
domain?: string;
|
|
13
|
-
path?: string;
|
|
14
|
-
secure?: boolean;
|
|
15
|
-
httpOnly?: boolean;
|
|
16
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Cookie storage implementation (client-side only)
|
|
20
|
-
* Note: This is for browser environments. Server-side should use Next.js cookies() API
|
|
21
|
-
*/
|
|
22
|
-
export declare class CookieStorage implements SessionStorage {
|
|
23
|
-
get(key: string): string | null;
|
|
24
|
-
set(key: string, value: string, options?: SessionCookieOptions): void;
|
|
25
|
-
remove(key: string): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Memory storage implementation (for testing)
|
|
29
|
-
*/
|
|
30
|
-
export declare class MemoryStorage implements SessionStorage {
|
|
31
|
-
private storage;
|
|
32
|
-
get(key: string): string | null;
|
|
33
|
-
set(key: string, value: string): void;
|
|
34
|
-
remove(key: string): void;
|
|
35
|
-
}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { AuthErrorCode } from './errors';
|
|
2
|
-
/**
|
|
3
|
-
* User interface representing an authenticated user.
|
|
4
|
-
*
|
|
5
|
-
* @property id - Unique user identifier
|
|
6
|
-
* @property email - User email address
|
|
7
|
-
* @property name - User display name
|
|
8
|
-
* @property avatar - Optional avatar URL
|
|
9
|
-
* @property roles - Optional user roles array
|
|
10
|
-
* @property emailVerified - Email verification status
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const user: User = {
|
|
15
|
-
* id: '123',
|
|
16
|
-
* email: 'user@example.com',
|
|
17
|
-
* name: 'John Doe',
|
|
18
|
-
* emailVerified: true
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export interface User {
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly email: string;
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly avatar?: string;
|
|
27
|
-
readonly roles?: readonly string[];
|
|
28
|
-
readonly emailVerified?: boolean;
|
|
29
|
-
readonly [key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Session object containing user information and authentication tokens.
|
|
33
|
-
*
|
|
34
|
-
* @template TUser - User type (defaults to base User)
|
|
35
|
-
*
|
|
36
|
-
* @property user - User object with authentication information
|
|
37
|
-
* @property expiresAt - Session expiration date/time
|
|
38
|
-
* @property accessToken - Access token for API authentication (optional)
|
|
39
|
-
* @property refreshToken - Refresh token for token refresh (optional)
|
|
40
|
-
* @property tokenType - Type of token (default: 'Bearer')
|
|
41
|
-
* @property expiresIn - Token expiration time in seconds (optional)
|
|
42
|
-
* @property refreshTokenExpiresAt - Refresh token expiration date/time (optional)
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const session: Session = {
|
|
47
|
-
* user: { id: '123', email: 'user@example.com', name: 'John' },
|
|
48
|
-
* expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
|
49
|
-
* accessToken: 'token123',
|
|
50
|
-
* tokenType: 'Bearer'
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export interface Session<TUser extends User = User> {
|
|
55
|
-
readonly user: TUser;
|
|
56
|
-
readonly expiresAt: Date | string;
|
|
57
|
-
readonly accessToken?: string;
|
|
58
|
-
readonly refreshToken?: string;
|
|
59
|
-
readonly tokenType?: 'Bearer' | 'Basic';
|
|
60
|
-
readonly expiresIn?: number;
|
|
61
|
-
readonly refreshTokenExpiresAt?: Date | string;
|
|
62
|
-
readonly [key: string]: unknown;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Base authentication result type.
|
|
66
|
-
*
|
|
67
|
-
* @template TUser - User type (defaults to base User)
|
|
68
|
-
* @template TSession - Session type (defaults to base Session)
|
|
69
|
-
*
|
|
70
|
-
* @property success - Whether the authentication was successful
|
|
71
|
-
* @property user - User object if authentication succeeded
|
|
72
|
-
* @property session - Session object if authentication succeeded
|
|
73
|
-
* @property error - Error message if authentication failed
|
|
74
|
-
* @property errorCode - Specific error code for programmatic error handling
|
|
75
|
-
* @property requires2FA - Whether 2FA verification is required
|
|
76
|
-
* @property email - Email address (required when requires2FA is true)
|
|
77
|
-
* @property userId - User ID (required when requires2FA is true)
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* const result = await auth.signIn.email(credentials)
|
|
82
|
-
* if (result.success) {
|
|
83
|
-
* // TypeScript knows result.user and result.session exist
|
|
84
|
-
* console.log(result.user.email)
|
|
85
|
-
* } else if (result.requires2FA) {
|
|
86
|
-
* // TypeScript knows result.email and result.userId exist
|
|
87
|
-
* await auth.verify2FA({ email: result.email, userId: result.userId, code: '123456' })
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export interface AuthResult<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
92
|
-
readonly success: boolean;
|
|
93
|
-
readonly user?: TUser;
|
|
94
|
-
readonly session?: TSession;
|
|
95
|
-
readonly error?: string;
|
|
96
|
-
readonly errorCode?: AuthErrorCode;
|
|
97
|
-
readonly requires2FA?: boolean;
|
|
98
|
-
readonly email?: string;
|
|
99
|
-
readonly userId?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Successful authentication result type.
|
|
103
|
-
*
|
|
104
|
-
* @template TUser - User type
|
|
105
|
-
* @template TSession - Session type
|
|
106
|
-
*/
|
|
107
|
-
export type SuccessfulAuthResult<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> = AuthResult<TUser, TSession> & {
|
|
108
|
-
readonly success: true;
|
|
109
|
-
readonly user: TUser;
|
|
110
|
-
readonly session: TSession;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Failed authentication result type.
|
|
114
|
-
*
|
|
115
|
-
* @template TUser - User type
|
|
116
|
-
* @template TSession - Session type
|
|
117
|
-
*/
|
|
118
|
-
export type FailedAuthResult<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> = AuthResult<TUser, TSession> & {
|
|
119
|
-
readonly success: false;
|
|
120
|
-
readonly error: string;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Two-factor authentication required result type.
|
|
124
|
-
*
|
|
125
|
-
* This type is returned when 2FA verification is required after initial authentication.
|
|
126
|
-
* Use the `isTwoFactorRequired()` type guard to narrow to this type.
|
|
127
|
-
*
|
|
128
|
-
* @template TUser - User type
|
|
129
|
-
* @template TSession - Session type
|
|
130
|
-
*
|
|
131
|
-
* @property success - Always false
|
|
132
|
-
* @property requires2FA - Always true
|
|
133
|
-
* @property email - Email address of the user requiring 2FA
|
|
134
|
-
* @property userId - User ID requiring 2FA
|
|
135
|
-
* @property errorCode - Always AuthErrorCode.TWO_FA_REQUIRED
|
|
136
|
-
* @property twoFactorMethod - Method of 2FA (optional)
|
|
137
|
-
* @property challengeToken - Challenge token for 2FA verification (optional)
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const result = await auth.signIn.email(credentials)
|
|
142
|
-
* if (isTwoFactorRequired(result)) {
|
|
143
|
-
* // TypeScript knows result is TwoFactorAuthResult here
|
|
144
|
-
* console.log('2FA required for:', result.email)
|
|
145
|
-
* console.log('Method:', result.twoFactorMethod)
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
export interface TwoFactorAuthResult<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> extends AuthResult<TUser, TSession> {
|
|
150
|
-
readonly success: false;
|
|
151
|
-
readonly requires2FA: true;
|
|
152
|
-
readonly email: string;
|
|
153
|
-
readonly userId: string;
|
|
154
|
-
readonly error: '2FA_REQUIRED';
|
|
155
|
-
readonly errorCode: AuthErrorCode.TWO_FA_REQUIRED;
|
|
156
|
-
readonly twoFactorMethod?: 'totp' | 'sms' | 'email';
|
|
157
|
-
readonly challengeToken?: string;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Email and password credentials for authentication.
|
|
161
|
-
*
|
|
162
|
-
* @property email - User email address
|
|
163
|
-
* @property password - User password
|
|
164
|
-
*/
|
|
165
|
-
export interface EmailCredentials {
|
|
166
|
-
readonly email: string;
|
|
167
|
-
readonly password: string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* User registration data.
|
|
171
|
-
*
|
|
172
|
-
* @property email - User email address
|
|
173
|
-
* @property password - User password
|
|
174
|
-
* @property name - User display name
|
|
175
|
-
*/
|
|
176
|
-
export interface RegisterData {
|
|
177
|
-
readonly email: string;
|
|
178
|
-
readonly password: string;
|
|
179
|
-
readonly name: string;
|
|
180
|
-
readonly [key: string]: unknown;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Data required for 2FA verification.
|
|
184
|
-
*
|
|
185
|
-
* @property email - User email address
|
|
186
|
-
* @property userId - User ID
|
|
187
|
-
* @property code - 2FA verification code
|
|
188
|
-
*/
|
|
189
|
-
export interface Verify2FAData {
|
|
190
|
-
readonly email: string;
|
|
191
|
-
readonly userId: string;
|
|
192
|
-
readonly code: string;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Type predicate to check if AuthResult indicates success.
|
|
196
|
-
*
|
|
197
|
-
* @template TUser - User type
|
|
198
|
-
* @template TSession - Session type
|
|
199
|
-
* @param result - AuthResult to check
|
|
200
|
-
* @returns True if result is successful
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* const result = await auth.signIn.email(credentials)
|
|
205
|
-
* if (isAuthSuccess(result)) {
|
|
206
|
-
* // TypeScript narrows to SuccessfulAuthResult
|
|
207
|
-
* console.log(result.user.email) // ✅ Type-safe
|
|
208
|
-
* console.log(result.session.expiresAt) // ✅ Type-safe
|
|
209
|
-
* }
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
export declare function isAuthSuccess<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(result: AuthResult<TUser, TSession>): result is SuccessfulAuthResult<TUser, TSession>;
|
|
213
|
-
/**
|
|
214
|
-
* Type predicate to check if AuthResult indicates failure.
|
|
215
|
-
*
|
|
216
|
-
* @template TUser - User type
|
|
217
|
-
* @template TSession - Session type
|
|
218
|
-
* @param result - AuthResult to check
|
|
219
|
-
* @returns True if result indicates failure
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```typescript
|
|
223
|
-
* const result = await auth.signIn.email(credentials)
|
|
224
|
-
* if (isAuthFailure(result)) {
|
|
225
|
-
* // TypeScript narrows to FailedAuthResult
|
|
226
|
-
* console.error(result.error) // ✅ Type-safe
|
|
227
|
-
* }
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
export declare function isAuthFailure<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(result: AuthResult<TUser, TSession>): result is FailedAuthResult<TUser, TSession>;
|
|
231
|
-
/**
|
|
232
|
-
* Type predicate to check if AuthResult indicates 2FA is required.
|
|
233
|
-
*
|
|
234
|
-
* @template TUser - User type
|
|
235
|
-
* @template TSession - Session type
|
|
236
|
-
* @param result - AuthResult to check
|
|
237
|
-
* @returns True if 2FA is required
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```typescript
|
|
241
|
-
* const result = await auth.signIn.email(credentials)
|
|
242
|
-
* if (isTwoFactorRequired(result)) {
|
|
243
|
-
* // TypeScript narrows to TwoFactorAuthResult
|
|
244
|
-
* await auth.verify2FA({
|
|
245
|
-
* email: result.email, // ✅ Type-safe
|
|
246
|
-
* userId: result.userId, // ✅ Type-safe
|
|
247
|
-
* code: '123456'
|
|
248
|
-
* })
|
|
249
|
-
* }
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
export declare function isTwoFactorRequired<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(result: AuthResult<TUser, TSession>): result is TwoFactorAuthResult<TUser, TSession>;
|
|
253
|
-
/**
|
|
254
|
-
* TODO: Performance
|
|
255
|
-
* - [ ] Consider using branded types for User.id to prevent ID mixing
|
|
256
|
-
* - [ ] Add type-level optimizations for discriminated unions
|
|
257
|
-
* - [ ] Implement compile-time validation for email format
|
|
258
|
-
* - [ ] Add type-level session expiration checking
|
|
259
|
-
*
|
|
260
|
-
* TODO: Features
|
|
261
|
-
* - [ ] Add conditional types for provider-specific result variants
|
|
262
|
-
* - [ ] Implement type-safe error handling with exhaustiveness checking
|
|
263
|
-
* - [ ] Create type-level validation for credentials strength
|
|
264
|
-
* - [ ] Add generic constraints for custom User/Session extensions
|
|
265
|
-
* - [ ] Implement type-safe middleware chain types
|
|
266
|
-
*
|
|
267
|
-
* TODO: Type Safety
|
|
268
|
-
* - [ ] Add branded types for sensitive data (tokens, passwords)
|
|
269
|
-
* - [ ] Create type guards for all public interfaces
|
|
270
|
-
* - [ ] Add type-level validation for registration data
|
|
271
|
-
* - [ ] Implement type-safe error codes with const assertions
|
|
272
|
-
*
|
|
273
|
-
* TODO: Testing
|
|
274
|
-
* - [ ] Add type-level tests using ts-expect
|
|
275
|
-
* - [ ] Test type inference in various scenarios
|
|
276
|
-
* - [ ] Verify type narrowing with type predicates
|
|
277
|
-
* - [ ] Test generic constraints and conditional types
|
|
278
|
-
* - [ ] Add tests for discriminated union narrowing
|
|
279
|
-
*
|
|
280
|
-
* TODO: Documentation
|
|
281
|
-
* - [ ] Add more JSDoc examples for generic types
|
|
282
|
-
* - [ ] Document type-level patterns and best practices
|
|
283
|
-
* - [ ] Create migration guide for custom User/Session types
|
|
284
|
-
*
|
|
285
|
-
* TODO: Limitations
|
|
286
|
-
* - [ ] Type inference may be limited with very deep generic chains
|
|
287
|
-
* - [ ] Branded types add minimal runtime overhead
|
|
288
|
-
* - [ ] Deep readonly types may impact performance with large objects
|
|
289
|
-
* - [ ] Discriminated unions require explicit type guards for narrowing
|
|
290
|
-
*/
|