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,289 +0,0 @@
|
|
|
1
|
-
import { d as f, g as R, c as v } from "./actions-DeCfLtHA.mjs";
|
|
2
|
-
import { redirect as T } from "next/navigation";
|
|
3
|
-
import { NextResponse as w } from "next/server";
|
|
4
|
-
function p(e) {
|
|
5
|
-
return !e || !e.expiresAt ? !1 : new Date(e.expiresAt) < /* @__PURE__ */ new Date();
|
|
6
|
-
}
|
|
7
|
-
function U(e, t = 5) {
|
|
8
|
-
if (!e || !e.expiresAt)
|
|
9
|
-
return !1;
|
|
10
|
-
const r = new Date(e.expiresAt), s = /* @__PURE__ */ new Date(), i = (r.getTime() - s.getTime()) / (1e3 * 60);
|
|
11
|
-
return i > 0 && i < t;
|
|
12
|
-
}
|
|
13
|
-
function q(e) {
|
|
14
|
-
if (!e || !e.expiresAt)
|
|
15
|
-
return null;
|
|
16
|
-
const t = new Date(e.expiresAt), r = /* @__PURE__ */ new Date(), s = (t.getTime() - r.getTime()) / (1e3 * 60);
|
|
17
|
-
return s > 0 ? Math.floor(s) : 0;
|
|
18
|
-
}
|
|
19
|
-
function M(e) {
|
|
20
|
-
return !(!e || !e.user || !e.user.id || !e.user.email || !e.user.name || p(e));
|
|
21
|
-
}
|
|
22
|
-
function m(e) {
|
|
23
|
-
if (!e || typeof e != "object")
|
|
24
|
-
return !1;
|
|
25
|
-
const t = e;
|
|
26
|
-
if (!t.user || typeof t.user != "object")
|
|
27
|
-
return !1;
|
|
28
|
-
const r = t.user;
|
|
29
|
-
if (typeof r.id != "string" || r.id.length === 0 || typeof r.email != "string" || r.email.length === 0 || typeof r.name != "string" || r.name.length === 0 || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r.email))
|
|
30
|
-
return !1;
|
|
31
|
-
if (t.expiresAt)
|
|
32
|
-
if (t.expiresAt instanceof Date) {
|
|
33
|
-
if (isNaN(t.expiresAt.getTime()))
|
|
34
|
-
return !1;
|
|
35
|
-
} else if (typeof t.expiresAt == "string") {
|
|
36
|
-
const i = new Date(t.expiresAt);
|
|
37
|
-
if (isNaN(i.getTime()))
|
|
38
|
-
return !1;
|
|
39
|
-
} else
|
|
40
|
-
return !1;
|
|
41
|
-
return !0;
|
|
42
|
-
}
|
|
43
|
-
function j(e, t) {
|
|
44
|
-
const r = t.cookieName || "__mulguard_session";
|
|
45
|
-
let s = null, i = 0;
|
|
46
|
-
const h = 6e4;
|
|
47
|
-
return {
|
|
48
|
-
/**
|
|
49
|
-
* Get current session from backend with automatic refresh
|
|
50
|
-
*/
|
|
51
|
-
async getSession(n) {
|
|
52
|
-
try {
|
|
53
|
-
if (!await R(r))
|
|
54
|
-
return s = null, null;
|
|
55
|
-
const o = Date.now();
|
|
56
|
-
if (s && o - i < h) {
|
|
57
|
-
if (!(n != null && n.skipRefresh) && this.shouldRefreshSession(s, t)) {
|
|
58
|
-
const u = await this.refreshSession();
|
|
59
|
-
if (u)
|
|
60
|
-
return s = u, i = o, u;
|
|
61
|
-
}
|
|
62
|
-
return s;
|
|
63
|
-
}
|
|
64
|
-
const c = await e.get("/api/auth/session");
|
|
65
|
-
if (!c.data.session)
|
|
66
|
-
return s = null, null;
|
|
67
|
-
const l = c.data.session;
|
|
68
|
-
if (!m(l))
|
|
69
|
-
return await f(r), s = null, null;
|
|
70
|
-
if (p(l)) {
|
|
71
|
-
if (!(n != null && n.skipRefresh) && this.shouldRefreshSession(l, t)) {
|
|
72
|
-
const u = await this.refreshSession();
|
|
73
|
-
if (u)
|
|
74
|
-
return s = u, i = o, u;
|
|
75
|
-
}
|
|
76
|
-
return await f(r), s = null, null;
|
|
77
|
-
}
|
|
78
|
-
if (!(n != null && n.skipRefresh) && this.shouldRefreshSession(l, t)) {
|
|
79
|
-
const u = await this.refreshSession();
|
|
80
|
-
if (u)
|
|
81
|
-
return s = u, i = o, u;
|
|
82
|
-
}
|
|
83
|
-
return s = l, i = o, l;
|
|
84
|
-
} catch {
|
|
85
|
-
return await f(r), s = null, null;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Set session cookie
|
|
90
|
-
*/
|
|
91
|
-
setSession(n, a) {
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* Clear session
|
|
95
|
-
*/
|
|
96
|
-
async clearSession(n) {
|
|
97
|
-
await f(r, {
|
|
98
|
-
path: n.path
|
|
99
|
-
}), s = null, i = 0;
|
|
100
|
-
},
|
|
101
|
-
/**
|
|
102
|
-
* Refresh session
|
|
103
|
-
*/
|
|
104
|
-
async refreshSession() {
|
|
105
|
-
try {
|
|
106
|
-
const n = await e.post("/api/auth/refresh");
|
|
107
|
-
if (!n.data.session)
|
|
108
|
-
return s = null, null;
|
|
109
|
-
const a = n.data.session;
|
|
110
|
-
return m(a) ? (s = a, i = Date.now(), a) : (s = null, null);
|
|
111
|
-
} catch {
|
|
112
|
-
return s = null, null;
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
/**
|
|
116
|
-
* Check if session is expired
|
|
117
|
-
*/
|
|
118
|
-
isSessionExpired(n) {
|
|
119
|
-
return p(n);
|
|
120
|
-
},
|
|
121
|
-
/**
|
|
122
|
-
* Check if session should be refreshed (within 5 minutes of expiration)
|
|
123
|
-
*/
|
|
124
|
-
shouldRefreshSession(n, a) {
|
|
125
|
-
if (!n.expiresAt)
|
|
126
|
-
return !1;
|
|
127
|
-
const o = new Date(n.expiresAt), c = /* @__PURE__ */ new Date(), l = o.getTime() - c.getTime(), u = 5 * 60 * 1e3;
|
|
128
|
-
return l > 0 && l < u;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
async function P(e, t) {
|
|
133
|
-
try {
|
|
134
|
-
const r = await e.post("/api/auth/refresh");
|
|
135
|
-
return r.data.session ? r.data.session : null;
|
|
136
|
-
} catch {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async function g(e) {
|
|
141
|
-
try {
|
|
142
|
-
const t = await e.getSession();
|
|
143
|
-
return !t || !m(t) || p(t) ? null : t;
|
|
144
|
-
} catch (t) {
|
|
145
|
-
return console.error("Failed to get server session:", t), null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
async function S(e, t = "/login") {
|
|
149
|
-
const r = await g(e);
|
|
150
|
-
return r || T(t), r;
|
|
151
|
-
}
|
|
152
|
-
async function _(e, t, r = "/unauthorized") {
|
|
153
|
-
const s = await S(e);
|
|
154
|
-
return (!s.user.roles || !s.user.roles.includes(t)) && T(r), s;
|
|
155
|
-
}
|
|
156
|
-
async function E(e) {
|
|
157
|
-
const t = await g(e);
|
|
158
|
-
return (t == null ? void 0 : t.user) ?? null;
|
|
159
|
-
}
|
|
160
|
-
function L(e, t) {
|
|
161
|
-
return {
|
|
162
|
-
getSession: () => g(e),
|
|
163
|
-
requireAuth: (r) => S(e, r),
|
|
164
|
-
requireRole: (r, s) => _(e, r, s)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function z(e) {
|
|
168
|
-
return {
|
|
169
|
-
getSession: () => g(e),
|
|
170
|
-
requireAuth: (t) => S(e, t),
|
|
171
|
-
requireRole: (t, r) => _(e, t, r),
|
|
172
|
-
getCurrentUser: () => E(e)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function x(e, t = []) {
|
|
176
|
-
return [...[
|
|
177
|
-
"/auth/login",
|
|
178
|
-
"/auth/register",
|
|
179
|
-
"/auth/forgot-password",
|
|
180
|
-
"/auth/reset-password",
|
|
181
|
-
"/auth/verify-email"
|
|
182
|
-
], ...t].some((i) => e.startsWith(i));
|
|
183
|
-
}
|
|
184
|
-
function D(e, t = {}) {
|
|
185
|
-
const {
|
|
186
|
-
redirectTo: r = "/auth/login",
|
|
187
|
-
requireAuth: s = !1,
|
|
188
|
-
allowedRoles: i = [],
|
|
189
|
-
publicRoutes: h = []
|
|
190
|
-
} = t;
|
|
191
|
-
return async (n) => {
|
|
192
|
-
const { pathname: a } = n.nextUrl;
|
|
193
|
-
if (x(a, h) || a.startsWith("/api/") || a.startsWith("/_next/") || a.startsWith("/favicon.ico") || a.match(/\.(ico|png|jpg|jpeg|svg|gif|webp|css|js|woff|woff2|ttf|eot)$/))
|
|
194
|
-
return null;
|
|
195
|
-
try {
|
|
196
|
-
const o = await e.getSession();
|
|
197
|
-
if (s && !o) {
|
|
198
|
-
const c = new URL(r, n.url);
|
|
199
|
-
return c.searchParams.set("redirect", a), w.redirect(c);
|
|
200
|
-
}
|
|
201
|
-
if (o && i.length > 0) {
|
|
202
|
-
const c = o.user.roles || [];
|
|
203
|
-
if (!i.some((u) => c.includes(u)))
|
|
204
|
-
return w.redirect(new URL("/unauthorized", n.url));
|
|
205
|
-
}
|
|
206
|
-
return o && x(a, h) ? w.redirect(new URL("/", n.url)) : null;
|
|
207
|
-
} catch (o) {
|
|
208
|
-
return process.env.NODE_ENV === "development" && console.error("[Mulguard Middleware] Error:", o), null;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function H(e, t = "/auth/login") {
|
|
213
|
-
return D(e, {
|
|
214
|
-
requireAuth: !0,
|
|
215
|
-
redirectTo: t
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function V(e, t, r = "/unauthorized") {
|
|
219
|
-
return D(e, {
|
|
220
|
-
requireAuth: !0,
|
|
221
|
-
allowedRoles: t,
|
|
222
|
-
redirectTo: r
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
const A = "__mulguard_oauth_state", y = 10 * 60;
|
|
226
|
-
async function k(e, t) {
|
|
227
|
-
try {
|
|
228
|
-
const r = JSON.stringify({ state: e, provider: t, expiresAt: Date.now() + y * 1e3 }), s = process.env.NODE_ENV === "production";
|
|
229
|
-
return await v({
|
|
230
|
-
name: A,
|
|
231
|
-
value: r,
|
|
232
|
-
httpOnly: !0,
|
|
233
|
-
secure: s,
|
|
234
|
-
sameSite: "strict",
|
|
235
|
-
maxAge: y,
|
|
236
|
-
path: "/"
|
|
237
|
-
});
|
|
238
|
-
} catch (r) {
|
|
239
|
-
return {
|
|
240
|
-
success: !1,
|
|
241
|
-
error: r instanceof Error ? r.message : "Failed to store OAuth state"
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async function N() {
|
|
246
|
-
try {
|
|
247
|
-
const e = await R(A);
|
|
248
|
-
if (!e)
|
|
249
|
-
return null;
|
|
250
|
-
const t = JSON.parse(e);
|
|
251
|
-
return t.expiresAt < Date.now() ? (await d(), null) : (await d(), {
|
|
252
|
-
state: t.state,
|
|
253
|
-
provider: t.provider
|
|
254
|
-
});
|
|
255
|
-
} catch {
|
|
256
|
-
return await d(), null;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async function d() {
|
|
260
|
-
await f(A, { path: "/" });
|
|
261
|
-
}
|
|
262
|
-
const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
263
|
-
__proto__: null,
|
|
264
|
-
deleteOAuthStateCookie: d,
|
|
265
|
-
getOAuthStateCookie: N,
|
|
266
|
-
storeOAuthStateCookie: k
|
|
267
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
268
|
-
export {
|
|
269
|
-
M as a,
|
|
270
|
-
p as b,
|
|
271
|
-
D as c,
|
|
272
|
-
V as d,
|
|
273
|
-
g as e,
|
|
274
|
-
S as f,
|
|
275
|
-
q as g,
|
|
276
|
-
_ as h,
|
|
277
|
-
U as i,
|
|
278
|
-
E as j,
|
|
279
|
-
z as k,
|
|
280
|
-
N as l,
|
|
281
|
-
d as m,
|
|
282
|
-
j as n,
|
|
283
|
-
P as o,
|
|
284
|
-
L as p,
|
|
285
|
-
W as q,
|
|
286
|
-
H as r,
|
|
287
|
-
k as s,
|
|
288
|
-
m as v
|
|
289
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const f=require("./actions-CExpv_dD.js"),C=require("next/navigation"),A=require("next/server");function d(e){return!e||!e.expiresAt?!1:new Date(e.expiresAt)<new Date}function E(e,t=5){if(!e||!e.expiresAt)return!1;const r=new Date(e.expiresAt),s=new Date,i=(r.getTime()-s.getTime())/(1e3*60);return i>0&&i<t}function D(e){if(!e||!e.expiresAt)return null;const t=new Date(e.expiresAt),r=new Date,s=(t.getTime()-r.getTime())/(1e3*60);return s>0?Math.floor(s):0}function N(e){return!(!e||!e.user||!e.user.id||!e.user.email||!e.user.name||d(e))}function S(e){if(!e||typeof e!="object")return!1;const t=e;if(!t.user||typeof t.user!="object")return!1;const r=t.user;if(typeof r.id!="string"||r.id.length===0||typeof r.email!="string"||r.email.length===0||typeof r.name!="string"||r.name.length===0||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r.email))return!1;if(t.expiresAt)if(t.expiresAt instanceof Date){if(isNaN(t.expiresAt.getTime()))return!1}else if(typeof t.expiresAt=="string"){const i=new Date(t.expiresAt);if(isNaN(i.getTime()))return!1}else return!1;return!0}function O(e,t){const r=t.cookieName||"__mulguard_session";let s=null,i=0;const p=6e4;return{async getSession(n){try{if(!await f.getCookie(r))return s=null,null;const a=Date.now();if(s&&a-i<p){if(!(n!=null&&n.skipRefresh)&&this.shouldRefreshSession(s,t)){const o=await this.refreshSession();if(o)return s=o,i=a,o}return s}const c=await e.get("/api/auth/session");if(!c.data.session)return s=null,null;const l=c.data.session;if(!S(l))return await f.deleteCookie(r),s=null,null;if(d(l)){if(!(n!=null&&n.skipRefresh)&&this.shouldRefreshSession(l,t)){const o=await this.refreshSession();if(o)return s=o,i=a,o}return await f.deleteCookie(r),s=null,null}if(!(n!=null&&n.skipRefresh)&&this.shouldRefreshSession(l,t)){const o=await this.refreshSession();if(o)return s=o,i=a,o}return s=l,i=a,l}catch{return await f.deleteCookie(r),s=null,null}},setSession(n,u){},async clearSession(n){await f.deleteCookie(r,{path:n.path}),s=null,i=0},async refreshSession(){try{const n=await e.post("/api/auth/refresh");if(!n.data.session)return s=null,null;const u=n.data.session;return S(u)?(s=u,i=Date.now(),u):(s=null,null)}catch{return s=null,null}},isSessionExpired(n){return d(n)},shouldRefreshSession(n,u){if(!n.expiresAt)return!1;const a=new Date(n.expiresAt),c=new Date,l=a.getTime()-c.getTime(),o=5*60*1e3;return l>0&&l<o}}}async function q(e,t){try{const r=await e.post("/api/auth/refresh");return r.data.session?r.data.session:null}catch{return null}}async function g(e){try{const t=await e.getSession();return!t||!S(t)||d(t)?null:t}catch(t){return console.error("Failed to get server session:",t),null}}async function w(e,t="/login"){const r=await g(e);return r||C.redirect(t),r}async function m(e,t,r="/unauthorized"){const s=await w(e);return(!s.user.roles||!s.user.roles.includes(t))&&C.redirect(r),s}async function _(e){const t=await g(e);return(t==null?void 0:t.user)??null}function M(e,t){return{getSession:()=>g(e),requireAuth:r=>w(e,r),requireRole:(r,s)=>m(e,r,s)}}function U(e){return{getSession:()=>g(e),requireAuth:t=>w(e,t),requireRole:(t,r)=>m(e,t,r),getCurrentUser:()=>_(e)}}function y(e,t=[]){return[...["/auth/login","/auth/register","/auth/forgot-password","/auth/reset-password","/auth/verify-email"],...t].some(i=>e.startsWith(i))}function x(e,t={}){const{redirectTo:r="/auth/login",requireAuth:s=!1,allowedRoles:i=[],publicRoutes:p=[]}=t;return async n=>{const{pathname:u}=n.nextUrl;if(y(u,p)||u.startsWith("/api/")||u.startsWith("/_next/")||u.startsWith("/favicon.ico")||u.match(/\.(ico|png|jpg|jpeg|svg|gif|webp|css|js|woff|woff2|ttf|eot)$/))return null;try{const a=await e.getSession();if(s&&!a){const c=new URL(r,n.url);return c.searchParams.set("redirect",u),A.NextResponse.redirect(c)}if(a&&i.length>0){const c=a.user.roles||[];if(!i.some(o=>c.includes(o)))return A.NextResponse.redirect(new URL("/unauthorized",n.url))}return a&&y(u,p)?A.NextResponse.redirect(new URL("/",n.url)):null}catch(a){return process.env.NODE_ENV==="development"&&console.error("[Mulguard Middleware] Error:",a),null}}}function b(e,t="/auth/login"){return x(e,{requireAuth:!0,redirectTo:t})}function P(e,t,r="/unauthorized"){return x(e,{requireAuth:!0,allowedRoles:t,redirectTo:r})}const R="__mulguard_oauth_state",T=10*60;async function k(e,t){try{const r=JSON.stringify({state:e,provider:t,expiresAt:Date.now()+T*1e3}),s=process.env.NODE_ENV==="production";return await f.setCookie({name:R,value:r,httpOnly:!0,secure:s,sameSite:"strict",maxAge:T,path:"/"})}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to store OAuth state"}}}async function v(){try{const e=await f.getCookie(R);if(!e)return null;const t=JSON.parse(e);return t.expiresAt<Date.now()?(await h(),null):(await h(),{state:t.state,provider:t.provider})}catch{return await h(),null}}async function h(){await f.deleteCookie(R,{path:"/"})}const j=Object.freeze(Object.defineProperty({__proto__:null,deleteOAuthStateCookie:h,getOAuthStateCookie:v,storeOAuthStateCookie:k},Symbol.toStringTag,{value:"Module"}));exports.createAuthMiddleware=x;exports.createServerHelpers=M;exports.createServerUtils=U;exports.createSessionManager=O;exports.deleteOAuthStateCookie=h;exports.getCurrentUser=_;exports.getOAuthStateCookie=v;exports.getServerSession=g;exports.getSessionTimeUntilExpiry=D;exports.isSessionExpiredNullable=d;exports.isSessionExpiringSoon=E;exports.isSessionValid=N;exports.oauthState=j;exports.refreshSession=q;exports.requireAuth=w;exports.requireAuthMiddleware=b;exports.requireRole=m;exports.requireRoleMiddleware=P;exports.storeOAuthStateCookie=k;exports.validateSessionStructure=S;
|
package/dist/server/actions.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { MulguardInstance } from '../mulguard';
|
|
2
|
-
import { Verify2FAData, AuthResult, EmailCredentials, RegisterData } from '../core/types';
|
|
3
|
-
/**
|
|
4
|
-
* Verify 2FA code - Server Action
|
|
5
|
-
*
|
|
6
|
-
* ✅ Works in all scenarios:
|
|
7
|
-
* - Direct import in client components
|
|
8
|
-
* - Wrapped in separate files with 'use server'
|
|
9
|
-
* - Automatic CSRF protection and cookie handling
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Option 1: Direct use in client component
|
|
14
|
-
* 'use client'
|
|
15
|
-
* import { verify2FAAction } from 'mulguard/server'
|
|
16
|
-
* import { auth } from '@/lib/auth'
|
|
17
|
-
*
|
|
18
|
-
* const result = await verify2FAAction(auth, { email, userId, code })
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Option 2: Wrap in separate file
|
|
24
|
-
* // lib/auth-actions.ts
|
|
25
|
-
* 'use server'
|
|
26
|
-
* import { verify2FAAction as baseVerify2FA } from 'mulguard/server'
|
|
27
|
-
* import { auth } from './auth'
|
|
28
|
-
*
|
|
29
|
-
* export async function verify2FA(data: Verify2FAData) {
|
|
30
|
-
* return await baseVerify2FA(auth, data)
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* // Then use in client component:
|
|
34
|
-
* 'use client'
|
|
35
|
-
* import { verify2FA } from '@/lib/auth-actions'
|
|
36
|
-
* const result = await verify2FA({ email, userId, code })
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function verify2FAAction(auth: MulguardInstance, data: Verify2FAData): Promise<AuthResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Sign out - Server Action
|
|
42
|
-
*
|
|
43
|
-
* ✅ Works in all scenarios:
|
|
44
|
-
* - Direct import in client components
|
|
45
|
-
* - Wrapped in separate files with 'use server'
|
|
46
|
-
* - Automatic cookie clearing
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Option 1: Direct use in client component
|
|
51
|
-
* 'use client'
|
|
52
|
-
* import { signOutAction } from 'mulguard/server'
|
|
53
|
-
* import { auth } from '@/lib/auth'
|
|
54
|
-
*
|
|
55
|
-
* await signOutAction(auth)
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // Option 2: Wrap in separate file
|
|
61
|
-
* // lib/auth-actions.ts
|
|
62
|
-
* 'use server'
|
|
63
|
-
* import { signOutAction as baseSignOut } from 'mulguard/server'
|
|
64
|
-
* import { auth } from './auth'
|
|
65
|
-
*
|
|
66
|
-
* export async function signOut() {
|
|
67
|
-
* return await baseSignOut(auth)
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function signOutAction(auth: MulguardInstance): Promise<{
|
|
72
|
-
success: boolean;
|
|
73
|
-
error?: string;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Sign in with email - Server Action
|
|
77
|
-
*
|
|
78
|
-
* ✅ Works in all scenarios
|
|
79
|
-
*/
|
|
80
|
-
export declare function signInEmailAction(auth: MulguardInstance, credentials: EmailCredentials): Promise<AuthResult>;
|
|
81
|
-
/**
|
|
82
|
-
* Sign up - Server Action
|
|
83
|
-
*
|
|
84
|
-
* ✅ Works in all scenarios
|
|
85
|
-
*/
|
|
86
|
-
export declare function signUpAction(auth: MulguardInstance, data: RegisterData): Promise<AuthResult>;
|
package/dist/server/auth.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Session, User } from '../core/types';
|
|
2
|
-
import { MulguardInstance } from '../mulguard';
|
|
3
|
-
/**
|
|
4
|
-
* Get server session using auth instance
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { auth } from '@/auth'
|
|
9
|
-
* import { getServerSession } from 'mulguard/server'
|
|
10
|
-
*
|
|
11
|
-
* export default async function Page() {
|
|
12
|
-
* const session = await getServerSession(auth)
|
|
13
|
-
* if (!session) {
|
|
14
|
-
* redirect('/login')
|
|
15
|
-
* }
|
|
16
|
-
* return <div>Hello {session.user.name}</div>
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function getServerSession(auth: MulguardInstance): Promise<Session | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Require authentication - redirects if not authenticated
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { auth } from '@/auth'
|
|
27
|
-
* import { requireAuth } from 'mulguard/server'
|
|
28
|
-
*
|
|
29
|
-
* export default async function ProtectedPage() {
|
|
30
|
-
* const session = await requireAuth(auth, '/login')
|
|
31
|
-
* return <div>Hello {session.user.name}</div>
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function requireAuth(auth: MulguardInstance, redirectTo?: string): Promise<Session>;
|
|
36
|
-
/**
|
|
37
|
-
* Require specific role
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { auth } from '@/auth'
|
|
42
|
-
* import { requireRole } from 'mulguard/server'
|
|
43
|
-
*
|
|
44
|
-
* export default async function AdminPage() {
|
|
45
|
-
* const session = await requireRole(auth, 'admin', '/unauthorized')
|
|
46
|
-
* return <div>Admin Dashboard</div>
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function requireRole(auth: MulguardInstance, role: string, redirectTo?: string): Promise<Session>;
|
|
51
|
-
/**
|
|
52
|
-
* Get current user
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* import { auth } from '@/auth'
|
|
57
|
-
* import { getCurrentUser } from 'mulguard/server'
|
|
58
|
-
*
|
|
59
|
-
* export default async function Page() {
|
|
60
|
-
* const user = await getCurrentUser(auth)
|
|
61
|
-
* return <div>{user ? `Hello ${user.name}` : 'Not logged in'}</div>
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export declare function getCurrentUser(auth: MulguardInstance): Promise<User | null>;
|
package/dist/server/cookies.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { SessionConfig } from '../core/types';
|
|
2
|
-
export interface CookieOptions {
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
maxAge?: number;
|
|
6
|
-
expires?: Date;
|
|
7
|
-
httpOnly?: boolean;
|
|
8
|
-
secure?: boolean;
|
|
9
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
10
|
-
path?: string;
|
|
11
|
-
domain?: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get cookie value from Next.js cookies
|
|
15
|
-
*/
|
|
16
|
-
export declare function getCookie(name: string): Promise<string | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Result of setting a cookie
|
|
19
|
-
*/
|
|
20
|
-
export interface SetCookieResult {
|
|
21
|
-
success: boolean;
|
|
22
|
-
error?: string;
|
|
23
|
-
warning?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Set cookie in Next.js response
|
|
27
|
-
* Note: This requires using Next.js 15+ with async cookies() or response cookies
|
|
28
|
-
*
|
|
29
|
-
* @returns Result indicating success or failure with error message
|
|
30
|
-
*/
|
|
31
|
-
export declare function setCookie(options: CookieOptions): Promise<SetCookieResult>;
|
|
32
|
-
/**
|
|
33
|
-
* Delete cookie
|
|
34
|
-
*/
|
|
35
|
-
export declare function deleteCookie(name: string, options?: {
|
|
36
|
-
path?: string;
|
|
37
|
-
domain?: string;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Build cookie options from session config
|
|
41
|
-
*/
|
|
42
|
-
export declare function buildCookieOptions(name: string, value: string, config: SessionConfig): CookieOptions;
|
package/dist/server/helpers.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MulguardInstance } from '../mulguard';
|
|
2
|
-
import { MulguardConfig } from '../core/types';
|
|
3
|
-
/**
|
|
4
|
-
* Create server-side auth helpers with pre-configured instance
|
|
5
|
-
*/
|
|
6
|
-
export declare function createServerHelpers(_auth: MulguardInstance, _config: MulguardConfig): {
|
|
7
|
-
getSession: () => Promise<import('..').Session<import('..').User> | null>;
|
|
8
|
-
requireAuth: (redirectTo?: string) => Promise<import('..').Session<import('..').User>>;
|
|
9
|
-
requireRole: (role: string, redirectTo?: string) => Promise<import('..').Session<import('..').User>>;
|
|
10
|
-
};
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side utilities for Next.js
|
|
3
|
-
*/
|
|
4
|
-
export * from './cookies';
|
|
5
|
-
export * from './session';
|
|
6
|
-
export * from './auth';
|
|
7
|
-
export * from './helpers';
|
|
8
|
-
export * from './utils';
|
|
9
|
-
export { isSessionExpiringSoon, getSessionTimeUntilExpiry, isSessionValid, validateSessionStructure, isSessionExpiredNullable, } from './session-helpers';
|
|
10
|
-
export { createAuthMiddleware as createServerAuthMiddleware, requireAuthMiddleware as requireServerAuthMiddleware, requireRoleMiddleware as requireServerRoleMiddleware, } from './middleware';
|
|
11
|
-
export { getServerSession, requireAuth, requireRole, getCurrentUser } from './auth';
|
|
12
|
-
export { createServerUtils } from './utils';
|
|
13
|
-
export { verify2FAAction, signOutAction, signInEmailAction, signUpAction, } from './actions';
|
|
14
|
-
export { storeOAuthStateCookie, getOAuthStateCookie, deleteOAuthStateCookie, } from './oauth-state';
|
package/dist/server/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../actions-CExpv_dD.js"),e=require("../oauth-state-DlvrCV11.js");exports.buildCookieOptions=i.buildCookieOptions;exports.deleteCookie=i.deleteCookie;exports.getCookie=i.getCookie;exports.setCookie=i.setCookie;exports.signInEmailAction=i.signInEmailAction;exports.signOutAction=i.signOutAction;exports.signUpAction=i.signUpAction;exports.verify2FAAction=i.verify2FAAction;exports.createServerAuthMiddleware=e.createAuthMiddleware;exports.createServerHelpers=e.createServerHelpers;exports.createServerUtils=e.createServerUtils;exports.createSessionManager=e.createSessionManager;exports.deleteOAuthStateCookie=e.deleteOAuthStateCookie;exports.getCurrentUser=e.getCurrentUser;exports.getOAuthStateCookie=e.getOAuthStateCookie;exports.getServerSession=e.getServerSession;exports.getSessionTimeUntilExpiry=e.getSessionTimeUntilExpiry;exports.isSessionExpiredNullable=e.isSessionExpiredNullable;exports.isSessionExpiringSoon=e.isSessionExpiringSoon;exports.isSessionValid=e.isSessionValid;exports.refreshSession=e.refreshSession;exports.requireAuth=e.requireAuth;exports.requireRole=e.requireRole;exports.requireServerAuthMiddleware=e.requireAuthMiddleware;exports.requireServerRoleMiddleware=e.requireRoleMiddleware;exports.storeOAuthStateCookie=e.storeOAuthStateCookie;exports.validateSessionStructure=e.validateSessionStructure;
|
package/dist/server/index.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { e as a, d as i, g as r, c as t, a as o, s as n, b as S, v as l } from "../actions-DeCfLtHA.mjs";
|
|
2
|
-
import { c as d, p as g, k as c, n as A, m as v, j as p, l as h, e as k, g as C, b as f, i as m, a as x, o as O, f as b, h as q, r as E, d as M, s as U, v as w } from "../oauth-state-DKle8eCr.mjs";
|
|
3
|
-
export {
|
|
4
|
-
a as buildCookieOptions,
|
|
5
|
-
d as createServerAuthMiddleware,
|
|
6
|
-
g as createServerHelpers,
|
|
7
|
-
c as createServerUtils,
|
|
8
|
-
A as createSessionManager,
|
|
9
|
-
i as deleteCookie,
|
|
10
|
-
v as deleteOAuthStateCookie,
|
|
11
|
-
r as getCookie,
|
|
12
|
-
p as getCurrentUser,
|
|
13
|
-
h as getOAuthStateCookie,
|
|
14
|
-
k as getServerSession,
|
|
15
|
-
C as getSessionTimeUntilExpiry,
|
|
16
|
-
f as isSessionExpiredNullable,
|
|
17
|
-
m as isSessionExpiringSoon,
|
|
18
|
-
x as isSessionValid,
|
|
19
|
-
O as refreshSession,
|
|
20
|
-
b as requireAuth,
|
|
21
|
-
q as requireRole,
|
|
22
|
-
E as requireServerAuthMiddleware,
|
|
23
|
-
M as requireServerRoleMiddleware,
|
|
24
|
-
t as setCookie,
|
|
25
|
-
o as signInEmailAction,
|
|
26
|
-
n as signOutAction,
|
|
27
|
-
S as signUpAction,
|
|
28
|
-
U as storeOAuthStateCookie,
|
|
29
|
-
w as validateSessionStructure,
|
|
30
|
-
l as verify2FAAction
|
|
31
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { MulguardInstance } from '../mulguard';
|
|
3
|
-
export interface AuthMiddlewareOptions {
|
|
4
|
-
/** Redirect to this URL if authentication is required but user is not authenticated */
|
|
5
|
-
redirectTo?: string;
|
|
6
|
-
/** Require authentication for all routes */
|
|
7
|
-
requireAuth?: boolean;
|
|
8
|
-
/** Require specific roles */
|
|
9
|
-
allowedRoles?: string[];
|
|
10
|
-
/** Public routes that don't require authentication */
|
|
11
|
-
publicRoutes?: string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create authentication middleware for Next.js
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // middleware.ts
|
|
19
|
-
* import { auth } from '@/lib/auth'
|
|
20
|
-
* import { createAuthMiddleware } from 'mulguard/server'
|
|
21
|
-
*
|
|
22
|
-
* export const middleware = createAuthMiddleware(auth, {
|
|
23
|
-
* requireAuth: true,
|
|
24
|
-
* redirectTo: '/auth/login',
|
|
25
|
-
* allowedRoles: ['admin'],
|
|
26
|
-
* })
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare function createAuthMiddleware(auth: MulguardInstance, options?: AuthMiddlewareOptions): (request: NextRequest) => Promise<NextResponse | null>;
|
|
30
|
-
/**
|
|
31
|
-
* Require authentication middleware
|
|
32
|
-
* Shortcut for createAuthMiddleware with requireAuth: true
|
|
33
|
-
*/
|
|
34
|
-
export declare function requireAuthMiddleware(auth: MulguardInstance, redirectTo?: string): (request: NextRequest) => Promise<NextResponse | null>;
|
|
35
|
-
/**
|
|
36
|
-
* Require role middleware
|
|
37
|
-
* Shortcut for createAuthMiddleware with allowedRoles
|
|
38
|
-
*/
|
|
39
|
-
export declare function requireRoleMiddleware(auth: MulguardInstance, roles: string[], redirectTo?: string): (request: NextRequest) => Promise<NextResponse | null>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side OAuth state management
|
|
3
|
-
* Stores OAuth state in httpOnly cookies for security
|
|
4
|
-
*
|
|
5
|
-
* ✅ SECURE: Uses httpOnly cookies to prevent XSS attacks
|
|
6
|
-
* ✅ PRODUCTION-READY: Works with Next.js Server Actions
|
|
7
|
-
*
|
|
8
|
-
* ⚠️ NOTE: For production with multiple server instances, use Redis or Database store instead.
|
|
9
|
-
* See: mulguard/core/auth/oauth-state-store-redis
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Store OAuth state in httpOnly cookie
|
|
13
|
-
* ✅ SECURE: Uses httpOnly cookie to prevent XSS attacks
|
|
14
|
-
*/
|
|
15
|
-
export declare function storeOAuthStateCookie(state: string, provider: string): Promise<{
|
|
16
|
-
success: boolean;
|
|
17
|
-
error?: string;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* Get and validate OAuth state from cookie
|
|
21
|
-
* ✅ SECURE: Validates state and deletes after use (one-time use)
|
|
22
|
-
*/
|
|
23
|
-
export declare function getOAuthStateCookie(): Promise<{
|
|
24
|
-
state: string;
|
|
25
|
-
provider: string;
|
|
26
|
-
} | null>;
|
|
27
|
-
/**
|
|
28
|
-
* Delete OAuth state cookie
|
|
29
|
-
*/
|
|
30
|
-
export declare function deleteOAuthStateCookie(): Promise<void>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Session } from '../core/types';
|
|
2
|
-
/**
|
|
3
|
-
* Check if session is expired (helper version that accepts null)
|
|
4
|
-
* Note: The main isSessionExpired is exported from session.ts
|
|
5
|
-
* This is a convenience helper for nullable sessions
|
|
6
|
-
*/
|
|
7
|
-
export declare function isSessionExpiredNullable(session: Session | null): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Check if session is expiring soon
|
|
10
|
-
* @param session - Session to check
|
|
11
|
-
* @param thresholdMinutes - Minutes before expiration to consider "soon" (default: 5)
|
|
12
|
-
*/
|
|
13
|
-
export declare function isSessionExpiringSoon(session: Session | null, thresholdMinutes?: number): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Get time until session expiration in minutes
|
|
16
|
-
*/
|
|
17
|
-
export declare function getSessionTimeUntilExpiry(session: Session | null): number | null;
|
|
18
|
-
/**
|
|
19
|
-
* Check if session is valid (not expired and has required fields)
|
|
20
|
-
*/
|
|
21
|
-
export declare function isSessionValid(session: Session | null): session is Session;
|
|
22
|
-
/**
|
|
23
|
-
* Validate session structure
|
|
24
|
-
* Centralized validation logic used across the library
|
|
25
|
-
*/
|
|
26
|
-
export declare function validateSessionStructure(session: unknown): session is Session;
|
package/dist/server/session.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Session, SessionConfig } from '../core/types';
|
|
2
|
-
type ApiClient = {
|
|
3
|
-
get: <T>(url: string) => Promise<{
|
|
4
|
-
data: T;
|
|
5
|
-
}>;
|
|
6
|
-
post: <T>(url: string, data?: unknown) => Promise<{
|
|
7
|
-
data: T;
|
|
8
|
-
}>;
|
|
9
|
-
};
|
|
10
|
-
export interface SessionManager {
|
|
11
|
-
getSession(options?: {
|
|
12
|
-
skipRefresh?: boolean;
|
|
13
|
-
}): Promise<Session | null>;
|
|
14
|
-
setSession(session: Session, config: SessionConfig): void;
|
|
15
|
-
clearSession(config: SessionConfig): Promise<void>;
|
|
16
|
-
refreshSession(): Promise<Session | null>;
|
|
17
|
-
isSessionExpired(session: Session): boolean;
|
|
18
|
-
shouldRefreshSession(session: Session, config: SessionConfig): boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create session manager with automatic refresh
|
|
22
|
-
*/
|
|
23
|
-
export declare function createSessionManager(client: ApiClient, config: SessionConfig): SessionManager;
|
|
24
|
-
/**
|
|
25
|
-
* Refresh session
|
|
26
|
-
*/
|
|
27
|
-
export declare function refreshSession(client: ApiClient, _config: SessionConfig): Promise<Session | null>;
|
|
28
|
-
export {};
|