mulguard 1.1.7 → 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 -582
- 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 -126
- 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-CMtg7FGv.js +0 -1
- package/dist/actions-CjQUKaXF.mjs +0 -200
- package/dist/client/index.js +0 -1
- package/dist/client/index.mjs +0 -484
- 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/email-password.d.ts +0 -145
- package/dist/core/auth/oauth/index.d.ts +0 -14
- package/dist/core/auth/oauth/oauth-handler.d.ts +0 -172
- package/dist/core/auth/oauth/pkce.d.ts +0 -168
- package/dist/core/auth/oauth/providers.d.ts +0 -198
- 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 -48
- package/dist/core/auth/otp.d.ts +0 -184
- 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/errors/index.d.ts +0 -269
- package/dist/core/index.d.ts +0 -9
- package/dist/core/logger/index.d.ts +0 -147
- 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/integration.d.ts +0 -104
- 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/security-manager.d.ts +0 -236
- 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/session/session-manager.d.ts +0 -235
- 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 -484
- package/dist/core/utils/auth-helpers.d.ts +0 -136
- package/dist/core/utils/logger.d.ts +0 -121
- package/dist/index/index.js +0 -1
- package/dist/index/index.mjs +0 -2736
- package/dist/index.d.ts +0 -18
- package/dist/mulguard.d.ts +0 -373
- package/dist/nextjs/client/hooks.d.ts +0 -122
- package/dist/nextjs/client/index.d.ts +0 -13
- package/dist/nextjs/client/provider.d.ts +0 -69
- package/dist/nextjs/client/server-actions-helper.d.ts +0 -22
- package/dist/nextjs/handlers/api.d.ts +0 -10
- package/dist/nextjs/handlers/index.d.ts +0 -9
- package/dist/nextjs/handlers/route.d.ts +0 -76
- package/dist/nextjs/index.d.ts +0 -15
- package/dist/nextjs/proxy/index.d.ts +0 -149
- package/dist/nextjs/proxy/security.d.ts +0 -9
- package/dist/nextjs/server/actions.d.ts +0 -30
- package/dist/nextjs/server/auth.d.ts +0 -65
- package/dist/nextjs/server/cookies.d.ts +0 -41
- package/dist/nextjs/server/index.d.ts +0 -18
- package/dist/nextjs/server/oauth-state.d.ts +0 -32
- package/dist/nextjs/server/session-helpers.d.ts +0 -24
- package/dist/nextjs/server/session.d.ts +0 -144
- package/dist/oauth-state-Drwz6fES.js +0 -1
- package/dist/oauth-state-pdypStuS.mjs +0 -210
- package/dist/server/index.js +0 -1
- package/dist/server/index.mjs +0 -29
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { AuthResult, OAuthUserInfo, User, Session, OAuthProviderConfig, OAuthProvidersConfig, CallbacksConfig } from '../types';
|
|
2
|
-
import { exchangeOAuthCode } from '../auth/oauth/providers';
|
|
3
|
-
/**
|
|
4
|
-
* OAuth handler configuration.
|
|
5
|
-
*/
|
|
6
|
-
export interface OAuthHandlerConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
|
|
7
|
-
readonly oauthProviders: OAuthProvidersConfig;
|
|
8
|
-
readonly baseUrl: string;
|
|
9
|
-
readonly callbacks: CallbacksConfig;
|
|
10
|
-
readonly createSession: (user: TUser, userInfo: OAuthUserInfo, tokens: Awaited<ReturnType<typeof exchangeOAuthCode>>) => TSession;
|
|
11
|
-
readonly saveSession: (session: TSession) => Promise<void>;
|
|
12
|
-
readonly onError?: (error: Error, context: string) => Promise<void> | void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* OAuth state validation function.
|
|
16
|
-
*/
|
|
17
|
-
export type ValidateOAuthState = (state: string, provider: string) => Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Creates OAuth callback handler.
|
|
20
|
-
*
|
|
21
|
-
* Automatically handles:
|
|
22
|
-
* 1. Code exchange for tokens
|
|
23
|
-
* 2. User profile retrieval
|
|
24
|
-
* 3. User creation/lookup via callback
|
|
25
|
-
* 4. Session creation and storage
|
|
26
|
-
*
|
|
27
|
-
* @template TUser - User type
|
|
28
|
-
* @template TSession - Session type
|
|
29
|
-
* @param config - OAuth handler configuration
|
|
30
|
-
* @param validateState - Function to validate OAuth state
|
|
31
|
-
* @returns OAuth callback handler
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const handler = createOAuthCallbackHandler(config, validateState)
|
|
36
|
-
* const result = await handler('google', 'code123', 'state456')
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function createOAuthCallbackHandler<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(config: OAuthHandlerConfig<TUser, TSession>, _validateState: ValidateOAuthState): (provider: string, code: string, _state: string) => Promise<AuthResult<TUser, TSession>>;
|
|
40
|
-
/**
|
|
41
|
-
* Creates OAuth initiation action if providers are configured.
|
|
42
|
-
*
|
|
43
|
-
* @param oauthProviders - OAuth providers configuration
|
|
44
|
-
* @param baseUrl - Base URL for redirects
|
|
45
|
-
* @param generateState - Function to generate CSRF state
|
|
46
|
-
* @param buildAuthUrl - Function to build authorization URL
|
|
47
|
-
* @returns OAuth initiation action or undefined
|
|
48
|
-
*/
|
|
49
|
-
export declare function createOAuthInitiationAction(oauthProviders: OAuthProvidersConfig, baseUrl: string, generateState: () => string, buildAuthUrl: (provider: string, config: OAuthProviderConfig, baseUrl: string, state: string) => string): ((provider: string) => Promise<{
|
|
50
|
-
url: string;
|
|
51
|
-
state: string;
|
|
52
|
-
}>) | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* TODO: Performance
|
|
55
|
-
* - [ ] Add token exchange result caching
|
|
56
|
-
* - [ ] Implement request retry logic
|
|
57
|
-
* - [ ] Add connection pooling for OAuth API calls
|
|
58
|
-
* - [ ] Cache user profile data
|
|
59
|
-
*
|
|
60
|
-
* TODO: Features
|
|
61
|
-
* - [ ] Add PKCE support
|
|
62
|
-
* - [ ] Implement token refresh flow
|
|
63
|
-
* - [ ] Add OAuth 2.1 compliance
|
|
64
|
-
* - [ ] Support for OpenID Connect
|
|
65
|
-
* - [ ] Add account linking
|
|
66
|
-
*
|
|
67
|
-
* TODO: Type Safety
|
|
68
|
-
* - [ ] Add type-safe provider configuration
|
|
69
|
-
* - [ ] Create type-level endpoint validation
|
|
70
|
-
* - [ ] Implement compile-time provider validation
|
|
71
|
-
*
|
|
72
|
-
* TODO: Security
|
|
73
|
-
* - [ ] Add token validation before use
|
|
74
|
-
* - [ ] Implement token encryption
|
|
75
|
-
* - [ ] Add request signing
|
|
76
|
-
* - [ ] Create security audit logging
|
|
77
|
-
*
|
|
78
|
-
* TODO: Testing
|
|
79
|
-
* - [ ] Add comprehensive OAuth handler tests
|
|
80
|
-
* - [ ] Test all provider flows
|
|
81
|
-
* - [ ] Test error handling
|
|
82
|
-
* - [ ] Add integration tests
|
|
83
|
-
*
|
|
84
|
-
* TODO: Documentation
|
|
85
|
-
* - [ ] Document OAuth flow
|
|
86
|
-
* - [ ] Add provider setup guides
|
|
87
|
-
* - [ ] Create troubleshooting guide
|
|
88
|
-
*
|
|
89
|
-
* TODO: Limitations
|
|
90
|
-
* - [ ] No support for OAuth 1.0
|
|
91
|
-
* - [ ] Token refresh not implemented
|
|
92
|
-
* - [ ] No PKCE support yet
|
|
93
|
-
*/
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Session, SessionConfig } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Session cache entry.
|
|
4
|
-
*/
|
|
5
|
-
interface SessionCacheEntry {
|
|
6
|
-
readonly session: Session | null;
|
|
7
|
-
readonly timestamp: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Session manager configuration.
|
|
11
|
-
*/
|
|
12
|
-
export interface SessionManagerConfig {
|
|
13
|
-
readonly sessionConfig: SessionConfig;
|
|
14
|
-
readonly cacheTtl: number;
|
|
15
|
-
readonly getSessionAction?: () => Promise<Session | null>;
|
|
16
|
-
readonly onSessionExpired?: (session: Session) => Promise<void> | void;
|
|
17
|
-
readonly onError?: (error: Error, context: string) => Promise<void> | void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Session operation result.
|
|
21
|
-
*/
|
|
22
|
-
export interface SessionResult {
|
|
23
|
-
readonly success: boolean;
|
|
24
|
-
readonly error?: string;
|
|
25
|
-
readonly warning?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates a session manager instance.
|
|
29
|
-
*
|
|
30
|
-
* @param config - Session manager configuration
|
|
31
|
-
* @returns Session manager functions
|
|
32
|
-
*/
|
|
33
|
-
export declare function createSessionManager(config: SessionManagerConfig): {
|
|
34
|
-
getSession: () => Promise<Session | null>;
|
|
35
|
-
setSession: (session: Session) => Promise<SessionResult>;
|
|
36
|
-
clearSessionCookie: () => Promise<void>;
|
|
37
|
-
getAccessToken: () => Promise<string | null>;
|
|
38
|
-
getRefreshToken: () => Promise<string | null>;
|
|
39
|
-
hasValidTokens: () => Promise<boolean>;
|
|
40
|
-
clearCache: () => void;
|
|
41
|
-
getSessionConfig: () => {
|
|
42
|
-
cookieName: string;
|
|
43
|
-
config: SessionConfig;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Type predicate to check if a value is a valid session cache entry.
|
|
48
|
-
*
|
|
49
|
-
* @param value - Value to check
|
|
50
|
-
* @returns True if value is a valid cache entry
|
|
51
|
-
*/
|
|
52
|
-
export declare function isSessionCacheEntry(value: unknown): value is SessionCacheEntry;
|
|
53
|
-
export {};
|
|
54
|
-
/**
|
|
55
|
-
* TODO: Performance
|
|
56
|
-
* - [ ] Add session compression for large sessions
|
|
57
|
-
* - [ ] Implement session chunking for very large sessions
|
|
58
|
-
* - [ ] Add session cache invalidation strategies
|
|
59
|
-
* - [ ] Consider using WeakMap for session references
|
|
60
|
-
*
|
|
61
|
-
* TODO: Features
|
|
62
|
-
* - [ ] Add session encryption at rest
|
|
63
|
-
* - [ ] Implement session rotation
|
|
64
|
-
* - [ ] Add session fingerprinting
|
|
65
|
-
* - [ ] Create session analytics
|
|
66
|
-
* - [ ] Add session migration support
|
|
67
|
-
*
|
|
68
|
-
* TODO: Type Safety
|
|
69
|
-
* - [ ] Add type-level session validation
|
|
70
|
-
* - [ ] Create type-safe session builders
|
|
71
|
-
* - [ ] Implement session schema validation
|
|
72
|
-
*
|
|
73
|
-
* TODO: Security
|
|
74
|
-
* - [ ] Add session hijacking detection
|
|
75
|
-
* - [ ] Implement session timeout warnings
|
|
76
|
-
* - [ ] Add session audit logging
|
|
77
|
-
* - [ ] Create session security monitoring
|
|
78
|
-
*
|
|
79
|
-
* TODO: Testing
|
|
80
|
-
* - [ ] Add comprehensive session manager tests
|
|
81
|
-
* - [ ] Test cache invalidation
|
|
82
|
-
* - [ ] Test session expiration
|
|
83
|
-
* - [ ] Test error handling
|
|
84
|
-
*
|
|
85
|
-
* TODO: Documentation
|
|
86
|
-
* - [ ] Document session lifecycle
|
|
87
|
-
* - [ ] Add session best practices guide
|
|
88
|
-
* - [ ] Create troubleshooting guide
|
|
89
|
-
*
|
|
90
|
-
* TODO: Limitations
|
|
91
|
-
* - [ ] Session cache is in-memory (not shared across instances)
|
|
92
|
-
* - [ ] No session persistence (consider database-backed sessions)
|
|
93
|
-
* - [ ] Session validation is basic (consider schema validation)
|
|
94
|
-
*/
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSRF Protection utilities
|
|
3
|
-
*/
|
|
4
|
-
export interface CSRFTokenStore {
|
|
5
|
-
get(key: string): string | null;
|
|
6
|
-
set(key: string, value: string, expiresIn?: number): void;
|
|
7
|
-
delete(key: string): void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* In-memory CSRF token store (for server-side)
|
|
11
|
-
*/
|
|
12
|
-
export declare class MemoryCSRFStore implements CSRFTokenStore {
|
|
13
|
-
private tokens;
|
|
14
|
-
get(key: string): string | null;
|
|
15
|
-
set(key: string, value: string, expiresIn?: number): void;
|
|
16
|
-
delete(key: string): void;
|
|
17
|
-
clear(): void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* CSRF Protection manager
|
|
21
|
-
*/
|
|
22
|
-
export declare class CSRFProtection {
|
|
23
|
-
private store;
|
|
24
|
-
private tokenLength;
|
|
25
|
-
constructor(store?: CSRFTokenStore, tokenLength?: number);
|
|
26
|
-
/**
|
|
27
|
-
* Generate CSRF token
|
|
28
|
-
*/
|
|
29
|
-
generateToken(key: string, expiresIn?: number): string;
|
|
30
|
-
/**
|
|
31
|
-
* Validate CSRF token
|
|
32
|
-
*/
|
|
33
|
-
validateToken(key: string, token: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Get stored token without validating
|
|
36
|
-
*/
|
|
37
|
-
getToken(key: string): string | null;
|
|
38
|
-
/**
|
|
39
|
-
* Delete token
|
|
40
|
-
*/
|
|
41
|
-
deleteToken(key: string): void;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Create CSRF protection instance
|
|
45
|
-
*/
|
|
46
|
-
export declare function createCSRFProtection(store?: CSRFTokenStore): CSRFProtection;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security Headers utilities
|
|
3
|
-
*/
|
|
4
|
-
export interface SecurityHeaders {
|
|
5
|
-
'X-Content-Type-Options'?: string;
|
|
6
|
-
'X-Frame-Options'?: string;
|
|
7
|
-
'X-XSS-Protection'?: string;
|
|
8
|
-
'Strict-Transport-Security'?: string;
|
|
9
|
-
'Content-Security-Policy'?: string;
|
|
10
|
-
'Referrer-Policy'?: string;
|
|
11
|
-
'Permissions-Policy'?: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Default security headers
|
|
15
|
-
*/
|
|
16
|
-
export declare const DEFAULT_SECURITY_HEADERS: SecurityHeaders;
|
|
17
|
-
/**
|
|
18
|
-
* Get security headers
|
|
19
|
-
*/
|
|
20
|
-
export declare function getSecurityHeaders(custom?: Partial<SecurityHeaders>): SecurityHeaders;
|
|
21
|
-
/**
|
|
22
|
-
* Apply security headers to response
|
|
23
|
-
*/
|
|
24
|
-
export declare function applySecurityHeaders(headers: Headers, custom?: Partial<SecurityHeaders>): void;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security utilities for Mulguard Authentication Library.
|
|
3
|
-
*
|
|
4
|
-
* Provides token generation, CSRF protection, input sanitization, and validation.
|
|
5
|
-
*
|
|
6
|
-
* @module @mulguard/core/security
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Generates a cryptographically secure random token.
|
|
10
|
-
*
|
|
11
|
-
* @param length - Token length in bytes (default: 32)
|
|
12
|
-
* @returns Base64url-encoded token
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const token = generateToken(32)
|
|
17
|
-
* // Returns: 'abc123xyz...' (base64url encoded)
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function generateToken(length?: number): string;
|
|
21
|
-
/**
|
|
22
|
-
* Generates a CSRF token for state validation.
|
|
23
|
-
*
|
|
24
|
-
* @returns Base64url-encoded CSRF token
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const state = generateCSRFToken()
|
|
29
|
-
* // Store state for validation
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function generateCSRFToken(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Validates a CSRF token using constant-time comparison.
|
|
35
|
-
*
|
|
36
|
-
* Uses constant-time comparison to prevent timing attacks.
|
|
37
|
-
*
|
|
38
|
-
* @param token - Token to validate
|
|
39
|
-
* @param expected - Expected token value
|
|
40
|
-
* @returns True if tokens match
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const isValid = validateCSRFToken(receivedToken, storedToken)
|
|
45
|
-
* if (!isValid) {
|
|
46
|
-
* throw new Error('Invalid CSRF token')
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function validateCSRFToken(token: unknown, expected: unknown): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Type predicate to check if CSRF token is valid.
|
|
53
|
-
*
|
|
54
|
-
* @param token - Token to check
|
|
55
|
-
* @param expected - Expected token
|
|
56
|
-
* @returns True if token is valid
|
|
57
|
-
*/
|
|
58
|
-
export declare function isValidCSRFToken(token: unknown, expected: unknown): token is string;
|
|
59
|
-
/**
|
|
60
|
-
* Sanitizes string input by trimming and removing dangerous characters.
|
|
61
|
-
*
|
|
62
|
-
* @param input - Input to sanitize
|
|
63
|
-
* @returns Sanitized string
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const sanitized = sanitizeInput(' <script>alert("xss")</script> ')
|
|
68
|
-
* // Returns: 'scriptalert("xss")script'
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function sanitizeInput(input: unknown): string;
|
|
72
|
-
/**
|
|
73
|
-
* Validates email format.
|
|
74
|
-
*
|
|
75
|
-
* @param email - Email to validate
|
|
76
|
-
* @returns True if email is valid
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* if (isValidEmail('user@example.com')) {
|
|
81
|
-
* // Email is valid
|
|
82
|
-
* }
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare function isValidEmail(email: unknown): email is string;
|
|
86
|
-
export * from './rate-limit';
|
|
87
|
-
export * from './headers';
|
|
88
|
-
export * from './validation';
|
|
89
|
-
export * from './csrf';
|
|
90
|
-
export * from './xss';
|
|
91
|
-
/**
|
|
92
|
-
* TODO: Performance
|
|
93
|
-
* - [ ] Add token generation caching for high-frequency operations
|
|
94
|
-
* - [ ] Optimize constant-time comparison for very long tokens
|
|
95
|
-
* - [ ] Consider using Web Crypto API for token generation
|
|
96
|
-
* - [ ] Add input sanitization result caching
|
|
97
|
-
*
|
|
98
|
-
* TODO: Features
|
|
99
|
-
* - [ ] Add token expiration validation
|
|
100
|
-
* - [ ] Implement token rotation support
|
|
101
|
-
* - [ ] Add rate limiting for token generation
|
|
102
|
-
* - [ ] Create token strength scoring
|
|
103
|
-
* - [ ] Add token format validation helpers
|
|
104
|
-
*
|
|
105
|
-
* TODO: Type Safety
|
|
106
|
-
* - [ ] Add branded types for tokens
|
|
107
|
-
* - [ ] Create type-safe token validation
|
|
108
|
-
* - [ ] Add type guards for all security functions
|
|
109
|
-
* - [ ] Implement type-level security constraints
|
|
110
|
-
*
|
|
111
|
-
* TODO: Security
|
|
112
|
-
* - [ ] Add token generation logging (with masking)
|
|
113
|
-
* - [ ] Implement token blacklisting
|
|
114
|
-
* - [ ] Add security event monitoring
|
|
115
|
-
* - [ ] Create security audit logging
|
|
116
|
-
*
|
|
117
|
-
* TODO: Testing
|
|
118
|
-
* - [ ] Add comprehensive security tests
|
|
119
|
-
* - [ ] Test timing attack resistance
|
|
120
|
-
* - [ ] Test token generation randomness
|
|
121
|
-
* - [ ] Add fuzzing tests
|
|
122
|
-
*
|
|
123
|
-
* TODO: Documentation
|
|
124
|
-
* - [ ] Document security best practices
|
|
125
|
-
* - [ ] Add security considerations guide
|
|
126
|
-
* - [ ] Document token lifecycle
|
|
127
|
-
*
|
|
128
|
-
* TODO: Limitations
|
|
129
|
-
* - [ ] Token generation uses Node.js Buffer (consider Web Crypto API for browsers)
|
|
130
|
-
* - [ ] Constant-time comparison may have micro-optimizations
|
|
131
|
-
* - [ ] Email validation is basic (use validation.ts for comprehensive validation)
|
|
132
|
-
*/
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rate Limiting utilities
|
|
3
|
-
* Client-side rate limiting helpers (actual rate limiting should be on backend)
|
|
4
|
-
*/
|
|
5
|
-
export interface RateLimitConfig {
|
|
6
|
-
maxAttempts: number;
|
|
7
|
-
windowMs: number;
|
|
8
|
-
keyPrefix?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface RateLimitResult {
|
|
11
|
-
allowed: boolean;
|
|
12
|
-
remaining: number;
|
|
13
|
-
resetAt: Date;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Client-side rate limit tracker
|
|
17
|
-
* Note: This is just a helper. Real rate limiting must be enforced on the backend.
|
|
18
|
-
*/
|
|
19
|
-
export declare class RateLimiter {
|
|
20
|
-
private attempts;
|
|
21
|
-
private config;
|
|
22
|
-
constructor(config: RateLimitConfig);
|
|
23
|
-
/**
|
|
24
|
-
* Check if request is allowed
|
|
25
|
-
*/
|
|
26
|
-
check(key: string): RateLimitResult;
|
|
27
|
-
/**
|
|
28
|
-
* Reset rate limit for a key
|
|
29
|
-
*/
|
|
30
|
-
reset(key: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Clear all rate limits
|
|
33
|
-
*/
|
|
34
|
-
clear(): void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create rate limiter instance
|
|
38
|
-
*/
|
|
39
|
-
export declare function createRateLimiter(config: RateLimitConfig): RateLimiter;
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { CSRFTokenStore } from './csrf';
|
|
2
|
-
import { ValidationResult } from './validation';
|
|
3
|
-
import { Logger } from '../logger';
|
|
4
|
-
/**
|
|
5
|
-
* Comprehensive security configuration.
|
|
6
|
-
*/
|
|
7
|
-
export interface SecurityConfig {
|
|
8
|
-
readonly csrfProtection?: {
|
|
9
|
-
readonly enabled: boolean;
|
|
10
|
-
readonly tokenLength?: number;
|
|
11
|
-
readonly expiresIn?: number;
|
|
12
|
-
readonly store?: CSRFTokenStore;
|
|
13
|
-
};
|
|
14
|
-
readonly rateLimiting?: {
|
|
15
|
-
readonly enabled: boolean;
|
|
16
|
-
readonly maxAttempts?: number;
|
|
17
|
-
readonly windowMs?: number;
|
|
18
|
-
readonly strategy?: 'ip' | 'user' | 'email';
|
|
19
|
-
};
|
|
20
|
-
readonly validation?: {
|
|
21
|
-
readonly strictEmail?: boolean;
|
|
22
|
-
readonly minPasswordLength?: number;
|
|
23
|
-
readonly requireStrongPassword?: boolean;
|
|
24
|
-
};
|
|
25
|
-
readonly xssProtection?: {
|
|
26
|
-
readonly enabled: boolean;
|
|
27
|
-
readonly sanitizeHtml?: boolean;
|
|
28
|
-
};
|
|
29
|
-
readonly logger?: Logger;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Comprehensive security manager for authentication operations.
|
|
33
|
-
*
|
|
34
|
-
* Provides unified access to all security utilities with centralized configuration.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const security = new SecurityManager({
|
|
39
|
-
* csrfProtection: { enabled: true },
|
|
40
|
-
* rateLimiting: { enabled: true, maxAttempts: 5 },
|
|
41
|
-
* })
|
|
42
|
-
*
|
|
43
|
-
* // Validate email
|
|
44
|
-
* const emailResult = security.validateEmail('user@example.com')
|
|
45
|
-
*
|
|
46
|
-
* // Check rate limit
|
|
47
|
-
* const rateLimitResult = security.checkRateLimit('user@example.com')
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare class SecurityManager {
|
|
51
|
-
private readonly config;
|
|
52
|
-
private readonly csrfProtection;
|
|
53
|
-
private readonly rateLimiter;
|
|
54
|
-
constructor(config?: SecurityConfig);
|
|
55
|
-
/**
|
|
56
|
-
* Validates and sanitizes an email address.
|
|
57
|
-
*
|
|
58
|
-
* @param email - Email address to validate
|
|
59
|
-
* @returns Validation result with sanitized email if valid
|
|
60
|
-
* @throws ValidationError if validation fails and strict mode is enabled
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const result = security.validateEmail('user@example.com')
|
|
65
|
-
* if (result.valid) {
|
|
66
|
-
* console.log(result.sanitized) // 'user@example.com'
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
validateEmail(email: unknown): ValidationResult<string>;
|
|
71
|
-
/**
|
|
72
|
-
* Validates and sanitizes a password with strength assessment.
|
|
73
|
-
*
|
|
74
|
-
* @param password - Password to validate
|
|
75
|
-
* @returns Validation result with strength indicator if valid
|
|
76
|
-
* @throws ValidationError if validation fails and strict mode is enabled
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const result = security.validatePassword('MyP@ssw0rd!')
|
|
81
|
-
* if (result.valid) {
|
|
82
|
-
* console.log(result.strength) // 'strong'
|
|
83
|
-
* }
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
validatePassword(password: unknown): ValidationResult<string>;
|
|
87
|
-
/**
|
|
88
|
-
* Validates and sanitizes a name.
|
|
89
|
-
*
|
|
90
|
-
* @param name - Name to validate
|
|
91
|
-
* @returns Validation result with sanitized name if valid
|
|
92
|
-
*/
|
|
93
|
-
validateName(name: unknown): ValidationResult<string>;
|
|
94
|
-
/**
|
|
95
|
-
* Validates a token format.
|
|
96
|
-
*
|
|
97
|
-
* @param token - Token to validate
|
|
98
|
-
* @returns Validation result
|
|
99
|
-
*/
|
|
100
|
-
validateToken(token: unknown): ValidationResult<string>;
|
|
101
|
-
/**
|
|
102
|
-
* Validates a URL.
|
|
103
|
-
*
|
|
104
|
-
* @param url - URL to validate
|
|
105
|
-
* @returns Validation result
|
|
106
|
-
*/
|
|
107
|
-
validateURL(url: unknown): ValidationResult<string>;
|
|
108
|
-
/**
|
|
109
|
-
* Validates and sanitizes generic input with XSS prevention.
|
|
110
|
-
*
|
|
111
|
-
* @param input - Input to validate and sanitize
|
|
112
|
-
* @param options - Sanitization options
|
|
113
|
-
* @returns Validation result with sanitized input if valid
|
|
114
|
-
*/
|
|
115
|
-
sanitizeInput(input: unknown, options?: {
|
|
116
|
-
maxLength?: number;
|
|
117
|
-
allowHtml?: boolean;
|
|
118
|
-
required?: boolean;
|
|
119
|
-
}): ValidationResult<string>;
|
|
120
|
-
/**
|
|
121
|
-
* Escapes HTML to prevent XSS.
|
|
122
|
-
*
|
|
123
|
-
* @param str - String to escape
|
|
124
|
-
* @returns Escaped string
|
|
125
|
-
*/
|
|
126
|
-
escapeHTML(str: string): string;
|
|
127
|
-
/**
|
|
128
|
-
* Sanitizes user input with XSS prevention.
|
|
129
|
-
*
|
|
130
|
-
* @param input - Input to sanitize
|
|
131
|
-
* @returns Sanitized string
|
|
132
|
-
*/
|
|
133
|
-
sanitizeUserInput(input: unknown): string;
|
|
134
|
-
/**
|
|
135
|
-
* Generates a CSRF token.
|
|
136
|
-
*
|
|
137
|
-
* @param key - Token key (e.g., session ID)
|
|
138
|
-
* @param expiresIn - Expiration time in milliseconds (optional)
|
|
139
|
-
* @returns CSRF token
|
|
140
|
-
* @throws Error if CSRF protection is disabled
|
|
141
|
-
*/
|
|
142
|
-
generateCSRFToken(key: string, expiresIn?: number): string;
|
|
143
|
-
/**
|
|
144
|
-
* Validates a CSRF token.
|
|
145
|
-
*
|
|
146
|
-
* @param key - Token key (e.g., session ID)
|
|
147
|
-
* @param token - Token to validate
|
|
148
|
-
* @returns True if token is valid
|
|
149
|
-
*/
|
|
150
|
-
validateCSRFToken(key: string, token: string): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Checks rate limit for a given key.
|
|
153
|
-
*
|
|
154
|
-
* @param key - Rate limit key (IP, user ID, email, etc.)
|
|
155
|
-
* @returns Rate limit result
|
|
156
|
-
* @throws RateLimitError if rate limit is exceeded
|
|
157
|
-
*/
|
|
158
|
-
checkRateLimit(key: string): {
|
|
159
|
-
allowed: boolean;
|
|
160
|
-
remaining: number;
|
|
161
|
-
resetAt: Date;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Resets rate limit for a given key.
|
|
165
|
-
*
|
|
166
|
-
* @param key - Rate limit key
|
|
167
|
-
*/
|
|
168
|
-
resetRateLimit(key: string): void;
|
|
169
|
-
/**
|
|
170
|
-
* Gets current security configuration.
|
|
171
|
-
*
|
|
172
|
-
* @returns Security configuration
|
|
173
|
-
*/
|
|
174
|
-
getConfig(): Readonly<SecurityConfig>;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Creates a security manager instance.
|
|
178
|
-
*
|
|
179
|
-
* @param config - Security configuration
|
|
180
|
-
* @returns Security manager instance
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```typescript
|
|
184
|
-
* const security = createSecurityManager({
|
|
185
|
-
* csrfProtection: { enabled: true },
|
|
186
|
-
* rateLimiting: { enabled: true, maxAttempts: 5 },
|
|
187
|
-
* })
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
export declare function createSecurityManager(config?: SecurityConfig): SecurityManager;
|
|
191
|
-
export * from './validation';
|
|
192
|
-
export * from './csrf';
|
|
193
|
-
export * from './rate-limit';
|
|
194
|
-
export * from './xss';
|
|
195
|
-
/**
|
|
196
|
-
* TODO: Performance
|
|
197
|
-
* - [ ] Add validation result caching (with TTL)
|
|
198
|
-
* - [ ] Optimize rate limiting with sliding window algorithm
|
|
199
|
-
* - [ ] Add batch validation support
|
|
200
|
-
* - [ ] Implement async validation for heavy operations
|
|
201
|
-
*
|
|
202
|
-
* TODO: Features
|
|
203
|
-
* - [ ] Add Redis-based rate limiting support
|
|
204
|
-
* - [ ] Implement distributed CSRF token storage
|
|
205
|
-
* - [ ] Add security event logging
|
|
206
|
-
* - [ ] Create security metrics collection
|
|
207
|
-
* - [ ] Add IP whitelist/blacklist support
|
|
208
|
-
* - [ ] Implement CAPTCHA integration
|
|
209
|
-
*
|
|
210
|
-
* TODO: Type Safety
|
|
211
|
-
* - [ ] Add branded types for validated inputs
|
|
212
|
-
* - [ ] Create type-safe security configuration
|
|
213
|
-
* - [ ] Implement compile-time validation rules
|
|
214
|
-
*
|
|
215
|
-
* TODO: Security
|
|
216
|
-
* - [ ] Add security headers management
|
|
217
|
-
* - [ ] Implement content security policy (CSP) helpers
|
|
218
|
-
* - [ ] Add security audit logging
|
|
219
|
-
* - [ ] Create security incident reporting
|
|
220
|
-
*
|
|
221
|
-
* TODO: Testing
|
|
222
|
-
* - [ ] Add comprehensive unit tests
|
|
223
|
-
* - [ ] Test rate limiting edge cases
|
|
224
|
-
* - [ ] Test CSRF token expiration
|
|
225
|
-
* - [ ] Add security fuzzing tests
|
|
226
|
-
*
|
|
227
|
-
* TODO: Documentation
|
|
228
|
-
* - [ ] Document security best practices
|
|
229
|
-
* - [ ] Add security configuration guide
|
|
230
|
-
* - [ ] Create security troubleshooting guide
|
|
231
|
-
*
|
|
232
|
-
* TODO: Limitations
|
|
233
|
-
* - [ ] Rate limiting is in-memory (consider Redis for distributed systems)
|
|
234
|
-
* - [ ] CSRF tokens are in-memory (consider persistent storage)
|
|
235
|
-
* - [ ] HTML sanitization is basic (consider DOMPurify for complex cases)
|
|
236
|
-
*/
|