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,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication error codes and error handling types.
|
|
3
|
-
*
|
|
4
|
-
* @module @mulguard/core/types/errors
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Authentication error code enumeration.
|
|
8
|
-
*
|
|
9
|
-
* Provides specific error codes for programmatic error handling.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* if (result.errorCode === AuthErrorCode.INVALID_CREDENTIALS) {
|
|
14
|
-
* // Handle invalid credentials
|
|
15
|
-
* } else if (result.errorCode === AuthErrorCode.TWO_FA_REQUIRED) {
|
|
16
|
-
* // Handle 2FA requirement
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare enum AuthErrorCode {
|
|
21
|
-
/** Invalid email or password credentials */
|
|
22
|
-
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
23
|
-
/** Account is temporarily locked due to failed attempts */
|
|
24
|
-
ACCOUNT_LOCKED = "ACCOUNT_LOCKED",
|
|
25
|
-
/** Account is inactive or disabled */
|
|
26
|
-
ACCOUNT_INACTIVE = "ACCOUNT_INACTIVE",
|
|
27
|
-
/** Two-factor authentication is required */
|
|
28
|
-
TWO_FA_REQUIRED = "TWO_FA_REQUIRED",
|
|
29
|
-
/** Invalid two-factor authentication code */
|
|
30
|
-
INVALID_TWO_FA_CODE = "INVALID_TWO_FA_CODE",
|
|
31
|
-
/** Session has expired */
|
|
32
|
-
SESSION_EXPIRED = "SESSION_EXPIRED",
|
|
33
|
-
/** User is not authorized for this operation */
|
|
34
|
-
UNAUTHORIZED = "UNAUTHORIZED",
|
|
35
|
-
/** Network or API communication error */
|
|
36
|
-
NETWORK_ERROR = "NETWORK_ERROR",
|
|
37
|
-
/** Input validation error */
|
|
38
|
-
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
39
|
-
/** Rate limit exceeded */
|
|
40
|
-
RATE_LIMITED = "RATE_LIMITED",
|
|
41
|
-
/** Unknown or unexpected error */
|
|
42
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Authentication error interface.
|
|
46
|
-
*
|
|
47
|
-
* Provides structured error information with code, message, and optional metadata.
|
|
48
|
-
*
|
|
49
|
-
* @property code - Specific error code
|
|
50
|
-
* @property message - Human-readable error message
|
|
51
|
-
* @property statusCode - HTTP status code (if applicable)
|
|
52
|
-
* @property details - Additional error details (optional)
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const error: AuthError = {
|
|
57
|
-
* code: AuthErrorCode.INVALID_CREDENTIALS,
|
|
58
|
-
* message: 'Invalid email or password',
|
|
59
|
-
* statusCode: 401
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export interface AuthError {
|
|
64
|
-
readonly code: AuthErrorCode;
|
|
65
|
-
readonly message: string;
|
|
66
|
-
readonly statusCode?: number;
|
|
67
|
-
readonly details?: unknown;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Error result type for failed operations.
|
|
71
|
-
*
|
|
72
|
-
* @template TCode - Error code type (defaults to AuthErrorCode)
|
|
73
|
-
*/
|
|
74
|
-
export type ErrorResult<TCode extends AuthErrorCode = AuthErrorCode> = {
|
|
75
|
-
readonly success: false;
|
|
76
|
-
readonly error: string;
|
|
77
|
-
readonly errorCode: TCode;
|
|
78
|
-
readonly details?: unknown;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Creates an authentication error object.
|
|
82
|
-
*
|
|
83
|
-
* @param code - Error code
|
|
84
|
-
* @param message - Human-readable error message
|
|
85
|
-
* @param statusCode - HTTP status code (optional)
|
|
86
|
-
* @param details - Additional error details (optional)
|
|
87
|
-
* @returns AuthError object
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* const error = createAuthError(
|
|
92
|
-
* AuthErrorCode.INVALID_CREDENTIALS,
|
|
93
|
-
* 'Invalid email or password',
|
|
94
|
-
* 401
|
|
95
|
-
* )
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function createAuthError(code: AuthErrorCode, message: string, statusCode?: number, details?: unknown): AuthError;
|
|
99
|
-
/**
|
|
100
|
-
* Creates an error result for failed authentication operations.
|
|
101
|
-
*
|
|
102
|
-
* @template TCode - Error code type
|
|
103
|
-
* @param code - Error code
|
|
104
|
-
* @param message - Error message
|
|
105
|
-
* @param details - Additional error details (optional)
|
|
106
|
-
* @returns ErrorResult object
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const result = createErrorResult(
|
|
111
|
-
* AuthErrorCode.INVALID_CREDENTIALS,
|
|
112
|
-
* 'Invalid email or password'
|
|
113
|
-
* )
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
export declare function createErrorResult<TCode extends AuthErrorCode = AuthErrorCode>(code: TCode, message: string, details?: unknown): ErrorResult<TCode>;
|
|
117
|
-
/**
|
|
118
|
-
* HTTP status code mapping for error codes.
|
|
119
|
-
*
|
|
120
|
-
* Maps authentication error codes to appropriate HTTP status codes.
|
|
121
|
-
*/
|
|
122
|
-
export declare const ERROR_STATUS_MAP: Readonly<Record<AuthErrorCode, number>>;
|
|
123
|
-
/**
|
|
124
|
-
* Gets the HTTP status code for an error code.
|
|
125
|
-
*
|
|
126
|
-
* @param code - Error code
|
|
127
|
-
* @returns HTTP status code
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* const statusCode = getErrorStatusCode(AuthErrorCode.INVALID_CREDENTIALS)
|
|
132
|
-
* // Returns 401
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export declare function getErrorStatusCode(code: AuthErrorCode): number;
|
|
136
|
-
/**
|
|
137
|
-
* Type predicate to check if a value is an AuthError.
|
|
138
|
-
*
|
|
139
|
-
* @param value - Value to check
|
|
140
|
-
* @returns True if value is an AuthError
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* if (isAuthError(error)) {
|
|
145
|
-
* // TypeScript knows error is AuthError here
|
|
146
|
-
* console.log(error.code, error.message)
|
|
147
|
-
* }
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
export declare function isAuthError(value: unknown): value is AuthError;
|
|
151
|
-
/**
|
|
152
|
-
* Type predicate to check if a value is an ErrorResult.
|
|
153
|
-
*
|
|
154
|
-
* @param value - Value to check
|
|
155
|
-
* @returns True if value is an ErrorResult
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```typescript
|
|
159
|
-
* if (isErrorResult(result)) {
|
|
160
|
-
* // TypeScript knows result is ErrorResult here
|
|
161
|
-
* console.log(result.errorCode, result.error)
|
|
162
|
-
* }
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
export declare function isErrorResult(value: unknown): value is ErrorResult;
|
|
166
|
-
/**
|
|
167
|
-
* TODO: Performance
|
|
168
|
-
* - [ ] Consider using const assertions for error code strings
|
|
169
|
-
* - [ ] Add type-level validation for error code mappings
|
|
170
|
-
* - [ ] Implement compile-time error code exhaustiveness checking
|
|
171
|
-
*
|
|
172
|
-
* TODO: Features
|
|
173
|
-
* - [ ] Add error recovery strategies
|
|
174
|
-
* - [ ] Implement error code hierarchies/categories
|
|
175
|
-
* - [ ] Add localized error messages support
|
|
176
|
-
* - [ ] Create error code to user-friendly message mapping
|
|
177
|
-
* - [ ] Add error code metadata (retryable, transient, etc.)
|
|
178
|
-
*
|
|
179
|
-
* TODO: Type Safety
|
|
180
|
-
* - [ ] Add branded types for error codes
|
|
181
|
-
* - [ ] Implement type-safe error code unions
|
|
182
|
-
* - [ ] Add exhaustiveness checking for error handling
|
|
183
|
-
* - [ ] Create type-safe error code validation
|
|
184
|
-
*
|
|
185
|
-
* TODO: Testing
|
|
186
|
-
* - [ ] Add tests for error code mappings
|
|
187
|
-
* - [ ] Test type guards with various inputs
|
|
188
|
-
* - [ ] Verify error result type narrowing
|
|
189
|
-
* - [ ] Test error factory functions
|
|
190
|
-
*
|
|
191
|
-
* TODO: Documentation
|
|
192
|
-
* - [ ] Add examples for each error code
|
|
193
|
-
* - [ ] Document error handling best practices
|
|
194
|
-
* - [ ] Create error code reference guide
|
|
195
|
-
*
|
|
196
|
-
* TODO: Limitations
|
|
197
|
-
* - [ ] Error code enum may need extension for custom errors
|
|
198
|
-
* - [ ] Status code mapping is fixed (consider configurable)
|
|
199
|
-
* - [ ] Error details type is unknown (consider generic)
|
|
200
|
-
*/
|
|
@@ -1,462 +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
|
-
* @property csrfProtection - Enable CSRF protection (default: true)
|
|
186
|
-
* @property rateLimiting - Enable rate limiting (default: true)
|
|
187
|
-
* @property requireHttps - Require HTTPS (default: true in production)
|
|
188
|
-
* @property allowedOrigins - Allowed origins for CORS
|
|
189
|
-
*/
|
|
190
|
-
export interface SecurityConfig {
|
|
191
|
-
readonly csrfProtection?: boolean;
|
|
192
|
-
readonly rateLimiting?: boolean;
|
|
193
|
-
readonly requireHttps?: boolean;
|
|
194
|
-
readonly allowedOrigins?: readonly string[];
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* OAuth provider identifier.
|
|
198
|
-
*/
|
|
199
|
-
export type OAuthProviderId = 'google' | 'github' | 'apple' | 'facebook' | string;
|
|
200
|
-
/**
|
|
201
|
-
* Sign-in provider type.
|
|
202
|
-
*/
|
|
203
|
-
export type SignInProvider = OAuthProviderId | 'credentials' | 'passkey' | 'otp';
|
|
204
|
-
/**
|
|
205
|
-
* Sign-in options for unified interface.
|
|
206
|
-
*
|
|
207
|
-
* @property provider - Authentication provider
|
|
208
|
-
* @property credentials - Email/password credentials (for 'credentials' provider)
|
|
209
|
-
* @property formData - Form data (alternative to credentials)
|
|
210
|
-
* @property options - Additional options (for 'otp' or 'passkey' providers)
|
|
211
|
-
*/
|
|
212
|
-
export interface SignInOptions {
|
|
213
|
-
readonly provider: SignInProvider;
|
|
214
|
-
readonly credentials?: Readonly<EmailCredentials>;
|
|
215
|
-
readonly formData?: FormData;
|
|
216
|
-
readonly options?: Readonly<{
|
|
217
|
-
userId?: string;
|
|
218
|
-
email?: string;
|
|
219
|
-
code?: string;
|
|
220
|
-
}>;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Lifecycle callbacks configuration.
|
|
224
|
-
*
|
|
225
|
-
* All callbacks are optional and can be used to hook into authentication events.
|
|
226
|
-
*
|
|
227
|
-
* @property onSignIn - Called after successful sign-in
|
|
228
|
-
* @property onSignOut - Called after sign-out
|
|
229
|
-
* @property onSessionUpdate - Called when session is updated (can modify session)
|
|
230
|
-
* @property onError - Called on authentication errors
|
|
231
|
-
* @property onTokenRefresh - Called when tokens are refreshed
|
|
232
|
-
* @property onSessionExpired - Called when session expires
|
|
233
|
-
* @property onOAuthUser - Called when OAuth user is received (for user creation/lookup)
|
|
234
|
-
*/
|
|
235
|
-
export interface CallbacksConfig {
|
|
236
|
-
readonly onSignIn?: (user: User, session: Session) => Promise<void> | void;
|
|
237
|
-
readonly onSignOut?: (user: User) => Promise<void> | void;
|
|
238
|
-
readonly onSessionUpdate?: (session: Session) => Promise<Session> | Session;
|
|
239
|
-
readonly onError?: (error: Error, context?: string) => Promise<void> | void;
|
|
240
|
-
readonly onTokenRefresh?: (oldSession: Session, newSession: Session) => Promise<void> | void;
|
|
241
|
-
readonly onSessionExpired?: (session: Session) => Promise<void> | void;
|
|
242
|
-
readonly onOAuthUser?: (userInfo: OAuthUserInfo, provider: string) => Promise<User>;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Request context for Server Actions.
|
|
246
|
-
*
|
|
247
|
-
* Provides access to request metadata for authentication operations.
|
|
248
|
-
*
|
|
249
|
-
* @property headers - Request headers
|
|
250
|
-
* @property cookies - Request cookies map
|
|
251
|
-
* @property ip - Client IP address (optional)
|
|
252
|
-
* @property userAgent - User agent string (optional)
|
|
253
|
-
*/
|
|
254
|
-
export interface RequestContext {
|
|
255
|
-
readonly headers: Headers;
|
|
256
|
-
readonly cookies: ReadonlyMap<string, string>;
|
|
257
|
-
readonly ip?: string;
|
|
258
|
-
readonly userAgent?: string;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Main Mulguard configuration interface.
|
|
262
|
-
*
|
|
263
|
-
* @template TUser - User type (extends base User)
|
|
264
|
-
* @template TSession - Session type (extends base Session)
|
|
265
|
-
*
|
|
266
|
-
* @property session - Session configuration
|
|
267
|
-
* @property actions - Custom authentication actions (required)
|
|
268
|
-
* @property callbacks - Lifecycle callbacks (optional)
|
|
269
|
-
* @property security - Security configuration (optional)
|
|
270
|
-
* @property tokenRefresh - Token refresh configuration (optional)
|
|
271
|
-
* @property providers - OAuth providers configuration (optional)
|
|
272
|
-
* @property oauthStateStore - OAuth state store (optional, uses in-memory by default)
|
|
273
|
-
* @property sessionCacheTtl - Session cache TTL in milliseconds (optional)
|
|
274
|
-
*/
|
|
275
|
-
export interface MulguardConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
276
|
-
readonly session?: SessionConfig;
|
|
277
|
-
readonly actions: AuthActions<TUser, TSession>;
|
|
278
|
-
readonly callbacks?: CallbacksConfig;
|
|
279
|
-
readonly security?: SecurityConfig;
|
|
280
|
-
readonly tokenRefresh?: import('../client/token-refresh-manager').TokenRefreshConfig;
|
|
281
|
-
readonly providers?: {
|
|
282
|
-
readonly oauth?: OAuthProvidersConfig;
|
|
283
|
-
};
|
|
284
|
-
readonly oauthStateStore?: import('../auth/oauth-state-store').OAuthStateStore;
|
|
285
|
-
readonly sessionCacheTtl?: number;
|
|
286
|
-
}
|
|
287
|
-
export type { User, Session, AuthResult, SuccessfulAuthResult, FailedAuthResult, TwoFactorAuthResult, EmailCredentials, RegisterData, Verify2FAData, };
|
|
288
|
-
export { isAuthSuccess, isAuthFailure, isTwoFactorRequired } from './auth';
|
|
289
|
-
/**
|
|
290
|
-
* Custom authentication actions interface.
|
|
291
|
-
*
|
|
292
|
-
* Users implement these actions to provide custom authentication logic.
|
|
293
|
-
* All actions are Server Actions that run on the server.
|
|
294
|
-
*
|
|
295
|
-
* @template TUser - User type
|
|
296
|
-
* @template TSession - Session type
|
|
297
|
-
*/
|
|
298
|
-
export interface AuthActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
299
|
-
readonly signIn: SignInActions<TUser, TSession>;
|
|
300
|
-
readonly signUp?: (data: RegisterData) => Promise<AuthResult<TUser, TSession>>;
|
|
301
|
-
readonly signOut?: () => Promise<{
|
|
302
|
-
success: boolean;
|
|
303
|
-
error?: string;
|
|
304
|
-
}>;
|
|
305
|
-
readonly resetPassword?: (email: string) => Promise<{
|
|
306
|
-
success: boolean;
|
|
307
|
-
error?: string;
|
|
308
|
-
}>;
|
|
309
|
-
readonly verifyEmail?: (token: string) => Promise<{
|
|
310
|
-
success: boolean;
|
|
311
|
-
error?: string;
|
|
312
|
-
}>;
|
|
313
|
-
readonly getSession?: () => Promise<TSession | null>;
|
|
314
|
-
readonly refreshSession?: () => Promise<TSession | null>;
|
|
315
|
-
readonly oauthCallback?: (provider: string, code: string, state: string) => Promise<AuthResult<TUser, TSession>>;
|
|
316
|
-
readonly passkey?: PasskeyActions<TUser, TSession>;
|
|
317
|
-
readonly twoFactor?: TwoFactorActions<TUser, TSession>;
|
|
318
|
-
readonly verify2FA?: (data: Verify2FAData) => Promise<AuthResult<TUser, TSession>>;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Sign-in actions interface.
|
|
322
|
-
*
|
|
323
|
-
* @template TUser - User type
|
|
324
|
-
* @template TSession - Session type
|
|
325
|
-
*/
|
|
326
|
-
export interface SignInActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
327
|
-
readonly email: (credentials: EmailCredentials) => Promise<AuthResult<TUser, TSession>>;
|
|
328
|
-
readonly oauth?: (provider: string) => Promise<{
|
|
329
|
-
url: string;
|
|
330
|
-
state: string;
|
|
331
|
-
}>;
|
|
332
|
-
readonly passkey?: (options?: {
|
|
333
|
-
userId?: string;
|
|
334
|
-
}) => Promise<AuthResult<TUser, TSession>>;
|
|
335
|
-
readonly otp?: (email: string, code?: string) => Promise<AuthResult<TUser, TSession>>;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Passkey actions interface.
|
|
339
|
-
*
|
|
340
|
-
* @template TUser - User type
|
|
341
|
-
* @template TSession - Session type
|
|
342
|
-
*/
|
|
343
|
-
export interface PasskeyActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
344
|
-
readonly register?: (options?: {
|
|
345
|
-
name?: string;
|
|
346
|
-
userId?: string;
|
|
347
|
-
}) => Promise<{
|
|
348
|
-
success: boolean;
|
|
349
|
-
passkeyId?: string;
|
|
350
|
-
error?: string;
|
|
351
|
-
}>;
|
|
352
|
-
readonly authenticate?: (options?: {
|
|
353
|
-
userId?: string;
|
|
354
|
-
}) => Promise<AuthResult<TUser, TSession>>;
|
|
355
|
-
readonly list?: () => Promise<ReadonlyArray<{
|
|
356
|
-
id: string;
|
|
357
|
-
name: string;
|
|
358
|
-
createdAt: Date;
|
|
359
|
-
lastUsedAt?: Date;
|
|
360
|
-
}>>;
|
|
361
|
-
readonly remove?: (passKeyId: string) => Promise<{
|
|
362
|
-
success: boolean;
|
|
363
|
-
error?: string;
|
|
364
|
-
}>;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Two-factor authentication actions interface.
|
|
368
|
-
*
|
|
369
|
-
* @template TUser - User type
|
|
370
|
-
* @template TSession - Session type
|
|
371
|
-
*/
|
|
372
|
-
export interface TwoFactorActions<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
373
|
-
readonly enable?: () => Promise<{
|
|
374
|
-
success: boolean;
|
|
375
|
-
qrCode?: string;
|
|
376
|
-
secret?: string;
|
|
377
|
-
error?: string;
|
|
378
|
-
}>;
|
|
379
|
-
readonly verify?: (code: string) => Promise<{
|
|
380
|
-
success: boolean;
|
|
381
|
-
backupCodes?: string[];
|
|
382
|
-
error?: string;
|
|
383
|
-
}>;
|
|
384
|
-
readonly disable?: () => Promise<{
|
|
385
|
-
success: boolean;
|
|
386
|
-
error?: string;
|
|
387
|
-
}>;
|
|
388
|
-
readonly generateBackupCodes?: () => Promise<{
|
|
389
|
-
success: boolean;
|
|
390
|
-
backupCodes?: string[];
|
|
391
|
-
error?: string;
|
|
392
|
-
}>;
|
|
393
|
-
readonly isEnabled?: () => Promise<boolean>;
|
|
394
|
-
readonly verify2FA?: (data: Verify2FAData) => Promise<AuthResult<TUser, TSession>>;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Type predicate to check if a value is a valid User object.
|
|
398
|
-
*
|
|
399
|
-
* @param value - Value to check
|
|
400
|
-
* @returns True if value is a valid User
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
* ```typescript
|
|
404
|
-
* if (isUser(data)) {
|
|
405
|
-
* // TypeScript knows data is User here
|
|
406
|
-
* console.log(data.email)
|
|
407
|
-
* }
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
export declare function isUser(value: unknown): value is User;
|
|
411
|
-
/**
|
|
412
|
-
* Type predicate to check if a value is a valid Session object.
|
|
413
|
-
*
|
|
414
|
-
* @template TUser - User type
|
|
415
|
-
* @param value - Value to check
|
|
416
|
-
* @returns True if value is a valid Session
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* ```typescript
|
|
420
|
-
* if (isSession(data)) {
|
|
421
|
-
* // TypeScript knows data is Session here
|
|
422
|
-
* console.log(data.user.email)
|
|
423
|
-
* }
|
|
424
|
-
* ```
|
|
425
|
-
*/
|
|
426
|
-
export declare function isSession<TUser extends User = User>(value: unknown): value is Session<TUser>;
|
|
427
|
-
/**
|
|
428
|
-
* TODO: Performance
|
|
429
|
-
* - [ ] Add type-level optimizations for large union types
|
|
430
|
-
* - [ ] Consider using branded types for IDs to prevent mixing
|
|
431
|
-
* - [ ] Add type-level validation for configuration objects
|
|
432
|
-
* - [ ] Implement type-safe builder pattern for complex configurations
|
|
433
|
-
*
|
|
434
|
-
* TODO: Features
|
|
435
|
-
* - [ ] Add conditional types for provider-specific OAuth configs
|
|
436
|
-
* - [ ] Implement discriminated unions for AuthResult variants
|
|
437
|
-
* - [ ] Add type-level session expiration checking
|
|
438
|
-
* - [ ] Create type-safe middleware chain types
|
|
439
|
-
* - [ ] Add generic constraints for custom User/Session extensions
|
|
440
|
-
*
|
|
441
|
-
* TODO: Type Safety
|
|
442
|
-
* - [ ] Add branded types for sensitive data (tokens, passwords)
|
|
443
|
-
* - [ ] Implement type-level validation for email formats
|
|
444
|
-
* - [ ] Add type guards for all public interfaces
|
|
445
|
-
* - [ ] Create type-safe error handling with exhaustiveness checking
|
|
446
|
-
*
|
|
447
|
-
* TODO: Testing
|
|
448
|
-
* - [ ] Add type-level tests using ts-expect
|
|
449
|
-
* - [ ] Test type inference in various scenarios
|
|
450
|
-
* - [ ] Verify type narrowing with type predicates
|
|
451
|
-
* - [ ] Test generic constraints and conditional types
|
|
452
|
-
*
|
|
453
|
-
* TODO: Documentation
|
|
454
|
-
* - [ ] Add more JSDoc examples for complex types
|
|
455
|
-
* - [ ] Document type-level patterns and best practices
|
|
456
|
-
* - [ ] Create type usage guides
|
|
457
|
-
*
|
|
458
|
-
* TODO: Limitations
|
|
459
|
-
* - [ ] Type inference may be limited with very complex generic chains
|
|
460
|
-
* - [ ] Branded types add runtime overhead (consider compile-time only)
|
|
461
|
-
* - [ ] Deep readonly types may impact performance with large objects
|
|
462
|
-
*/
|