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/webauthn.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { apiBaseUrl } from "./lib/client.js";
|
|
2
|
+
import { startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
3
|
+
import { getCsrfToken, getProviders, __NEXTAUTH } from "./react.js";
|
|
4
|
+
const logger = {
|
|
5
|
+
debug: console.debug,
|
|
6
|
+
error: console.error,
|
|
7
|
+
warn: console.warn,
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Fetch webauthn options from server and prompt user for authentication or registration.
|
|
11
|
+
* Returns either the completed WebAuthn response or an error request.
|
|
12
|
+
*/
|
|
13
|
+
async function webAuthnOptions(providerID, nextAuthConfig, options) {
|
|
14
|
+
const baseUrl = apiBaseUrl(nextAuthConfig);
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
const params = new URLSearchParams(options);
|
|
17
|
+
const optionsResp = await fetch(`${baseUrl}/webauthn-options/${providerID}?${params}`);
|
|
18
|
+
if (!optionsResp.ok) {
|
|
19
|
+
return { error: optionsResp };
|
|
20
|
+
}
|
|
21
|
+
const optionsData = await optionsResp.json();
|
|
22
|
+
if (optionsData.action === "authenticate") {
|
|
23
|
+
const webAuthnResponse = await startAuthentication(optionsData.options);
|
|
24
|
+
return { data: webAuthnResponse, action: "authenticate" };
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const webAuthnResponse = await startRegistration(optionsData.options);
|
|
28
|
+
return { data: webAuthnResponse, action: "register" };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function signIn(provider, options, authorizationParams) {
|
|
32
|
+
const { callbackUrl, ...rest } = options ?? {};
|
|
33
|
+
const { redirectTo = callbackUrl ?? window.location.href, redirect = true, ...signInParams } = rest;
|
|
34
|
+
const baseUrl = apiBaseUrl(__NEXTAUTH);
|
|
35
|
+
const providers = await getProviders();
|
|
36
|
+
if (!providers) {
|
|
37
|
+
window.location.href = `${baseUrl}/error`;
|
|
38
|
+
return; // TODO: Return error if `redirect: false`
|
|
39
|
+
}
|
|
40
|
+
if (!provider ||
|
|
41
|
+
!providers[provider] ||
|
|
42
|
+
providers[provider].type !== "webauthn") {
|
|
43
|
+
// TODO: Add docs link with explanation
|
|
44
|
+
throw new TypeError([
|
|
45
|
+
`Provider id "${provider}" does not refer to a WebAuthn provider.`,
|
|
46
|
+
'Please use `import { signIn } from "next-auth/react"` instead.',
|
|
47
|
+
].join("\n"));
|
|
48
|
+
}
|
|
49
|
+
const webAuthnBody = {};
|
|
50
|
+
const webAuthnResponse = await webAuthnOptions(provider, __NEXTAUTH, signInParams);
|
|
51
|
+
if (webAuthnResponse.error) {
|
|
52
|
+
logger.error(new Error(await webAuthnResponse.error.text()));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
webAuthnBody.data = JSON.stringify(webAuthnResponse.data);
|
|
56
|
+
webAuthnBody.action = webAuthnResponse.action;
|
|
57
|
+
const signInUrl = `${baseUrl}/callback/${provider}?${new URLSearchParams(authorizationParams)}`;
|
|
58
|
+
const res = await fetch(signInUrl, {
|
|
59
|
+
method: "post",
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
62
|
+
"X-Auth-Return-Redirect": "1",
|
|
63
|
+
},
|
|
64
|
+
body: new URLSearchParams({
|
|
65
|
+
...signInParams,
|
|
66
|
+
...webAuthnBody,
|
|
67
|
+
csrfToken: await getCsrfToken(),
|
|
68
|
+
callbackUrl: redirectTo,
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
const data = await res.json();
|
|
72
|
+
if (redirect) {
|
|
73
|
+
const url = data.url ?? callbackUrl;
|
|
74
|
+
window.location.href = url;
|
|
75
|
+
// If url contains a hash, the browser does not reload the page. We reload manually
|
|
76
|
+
if (url.includes("#"))
|
|
77
|
+
window.location.reload();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const error = new URL(data.url).searchParams.get("error");
|
|
81
|
+
const code = new URL(data.url).searchParams.get("code");
|
|
82
|
+
if (res.ok) {
|
|
83
|
+
await __NEXTAUTH._getSession({ event: "storage" });
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
error,
|
|
87
|
+
code,
|
|
88
|
+
status: res.status,
|
|
89
|
+
ok: res.ok,
|
|
90
|
+
url: error ? null : data.url,
|
|
91
|
+
};
|
|
92
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
---
|
|
3
|
-
|
|
4
|
-
**Mulverse M.U.V GENERAL PUBLIC LICENSE**
|
|
5
|
-
|
|
6
|
-
**Version 1.0**
|
|
7
|
-
|
|
8
|
-
**Copyright (C) [2022] Mulverse Inc.**
|
|
9
|
-
|
|
10
|
-
**1. Definitions**
|
|
11
|
-
|
|
12
|
-
1.1 **"Software"** refers to the Mulverse software distributed under this license, including all associated files, documentation, and any updates or modifications.
|
|
13
|
-
|
|
14
|
-
1.2 **"You"** means the individual or entity who receives or uses the Software.
|
|
15
|
-
|
|
16
|
-
1.3 **"Distribution"** refers to any form of sharing or redistribution of the Software, including copies or derivative works.
|
|
17
|
-
|
|
18
|
-
**2. Permissions**
|
|
19
|
-
|
|
20
|
-
2.1 **Use**: You are granted the right to use the Software for any purpose.
|
|
21
|
-
|
|
22
|
-
2.2 **Copy and Distribution**: You may distribute copies of the Software, either in its original form or as modified, provided that all copies include the same license terms.
|
|
23
|
-
|
|
24
|
-
2.3 **Modification**: You may modify the Software and distribute the modified versions, provided that the modified Software is also licensed under this GPL and that you include a prominent notice stating the changes made.
|
|
25
|
-
|
|
26
|
-
**3. Copyleft**
|
|
27
|
-
|
|
28
|
-
3.1 **Source Code**: If you distribute the Software or any derivative works, you must either include the source code or make it available in a manner specified by this license.
|
|
29
|
-
|
|
30
|
-
3.2 **License Continuity**: All copies and derivative works of the Software must be distributed under the terms of this GPL. You must include a copy of this license with all distributions.
|
|
31
|
-
|
|
32
|
-
**4. Conditions**
|
|
33
|
-
|
|
34
|
-
4.1 **Attribution**: You must provide appropriate credit to Mulverse Inc., including a notice that the Software is licensed under the Mulverse S.N.E General Public License.
|
|
35
|
-
|
|
36
|
-
4.2 **No Warranty**: The Software is provided "as is," without any warranty of any kind. Mulverse Inc. disclaims all warranties and conditions, including but not limited to implied warranties of merchantability and fitness for a particular purpose.
|
|
37
|
-
|
|
38
|
-
4.3 **No Additional Restrictions**: You may not impose any additional restrictions on the rights granted by this license. This includes, but is not limited to, additional licenses or agreements.
|
|
39
|
-
|
|
40
|
-
**5. Termination**
|
|
41
|
-
|
|
42
|
-
5.1 **Automatic Termination**: If you breach any of the terms of this license, your rights under this license will be terminated automatically.
|
|
43
|
-
|
|
44
|
-
5.2 **Reinstatement**: You may be reinstated if you cure the breach and notify Mulverse Inc. of the cure within 30 days of the termination.
|
|
45
|
-
|
|
46
|
-
**6. Patent Grant**
|
|
47
|
-
|
|
48
|
-
6.1 **Patent License**: You grant to Mulverse Inc. a non-exclusive, royalty-free license to any patents you may hold that are necessary to use the Software.
|
|
49
|
-
|
|
50
|
-
**7. Indemnity**
|
|
51
|
-
|
|
52
|
-
7.1 **Indemnification**: You agree to indemnify and hold Mulverse Inc. harmless from any claims, damages, or liabilities arising from your use or distribution of the Software.
|
|
53
|
-
|
|
54
|
-
**8. Governing Law**
|
|
55
|
-
|
|
56
|
-
8.1 **Jurisdiction**: This license shall be governed by and construed in accordance with the laws of [Your Jurisdiction].
|
|
57
|
-
|
|
58
|
-
**9. Miscellaneous**
|
|
59
|
-
|
|
60
|
-
9.1 **Severability**: If any provision of this license is held to be invalid or unenforceable, the remaining provisions will remain in effect.
|
|
61
|
-
|
|
62
|
-
9.2 **Entire Agreement**: This license constitutes the entire agreement between you and Mulverse Inc. regarding the Software and supersedes all prior agreements and understandings.
|
|
63
|
-
|
|
64
|
-
**10. Contact**
|
|
65
|
-
|
|
66
|
-
10.1 **Inquiries**: For any questions or concerns regarding this license, please contact Mulverse Inc. at [Contact Information].
|
|
67
|
-
|
|
68
|
-
**End of License**
|
|
69
|
-
|
|
70
|
-
---
|
package/dist/actions-CExpv_dD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const O=require("next/headers");var r=(s=>(s.INVALID_CREDENTIALS="INVALID_CREDENTIALS",s.ACCOUNT_LOCKED="ACCOUNT_LOCKED",s.ACCOUNT_INACTIVE="ACCOUNT_INACTIVE",s.TWO_FA_REQUIRED="TWO_FA_REQUIRED",s.INVALID_TWO_FA_CODE="INVALID_TWO_FA_CODE",s.SESSION_EXPIRED="SESSION_EXPIRED",s.UNAUTHORIZED="UNAUTHORIZED",s.NETWORK_ERROR="NETWORK_ERROR",s.VALIDATION_ERROR="VALIDATION_ERROR",s.RATE_LIMITED="RATE_LIMITED",s.UNKNOWN_ERROR="UNKNOWN_ERROR",s))(r||{});async function R(s){var n;try{return(n=(await O.cookies()).get(s))==null?void 0:n.value}catch(e){const o=(e==null?void 0:e.message)||"";if(o.includes("cookies")||o.includes("request scope")||o.includes("outside")||o.includes("dynamic"))return;throw e}}async function u(s){try{return(await O.cookies()).set({name:s.name,value:s.value,maxAge:s.maxAge,expires:s.expires,httpOnly:s.httpOnly??!0,secure:s.secure,sameSite:s.sameSite??"lax",path:s.path??"/",domain:s.domain}),{success:!0}}catch(n){const e=(n==null?void 0:n.message)||"";if(e.includes("cookies")||e.includes("request scope")||e.includes("outside")||e.includes("dynamic")){const o=`Cannot set cookie "${s.name}" outside request scope. Make sure this is called from a Server Action or Route Handler.`;return process.env.NODE_ENV==="development"&&console.warn(`[Mulguard] ${o}`),{success:!1,error:e,warning:o}}throw n}}async function f(s,n){try{(await O.cookies()).set({name:s,value:"",maxAge:0,expires:new Date(0),httpOnly:!0,path:(n==null?void 0:n.path)??"/",domain:n==null?void 0:n.domain})}catch(e){const o=(e==null?void 0:e.message)||"";if(o.includes("cookies")||o.includes("request scope")||o.includes("outside")||o.includes("dynamic")){process.env.NODE_ENV==="development"&&console.warn(`[Mulguard] Cannot delete cookie "${s}" outside request scope`);return}throw e}}function l(s,n,e){const o=process.env.NODE_ENV==="production";return{name:s,value:n,maxAge:e.expiresIn,httpOnly:e.httpOnly??!0,secure:e.secure??o,sameSite:e.sameSite??"lax",path:e.path??"/"}}async function g(s,n){if(!s.verify2FA)return{success:!1,error:"2FA verification is not configured",errorCode:r.VALIDATION_ERROR};try{const e=await s.verify2FA(n,{skipCookieSave:!0});if(e.success&&e.session)try{const{cookieName:o,config:t}=s._getSessionConfig(),c=typeof e.session=="object"&&"token"in e.session?String(e.session.token):JSON.stringify(e.session),i=l(o,c,t),a=await u(i);a.success||process.env.NODE_ENV==="development"&&console.warn("[Mulguard] Failed to save session after 2FA verification:",a.error||a.warning)}catch(o){process.env.NODE_ENV==="development"&&console.warn("[Mulguard] Failed to save session cookie:",o)}return e}catch(e){return{success:!1,error:e instanceof Error?e.message:"2FA verification failed",errorCode:r.UNKNOWN_ERROR}}}async function N(s){var n;try{const e=await s.getSession(),o=e==null?void 0:e.user;s.signOut&&await s.signOut();const{cookieName:t,config:c}=s._getSessionConfig();await f(t,{path:c.path||"/"});const i=(n=s._getCallbacks)==null?void 0:n.call(s);return o&&(i!=null&&i.onSignOut)&&await i.onSignOut(o),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Sign out failed"}}}async function d(s,n){var e;if(!((e=s.signIn)!=null&&e.email))return{success:!1,error:"Email sign in is not configured",errorCode:r.VALIDATION_ERROR};try{const o=await s.signIn.email(n);if(o.success&&o.session)try{const{cookieName:t,config:c}=s._getSessionConfig(),i=typeof o.session=="object"&&"token"in o.session?String(o.session.token):JSON.stringify(o.session),a=l(t,i,c);await u(a)}catch(t){process.env.NODE_ENV==="development"&&console.warn("[Mulguard] Failed to save session cookie:",t)}return o}catch(o){return{success:!1,error:o instanceof Error?o.message:"Sign in failed",errorCode:r.UNKNOWN_ERROR}}}async function E(s,n){if(!s.signUp)return{success:!1,error:"Sign up is not configured",errorCode:r.VALIDATION_ERROR};try{const e=await s.signUp(n);if(e.success&&e.session)try{const{cookieName:o,config:t}=s._getSessionConfig(),c=typeof e.session=="object"&&"token"in e.session?String(e.session.token):JSON.stringify(e.session),i=l(o,c,t);await u(i)}catch(o){process.env.NODE_ENV==="development"&&console.warn("[Mulguard] Failed to save session cookie:",o)}return e}catch(e){return{success:!1,error:e instanceof Error?e.message:"Sign up failed",errorCode:r.UNKNOWN_ERROR}}}const _=Object.freeze(Object.defineProperty({__proto__:null,signInEmailAction:d,signOutAction:N,signUpAction:E,verify2FAAction:g},Symbol.toStringTag,{value:"Module"}));exports.AuthErrorCode=r;exports.actions=_;exports.buildCookieOptions=l;exports.deleteCookie=f;exports.getCookie=R;exports.setCookie=u;exports.signInEmailAction=d;exports.signOutAction=N;exports.signUpAction=E;exports.verify2FAAction=g;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { cookies as u } from "next/headers";
|
|
2
|
-
var c = /* @__PURE__ */ ((s) => (s.INVALID_CREDENTIALS = "INVALID_CREDENTIALS", s.ACCOUNT_LOCKED = "ACCOUNT_LOCKED", s.ACCOUNT_INACTIVE = "ACCOUNT_INACTIVE", s.TWO_FA_REQUIRED = "TWO_FA_REQUIRED", s.INVALID_TWO_FA_CODE = "INVALID_TWO_FA_CODE", s.SESSION_EXPIRED = "SESSION_EXPIRED", s.UNAUTHORIZED = "UNAUTHORIZED", s.NETWORK_ERROR = "NETWORK_ERROR", s.VALIDATION_ERROR = "VALIDATION_ERROR", s.RATE_LIMITED = "RATE_LIMITED", s.UNKNOWN_ERROR = "UNKNOWN_ERROR", s))(c || {});
|
|
3
|
-
async function _(s) {
|
|
4
|
-
var o;
|
|
5
|
-
try {
|
|
6
|
-
return (o = (await u()).get(s)) == null ? void 0 : o.value;
|
|
7
|
-
} catch (e) {
|
|
8
|
-
const n = (e == null ? void 0 : e.message) || "";
|
|
9
|
-
if (n.includes("cookies") || n.includes("request scope") || n.includes("outside") || n.includes("dynamic"))
|
|
10
|
-
return;
|
|
11
|
-
throw e;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
async function l(s) {
|
|
15
|
-
try {
|
|
16
|
-
return (await u()).set({
|
|
17
|
-
name: s.name,
|
|
18
|
-
value: s.value,
|
|
19
|
-
maxAge: s.maxAge,
|
|
20
|
-
expires: s.expires,
|
|
21
|
-
httpOnly: s.httpOnly ?? !0,
|
|
22
|
-
secure: s.secure,
|
|
23
|
-
sameSite: s.sameSite ?? "lax",
|
|
24
|
-
path: s.path ?? "/",
|
|
25
|
-
domain: s.domain
|
|
26
|
-
}), { success: !0 };
|
|
27
|
-
} catch (o) {
|
|
28
|
-
const e = (o == null ? void 0 : o.message) || "";
|
|
29
|
-
if (e.includes("cookies") || e.includes("request scope") || e.includes("outside") || e.includes("dynamic")) {
|
|
30
|
-
const n = `Cannot set cookie "${s.name}" outside request scope. Make sure this is called from a Server Action or Route Handler.`;
|
|
31
|
-
return process.env.NODE_ENV === "development" && console.warn(`[Mulguard] ${n}`), {
|
|
32
|
-
success: !1,
|
|
33
|
-
error: e,
|
|
34
|
-
warning: n
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
throw o;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function O(s, o) {
|
|
41
|
-
try {
|
|
42
|
-
(await u()).set({
|
|
43
|
-
name: s,
|
|
44
|
-
value: "",
|
|
45
|
-
maxAge: 0,
|
|
46
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
47
|
-
httpOnly: !0,
|
|
48
|
-
path: (o == null ? void 0 : o.path) ?? "/",
|
|
49
|
-
domain: o == null ? void 0 : o.domain
|
|
50
|
-
});
|
|
51
|
-
} catch (e) {
|
|
52
|
-
const n = (e == null ? void 0 : e.message) || "";
|
|
53
|
-
if (n.includes("cookies") || n.includes("request scope") || n.includes("outside") || n.includes("dynamic")) {
|
|
54
|
-
process.env.NODE_ENV === "development" && console.warn(`[Mulguard] Cannot delete cookie "${s}" outside request scope`);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function f(s, o, e) {
|
|
61
|
-
const n = process.env.NODE_ENV === "production";
|
|
62
|
-
return {
|
|
63
|
-
name: s,
|
|
64
|
-
value: o,
|
|
65
|
-
maxAge: e.expiresIn,
|
|
66
|
-
httpOnly: e.httpOnly ?? !0,
|
|
67
|
-
secure: e.secure ?? n,
|
|
68
|
-
sameSite: e.sameSite ?? "lax",
|
|
69
|
-
path: e.path ?? "/"
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
async function g(s, o) {
|
|
73
|
-
if (!s.verify2FA)
|
|
74
|
-
return {
|
|
75
|
-
success: !1,
|
|
76
|
-
error: "2FA verification is not configured",
|
|
77
|
-
errorCode: c.VALIDATION_ERROR
|
|
78
|
-
};
|
|
79
|
-
try {
|
|
80
|
-
const e = await s.verify2FA(o, { skipCookieSave: !0 });
|
|
81
|
-
if (e.success && e.session)
|
|
82
|
-
try {
|
|
83
|
-
const { cookieName: n, config: r } = s._getSessionConfig(), t = typeof e.session == "object" && "token" in e.session ? String(e.session.token) : JSON.stringify(e.session), i = f(n, t, r), a = await l(i);
|
|
84
|
-
a.success || process.env.NODE_ENV === "development" && console.warn("[Mulguard] Failed to save session after 2FA verification:", a.error || a.warning);
|
|
85
|
-
} catch (n) {
|
|
86
|
-
process.env.NODE_ENV === "development" && console.warn("[Mulguard] Failed to save session cookie:", n);
|
|
87
|
-
}
|
|
88
|
-
return e;
|
|
89
|
-
} catch (e) {
|
|
90
|
-
return {
|
|
91
|
-
success: !1,
|
|
92
|
-
error: e instanceof Error ? e.message : "2FA verification failed",
|
|
93
|
-
errorCode: c.UNKNOWN_ERROR
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function N(s) {
|
|
98
|
-
var o;
|
|
99
|
-
try {
|
|
100
|
-
const e = await s.getSession(), n = e == null ? void 0 : e.user;
|
|
101
|
-
s.signOut && await s.signOut();
|
|
102
|
-
const { cookieName: r, config: t } = s._getSessionConfig();
|
|
103
|
-
await O(r, {
|
|
104
|
-
path: t.path || "/"
|
|
105
|
-
});
|
|
106
|
-
const i = (o = s._getCallbacks) == null ? void 0 : o.call(s);
|
|
107
|
-
return n && (i != null && i.onSignOut) && await i.onSignOut(n), { success: !0 };
|
|
108
|
-
} catch (e) {
|
|
109
|
-
return {
|
|
110
|
-
success: !1,
|
|
111
|
-
error: e instanceof Error ? e.message : "Sign out failed"
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async function d(s, o) {
|
|
116
|
-
var e;
|
|
117
|
-
if (!((e = s.signIn) != null && e.email))
|
|
118
|
-
return {
|
|
119
|
-
success: !1,
|
|
120
|
-
error: "Email sign in is not configured",
|
|
121
|
-
errorCode: c.VALIDATION_ERROR
|
|
122
|
-
};
|
|
123
|
-
try {
|
|
124
|
-
const n = await s.signIn.email(o);
|
|
125
|
-
if (n.success && n.session)
|
|
126
|
-
try {
|
|
127
|
-
const { cookieName: r, config: t } = s._getSessionConfig(), i = typeof n.session == "object" && "token" in n.session ? String(n.session.token) : JSON.stringify(n.session), a = f(r, i, t);
|
|
128
|
-
await l(a);
|
|
129
|
-
} catch (r) {
|
|
130
|
-
process.env.NODE_ENV === "development" && console.warn("[Mulguard] Failed to save session cookie:", r);
|
|
131
|
-
}
|
|
132
|
-
return n;
|
|
133
|
-
} catch (n) {
|
|
134
|
-
return {
|
|
135
|
-
success: !1,
|
|
136
|
-
error: n instanceof Error ? n.message : "Sign in failed",
|
|
137
|
-
errorCode: c.UNKNOWN_ERROR
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async function E(s, o) {
|
|
142
|
-
if (!s.signUp)
|
|
143
|
-
return {
|
|
144
|
-
success: !1,
|
|
145
|
-
error: "Sign up is not configured",
|
|
146
|
-
errorCode: c.VALIDATION_ERROR
|
|
147
|
-
};
|
|
148
|
-
try {
|
|
149
|
-
const e = await s.signUp(o);
|
|
150
|
-
if (e.success && e.session)
|
|
151
|
-
try {
|
|
152
|
-
const { cookieName: n, config: r } = s._getSessionConfig(), t = typeof e.session == "object" && "token" in e.session ? String(e.session.token) : JSON.stringify(e.session), i = f(n, t, r);
|
|
153
|
-
await l(i);
|
|
154
|
-
} catch (n) {
|
|
155
|
-
process.env.NODE_ENV === "development" && console.warn("[Mulguard] Failed to save session cookie:", n);
|
|
156
|
-
}
|
|
157
|
-
return e;
|
|
158
|
-
} catch (e) {
|
|
159
|
-
return {
|
|
160
|
-
success: !1,
|
|
161
|
-
error: e instanceof Error ? e.message : "Sign up failed",
|
|
162
|
-
errorCode: c.UNKNOWN_ERROR
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
167
|
-
__proto__: null,
|
|
168
|
-
signInEmailAction: d,
|
|
169
|
-
signOutAction: N,
|
|
170
|
-
signUpAction: E,
|
|
171
|
-
verify2FAAction: g
|
|
172
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
173
|
-
export {
|
|
174
|
-
c as A,
|
|
175
|
-
d as a,
|
|
176
|
-
E as b,
|
|
177
|
-
l as c,
|
|
178
|
-
O as d,
|
|
179
|
-
f as e,
|
|
180
|
-
m as f,
|
|
181
|
-
_ as g,
|
|
182
|
-
N as s,
|
|
183
|
-
g as v
|
|
184
|
-
};
|
package/dist/client/hooks.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Session, AuthResult, EmailCredentials, RegisterData, RememberedUser, Verify2FAData } from '../core/types';
|
|
2
|
-
import { MulguardInstance } from '../mulguard';
|
|
3
|
-
export interface UseAuthReturn {
|
|
4
|
-
session: Session | null;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Unified sign in method - professional interface similar to auth.js
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // OAuth providers
|
|
12
|
-
* await signIn('google')
|
|
13
|
-
* await signIn('github')
|
|
14
|
-
*
|
|
15
|
-
* // Credentials
|
|
16
|
-
* await signIn('credentials', { email: 'user@example.com', password: 'password' })
|
|
17
|
-
*
|
|
18
|
-
* // OTP
|
|
19
|
-
* await signIn('otp', { email: 'user@example.com', code: '123456' })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
signIn(provider: 'google' | 'github' | 'apple' | 'facebook' | string): Promise<{
|
|
23
|
-
url: string;
|
|
24
|
-
state: string;
|
|
25
|
-
}>;
|
|
26
|
-
signIn(provider: 'credentials', credentials: EmailCredentials): Promise<AuthResult>;
|
|
27
|
-
signIn(provider: 'otp', options: {
|
|
28
|
-
email: string;
|
|
29
|
-
code?: string;
|
|
30
|
-
}): Promise<AuthResult>;
|
|
31
|
-
signIn(provider: 'passkey', options?: {
|
|
32
|
-
userId?: string;
|
|
33
|
-
}): Promise<AuthResult>;
|
|
34
|
-
/**
|
|
35
|
-
* Legacy sign in methods (for backward compatibility)
|
|
36
|
-
*/
|
|
37
|
-
signInMethods: {
|
|
38
|
-
email(credentials: EmailCredentials): Promise<AuthResult>;
|
|
39
|
-
oauth(provider: string): Promise<{
|
|
40
|
-
url: string;
|
|
41
|
-
state: string;
|
|
42
|
-
}>;
|
|
43
|
-
passkey(options?: {
|
|
44
|
-
userId?: string;
|
|
45
|
-
}): Promise<AuthResult>;
|
|
46
|
-
otp(email: string, code?: string): Promise<AuthResult>;
|
|
47
|
-
};
|
|
48
|
-
signUp(data: RegisterData): Promise<AuthResult>;
|
|
49
|
-
signOut(): Promise<void>;
|
|
50
|
-
resetPassword(email: string): Promise<{
|
|
51
|
-
success: boolean;
|
|
52
|
-
error?: string;
|
|
53
|
-
}>;
|
|
54
|
-
verifyEmail(token: string): Promise<{
|
|
55
|
-
success: boolean;
|
|
56
|
-
error?: string;
|
|
57
|
-
}>;
|
|
58
|
-
verify2FA(data: Verify2FAData): Promise<AuthResult>;
|
|
59
|
-
}
|
|
60
|
-
export interface UseSessionReturn {
|
|
61
|
-
session: Session | null;
|
|
62
|
-
isLoading: boolean;
|
|
63
|
-
error: Error | null;
|
|
64
|
-
}
|
|
65
|
-
export interface UseAccountPickerReturn {
|
|
66
|
-
lastUsers: RememberedUser[];
|
|
67
|
-
isLoading: boolean;
|
|
68
|
-
rememberUser: (user: {
|
|
69
|
-
id: string;
|
|
70
|
-
email: string;
|
|
71
|
-
name: string;
|
|
72
|
-
avatar?: string;
|
|
73
|
-
}, provider?: 'email' | 'oauth' | 'passkey') => Promise<void>;
|
|
74
|
-
clearUser: (userId: string) => Promise<void>;
|
|
75
|
-
clearAll: () => Promise<void>;
|
|
76
|
-
refresh: () => Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Main authentication hook
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```tsx
|
|
83
|
-
* import { useAuth } from 'mulguard/client'
|
|
84
|
-
* import { auth } from '@/auth'
|
|
85
|
-
*
|
|
86
|
-
* function LoginButton() {
|
|
87
|
-
* const { session, signIn, signOut } = useAuth(auth)
|
|
88
|
-
* // ...
|
|
89
|
-
* }
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare function useAuth(auth: MulguardInstance): UseAuthReturn;
|
|
93
|
-
/**
|
|
94
|
-
* Session hook
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```tsx
|
|
98
|
-
* import { useSession } from 'mulguard/client'
|
|
99
|
-
* import { auth } from '@/auth'
|
|
100
|
-
*
|
|
101
|
-
* function Profile() {
|
|
102
|
-
* const { session, isLoading } = useSession(auth)
|
|
103
|
-
* // ...
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export declare function useSession(auth: MulguardInstance): UseSessionReturn;
|
|
108
|
-
/**
|
|
109
|
-
* Account Picker hook
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```tsx
|
|
113
|
-
* import { useAccountPicker } from 'mulguard/client'
|
|
114
|
-
* import { auth } from '@/auth'
|
|
115
|
-
*
|
|
116
|
-
* function AccountList() {
|
|
117
|
-
* const { lastUsers, clearUser } = useAccountPicker(auth)
|
|
118
|
-
* // ...
|
|
119
|
-
* }
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export declare function useAccountPicker(auth: MulguardInstance): UseAccountPickerReturn;
|
package/dist/client/index.d.ts
DELETED
package/dist/client/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),O=require("react/jsx-runtime");function v(){return typeof window>"u"}async function h(){try{return await Promise.resolve().then(()=>require("../actions-CExpv_dD.js")).then(l=>l.actions)}catch{return null}}async function N(e,l){if(v())return e.verify2FA?e.verify2FA(l):{success:!1,error:"2FA verification is not configured"};try{const r=await h();if(r)return await r.verify2FAAction(e,l)}catch{}try{const r=await fetch("/api/auth/verify-2fa",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(l)});if(!r.ok){const a=await r.json().catch(()=>({}));return{success:!1,error:a.error||"2FA verification failed",errorCode:a.errorCode}}return await r.json()}catch(r){return{success:!1,error:r instanceof Error?r.message:"2FA verification failed"}}}async function _(e,l){var r;if(v())return(r=e.signIn)!=null&&r.email?e.signIn.email(l):{success:!1,error:"Email sign in is not configured"};try{const a=await h();if(a)return await a.signInEmailAction(e,l)}catch{}try{const a=await fetch("/api/auth/sign-in",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({provider:"email",credentials:l})});if(!a.ok){const u=await a.json().catch(()=>({}));return{success:!1,error:u.error||"Sign in failed",errorCode:u.errorCode}}return await a.json()}catch(a){return{success:!1,error:a instanceof Error?a.message:"Sign in failed"}}}async function D(e,l){if(v())return e.signUp?e.signUp(l):{success:!1,error:"Sign up is not configured"};try{const r=await h();if(r)return await r.signUpAction(e,l)}catch{}try{const r=await fetch("/api/auth/sign-up",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(l)});if(!r.ok){const a=await r.json().catch(()=>({}));return{success:!1,error:a.error||"Sign up failed",errorCode:a.errorCode}}return await r.json()}catch(r){return{success:!1,error:r instanceof Error?r.message:"Sign up failed"}}}function E(e){const[l,r]=o.useState(null),[a,u]=o.useState(!0),c=o.useCallback(async(s=!1)=>{u(!0);try{const n="/api/auth/session"+(s?`?t=${Date.now()}`:""),i=await fetch(n,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:"0"},cache:"no-store"});if(i.status===401||i.status===403){r(null);return}if(i.ok){const t=await i.json();t.session?r(t.session):r(null)}else r(null)}catch(n){process.env.NODE_ENV==="development"&&console.error("Failed to load session:",n),r(null)}finally{u(!1)}},[e]),g=o.useCallback(s=>{if(!s||!s.expiresAt||!e.refreshSession)return()=>{};const n=new Date(s.expiresAt),i=new Date,t=n.getTime()-i.getTime(),f=5*60*1e3;if(t>0&&t<f)return e.refreshSession().catch(()=>{}),()=>{};if(t>f){const p=t-f,S=setTimeout(()=>{var C;(C=e.refreshSession)==null||C.call(e).catch(()=>{})},p);return()=>clearTimeout(S)}return()=>{}},[e]);o.useEffect(()=>{let s=null;(async()=>{await c();try{const t=await fetch("/api/auth/session",{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"},cache:"no-store"});if(t.ok){const f=await t.json();f.session?s=g(f.session):r(null)}else r(null)}catch(t){process.env.NODE_ENV==="development"&&console.debug("Failed to schedule proactive refresh:",t),r(null)}})();const i=setInterval(()=>{fetch("/api/auth/session",{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"},cache:"no-store"}).then(t=>t.status===401||t.status===403?(r(null),s&&(s(),s=null),typeof window<"u"&&window.location.pathname!=="/auth/login"&&window.location.replace("/auth/login?reason=session_expired"),null):t.json()).then(t=>{t&&(t.session?(r(t.session),s&&s(),s=g(t.session)):(r(null),s&&(s(),s=null)))}).catch(()=>{r(null),s&&(s(),s=null)})},60*1e3);return()=>{clearInterval(i),s&&s()}},[c,g]);const y=o.useCallback(async s=>{try{const n=await _(e,s);return n.success&&await c(),n}catch(n){return{success:!1,error:n instanceof Error?n.message:"Sign in failed"}}},[e,c]),w=o.useCallback(async s=>{if(!e.signIn.oauth)throw new Error("OAuth sign in is not configured");return e.signIn.oauth(s)},[e]),d=o.useCallback(async s=>{if(!e.signIn.passkey)return{success:!1,error:"PassKey sign in is not configured"};try{const n=await e.signIn.passkey(s);return n.success&&await c(),n}catch(n){return{success:!1,error:n instanceof Error?n.message:"PassKey authentication failed"}}},[e,c]),m=o.useCallback(async s=>{if(!e.signUp)return{success:!1,error:"Sign up is not configured"};try{const n=await D(e,s);return n.success&&await c(),n}catch(n){return{success:!1,error:n instanceof Error?n.message:"Sign up failed"}}},[e,c]),U=o.useCallback(async()=>{var s,n;try{if(r(null),u(!0),typeof window<"u"){try{window.sessionStorage.clear()}catch{}try{const i=(s=e._getSessionConfig)==null?void 0:s.call(e),t=(i==null?void 0:i.cookieName)||"__mulguard_session";try{window.localStorage.removeItem(t)}catch{}}catch{}}if(await e.signOut(),await c(!0),r(null),u(!1),typeof window<"u"){const i="/auth/login",t=window.location.pathname,f=window.location.search;if(t===i||t.startsWith("/auth/")){window.location.reload();return}const p=new URL(i,window.location.origin);t&&t!=="/"&&p.searchParams.set("redirect",t+f),window.location.replace(p.toString())}}catch(i){if(process.env.NODE_ENV==="development"&&console.error("Sign out error:",i),r(null),u(!1),typeof window<"u"){try{window.sessionStorage.clear();const f=(n=e._getSessionConfig)==null?void 0:n.call(e),p=(f==null?void 0:f.cookieName)||"__mulguard_session";try{window.localStorage.removeItem(p)}catch{}}catch{}const t="/auth/login";window.location.pathname!==t&&!window.location.pathname.startsWith("/auth/")?window.location.replace(t):window.location.reload()}}},[e,c]),T=o.useCallback(async s=>{if(!e.resetPassword)throw new Error("Password reset is not configured");return e.resetPassword(s)},[e]),F=o.useCallback(async s=>{if(!e.verifyEmail)throw new Error("Email verification is not configured");return e.verifyEmail(s)},[e]),x=o.useCallback(async s=>{if(!e.verify2FA)return{success:!1,error:"2FA verification is not configured"};try{const n=await N(e,s);return n.success&&(await new Promise(i=>setTimeout(i,100)),await c()),n}catch(n){return{success:!1,error:n instanceof Error?n.message:"2FA verification failed"}}},[e,c]),j=o.useCallback(async(s,n)=>e.signIn(s,n),[e]);return{session:l,isLoading:a,signIn:j,signInMethods:{email:y,oauth:w,passkey:d,otp:o.useCallback(async(s,n)=>{if(!e.signIn.otp)return{success:!1,error:"OTP sign in is not configured"};try{const i=await e.signIn.otp(s,n);return i.success&&await c(),i}catch(i){return{success:!1,error:i instanceof Error?i.message:"OTP sign in failed"}}},[e,c])},signUp:m,signOut:U,resetPassword:T,verifyEmail:F,verify2FA:x}}function A(e){const[l,r]=o.useState(null),[a,u]=o.useState(!0),[c,g]=o.useState(null),y=o.useCallback(async()=>{u(!0),g(null);try{const w=await e.getSession();r(w)}catch(w){const d=w instanceof Error?w:new Error("Failed to load session");g(d),r(null)}finally{u(!1)}},[e]);return o.useEffect(()=>{y();const w=setInterval(()=>{y()},5*60*1e3);return()=>clearInterval(w)},[y]),{session:l,isLoading:a,error:c}}function P(e){const[l,r]=o.useState([]),[a,u]=o.useState(!0),c=o.useCallback(async()=>{if(!e.accountPicker){r([]),u(!1);return}u(!0);try{const d=await e.accountPicker.getLastUsers();r(d)}catch(d){process.env.NODE_ENV==="development"&&console.error("Failed to load last users:",d),r([])}finally{u(!1)}},[e]);o.useEffect(()=>{c()},[c]);const g=o.useCallback(async(d,m)=>{e.accountPicker&&(await e.accountPicker.rememberUser(d,m),await c())},[e,c]),y=o.useCallback(async d=>{e.accountPicker&&(await e.accountPicker.clearUser(d),await c())},[e,c]),w=o.useCallback(async()=>{e.accountPicker&&(await e.accountPicker.clearAll(),await c())},[e,c]);return{lastUsers:l,isLoading:a,rememberUser:g,clearUser:y,clearAll:w,refresh:c}}const b=o.createContext(null);function I({auth:e,children:l}){const r=A(e),a=P(e);return O.jsx(b.Provider,{value:{auth:e,session:r,accountPicker:a},children:l})}function k(){const e=o.useContext(b);if(!e)throw new Error("useMulguardContext must be used within MulguardProvider");return e}function L(){const{auth:e}=k();return E(e)}const M=I,R=k;exports.AuthProvider=M;exports.MulguardProvider=I;exports.useAccountPicker=P;exports.useAuth=E;exports.useAuthContext=R;exports.useAuthFromContext=L;exports.useMulguardContext=k;exports.useSession=A;
|