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
package/README.md
CHANGED
|
@@ -1,1078 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- [Configuration](#-configuration)
|
|
23
|
-
- [Server-Side Usage](#-server-side-usage)
|
|
24
|
-
- [Client-Side Usage](#-client-side-usage)
|
|
25
|
-
- [Components](#-components)
|
|
26
|
-
- [Security](#-security)
|
|
27
|
-
- [Backend Integration](#-backend-integration)
|
|
28
|
-
- [Advanced Features](#-advanced-features)
|
|
29
|
-
- [API Reference](#-api-reference)
|
|
30
|
-
- [Examples](#-examples)
|
|
31
|
-
- [Testing](#-testing)
|
|
32
|
-
- [Contributing](#-contributing)
|
|
33
|
-
- [License](#-license)
|
|
34
|
-
- [Support](#-support)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## โจ Features
|
|
39
|
-
|
|
40
|
-
### ๐ Multiple Authentication Methods
|
|
41
|
-
- **Email/Password** - Traditional credential-based authentication
|
|
42
|
-
- **OAuth 2.1** - Support for Google, GitHub, and other OAuth providers
|
|
43
|
-
- **PassKey/WebAuthn** - Passwordless authentication with biometric support
|
|
44
|
-
- **Two-Factor Authentication (2FA/TOTP)** - Time-based one-time passwords with backup codes
|
|
45
|
-
- **OTP** - One-time password authentication
|
|
46
|
-
|
|
47
|
-
### ๐ฏ Account Picker
|
|
48
|
-
- Remember last logged-in users
|
|
49
|
-
- Quick re-login experience
|
|
50
|
-
- Encrypted local storage for security
|
|
51
|
-
- Configurable account limits
|
|
52
|
-
|
|
53
|
-
### ๐ Security First
|
|
54
|
-
- **CSRF Protection** - Token-based cross-site request forgery protection
|
|
55
|
-
- **XSS Prevention** - Input sanitization and HTML escaping
|
|
56
|
-
- **Security Headers** - Automatic security headers configuration
|
|
57
|
-
- **Input Validation** - Comprehensive validation and sanitization
|
|
58
|
-
- **Rate Limiting** - Built-in rate limiting utilities
|
|
59
|
-
- **Secure Cookies** - HttpOnly, Secure, SameSite cookie configuration
|
|
60
|
-
|
|
61
|
-
### โก Next.js Optimized
|
|
62
|
-
- **Server Components** - Full support for React Server Components
|
|
63
|
-
- **Client Hooks** - `useAuth`, `useSession` for client-side state management
|
|
64
|
-
- **Middleware Integration** - Seamless Next.js middleware support
|
|
65
|
-
- **API Route Handlers** - Pre-built route handlers for authentication endpoints
|
|
66
|
-
- **Server Actions** - Native support for Next.js Server Actions
|
|
67
|
-
|
|
68
|
-
### ๐ Backend-First Architecture
|
|
69
|
-
- **No Database Adapter Required** - Works with your existing backend API
|
|
70
|
-
- **Custom Actions** - Implement your own authentication logic
|
|
71
|
-
- **Flexible Integration** - Works with any backend (REST, GraphQL, etc.)
|
|
72
|
-
- **Mulink Integration** - Optional integration with Mulink API client
|
|
73
|
-
- **Full TypeScript Support** - Complete type safety throughout
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## ๐ฆ Installation
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
npm install mulguard
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Peer Dependencies
|
|
84
|
-
|
|
85
|
-
Mulguard requires the following peer dependencies:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
npm install next@>=14.0.0 react@>=18.0.0 react-dom@>=18.0.0
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## ๐ Quick Start
|
|
94
|
-
|
|
95
|
-
### 1. Create Auth Configuration
|
|
96
|
-
|
|
97
|
-
Create a new file `lib/auth.ts`:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { mulguard } from 'mulguard'
|
|
101
|
-
import type { EmailCredentials, AuthResult, Session } from 'mulguard'
|
|
102
|
-
import { db } from '@/lib/db'
|
|
103
|
-
import { comparePassword } from '@/lib/password'
|
|
104
|
-
|
|
105
|
-
export const auth = mulguard({
|
|
106
|
-
// Session configuration
|
|
107
|
-
session: {
|
|
108
|
-
cookieName: '__mulguard_session',
|
|
109
|
-
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
|
110
|
-
httpOnly: true,
|
|
111
|
-
secure: process.env.NODE_ENV === 'production', // HTTPS only in production
|
|
112
|
-
sameSite: 'lax',
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// Required: Implement your authentication actions
|
|
116
|
-
actions: {
|
|
117
|
-
signIn: {
|
|
118
|
-
// โ
Unified interface: auth.signIn('credentials', {...}) or auth.signIn.email({...})
|
|
119
|
-
email: async (credentials: EmailCredentials): Promise<AuthResult> => {
|
|
120
|
-
// Your custom sign-in logic
|
|
121
|
-
const user = await db.user.findUnique({
|
|
122
|
-
where: { email: credentials.email }
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
if (!user || !await comparePassword(credentials.password, user.password)) {
|
|
126
|
-
return {
|
|
127
|
-
success: false,
|
|
128
|
-
error: 'Invalid credentials',
|
|
129
|
-
errorCode: 'INVALID_CREDENTIALS'
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const session: Session = {
|
|
134
|
-
user: {
|
|
135
|
-
id: user.id,
|
|
136
|
-
email: user.email,
|
|
137
|
-
name: user.name,
|
|
138
|
-
emailVerified: user.emailVerified,
|
|
139
|
-
},
|
|
140
|
-
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return { success: true, user: session.user, session }
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
getSession: async (): Promise<Session | null> => {
|
|
148
|
-
// Your custom session retrieval logic
|
|
149
|
-
// Can read from cookie or database
|
|
150
|
-
return await db.getSession()
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
signOut: async () => {
|
|
154
|
-
// Your custom sign-out logic
|
|
155
|
-
await db.invalidateSession()
|
|
156
|
-
return { success: true }
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
// Optional: OAuth providers (auto-generates OAuth actions)
|
|
161
|
-
providers: {
|
|
162
|
-
oauth: {
|
|
163
|
-
google: {
|
|
164
|
-
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
165
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET, // Server-side only
|
|
166
|
-
redirectUri: `${process.env.NEXT_PUBLIC_URL}/api/auth/callback/google`,
|
|
167
|
-
scopes: ['openid', 'profile', 'email'],
|
|
168
|
-
},
|
|
169
|
-
github: {
|
|
170
|
-
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
171
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
|
172
|
-
redirectUri: `${process.env.NEXT_PUBLIC_URL}/api/auth/callback/github`,
|
|
173
|
-
scopes: ['user:email'],
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
// Optional: Callbacks for lifecycle events
|
|
179
|
-
callbacks: {
|
|
180
|
-
onSignIn: async (user, session) => {
|
|
181
|
-
// Track sign-in analytics, update last login, etc.
|
|
182
|
-
console.log('User signed in:', user.email)
|
|
183
|
-
},
|
|
184
|
-
onError: async (error, context) => {
|
|
185
|
-
// Log errors for monitoring
|
|
186
|
-
console.error(`Auth error in ${context}:`, error)
|
|
187
|
-
},
|
|
188
|
-
// โ
OAuth callback: receives userInfo with accessToken, refreshToken, profile, etc.
|
|
189
|
-
onOAuthUser: async (userInfo, provider) => {
|
|
190
|
-
// Backend API example:
|
|
191
|
-
// const response = await fetch('/api/v1/auth/oauth/callback', {
|
|
192
|
-
// method: 'POST',
|
|
193
|
-
// body: JSON.stringify({
|
|
194
|
-
// provider,
|
|
195
|
-
// access_token: userInfo.accessToken,
|
|
196
|
-
// refresh_token: userInfo.refreshToken,
|
|
197
|
-
// profile: userInfo,
|
|
198
|
-
// email: userInfo.email,
|
|
199
|
-
// })
|
|
200
|
-
// })
|
|
201
|
-
// return await response.json()
|
|
202
|
-
|
|
203
|
-
// Database example:
|
|
204
|
-
let user = await db.user.findUnique({ where: { email: userInfo.email } })
|
|
205
|
-
if (!user) {
|
|
206
|
-
user = await db.user.create({
|
|
207
|
-
data: {
|
|
208
|
-
email: userInfo.email,
|
|
209
|
-
name: userInfo.name,
|
|
210
|
-
emailVerified: userInfo.emailVerified,
|
|
211
|
-
oauthProvider: provider,
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
id: user.id,
|
|
217
|
-
email: user.email,
|
|
218
|
-
name: user.name,
|
|
219
|
-
emailVerified: user.emailVerified,
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
})
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
> ๐ **For a complete guide with best practices**, see [GUIDE.md](./GUIDE.md)
|
|
227
|
-
|
|
228
|
-
### 2. Server-Side Usage
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
// app/dashboard/page.tsx
|
|
232
|
-
import { getServerSession } from 'mulguard/server'
|
|
233
|
-
import { auth } from '@/lib/auth'
|
|
234
|
-
import { redirect } from 'next/navigation'
|
|
235
|
-
|
|
236
|
-
export default async function DashboardPage() {
|
|
237
|
-
const session = await getServerSession(auth)
|
|
238
|
-
|
|
239
|
-
if (!session) {
|
|
240
|
-
redirect('/login')
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<div>
|
|
245
|
-
<h1>Welcome, {session.user.name}!</h1>
|
|
246
|
-
<p>Email: {session.user.email}</p>
|
|
247
|
-
</div>
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### 3. Client-Side Usage
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
// app/login/page.tsx
|
|
256
|
-
'use client'
|
|
257
|
-
|
|
258
|
-
import { useAuth } from 'mulguard/client'
|
|
259
|
-
import { auth } from '@/lib/auth'
|
|
260
|
-
import { useState } from 'react'
|
|
261
|
-
|
|
262
|
-
export default function LoginPage() {
|
|
263
|
-
const { signIn, session, isLoading } = useAuth(auth)
|
|
264
|
-
const [email, setEmail] = useState('')
|
|
265
|
-
const [password, setPassword] = useState('')
|
|
266
|
-
|
|
267
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
268
|
-
e.preventDefault()
|
|
269
|
-
|
|
270
|
-
// โ
Unified interface (recommended)
|
|
271
|
-
const result = await signIn('credentials', { email, password })
|
|
272
|
-
|
|
273
|
-
// Or use direct method:
|
|
274
|
-
// const result = await signIn.email({ email, password })
|
|
275
|
-
|
|
276
|
-
if (result.success) {
|
|
277
|
-
// Redirect to dashboard
|
|
278
|
-
window.location.href = '/dashboard'
|
|
279
|
-
} else {
|
|
280
|
-
// Handle error
|
|
281
|
-
alert(result.error)
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (isLoading) return <div>Loading...</div>
|
|
286
|
-
if (session) return <div>Already logged in</div>
|
|
287
|
-
|
|
288
|
-
return (
|
|
289
|
-
<form onSubmit={handleSubmit}>
|
|
290
|
-
<input
|
|
291
|
-
type="email"
|
|
292
|
-
value={email}
|
|
293
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
294
|
-
placeholder="Email"
|
|
295
|
-
required
|
|
296
|
-
/>
|
|
297
|
-
<input
|
|
298
|
-
type="password"
|
|
299
|
-
value={password}
|
|
300
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
301
|
-
placeholder="Password"
|
|
302
|
-
required
|
|
303
|
-
/>
|
|
304
|
-
<button type="submit">Sign In</button>
|
|
305
|
-
</form>
|
|
306
|
-
)
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### 4. Middleware (Optional)
|
|
311
|
-
|
|
312
|
-
```typescript
|
|
313
|
-
// middleware.ts
|
|
314
|
-
import { createAuthMiddleware } from 'mulguard/middleware'
|
|
315
|
-
import { auth } from '@/lib/auth'
|
|
316
|
-
|
|
317
|
-
export default createAuthMiddleware(auth, {
|
|
318
|
-
protectedRoutes: ['/dashboard', '/profile'],
|
|
319
|
-
redirectTo: '/login',
|
|
320
|
-
redirectIfAuthenticated: '/dashboard',
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
export const config = {
|
|
324
|
-
matcher: ['/dashboard/:path*', '/profile/:path*'],
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
## ๐ Core Concepts
|
|
331
|
-
|
|
332
|
-
### Backend-First Architecture
|
|
333
|
-
|
|
334
|
-
Mulguard follows a **backend-first** approach, meaning you implement your own authentication logic through **actions**. This gives you:
|
|
335
|
-
|
|
336
|
-
- **Full Control** - Complete control over your authentication flow
|
|
337
|
-
- **Flexibility** - Works with any backend architecture
|
|
338
|
-
- **No Lock-in** - No database adapter required
|
|
339
|
-
- **Custom Logic** - Implement business-specific authentication rules
|
|
340
|
-
|
|
341
|
-
### Actions
|
|
342
|
-
|
|
343
|
-
Actions are functions you provide to handle authentication operations:
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
actions: {
|
|
347
|
-
signIn: {
|
|
348
|
-
email: async (credentials) => { /* ... */ },
|
|
349
|
-
oauth: async (provider) => { /* ... */ },
|
|
350
|
-
passkey: async (options) => { /* ... */ },
|
|
351
|
-
},
|
|
352
|
-
signUp: async (data) => { /* ... */ },
|
|
353
|
-
signOut: async () => { /* ... */ },
|
|
354
|
-
getSession: async () => { /* ... */ },
|
|
355
|
-
// ... more actions
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Sessions
|
|
360
|
-
|
|
361
|
-
Sessions are stored in HTTP-only cookies and contain:
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
interface Session {
|
|
365
|
-
user: {
|
|
366
|
-
id: string
|
|
367
|
-
email: string
|
|
368
|
-
name?: string
|
|
369
|
-
avatar?: string
|
|
370
|
-
emailVerified?: boolean
|
|
371
|
-
}
|
|
372
|
-
expiresAt: Date
|
|
373
|
-
accessToken?: string
|
|
374
|
-
refreshToken?: string
|
|
375
|
-
tokenType?: string
|
|
376
|
-
expiresIn?: number
|
|
377
|
-
}
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
## ๐ Authentication Methods
|
|
383
|
-
|
|
384
|
-
### Unified Sign-In Interface
|
|
385
|
-
|
|
386
|
-
Mulguard provides a **unified interface** for all authentication methods, similar to auth.js:
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
// โ
Unified interface (recommended)
|
|
390
|
-
await auth.signIn('credentials', { email: 'user@example.com', password: 'password123' })
|
|
391
|
-
await auth.signIn('google')
|
|
392
|
-
await auth.signIn('otp', { email: 'user@example.com', code: '123456' })
|
|
393
|
-
await auth.signIn('passkey', { userId: 'user-id' })
|
|
394
|
-
|
|
395
|
-
// โ
Direct methods (for backward compatibility)
|
|
396
|
-
await auth.signIn.email({ email: 'user@example.com', password: 'password123' })
|
|
397
|
-
await auth.signIn.oauth('google')
|
|
398
|
-
await auth.signIn.otp('user@example.com', '123456')
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
### Email/Password Authentication
|
|
402
|
-
|
|
403
|
-
```typescript
|
|
404
|
-
// Using unified interface
|
|
405
|
-
const result = await auth.signIn('credentials', {
|
|
406
|
-
email: 'user@example.com',
|
|
407
|
-
password: 'password123',
|
|
408
|
-
})
|
|
409
|
-
|
|
410
|
-
// Or using direct method
|
|
411
|
-
const result = await auth.signIn.email({
|
|
412
|
-
email: 'user@example.com',
|
|
413
|
-
password: 'password123',
|
|
414
|
-
})
|
|
415
|
-
|
|
416
|
-
if (result.success) {
|
|
417
|
-
console.log('Signed in:', result.user)
|
|
418
|
-
} else {
|
|
419
|
-
console.error('Error:', result.error, result.errorCode)
|
|
420
|
-
}
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
### OAuth Authentication
|
|
424
|
-
|
|
425
|
-
```typescript
|
|
426
|
-
// Initiate OAuth flow (unified interface)
|
|
427
|
-
const { url } = await auth.signIn('google')
|
|
428
|
-
window.location.href = url
|
|
429
|
-
|
|
430
|
-
// Or using direct method
|
|
431
|
-
const { url } = await auth.signIn.oauth('google')
|
|
432
|
-
window.location.href = url
|
|
433
|
-
|
|
434
|
-
// Handle callback (in your API route)
|
|
435
|
-
const result = await auth.oauthCallback(provider, code, state)
|
|
436
|
-
|
|
437
|
-
// โ
OAuth providers are auto-configured when you add them to providers.oauth
|
|
438
|
-
// No need to implement oauth action manually!
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### PassKey/WebAuthn Authentication
|
|
442
|
-
|
|
443
|
-
```typescript
|
|
444
|
-
// Register PassKey
|
|
445
|
-
const result = await auth.passkey.register({
|
|
446
|
-
name: 'My iPhone',
|
|
447
|
-
userId: 'user-id',
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
// Authenticate with PassKey
|
|
451
|
-
const result = await auth.signIn.passkey({ userId: 'user-id' })
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### Two-Factor Authentication (2FA)
|
|
455
|
-
|
|
456
|
-
```typescript
|
|
457
|
-
// Enable 2FA
|
|
458
|
-
const enableResult = await auth.twoFactor.enable()
|
|
459
|
-
// Display QR code to user
|
|
460
|
-
|
|
461
|
-
// Verify 2FA code
|
|
462
|
-
const verifyResult = await auth.twoFactor.verify('123456')
|
|
463
|
-
|
|
464
|
-
// Check if 2FA is enabled
|
|
465
|
-
const isEnabled = await auth.twoFactor.isEnabled()
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
---
|
|
469
|
-
|
|
470
|
-
## โ๏ธ Configuration
|
|
471
|
-
|
|
472
|
-
### Full Configuration Options
|
|
473
|
-
|
|
474
|
-
```typescript
|
|
475
|
-
import { mulguard } from 'mulguard'
|
|
476
|
-
|
|
477
|
-
export const auth = mulguard({
|
|
478
|
-
// Session configuration
|
|
479
|
-
session: {
|
|
480
|
-
cookieName: '__mulguard_session',
|
|
481
|
-
expiresIn: 60 * 60 * 24 * 7, // 7 days in seconds
|
|
482
|
-
httpOnly: true,
|
|
483
|
-
secure: process.env.NODE_ENV === 'production',
|
|
484
|
-
sameSite: 'lax',
|
|
485
|
-
path: '/',
|
|
486
|
-
domain: undefined,
|
|
487
|
-
cacheTtl: 5000, // Session cache TTL in milliseconds
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
// Required: Authentication actions
|
|
491
|
-
actions: {
|
|
492
|
-
signIn: {
|
|
493
|
-
email: async (credentials) => { /* ... */ },
|
|
494
|
-
// Optional: oauth, passkey, otp
|
|
495
|
-
},
|
|
496
|
-
getSession: async () => { /* ... */ },
|
|
497
|
-
signOut: async () => { /* ... */ },
|
|
498
|
-
// Optional: signUp, resetPassword, verifyEmail, refreshSession, etc.
|
|
499
|
-
},
|
|
500
|
-
|
|
501
|
-
// Optional: OAuth providers
|
|
502
|
-
providers: {
|
|
503
|
-
oauth: {
|
|
504
|
-
google: {
|
|
505
|
-
clientId: '...',
|
|
506
|
-
clientSecret: '...', // Server-side only
|
|
507
|
-
redirectUri: '...',
|
|
508
|
-
scopes: ['openid', 'profile', 'email'],
|
|
509
|
-
name: 'Google',
|
|
510
|
-
},
|
|
511
|
-
github: {
|
|
512
|
-
clientId: '...',
|
|
513
|
-
redirectUri: '...',
|
|
514
|
-
scopes: ['user:email'],
|
|
515
|
-
},
|
|
516
|
-
},
|
|
517
|
-
},
|
|
518
|
-
|
|
519
|
-
// Optional: Two-Factor Authentication
|
|
520
|
-
twoFactor: {
|
|
521
|
-
enabled: true,
|
|
522
|
-
},
|
|
523
|
-
|
|
524
|
-
// Optional: Account Picker
|
|
525
|
-
accountPicker: {
|
|
526
|
-
enabled: true,
|
|
527
|
-
maxAccounts: 3,
|
|
528
|
-
encryptStorage: true,
|
|
529
|
-
storageKey: '__mulguard_accounts',
|
|
530
|
-
},
|
|
531
|
-
|
|
532
|
-
// Optional: Security settings
|
|
533
|
-
security: {
|
|
534
|
-
csrfProtection: true,
|
|
535
|
-
rateLimiting: {
|
|
536
|
-
maxAttempts: 5,
|
|
537
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
538
|
-
},
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
// Optional: Callbacks
|
|
542
|
-
callbacks: {
|
|
543
|
-
onSignIn: async (user, session) => {
|
|
544
|
-
// Called after successful sign-in
|
|
545
|
-
},
|
|
546
|
-
onSignOut: async (user) => {
|
|
547
|
-
// Called after sign-out
|
|
548
|
-
},
|
|
549
|
-
onSessionExpired: async (session) => {
|
|
550
|
-
// Called when session expires
|
|
551
|
-
},
|
|
552
|
-
onError: async (error, context) => {
|
|
553
|
-
// Called on authentication errors
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
|
|
557
|
-
// Optional: Token refresh configuration
|
|
558
|
-
tokenRefresh: {
|
|
559
|
-
enabled: true,
|
|
560
|
-
refreshThreshold: 300, // 5 minutes before expiration
|
|
561
|
-
maxRetries: 0,
|
|
562
|
-
retryDelay: 1000,
|
|
563
|
-
rateLimit: 1, // 1 attempt per minute
|
|
564
|
-
autoSignOutOnFailure: true,
|
|
565
|
-
redirectToLogin: '/login',
|
|
566
|
-
},
|
|
567
|
-
})
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
---
|
|
571
|
-
|
|
572
|
-
## ๐ฅ๏ธ Server-Side Usage
|
|
573
|
-
|
|
574
|
-
### Get Server Session
|
|
575
|
-
|
|
576
|
-
```typescript
|
|
577
|
-
import { getServerSession } from 'mulguard/server'
|
|
578
|
-
import { auth } from '@/lib/auth'
|
|
579
|
-
|
|
580
|
-
// In Server Components
|
|
581
|
-
const session = await getServerSession(auth)
|
|
582
|
-
|
|
583
|
-
// In API Routes
|
|
584
|
-
export async function GET(request: Request) {
|
|
585
|
-
const session = await getServerSession(auth)
|
|
586
|
-
if (!session) {
|
|
587
|
-
return new Response('Unauthorized', { status: 401 })
|
|
588
|
-
}
|
|
589
|
-
return Response.json({ user: session.user })
|
|
590
|
-
}
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
### Server Actions
|
|
594
|
-
|
|
595
|
-
```typescript
|
|
596
|
-
'use server'
|
|
597
|
-
|
|
598
|
-
import { auth } from '@/lib/auth'
|
|
599
|
-
|
|
600
|
-
export async function signInAction(email: string, password: string) {
|
|
601
|
-
const result = await auth.signIn.email({ email, password })
|
|
602
|
-
return result
|
|
603
|
-
}
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
### API Route Handlers
|
|
607
|
-
|
|
608
|
-
```typescript
|
|
609
|
-
// app/api/auth/[...mulguard]/route.ts
|
|
610
|
-
import { createAuthHandler } from 'mulguard/handlers/route'
|
|
611
|
-
import { auth } from '@/lib/auth'
|
|
612
|
-
|
|
613
|
-
export const { GET, POST } = createAuthHandler(auth)
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
---
|
|
617
|
-
|
|
618
|
-
## ๐ป Client-Side Usage
|
|
619
|
-
|
|
620
|
-
### React Hooks
|
|
621
|
-
|
|
622
|
-
```typescript
|
|
623
|
-
'use client'
|
|
624
|
-
|
|
625
|
-
import { useAuth, useSession } from 'mulguard/client'
|
|
626
|
-
import { auth } from '@/lib/auth'
|
|
627
|
-
|
|
628
|
-
export function AuthComponent() {
|
|
629
|
-
const { signIn, signOut, isLoading } = useAuth(auth)
|
|
630
|
-
const { session, isLoading: sessionLoading } = useSession(auth)
|
|
631
|
-
|
|
632
|
-
// Use hooks...
|
|
633
|
-
}
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
### Mulguard Provider
|
|
637
|
-
|
|
638
|
-
```typescript
|
|
639
|
-
// app/layout.tsx
|
|
640
|
-
'use client'
|
|
641
|
-
|
|
642
|
-
import { MulguardProvider } from 'mulguard/client'
|
|
643
|
-
import { auth } from '@/lib/auth'
|
|
644
|
-
|
|
645
|
-
export default function RootLayout({ children }) {
|
|
646
|
-
return (
|
|
647
|
-
<html>
|
|
648
|
-
<body>
|
|
649
|
-
<MulguardProvider auth={auth}>
|
|
650
|
-
{children}
|
|
651
|
-
</MulguardProvider>
|
|
652
|
-
</body>
|
|
653
|
-
</html>
|
|
654
|
-
)
|
|
655
|
-
}
|
|
656
|
-
```
|
|
657
|
-
|
|
658
|
-
> **Note:** `AuthProvider` is still available for backward compatibility but is deprecated. Use `MulguardProvider` instead.
|
|
659
|
-
|
|
660
|
-
---
|
|
661
|
-
|
|
662
|
-
## ๐จ Components
|
|
663
|
-
|
|
664
|
-
### Account Picker
|
|
665
|
-
|
|
666
|
-
```typescript
|
|
667
|
-
import { AccountPicker } from 'mulguard'
|
|
668
|
-
|
|
669
|
-
<AccountPicker
|
|
670
|
-
auth={auth}
|
|
671
|
-
onSelectUser={(user) => {
|
|
672
|
-
// Pre-fill email or handle quick login
|
|
673
|
-
setEmail(user.email)
|
|
674
|
-
}}
|
|
675
|
-
onUseDifferentAccount={() => {
|
|
676
|
-
// Show full login form
|
|
677
|
-
}}
|
|
678
|
-
/>
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
### OAuth Button
|
|
682
|
-
|
|
683
|
-
```typescript
|
|
684
|
-
import { OAuthButton } from 'mulguard'
|
|
685
|
-
|
|
686
|
-
<OAuthButton
|
|
687
|
-
auth={auth}
|
|
688
|
-
provider="google"
|
|
689
|
-
onSuccess={() => {
|
|
690
|
-
// Handle success
|
|
691
|
-
}}
|
|
692
|
-
onError={(error) => {
|
|
693
|
-
// Handle error
|
|
694
|
-
}}
|
|
695
|
-
>
|
|
696
|
-
Sign in with Google
|
|
697
|
-
</OAuthButton>
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
### Two-Factor Setup
|
|
701
|
-
|
|
702
|
-
```typescript
|
|
703
|
-
import { TwoFactorSetup } from 'mulguard'
|
|
704
|
-
|
|
705
|
-
<TwoFactorSetup
|
|
706
|
-
auth={auth}
|
|
707
|
-
onSuccess={() => {
|
|
708
|
-
// 2FA enabled
|
|
709
|
-
}}
|
|
710
|
-
/>
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
### PassKey Components
|
|
714
|
-
|
|
715
|
-
```typescript
|
|
716
|
-
import { PassKeyButton, PassKeyRegister } from 'mulguard'
|
|
717
|
-
|
|
718
|
-
// Register PassKey
|
|
719
|
-
<PassKeyRegister auth={auth} />
|
|
720
|
-
|
|
721
|
-
// Authenticate with PassKey
|
|
722
|
-
<PassKeyButton auth={auth} />
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
---
|
|
726
|
-
|
|
727
|
-
## ๐ Security
|
|
728
|
-
|
|
729
|
-
Mulguard implements **comprehensive security features** with automatic input validation and sanitization:
|
|
730
|
-
|
|
731
|
-
### โ
Built-in Security Features
|
|
732
|
-
|
|
733
|
-
#### Input Validation & Sanitization
|
|
734
|
-
- **Automatic email validation** - Validates and sanitizes email addresses
|
|
735
|
-
- **Password length checks** - Prevents DoS attacks with extremely long passwords
|
|
736
|
-
- **Provider validation** - Sanitizes OAuth provider strings to prevent injection
|
|
737
|
-
- **OTP code validation** - Validates OTP code format before processing
|
|
738
|
-
- **XSS Prevention** - Automatic HTML escaping and input sanitization
|
|
739
|
-
|
|
740
|
-
#### CSRF Protection
|
|
741
|
-
- Token-based CSRF protection for OAuth flows
|
|
742
|
-
- State parameter validation with constant-time comparison
|
|
743
|
-
- Secure state storage (pluggable for production - Redis, Database, etc.)
|
|
744
|
-
|
|
745
|
-
#### Error Handling
|
|
746
|
-
- **Generic error messages** - Prevents information disclosure
|
|
747
|
-
- **Error codes** - Programmatic error handling without exposing details
|
|
748
|
-
- **Security logging** - Logs authentication events (with sensitive data masked)
|
|
749
|
-
|
|
750
|
-
#### Secure Cookies
|
|
751
|
-
- HttpOnly cookies (prevents JavaScript access)
|
|
752
|
-
- Secure flag in production (HTTPS only)
|
|
753
|
-
- SameSite attribute (CSRF protection)
|
|
754
|
-
- Configurable expiration
|
|
755
|
-
|
|
756
|
-
#### Rate Limiting
|
|
757
|
-
- Configurable rate limiting
|
|
758
|
-
- Client-side tracking
|
|
759
|
-
- Automatic throttling
|
|
760
|
-
- Circuit breaker pattern for token refresh
|
|
761
|
-
|
|
762
|
-
### Security Best Practices
|
|
763
|
-
|
|
764
|
-
```typescript
|
|
765
|
-
// โ
Good: Generic error messages
|
|
766
|
-
return {
|
|
767
|
-
success: false,
|
|
768
|
-
error: 'Invalid credentials',
|
|
769
|
-
errorCode: 'INVALID_CREDENTIALS'
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// โ Bad: Information disclosure
|
|
773
|
-
return {
|
|
774
|
-
success: false,
|
|
775
|
-
error: 'User not found with email: user@example.com'
|
|
776
|
-
}
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
### Security Logging
|
|
780
|
-
|
|
781
|
-
All authentication events are automatically logged with sensitive data masked:
|
|
782
|
-
|
|
783
|
-
```typescript
|
|
784
|
-
// Logs show: "Sign in successful" with email: "use***"
|
|
785
|
-
// Never logs full email addresses or passwords
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
For detailed security documentation, see the [Security Guide](./docs/SECURITY.md) and [Complete Guide](./GUIDE.md).
|
|
789
|
-
|
|
790
|
-
---
|
|
791
|
-
|
|
792
|
-
## ๐ Backend Integration
|
|
793
|
-
|
|
794
|
-
Mulguard is designed to work with your existing backend. You implement the authentication logic through **actions**, which can:
|
|
795
|
-
|
|
796
|
-
- Connect to your database
|
|
797
|
-
- Call your API endpoints
|
|
798
|
-
- Use your existing authentication services
|
|
799
|
-
- Integrate with third-party services
|
|
800
|
-
|
|
801
|
-
### Example: Database Integration
|
|
802
|
-
|
|
803
|
-
```typescript
|
|
804
|
-
import { mulguard } from 'mulguard'
|
|
805
|
-
import { db } from '@/lib/db'
|
|
806
|
-
import { comparePassword, hashPassword } from '@/lib/password'
|
|
807
|
-
|
|
808
|
-
export const auth = mulguard({
|
|
809
|
-
actions: {
|
|
810
|
-
signIn: {
|
|
811
|
-
email: async ({ email, password }) => {
|
|
812
|
-
const user = await db.user.findUnique({ where: { email } })
|
|
813
|
-
|
|
814
|
-
if (!user || !await comparePassword(password, user.password)) {
|
|
815
|
-
return { success: false, error: 'Invalid credentials' }
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
return {
|
|
819
|
-
success: true,
|
|
820
|
-
user: {
|
|
821
|
-
id: user.id,
|
|
822
|
-
email: user.email,
|
|
823
|
-
name: user.name,
|
|
824
|
-
},
|
|
825
|
-
session: {
|
|
826
|
-
user: { /* ... */ },
|
|
827
|
-
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
|
828
|
-
},
|
|
829
|
-
}
|
|
830
|
-
},
|
|
831
|
-
},
|
|
832
|
-
// ... more actions
|
|
833
|
-
},
|
|
834
|
-
})
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
### Example: API Integration
|
|
838
|
-
|
|
839
|
-
```typescript
|
|
840
|
-
import { mulguard } from 'mulguard'
|
|
841
|
-
|
|
842
|
-
export const auth = mulguard({
|
|
843
|
-
actions: {
|
|
844
|
-
signIn: {
|
|
845
|
-
email: async ({ email, password }) => {
|
|
846
|
-
const response = await fetch('https://api.example.com/auth/signin', {
|
|
847
|
-
method: 'POST',
|
|
848
|
-
headers: { 'Content-Type': 'application/json' },
|
|
849
|
-
body: JSON.stringify({ email, password }),
|
|
850
|
-
})
|
|
851
|
-
|
|
852
|
-
if (!response.ok) {
|
|
853
|
-
return { success: false, error: 'Authentication failed' }
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
const data = await response.json()
|
|
857
|
-
return {
|
|
858
|
-
success: true,
|
|
859
|
-
user: data.user,
|
|
860
|
-
session: data.session,
|
|
861
|
-
}
|
|
862
|
-
},
|
|
863
|
-
},
|
|
864
|
-
},
|
|
865
|
-
})
|
|
866
|
-
```
|
|
867
|
-
|
|
868
|
-
---
|
|
869
|
-
|
|
870
|
-
## ๐ Advanced Features
|
|
871
|
-
|
|
872
|
-
### Token Refresh
|
|
873
|
-
|
|
874
|
-
Automatic token refresh is built-in when you provide a `refreshSession` action:
|
|
875
|
-
|
|
876
|
-
```typescript
|
|
877
|
-
actions: {
|
|
878
|
-
refreshSession: async () => {
|
|
879
|
-
// Your token refresh logic
|
|
880
|
-
const newSession = await yourApi.refreshToken()
|
|
881
|
-
return newSession
|
|
882
|
-
},
|
|
883
|
-
}
|
|
884
|
-
```
|
|
885
|
-
|
|
886
|
-
### Custom Callbacks
|
|
887
|
-
|
|
888
|
-
```typescript
|
|
889
|
-
callbacks: {
|
|
890
|
-
onSignIn: async (user, session) => {
|
|
891
|
-
// Track sign-in analytics
|
|
892
|
-
await analytics.track('user_signed_in', { userId: user.id })
|
|
893
|
-
},
|
|
894
|
-
onSignOut: async (user) => {
|
|
895
|
-
// Cleanup logic
|
|
896
|
-
await cleanupUserSession(user.id)
|
|
897
|
-
},
|
|
898
|
-
onError: async (error, context) => {
|
|
899
|
-
// Error logging
|
|
900
|
-
console.error(`Auth error in ${context}:`, error)
|
|
901
|
-
},
|
|
902
|
-
}
|
|
903
|
-
```
|
|
904
|
-
|
|
905
|
-
### OAuth State Store
|
|
906
|
-
|
|
907
|
-
For production, use a persistent OAuth state store:
|
|
908
|
-
|
|
909
|
-
```typescript
|
|
910
|
-
import { createRedisOAuthStateStore } from 'mulguard'
|
|
911
|
-
|
|
912
|
-
const auth = mulguard({
|
|
913
|
-
oauthStateStore: createRedisOAuthStateStore(redisClient),
|
|
914
|
-
// ... rest of config
|
|
915
|
-
})
|
|
916
|
-
```
|
|
917
|
-
|
|
918
|
-
---
|
|
919
|
-
|
|
920
|
-
## ๐ API Reference
|
|
921
|
-
|
|
922
|
-
### Core Functions
|
|
923
|
-
|
|
924
|
-
#### `mulguard(config: MulguardConfig): MulguardInstance`
|
|
925
|
-
|
|
926
|
-
Creates a new Mulguard authentication instance.
|
|
927
|
-
|
|
928
|
-
#### `getServerSession(auth: MulguardInstance): Promise<Session | null>`
|
|
929
|
-
|
|
930
|
-
Gets the current session on the server.
|
|
931
|
-
|
|
932
|
-
### Client Hooks
|
|
933
|
-
|
|
934
|
-
#### `useAuth(auth: MulguardInstance)`
|
|
935
|
-
|
|
936
|
-
Returns authentication methods and state.
|
|
937
|
-
|
|
938
|
-
```typescript
|
|
939
|
-
const { signIn, signOut, isLoading } = useAuth(auth)
|
|
940
|
-
```
|
|
941
|
-
|
|
942
|
-
#### `useSession(auth: MulguardInstance)`
|
|
943
|
-
|
|
944
|
-
Returns the current session.
|
|
945
|
-
|
|
946
|
-
```typescript
|
|
947
|
-
const { session, isLoading } = useSession(auth)
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
### Instance Methods
|
|
951
|
-
|
|
952
|
-
#### `auth.getSession(): Promise<Session | null>`
|
|
953
|
-
|
|
954
|
-
Gets the current session.
|
|
955
|
-
|
|
956
|
-
#### `auth.signIn.email(credentials): Promise<AuthResult>`
|
|
957
|
-
|
|
958
|
-
Signs in with email and password.
|
|
959
|
-
|
|
960
|
-
#### `auth.signIn.oauth(provider): Promise<{ url: string; state: string }>`
|
|
961
|
-
|
|
962
|
-
Initiates OAuth flow.
|
|
963
|
-
|
|
964
|
-
#### `auth.signOut(): Promise<{ success: boolean }>`
|
|
965
|
-
|
|
966
|
-
Signs out the current user.
|
|
967
|
-
|
|
968
|
-
For complete API documentation, see the [API Reference](./docs/API_REFERENCE.md).
|
|
969
|
-
|
|
970
|
-
---
|
|
971
|
-
|
|
972
|
-
## ๐ Examples & Guides
|
|
973
|
-
|
|
974
|
-
### Complete Guide
|
|
975
|
-
|
|
976
|
-
๐ **[Complete Usage Guide](./GUIDE.md)** - Comprehensive guide with:
|
|
977
|
-
- Best practices for writing `auth.ts`
|
|
978
|
-
- Production-ready examples
|
|
979
|
-
- Security recommendations
|
|
980
|
-
- Backend integration patterns
|
|
981
|
-
- Advanced usage examples
|
|
982
|
-
|
|
983
|
-
### Code Examples
|
|
984
|
-
|
|
985
|
-
- **[Basic Email Authentication](./src/examples/email-auth.ts)** - Simple email/password setup
|
|
986
|
-
- **[OAuth Authentication](./src/examples/oauth-auth.ts)** - Google, GitHub, etc.
|
|
987
|
-
- **[PassKey Authentication](./src/examples/passkey-auth.ts)** - WebAuthn/PassKey setup
|
|
988
|
-
- **[Two-Factor Authentication](./src/examples/two-factor-auth.ts)** - 2FA/TOTP implementation
|
|
989
|
-
- **[Middleware Integration](./src/examples/middleware-example.ts)** - Next.js middleware
|
|
990
|
-
- **[Server Components](./src/examples/server-component-example.tsx)** - Server-side usage
|
|
991
|
-
|
|
992
|
-
---
|
|
993
|
-
|
|
994
|
-
## ๐งช Testing
|
|
995
|
-
|
|
996
|
-
```bash
|
|
997
|
-
# Run tests
|
|
998
|
-
npm test
|
|
999
|
-
|
|
1000
|
-
# Watch mode
|
|
1001
|
-
npm run test:watch
|
|
1002
|
-
|
|
1003
|
-
# Coverage
|
|
1004
|
-
npm run test:coverage
|
|
1005
|
-
|
|
1006
|
-
# Type checking
|
|
1007
|
-
npm run type-check
|
|
1008
|
-
```
|
|
1009
|
-
|
|
1010
|
-
---
|
|
1011
|
-
|
|
1012
|
-
## ๐ค Contributing
|
|
1013
|
-
|
|
1014
|
-
Contributions are welcome! Please read our contributing guidelines before submitting a pull request.
|
|
1015
|
-
|
|
1016
|
-
1. Fork the repository
|
|
1017
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
1018
|
-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
1019
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
1020
|
-
5. Open a Pull Request
|
|
1021
|
-
|
|
1022
|
-
### Development Setup
|
|
1023
|
-
|
|
1024
|
-
```bash
|
|
1025
|
-
# Clone the repository
|
|
1026
|
-
git clone https://github.com/mulverse/mulguard.git
|
|
1027
|
-
|
|
1028
|
-
# Install dependencies
|
|
1029
|
-
npm install
|
|
1030
|
-
|
|
1031
|
-
# Run development build
|
|
1032
|
-
npm run dev
|
|
1033
|
-
|
|
1034
|
-
# Run tests
|
|
1035
|
-
npm test
|
|
1036
|
-
```
|
|
1037
|
-
|
|
1038
|
-
---
|
|
1039
|
-
|
|
1040
|
-
## ๐ License
|
|
1041
|
-
|
|
1042
|
-
This project is licensed under the **MUV (Mulverse M.U.V General Public License)**.
|
|
1043
|
-
|
|
1044
|
-
Copyright (C) 2022 Mulverse Inc.
|
|
1045
|
-
|
|
1046
|
-
See the [LICENSE](./LICENSE) file for details.
|
|
1047
|
-
|
|
1048
|
-
---
|
|
1049
|
-
|
|
1050
|
-
## ๐ฌ Support
|
|
1051
|
-
|
|
1052
|
-
- **๐ Complete Guide**: [GUIDE.md](./GUIDE.md) - Comprehensive usage guide with best practices
|
|
1053
|
-
- **๐ Documentation**: Check the [docs](./docs) directory for detailed guides
|
|
1054
|
-
- **๐ Issues**: [GitHub Issues](https://github.com/mulverse/mulguard/issues)
|
|
1055
|
-
- **๐ฌ Discussions**: [GitHub Discussions](https://github.com/mulverse/mulguard/discussions)
|
|
1056
|
-
|
|
1057
|
-
## ๐ฏ Key Features & Improvements
|
|
1058
|
-
|
|
1059
|
-
### โจ Latest Updates
|
|
1060
|
-
|
|
1061
|
-
- **โ
Unified Sign-In Interface** - Use `auth.signIn('credentials', {...})` or `auth.signIn.email({...})`
|
|
1062
|
-
- **โ
Automatic Input Validation** - Built-in email, password, and provider validation
|
|
1063
|
-
- **โ
Enhanced Security** - Generic error messages, security logging, XSS/Injection prevention
|
|
1064
|
-
- **โ
Single Unified Logic** - All sign-in methods use the same core logic
|
|
1065
|
-
- **โ
Type-Safe** - Full TypeScript support with proper typing
|
|
1066
|
-
- **โ
Production Ready** - Best practices built-in by default
|
|
1067
|
-
|
|
1068
|
-
---
|
|
1069
|
-
|
|
1070
|
-
## ๐ About Mulverse
|
|
1071
|
-
|
|
1072
|
-
**Mulguard** is part of the **Mulverse** ecosystem - a collection of modern, developer-friendly libraries and tools for building next-generation web applications.
|
|
1073
|
-
|
|
1074
|
-
Visit [mulverse.com](https://mulverse.com) to learn more about our other projects.
|
|
1075
|
-
|
|
1076
|
-
---
|
|
1077
|
-
|
|
1078
|
-
**Made with โค๏ธ by the Mulverse Team**
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://nextjs.org" target="_blank"><img height="96px" src="https://authjs.dev/img/etc/nextjs.svg" /></a>
|
|
3
|
+
<a href="https://mulverse.com" target="_blank"><img height="96px" src="https://authjs.dev/img/logo-sm.png" /></a>
|
|
4
|
+
<h1 align="center">MulGuard</h1>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
Authentication for Next.js with Backend-First Architecture.
|
|
8
|
+
</p>
|
|
9
|
+
<p align="center">
|
|
10
|
+
Part of the <a href="https://mulverse.com" target="_blank">Mulverse Network</a>
|
|
11
|
+
</p>
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/mulguard"><img src="https://img.shields.io/npm/v/mulguard/beta?style=flat-square&label=latest&color=purple" alt="npm beta release" /></a>
|
|
14
|
+
<a href="https://www.npmtrends.com/mulguard"><img src="https://img.shields.io/npm/dm/mulguard?style=flat-square&color=cyan" alt="Downloads" /></a>
|
|
15
|
+
<a href="https://github.com/mulguard/mulguard/stargazers"><img src="https://img.shields.io/github/stars/mulguard/mulguard?style=flat-square&color=orange" alt="GitHub Stars" /></a>
|
|
16
|
+
<img src="https://shields.io/badge/TypeScript-3178C6?logo=TypeScript&logoColor=fff&style=flat-square" alt="TypeScript" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Check out the documentation at [mulverse.com](https://mulverse.com) or visit the [Mulverse Network](https://mulverse.com) for more information.
|