@entro314labs/entro-auth 0.0.0-stage → 1.8.0-beta.11
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/LICENSE.md +20 -0
- package/README.md +31 -2
- package/dist/_virtual/_rolldown/runtime.mjs +26 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +1 -0
- package/dist/adapters/drizzle-adapter/index.mjs +2 -0
- package/dist/adapters/index.d.mts +19 -0
- package/dist/adapters/index.mjs +8 -0
- package/dist/adapters/kysely-adapter/index.d.mts +1 -0
- package/dist/adapters/kysely-adapter/index.mjs +2 -0
- package/dist/adapters/memory-adapter/index.d.mts +1 -0
- package/dist/adapters/memory-adapter/index.mjs +2 -0
- package/dist/api/dispatch.d.mts +31 -0
- package/dist/api/dispatch.mjs +318 -0
- package/dist/api/index.d.mts +4117 -0
- package/dist/api/index.mjs +227 -0
- package/dist/api/middlewares/authorization.d.mts +70 -0
- package/dist/api/middlewares/authorization.mjs +78 -0
- package/dist/api/middlewares/index.d.mts +3 -0
- package/dist/api/middlewares/origin-check.d.mts +12 -0
- package/dist/api/middlewares/origin-check.mjs +154 -0
- package/dist/api/rate-limiter/index.mjs +322 -0
- package/dist/api/routes/account.d.mts +407 -0
- package/dist/api/routes/account.mjs +642 -0
- package/dist/api/routes/callback.d.mts +27 -0
- package/dist/api/routes/callback.mjs +184 -0
- package/dist/api/routes/email-verification.d.mts +153 -0
- package/dist/api/routes/email-verification.mjs +315 -0
- package/dist/api/routes/error.d.mts +22 -0
- package/dist/api/routes/error.mjs +386 -0
- package/dist/api/routes/id-token-nonce.d.mts +83 -0
- package/dist/api/routes/id-token-nonce.mjs +79 -0
- package/dist/api/routes/index.d.mts +14 -0
- package/dist/api/routes/ok.d.mts +30 -0
- package/dist/api/routes/ok.mjs +26 -0
- package/dist/api/routes/password.d.mts +177 -0
- package/dist/api/routes/password.mjs +198 -0
- package/dist/api/routes/session.d.mts +446 -0
- package/dist/api/routes/session.mjs +488 -0
- package/dist/api/routes/sign-in.d.mts +182 -0
- package/dist/api/routes/sign-in.mjs +374 -0
- package/dist/api/routes/sign-out.d.mts +46 -0
- package/dist/api/routes/sign-out.mjs +101 -0
- package/dist/api/routes/sign-up.d.mts +155 -0
- package/dist/api/routes/sign-up.mjs +279 -0
- package/dist/api/routes/update-session.d.mts +70 -0
- package/dist/api/routes/update-session.mjs +56 -0
- package/dist/api/routes/update-user.d.mts +424 -0
- package/dist/api/routes/update-user.mjs +524 -0
- package/dist/api/state/oauth.d.mts +48 -0
- package/dist/api/state/oauth.mjs +38 -0
- package/dist/api/state/should-session-refresh.d.mts +10 -0
- package/dist/api/state/should-session-refresh.mjs +12 -0
- package/dist/api/to-auth-endpoints.mjs +59 -0
- package/dist/auth/base.mjs +60 -0
- package/dist/auth/full.d.mts +25 -0
- package/dist/auth/full.mjs +28 -0
- package/dist/auth/minimal.d.mts +8 -0
- package/dist/auth/minimal.mjs +10 -0
- package/dist/auth/trusted-origins.mjs +130 -0
- package/dist/client/broadcast-channel.d.mts +16 -0
- package/dist/client/broadcast-channel.mjs +44 -0
- package/dist/client/config.d.mts +84 -0
- package/dist/client/config.mjs +111 -0
- package/dist/client/equality.d.mts +15 -0
- package/dist/client/equality.mjs +41 -0
- package/dist/client/fetch-plugins.mjs +16 -0
- package/dist/client/focus-manager.d.mts +7 -0
- package/dist/client/focus-manager.mjs +30 -0
- package/dist/client/index.d.mts +35 -0
- package/dist/client/index.mjs +21 -0
- package/dist/client/lynx/index.d.mts +40 -0
- package/dist/client/lynx/index.mjs +22 -0
- package/dist/client/lynx/lynx-store.d.mts +43 -0
- package/dist/client/lynx/lynx-store.mjs +43 -0
- package/dist/client/online-manager.d.mts +8 -0
- package/dist/client/online-manager.mjs +33 -0
- package/dist/client/parser.d.mts +12 -0
- package/dist/client/parser.mjs +59 -0
- package/dist/client/path-to-object.d.mts +110 -0
- package/dist/client/plugins/index.d.mts +44 -0
- package/dist/client/plugins/index.mjs +30 -0
- package/dist/client/plugins/infer-plugin.d.mts +12 -0
- package/dist/client/plugins/infer-plugin.mjs +10 -0
- package/dist/client/proxy.mjs +70 -0
- package/dist/client/query-atom.mjs +12 -0
- package/dist/client/query.d.mts +19 -0
- package/dist/client/query.mjs +133 -0
- package/dist/client/react/index.d.mts +41 -0
- package/dist/client/react/index.mjs +22 -0
- package/dist/client/react/react-store.d.mts +43 -0
- package/dist/client/react/react-store.mjs +44 -0
- package/dist/client/session-atom.d.mts +9 -0
- package/dist/client/session-atom.mjs +179 -0
- package/dist/client/session-refresh.d.mts +16 -0
- package/dist/client/session-refresh.mjs +131 -0
- package/dist/client/solid/index.d.mts +41 -0
- package/dist/client/solid/index.mjs +22 -0
- package/dist/client/solid/solid-store.mjs +20 -0
- package/dist/client/svelte/index.d.mts +41 -0
- package/dist/client/svelte/index.mjs +18 -0
- package/dist/client/types.d.mts +49 -0
- package/dist/client/vanilla.d.mts +39 -0
- package/dist/client/vanilla.mjs +18 -0
- package/dist/client/vue/index.d.mts +64 -0
- package/dist/client/vue/index.mjs +60 -0
- package/dist/client/vue/vue-store.mjs +22 -0
- package/dist/context/create-context.mjs +229 -0
- package/dist/context/helpers.mjs +159 -0
- package/dist/context/init-minimal.mjs +15 -0
- package/dist/context/init.mjs +16 -0
- package/dist/context/secret-utils.mjs +52 -0
- package/dist/context/store-capabilities.mjs +11 -0
- package/dist/cookies/cache.mjs +33 -0
- package/dist/cookies/cookie-utils.d.mts +70 -0
- package/dist/cookies/cookie-utils.mjs +200 -0
- package/dist/cookies/index.d.mts +121 -0
- package/dist/cookies/index.mjs +356 -0
- package/dist/cookies/jwt.mjs +44 -0
- package/dist/cookies/session-store.d.mts +31 -0
- package/dist/cookies/session-store.mjs +183 -0
- package/dist/crypto/buffer.d.mts +4 -0
- package/dist/crypto/buffer.mjs +15 -0
- package/dist/crypto/index.d.mts +24 -0
- package/dist/crypto/index.mjs +70 -0
- package/dist/crypto/jwt.d.mts +5 -0
- package/dist/crypto/jwt.mjs +141 -0
- package/dist/crypto/password.d.mts +7 -0
- package/dist/crypto/password.mjs +13 -0
- package/dist/crypto/purpose.d.mts +12 -0
- package/dist/crypto/purpose.mjs +27 -0
- package/dist/crypto/random.d.mts +1 -0
- package/dist/crypto/random.mjs +4 -0
- package/dist/db/adapter-base.d.mts +3 -0
- package/dist/db/adapter-base.mjs +24 -0
- package/dist/db/adapter-kysely.d.mts +3 -0
- package/dist/db/adapter-kysely.mjs +16 -0
- package/dist/db/field-converter.d.mts +3 -0
- package/dist/db/field-converter.mjs +18 -0
- package/dist/db/field.d.mts +38 -0
- package/dist/db/get-migration.d.mts +50 -0
- package/dist/db/get-migration.mjs +685 -0
- package/dist/db/get-schema.d.mts +9 -0
- package/dist/db/get-schema.mjs +54 -0
- package/dist/db/index.d.mts +10 -0
- package/dist/db/index.mjs +34 -0
- package/dist/db/internal-adapter.d.mts +10 -0
- package/dist/db/internal-adapter.mjs +1083 -0
- package/dist/db/revoke-unproven-account-access.d.mts +18 -0
- package/dist/db/revoke-unproven-account-access.mjs +57 -0
- package/dist/db/schema.d.mts +59 -0
- package/dist/db/schema.mjs +172 -0
- package/dist/db/to-zod.d.mts +31 -0
- package/dist/db/to-zod.mjs +32 -0
- package/dist/db/verification-token-storage.mjs +24 -0
- package/dist/db/with-hooks.d.mts +33 -0
- package/dist/db/with-hooks.mjs +248 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.mjs +16 -0
- package/dist/integrations/cookie-plugin-guard.mjs +17 -0
- package/dist/integrations/next-js.d.mts +23 -0
- package/dist/integrations/next-js.mjs +104 -0
- package/dist/integrations/node.d.mts +7 -0
- package/dist/integrations/node.mjs +14 -0
- package/dist/integrations/solid-start.d.mts +19 -0
- package/dist/integrations/solid-start.mjs +14 -0
- package/dist/integrations/svelte-kit.d.mts +28 -0
- package/dist/integrations/svelte-kit.mjs +56 -0
- package/dist/integrations/tanstack-start-solid.d.mts +27 -0
- package/dist/integrations/tanstack-start-solid.mjs +56 -0
- package/dist/integrations/tanstack-start.d.mts +27 -0
- package/dist/integrations/tanstack-start.mjs +56 -0
- package/dist/oauth2/account-fields.mjs +51 -0
- package/dist/oauth2/account-key.mjs +42 -0
- package/dist/oauth2/callback.mjs +67 -0
- package/dist/oauth2/dpop-client.d.mts +1 -0
- package/dist/oauth2/dpop-client.mjs +2 -0
- package/dist/oauth2/errors.mjs +48 -0
- package/dist/oauth2/index.d.mts +5 -0
- package/dist/oauth2/index.mjs +5 -0
- package/dist/oauth2/link-account.d.mts +126 -0
- package/dist/oauth2/link-account.mjs +429 -0
- package/dist/oauth2/state.d.mts +49 -0
- package/dist/oauth2/state.mjs +66 -0
- package/dist/oauth2/utils.d.mts +21 -0
- package/dist/oauth2/utils.mjs +44 -0
- package/dist/package.mjs +3 -0
- package/dist/plugins/access/access.d.mts +13 -0
- package/dist/plugins/access/access.mjs +77 -0
- package/dist/plugins/access/index.d.mts +3 -0
- package/dist/plugins/access/index.mjs +1 -0
- package/dist/plugins/access/types.d.mts +20 -0
- package/dist/plugins/additional-fields/client.d.mts +96 -0
- package/dist/plugins/additional-fields/client.mjs +10 -0
- package/dist/plugins/admin/access/index.d.mts +2 -0
- package/dist/plugins/admin/access/index.mjs +1 -0
- package/dist/plugins/admin/access/statement.d.mts +49 -0
- package/dist/plugins/admin/access/statement.mjs +53 -0
- package/dist/plugins/admin/admin.d.mts +908 -0
- package/dist/plugins/admin/admin.mjs +90 -0
- package/dist/plugins/admin/client.d.mts +84 -0
- package/dist/plugins/admin/client.mjs +38 -0
- package/dist/plugins/admin/error-codes.d.mts +30 -0
- package/dist/plugins/admin/error-codes.mjs +33 -0
- package/dist/plugins/admin/has-permission.mjs +11 -0
- package/dist/plugins/admin/index.d.mts +3 -0
- package/dist/plugins/admin/index.mjs +1 -0
- package/dist/plugins/admin/routes.mjs +940 -0
- package/dist/plugins/admin/schema.d.mts +37 -0
- package/dist/plugins/admin/schema.mjs +32 -0
- package/dist/plugins/admin/types.d.mts +89 -0
- package/dist/plugins/anonymous/client.d.mts +28 -0
- package/dist/plugins/anonymous/client.mjs +20 -0
- package/dist/plugins/anonymous/error-codes.d.mts +10 -0
- package/dist/plugins/anonymous/error-codes.mjs +13 -0
- package/dist/plugins/anonymous/index.d.mts +170 -0
- package/dist/plugins/anonymous/index.mjs +220 -0
- package/dist/plugins/anonymous/schema.d.mts +12 -0
- package/dist/plugins/anonymous/schema.mjs +8 -0
- package/dist/plugins/anonymous/types.d.mts +62 -0
- package/dist/plugins/bearer/index.d.mts +39 -0
- package/dist/plugins/bearer/index.mjs +73 -0
- package/dist/plugins/captcha/constants.d.mts +7 -0
- package/dist/plugins/captcha/constants.mjs +27 -0
- package/dist/plugins/captcha/error-codes.mjs +12 -0
- package/dist/plugins/captcha/index.d.mts +22 -0
- package/dist/plugins/captcha/index.mjs +84 -0
- package/dist/plugins/captcha/types.d.mts +90 -0
- package/dist/plugins/captcha/utils.mjs +18 -0
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +26 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +46 -0
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +31 -0
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +26 -0
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +26 -0
- package/dist/plugins/custom-session/client.d.mts +13 -0
- package/dist/plugins/custom-session/client.mjs +6 -0
- package/dist/plugins/custom-session/index.d.mts +65 -0
- package/dist/plugins/custom-session/index.mjs +57 -0
- package/dist/plugins/device-authorization/client.d.mts +13 -0
- package/dist/plugins/device-authorization/client.mjs +17 -0
- package/dist/plugins/device-authorization/error-codes.mjs +18 -0
- package/dist/plugins/device-authorization/index.d.mts +550 -0
- package/dist/plugins/device-authorization/index.mjs +79 -0
- package/dist/plugins/device-authorization/routes.d.mts +96 -0
- package/dist/plugins/device-authorization/routes.mjs +734 -0
- package/dist/plugins/device-authorization/schema.d.mts +15 -0
- package/dist/plugins/device-authorization/schema.mjs +62 -0
- package/dist/plugins/email-otp/client.d.mts +17 -0
- package/dist/plugins/email-otp/client.mjs +16 -0
- package/dist/plugins/email-otp/error-codes.d.mts +5 -0
- package/dist/plugins/email-otp/error-codes.mjs +8 -0
- package/dist/plugins/email-otp/index.d.mts +542 -0
- package/dist/plugins/email-otp/index.mjs +144 -0
- package/dist/plugins/email-otp/otp-token.mjs +66 -0
- package/dist/plugins/email-otp/routes.mjs +774 -0
- package/dist/plugins/email-otp/types.d.mts +105 -0
- package/dist/plugins/email-otp/utils.mjs +16 -0
- package/dist/plugins/generic-oauth/error-codes.mjs +8 -0
- package/dist/plugins/generic-oauth/index.d.mts +57 -0
- package/dist/plugins/generic-oauth/index.mjs +459 -0
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +32 -0
- package/dist/plugins/generic-oauth/providers/auth0.mjs +48 -0
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +27 -0
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +61 -0
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +32 -0
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +65 -0
- package/dist/plugins/generic-oauth/providers/index.d.mts +11 -0
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +32 -0
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +46 -0
- package/dist/plugins/generic-oauth/providers/line.d.mts +50 -0
- package/dist/plugins/generic-oauth/providers/line.mjs +92 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +35 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +104 -0
- package/dist/plugins/generic-oauth/providers/okta.d.mts +32 -0
- package/dist/plugins/generic-oauth/providers/okta.mjs +47 -0
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +25 -0
- package/dist/plugins/generic-oauth/providers/patreon.mjs +60 -0
- package/dist/plugins/generic-oauth/providers/slack.d.mts +25 -0
- package/dist/plugins/generic-oauth/providers/slack.mjs +65 -0
- package/dist/plugins/generic-oauth/providers/token-endpoint-audience.mjs +15 -0
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +25 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +66 -0
- package/dist/plugins/generic-oauth/types.d.mts +328 -0
- package/dist/plugins/haveibeenpwned/index.d.mts +57 -0
- package/dist/plugins/haveibeenpwned/index.mjs +80 -0
- package/dist/plugins/index.d.mts +76 -0
- package/dist/plugins/index.mjs +53 -0
- package/dist/plugins/jwt/adapter.mjs +78 -0
- package/dist/plugins/jwt/client.d.mts +38 -0
- package/dist/plugins/jwt/client.mjs +18 -0
- package/dist/plugins/jwt/cookie-cache.mjs +71 -0
- package/dist/plugins/jwt/index.d.mts +241 -0
- package/dist/plugins/jwt/index.mjs +213 -0
- package/dist/plugins/jwt/schema.d.mts +30 -0
- package/dist/plugins/jwt/schema.mjs +28 -0
- package/dist/plugins/jwt/sign.d.mts +127 -0
- package/dist/plugins/jwt/sign.mjs +134 -0
- package/dist/plugins/jwt/types.d.mts +255 -0
- package/dist/plugins/jwt/utils.d.mts +36 -0
- package/dist/plugins/jwt/utils.mjs +63 -0
- package/dist/plugins/jwt/verify.d.mts +7 -0
- package/dist/plugins/jwt/verify.mjs +50 -0
- package/dist/plugins/last-login-method/client.d.mts +45 -0
- package/dist/plugins/last-login-method/client.mjs +47 -0
- package/dist/plugins/last-login-method/index.d.mts +121 -0
- package/dist/plugins/last-login-method/index.mjs +98 -0
- package/dist/plugins/magic-link/client.d.mts +6 -0
- package/dist/plugins/magic-link/client.mjs +10 -0
- package/dist/plugins/magic-link/index.d.mts +208 -0
- package/dist/plugins/magic-link/index.mjs +223 -0
- package/dist/plugins/magic-link/utils.mjs +8 -0
- package/dist/plugins/multi-session/client.d.mts +15 -0
- package/dist/plugins/multi-session/client.mjs +18 -0
- package/dist/plugins/multi-session/error-codes.d.mts +3 -0
- package/dist/plugins/multi-session/error-codes.mjs +4 -0
- package/dist/plugins/multi-session/index.d.mts +206 -0
- package/dist/plugins/multi-session/index.mjs +216 -0
- package/dist/plugins/oauth-popup/client.d.mts +74 -0
- package/dist/plugins/oauth-popup/client.mjs +204 -0
- package/dist/plugins/oauth-popup/constants.d.mts +8 -0
- package/dist/plugins/oauth-popup/constants.mjs +10 -0
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -0
- package/dist/plugins/oauth-popup/error-codes.mjs +9 -0
- package/dist/plugins/oauth-popup/index.d.mts +61 -0
- package/dist/plugins/oauth-popup/index.mjs +232 -0
- package/dist/plugins/oauth-popup/types.d.mts +26 -0
- package/dist/plugins/oauth-proxy/index.d.mts +123 -0
- package/dist/plugins/oauth-proxy/index.mjs +397 -0
- package/dist/plugins/oauth-proxy/utils.mjs +54 -0
- package/dist/plugins/one-tap/client.d.mts +187 -0
- package/dist/plugins/one-tap/client.mjs +208 -0
- package/dist/plugins/one-tap/index.d.mts +117 -0
- package/dist/plugins/one-tap/index.mjs +146 -0
- package/dist/plugins/one-time-token/client.d.mts +7 -0
- package/dist/plugins/one-time-token/client.mjs +10 -0
- package/dist/plugins/one-time-token/index.d.mts +128 -0
- package/dist/plugins/one-time-token/index.mjs +106 -0
- package/dist/plugins/one-time-token/utils.mjs +8 -0
- package/dist/plugins/open-api/generator.d.mts +124 -0
- package/dist/plugins/open-api/generator.mjs +557 -0
- package/dist/plugins/open-api/index.d.mts +93 -0
- package/dist/plugins/open-api/index.mjs +64 -0
- package/dist/plugins/open-api/logo.mjs +12 -0
- package/dist/plugins/organization/access/index.d.mts +2 -0
- package/dist/plugins/organization/access/index.mjs +1 -0
- package/dist/plugins/organization/access/statement.d.mts +111 -0
- package/dist/plugins/organization/access/statement.mjs +76 -0
- package/dist/plugins/organization/adapter.d.mts +786 -0
- package/dist/plugins/organization/adapter.mjs +821 -0
- package/dist/plugins/organization/call.mjs +14 -0
- package/dist/plugins/organization/client.d.mts +375 -0
- package/dist/plugins/organization/client.mjs +108 -0
- package/dist/plugins/organization/error-codes.d.mts +62 -0
- package/dist/plugins/organization/error-codes.mjs +65 -0
- package/dist/plugins/organization/has-permission.d.mts +12 -0
- package/dist/plugins/organization/has-permission.mjs +72 -0
- package/dist/plugins/organization/index.d.mts +7 -0
- package/dist/plugins/organization/index.mjs +5 -0
- package/dist/plugins/organization/organization.d.mts +418 -0
- package/dist/plugins/organization/organization.mjs +888 -0
- package/dist/plugins/organization/permission.d.mts +12 -0
- package/dist/plugins/organization/permission.mjs +13 -0
- package/dist/plugins/organization/roles.d.mts +6 -0
- package/dist/plugins/organization/roles.mjs +25 -0
- package/dist/plugins/organization/routes/crud-access-control.d.mts +509 -0
- package/dist/plugins/organization/routes/crud-access-control.mjs +674 -0
- package/dist/plugins/organization/routes/crud-invites.d.mts +1173 -0
- package/dist/plugins/organization/routes/crud-invites.mjs +619 -0
- package/dist/plugins/organization/routes/crud-members.d.mts +1010 -0
- package/dist/plugins/organization/routes/crud-members.mjs +515 -0
- package/dist/plugins/organization/routes/crud-org.d.mts +914 -0
- package/dist/plugins/organization/routes/crud-org.mjs +465 -0
- package/dist/plugins/organization/routes/crud-team.d.mts +1235 -0
- package/dist/plugins/organization/routes/crud-team.mjs +767 -0
- package/dist/plugins/organization/schema.d.mts +388 -0
- package/dist/plugins/organization/schema.mjs +64 -0
- package/dist/plugins/organization/types.d.mts +688 -0
- package/dist/plugins/phone-number/client.d.mts +29 -0
- package/dist/plugins/phone-number/client.mjs +18 -0
- package/dist/plugins/phone-number/error-codes.d.mts +16 -0
- package/dist/plugins/phone-number/error-codes.mjs +19 -0
- package/dist/plugins/phone-number/index.d.mts +376 -0
- package/dist/plugins/phone-number/index.mjs +72 -0
- package/dist/plugins/phone-number/routes.mjs +612 -0
- package/dist/plugins/phone-number/schema.d.mts +19 -0
- package/dist/plugins/phone-number/schema.mjs +17 -0
- package/dist/plugins/phone-number/types.d.mts +119 -0
- package/dist/plugins/siwe/client.d.mts +10 -0
- package/dist/plugins/siwe/client.mjs +14 -0
- package/dist/plugins/siwe/index.d.mts +58 -0
- package/dist/plugins/siwe/index.mjs +288 -0
- package/dist/plugins/siwe/parse-message.mjs +57 -0
- package/dist/plugins/siwe/schema.d.mts +32 -0
- package/dist/plugins/siwe/schema.mjs +29 -0
- package/dist/plugins/siwe/types.d.mts +41 -0
- package/dist/plugins/test-utils/auth-helpers.mjs +34 -0
- package/dist/plugins/test-utils/cookie-builder.mjs +54 -0
- package/dist/plugins/test-utils/db-helpers.mjs +64 -0
- package/dist/plugins/test-utils/factories.mjs +37 -0
- package/dist/plugins/test-utils/index.d.mts +69 -0
- package/dist/plugins/test-utils/index.mjs +96 -0
- package/dist/plugins/test-utils/otp-sink.mjs +20 -0
- package/dist/plugins/test-utils/types.d.mts +49 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +286 -0
- package/dist/plugins/two-factor/backup-codes/index.mjs +354 -0
- package/dist/plugins/two-factor/claim.d.mts +86 -0
- package/dist/plugins/two-factor/claim.mjs +171 -0
- package/dist/plugins/two-factor/client.d.mts +76 -0
- package/dist/plugins/two-factor/client.mjs +40 -0
- package/dist/plugins/two-factor/constant.d.mts +7 -0
- package/dist/plugins/two-factor/constant.mjs +12 -0
- package/dist/plugins/two-factor/error-code.d.mts +20 -0
- package/dist/plugins/two-factor/error-code.mjs +23 -0
- package/dist/plugins/two-factor/index.d.mts +746 -0
- package/dist/plugins/two-factor/index.mjs +493 -0
- package/dist/plugins/two-factor/otp/index.d.mts +211 -0
- package/dist/plugins/two-factor/otp/index.mjs +262 -0
- package/dist/plugins/two-factor/passkey.mjs +47 -0
- package/dist/plugins/two-factor/schema.d.mts +66 -0
- package/dist/plugins/two-factor/schema.mjs +66 -0
- package/dist/plugins/two-factor/totp/index.d.mts +214 -0
- package/dist/plugins/two-factor/totp/index.mjs +290 -0
- package/dist/plugins/two-factor/types.d.mts +112 -0
- package/dist/plugins/two-factor/utils.mjs +8 -0
- package/dist/plugins/two-factor/verify-two-factor.d.mts +121 -0
- package/dist/plugins/two-factor/verify-two-factor.mjs +314 -0
- package/dist/plugins/username/client.d.mts +34 -0
- package/dist/plugins/username/client.mjs +16 -0
- package/dist/plugins/username/error-codes.d.mts +11 -0
- package/dist/plugins/username/error-codes.mjs +14 -0
- package/dist/plugins/username/index.d.mts +319 -0
- package/dist/plugins/username/index.mjs +304 -0
- package/dist/plugins/username/schema.d.mts +45 -0
- package/dist/plugins/username/schema.mjs +24 -0
- package/dist/social-providers/index.d.mts +1 -0
- package/dist/social-providers/index.mjs +2 -0
- package/dist/state.d.mts +48 -0
- package/dist/state.mjs +153 -0
- package/dist/test-utils/headers.d.mts +5 -0
- package/dist/test-utils/headers.mjs +16 -0
- package/dist/test-utils/http-test-instance.d.mts +420 -0
- package/dist/test-utils/http-test-instance.mjs +106 -0
- package/dist/test-utils/index.d.mts +4 -0
- package/dist/test-utils/index.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +55 -0
- package/dist/test-utils/test-instance.mjs +252 -0
- package/dist/types/adapter.d.mts +2 -0
- package/dist/types/api.d.mts +24 -0
- package/dist/types/auth.d.mts +28 -0
- package/dist/types/helper.d.mts +23 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/models.d.mts +7 -0
- package/dist/types/plugins.d.mts +16 -0
- package/dist/utils/constants.mjs +3 -0
- package/dist/utils/date.mjs +5 -0
- package/dist/utils/hashing.mjs +17 -0
- package/dist/utils/hide-metadata.d.mts +2 -0
- package/dist/utils/hide-metadata.mjs +1 -0
- package/dist/utils/index.d.mts +5 -0
- package/dist/utils/is-api-error.d.mts +2 -0
- package/dist/utils/is-api-error.mjs +1 -0
- package/dist/utils/is-atom.mjs +5 -0
- package/dist/utils/is-promise.mjs +5 -0
- package/dist/utils/middleware-response.mjs +9 -0
- package/dist/utils/password.mjs +90 -0
- package/dist/utils/plugin-helper.mjs +13 -0
- package/dist/utils/request.mjs +22 -0
- package/dist/utils/shim.mjs +21 -0
- package/dist/utils/time.d.mts +46 -0
- package/dist/utils/time.mjs +97 -0
- package/dist/utils/url.d.mts +74 -0
- package/dist/utils/url.mjs +237 -0
- package/dist/utils/validate-user-info.mjs +43 -0
- package/dist/utils/wildcard.mjs +107 -0
- package/dist/version.mjs +4 -0
- package/package.json +601 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/plugins/generic-oauth/providers/auth0.ts
|
|
2
|
+
/**
|
|
3
|
+
* Auth0 OAuth provider helper
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { genericOAuth, auth0 } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
8
|
+
*
|
|
9
|
+
* export const auth = entroAuth({
|
|
10
|
+
* plugins: [
|
|
11
|
+
* genericOAuth({
|
|
12
|
+
* config: [
|
|
13
|
+
* auth0({
|
|
14
|
+
* clientId: process.env.AUTH0_CLIENT_ID,
|
|
15
|
+
* clientSecret: process.env.AUTH0_CLIENT_SECRET,
|
|
16
|
+
* domain: process.env.AUTH0_DOMAIN,
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function auth0(options) {
|
|
25
|
+
const defaultScopes = [
|
|
26
|
+
"openid",
|
|
27
|
+
"profile",
|
|
28
|
+
"email"
|
|
29
|
+
];
|
|
30
|
+
const domainUrl = options.domain.startsWith("http://") || options.domain.startsWith("https://") ? options.domain : `https://${options.domain}`;
|
|
31
|
+
return {
|
|
32
|
+
providerId: "auth0",
|
|
33
|
+
discoveryUrl: `https://${new URL(domainUrl).host}/.well-known/openid-configuration`,
|
|
34
|
+
clientId: options.clientId,
|
|
35
|
+
clientSecret: options.clientSecret,
|
|
36
|
+
tokenEndpointAuth: options.tokenEndpointAuth,
|
|
37
|
+
scopes: options.scopes ?? defaultScopes,
|
|
38
|
+
redirectURI: options.redirectURI,
|
|
39
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
40
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
41
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
42
|
+
pkce: options.pkce,
|
|
43
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
44
|
+
disableSignUp: options.disableSignUp,
|
|
45
|
+
overrideUserInfo: options.overrideUserInfo
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export { auth0 };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface GumroadOptions extends BaseOAuthProviderOptions {}
|
|
4
|
+
/**
|
|
5
|
+
* Gumroad OAuth provider helper
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { genericOAuth, gumroad } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
10
|
+
*
|
|
11
|
+
* export const auth = entroAuth({
|
|
12
|
+
* plugins: [
|
|
13
|
+
* genericOAuth({
|
|
14
|
+
* config: [
|
|
15
|
+
* gumroad({
|
|
16
|
+
* clientId: process.env.GUMROAD_CLIENT_ID,
|
|
17
|
+
* clientSecret: process.env.GUMROAD_CLIENT_SECRET,
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see https://app.gumroad.com/oauth
|
|
26
|
+
*/
|
|
27
|
+
export declare function gumroad(options: GumroadOptions): GenericOAuthConfig<"gumroad">;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
// src/plugins/generic-oauth/providers/gumroad.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gumroad OAuth provider helper
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { genericOAuth, gumroad } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
9
|
+
*
|
|
10
|
+
* export const auth = entroAuth({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* genericOAuth({
|
|
13
|
+
* config: [
|
|
14
|
+
* gumroad({
|
|
15
|
+
* clientId: process.env.GUMROAD_CLIENT_ID,
|
|
16
|
+
* clientSecret: process.env.GUMROAD_CLIENT_SECRET,
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see https://app.gumroad.com/oauth
|
|
25
|
+
*/
|
|
26
|
+
function gumroad(options) {
|
|
27
|
+
const getUserInfo = async (tokens) => {
|
|
28
|
+
const { data: profile, error } = await betterFetch("https://api.gumroad.com/v2/user", {
|
|
29
|
+
method: "GET",
|
|
30
|
+
headers: { Authorization: `Bearer ${tokens.accessToken}` }
|
|
31
|
+
});
|
|
32
|
+
if (error || !profile?.success || !profile.user) return null;
|
|
33
|
+
return {
|
|
34
|
+
id: profile.user.user_id,
|
|
35
|
+
name: profile.user.name ?? void 0,
|
|
36
|
+
email: profile.user.email,
|
|
37
|
+
image: profile.user.profile_url,
|
|
38
|
+
emailVerified: false
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
providerId: "gumroad",
|
|
43
|
+
accountSubject: ({ profile }) => profile.id ?? "",
|
|
44
|
+
authorizationUrl: "https://gumroad.com/oauth/authorize",
|
|
45
|
+
tokenUrl: "https://api.gumroad.com/oauth/token",
|
|
46
|
+
clientId: options.clientId,
|
|
47
|
+
clientSecret: options.clientSecret,
|
|
48
|
+
tokenEndpointAuth: options.tokenEndpointAuth,
|
|
49
|
+
scopes: options.scopes ?? ["view_profile"],
|
|
50
|
+
redirectURI: options.redirectURI,
|
|
51
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
52
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
53
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
54
|
+
pkce: options.pkce,
|
|
55
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
56
|
+
disableSignUp: options.disableSignUp,
|
|
57
|
+
overrideUserInfo: options.overrideUserInfo,
|
|
58
|
+
getUserInfo
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export { gumroad };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface HubSpotOptions extends BaseOAuthProviderOptions {
|
|
4
|
+
/**
|
|
5
|
+
* OAuth scopes to request.
|
|
6
|
+
* @default ["oauth"]
|
|
7
|
+
*/
|
|
8
|
+
scopes?: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* HubSpot OAuth provider helper
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { genericOAuth, hubspot } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
16
|
+
*
|
|
17
|
+
* export const auth = entroAuth({
|
|
18
|
+
* plugins: [
|
|
19
|
+
* genericOAuth({
|
|
20
|
+
* config: [
|
|
21
|
+
* hubspot({
|
|
22
|
+
* clientId: process.env.HUBSPOT_CLIENT_ID,
|
|
23
|
+
* clientSecret: process.env.HUBSPOT_CLIENT_SECRET,
|
|
24
|
+
* scopes: ["oauth", "contacts"],
|
|
25
|
+
* }),
|
|
26
|
+
* ],
|
|
27
|
+
* }),
|
|
28
|
+
* ],
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function hubspot(options: HubSpotOptions): GenericOAuthConfig<"hubspot">;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
// src/plugins/generic-oauth/providers/hubspot.ts
|
|
3
|
+
/**
|
|
4
|
+
* HubSpot OAuth provider helper
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { genericOAuth, hubspot } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
9
|
+
*
|
|
10
|
+
* export const auth = entroAuth({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* genericOAuth({
|
|
13
|
+
* config: [
|
|
14
|
+
* hubspot({
|
|
15
|
+
* clientId: process.env.HUBSPOT_CLIENT_ID,
|
|
16
|
+
* clientSecret: process.env.HUBSPOT_CLIENT_SECRET,
|
|
17
|
+
* scopes: ["oauth", "contacts"],
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function hubspot(options) {
|
|
26
|
+
const defaultScopes = ["oauth"];
|
|
27
|
+
const getUserInfo = async (tokens) => {
|
|
28
|
+
if (!tokens.accessToken) return null;
|
|
29
|
+
const { data: profile, error } = await betterFetch("https://api.hubapi.com/oauth/v1/access-tokens/:token", {
|
|
30
|
+
params: { token: tokens.accessToken },
|
|
31
|
+
headers: { "Content-Type": "application/json" }
|
|
32
|
+
});
|
|
33
|
+
if (error || !profile) return null;
|
|
34
|
+
const id = profile.user_id ?? profile.signed_access_token?.userId;
|
|
35
|
+
if (!id) return null;
|
|
36
|
+
return {
|
|
37
|
+
id,
|
|
38
|
+
name: profile.user,
|
|
39
|
+
email: profile.user,
|
|
40
|
+
image: void 0,
|
|
41
|
+
emailVerified: false
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
providerId: "hubspot",
|
|
46
|
+
accountSubject: ({ profile }) => profile.id ?? "",
|
|
47
|
+
authorizationUrl: "https://app.hubspot.com/oauth/authorize",
|
|
48
|
+
tokenUrl: "https://api.hubapi.com/oauth/v1/token",
|
|
49
|
+
clientId: options.clientId,
|
|
50
|
+
clientSecret: options.clientSecret,
|
|
51
|
+
tokenEndpointAuth: options.tokenEndpointAuth,
|
|
52
|
+
scopes: options.scopes ?? defaultScopes,
|
|
53
|
+
redirectURI: options.redirectURI,
|
|
54
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
55
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
56
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
57
|
+
authentication: "post",
|
|
58
|
+
pkce: options.pkce,
|
|
59
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
60
|
+
disableSignUp: options.disableSignUp,
|
|
61
|
+
overrideUserInfo: options.overrideUserInfo,
|
|
62
|
+
getUserInfo
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export { hubspot };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Auth0Options, auth0 } from "./auth0.mjs";
|
|
2
|
+
import { GumroadOptions, gumroad } from "./gumroad.mjs";
|
|
3
|
+
import { HubSpotOptions, hubspot } from "./hubspot.mjs";
|
|
4
|
+
import { KeycloakOptions, keycloak } from "./keycloak.mjs";
|
|
5
|
+
import { LineOptions, line } from "./line.mjs";
|
|
6
|
+
import { MicrosoftEntraIdOptions, microsoftEntraId } from "./microsoft-entra-id.mjs";
|
|
7
|
+
import { OktaOptions, okta } from "./okta.mjs";
|
|
8
|
+
import { PatreonOptions, patreon } from "./patreon.mjs";
|
|
9
|
+
import { SlackOptions, slack } from "./slack.mjs";
|
|
10
|
+
import { YandexOptions, yandex } from "./yandex.mjs";
|
|
11
|
+
export { type Auth0Options, type GumroadOptions, type HubSpotOptions, type KeycloakOptions, type LineOptions, type MicrosoftEntraIdOptions, type OktaOptions, type PatreonOptions, type SlackOptions, type YandexOptions, auth0, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface KeycloakOptions extends BaseOAuthProviderOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Keycloak issuer URL (includes realm, e.g., https://my-domain/realms/MyRealm)
|
|
6
|
+
* This will be used to construct the discovery URL.
|
|
7
|
+
*/
|
|
8
|
+
issuer: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Keycloak OAuth provider helper
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { genericOAuth, keycloak } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
16
|
+
*
|
|
17
|
+
* export const auth = entroAuth({
|
|
18
|
+
* plugins: [
|
|
19
|
+
* genericOAuth({
|
|
20
|
+
* config: [
|
|
21
|
+
* keycloak({
|
|
22
|
+
* clientId: process.env.KEYCLOAK_CLIENT_ID,
|
|
23
|
+
* clientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
|
|
24
|
+
* issuer: process.env.KEYCLOAK_ISSUER,
|
|
25
|
+
* }),
|
|
26
|
+
* ],
|
|
27
|
+
* }),
|
|
28
|
+
* ],
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function keycloak(options: KeycloakOptions): GenericOAuthConfig<"keycloak">;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/plugins/generic-oauth/providers/keycloak.ts
|
|
2
|
+
/**
|
|
3
|
+
* Keycloak OAuth provider helper
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { genericOAuth, keycloak } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
8
|
+
*
|
|
9
|
+
* export const auth = entroAuth({
|
|
10
|
+
* plugins: [
|
|
11
|
+
* genericOAuth({
|
|
12
|
+
* config: [
|
|
13
|
+
* keycloak({
|
|
14
|
+
* clientId: process.env.KEYCLOAK_CLIENT_ID,
|
|
15
|
+
* clientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
|
|
16
|
+
* issuer: process.env.KEYCLOAK_ISSUER,
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function keycloak(options) {
|
|
25
|
+
return {
|
|
26
|
+
providerId: "keycloak",
|
|
27
|
+
discoveryUrl: `${options.issuer.replace(/\/$/, "")}/.well-known/openid-configuration`,
|
|
28
|
+
clientId: options.clientId,
|
|
29
|
+
clientSecret: options.clientSecret,
|
|
30
|
+
tokenEndpointAuth: options.tokenEndpointAuth,
|
|
31
|
+
scopes: options.scopes ?? [
|
|
32
|
+
"openid",
|
|
33
|
+
"profile",
|
|
34
|
+
"email"
|
|
35
|
+
],
|
|
36
|
+
redirectURI: options.redirectURI,
|
|
37
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
38
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
39
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
40
|
+
pkce: options.pkce,
|
|
41
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
42
|
+
disableSignUp: options.disableSignUp,
|
|
43
|
+
overrideUserInfo: options.overrideUserInfo
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export { keycloak };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface LineOptions extends BaseOAuthProviderOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Unique provider identifier for this LINE channel.
|
|
6
|
+
* Use different providerIds for different countries/channels (e.g., "line-jp", "line-th", "line-tw").
|
|
7
|
+
* @default "line"
|
|
8
|
+
*/
|
|
9
|
+
providerId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* LINE OAuth provider helper
|
|
13
|
+
*
|
|
14
|
+
* LINE requires separate channels for different countries (Japan, Thailand, Taiwan, etc.).
|
|
15
|
+
* Each channel has its own clientId and clientSecret. To support multiple countries,
|
|
16
|
+
* call this function multiple times with different providerIds and credentials.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { genericOAuth, line } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
21
|
+
*
|
|
22
|
+
* export const auth = entroAuth({
|
|
23
|
+
* plugins: [
|
|
24
|
+
* genericOAuth({
|
|
25
|
+
* config: [
|
|
26
|
+
* // Japan channel
|
|
27
|
+
* line({
|
|
28
|
+
* providerId: "line-jp",
|
|
29
|
+
* clientId: process.env.LINE_JP_CLIENT_ID,
|
|
30
|
+
* clientSecret: process.env.LINE_JP_CLIENT_SECRET,
|
|
31
|
+
* }),
|
|
32
|
+
* // Thailand channel
|
|
33
|
+
* line({
|
|
34
|
+
* providerId: "line-th",
|
|
35
|
+
* clientId: process.env.LINE_TH_CLIENT_ID,
|
|
36
|
+
* clientSecret: process.env.LINE_TH_CLIENT_SECRET,
|
|
37
|
+
* }),
|
|
38
|
+
* // Taiwan channel
|
|
39
|
+
* line({
|
|
40
|
+
* providerId: "line-tw",
|
|
41
|
+
* clientId: process.env.LINE_TW_CLIENT_ID,
|
|
42
|
+
* clientSecret: process.env.LINE_TW_CLIENT_SECRET,
|
|
43
|
+
* }),
|
|
44
|
+
* ],
|
|
45
|
+
* }),
|
|
46
|
+
* ],
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function line(options: LineOptions): GenericOAuthConfig;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { decodeJwt } from "jose";
|
|
2
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
+
// src/plugins/generic-oauth/providers/line.ts
|
|
4
|
+
/**
|
|
5
|
+
* LINE OAuth provider helper
|
|
6
|
+
*
|
|
7
|
+
* LINE requires separate channels for different countries (Japan, Thailand, Taiwan, etc.).
|
|
8
|
+
* Each channel has its own clientId and clientSecret. To support multiple countries,
|
|
9
|
+
* call this function multiple times with different providerIds and credentials.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { genericOAuth, line } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
14
|
+
*
|
|
15
|
+
* export const auth = entroAuth({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* genericOAuth({
|
|
18
|
+
* config: [
|
|
19
|
+
* // Japan channel
|
|
20
|
+
* line({
|
|
21
|
+
* providerId: "line-jp",
|
|
22
|
+
* clientId: process.env.LINE_JP_CLIENT_ID,
|
|
23
|
+
* clientSecret: process.env.LINE_JP_CLIENT_SECRET,
|
|
24
|
+
* }),
|
|
25
|
+
* // Thailand channel
|
|
26
|
+
* line({
|
|
27
|
+
* providerId: "line-th",
|
|
28
|
+
* clientId: process.env.LINE_TH_CLIENT_ID,
|
|
29
|
+
* clientSecret: process.env.LINE_TH_CLIENT_SECRET,
|
|
30
|
+
* }),
|
|
31
|
+
* // Taiwan channel
|
|
32
|
+
* line({
|
|
33
|
+
* providerId: "line-tw",
|
|
34
|
+
* clientId: process.env.LINE_TW_CLIENT_ID,
|
|
35
|
+
* clientSecret: process.env.LINE_TW_CLIENT_SECRET,
|
|
36
|
+
* }),
|
|
37
|
+
* ],
|
|
38
|
+
* }),
|
|
39
|
+
* ],
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function line(options) {
|
|
44
|
+
const defaultScopes = [
|
|
45
|
+
"openid",
|
|
46
|
+
"profile",
|
|
47
|
+
"email"
|
|
48
|
+
];
|
|
49
|
+
const authorizationUrl = "https://access.line.me/oauth2/v2.1/authorize";
|
|
50
|
+
const tokenUrl = "https://api.line.me/oauth2/v2.1/token";
|
|
51
|
+
const userInfoUrl = "https://api.line.me/oauth2/v2.1/userinfo";
|
|
52
|
+
const getUserInfo = async (tokens) => {
|
|
53
|
+
let profile = null;
|
|
54
|
+
if (tokens.idToken) try {
|
|
55
|
+
profile = decodeJwt(tokens.idToken);
|
|
56
|
+
} catch {}
|
|
57
|
+
if (!profile) {
|
|
58
|
+
const { data, error } = await betterFetch(userInfoUrl, { headers: { Authorization: `Bearer ${tokens.accessToken}` } });
|
|
59
|
+
if (error || !data) return null;
|
|
60
|
+
profile = data;
|
|
61
|
+
}
|
|
62
|
+
if (!profile) return null;
|
|
63
|
+
return {
|
|
64
|
+
sub: profile.sub,
|
|
65
|
+
name: profile.name,
|
|
66
|
+
email: profile.email,
|
|
67
|
+
image: profile.picture,
|
|
68
|
+
emailVerified: false
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
providerId: options.providerId ?? "line",
|
|
73
|
+
accountSubject: ({ profile }) => profile.sub ?? "",
|
|
74
|
+
authorizationUrl,
|
|
75
|
+
tokenUrl,
|
|
76
|
+
userInfoUrl,
|
|
77
|
+
clientId: options.clientId,
|
|
78
|
+
clientSecret: options.clientSecret,
|
|
79
|
+
tokenEndpointAuth: options.tokenEndpointAuth,
|
|
80
|
+
scopes: options.scopes ?? defaultScopes,
|
|
81
|
+
redirectURI: options.redirectURI,
|
|
82
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
83
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
84
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
85
|
+
pkce: options.pkce,
|
|
86
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
87
|
+
disableSignUp: options.disableSignUp,
|
|
88
|
+
overrideUserInfo: options.overrideUserInfo,
|
|
89
|
+
getUserInfo
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export { line };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface MicrosoftEntraIdOptions extends BaseOAuthProviderOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Concrete Microsoft Entra ID tenant GUID.
|
|
6
|
+
*
|
|
7
|
+
* Use Entro Auth's built-in Microsoft provider for the multi-tenant
|
|
8
|
+
* `common`, `organizations`, or `consumers` authorities. Those authorities
|
|
9
|
+
* require ID-token claim validation to derive the account's actual issuer.
|
|
10
|
+
*/
|
|
11
|
+
tenantId: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Microsoft Entra ID (Azure AD) OAuth provider helper
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { genericOAuth, microsoftEntraId } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
19
|
+
*
|
|
20
|
+
* export const auth = entroAuth({
|
|
21
|
+
* plugins: [
|
|
22
|
+
* genericOAuth({
|
|
23
|
+
* config: [
|
|
24
|
+
* microsoftEntraId({
|
|
25
|
+
* clientId: process.env.MS_APP_ID,
|
|
26
|
+
* clientSecret: process.env.MS_CLIENT_SECRET,
|
|
27
|
+
* tenantId: process.env.MS_TENANT_ID,
|
|
28
|
+
* }),
|
|
29
|
+
* ],
|
|
30
|
+
* }),
|
|
31
|
+
* ],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function microsoftEntraId(options: MicrosoftEntraIdOptions): GenericOAuthConfig<"microsoft-entra-id">;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { signForTokenEndpoint } from "./token-endpoint-audience.mjs";
|
|
2
|
+
import { decodeJwt } from "jose";
|
|
3
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
4
|
+
import { createPlaceholderEmail } from "@entro314labs/entro-auth-core/utils/email";
|
|
5
|
+
// src/plugins/generic-oauth/providers/microsoft-entra-id.ts
|
|
6
|
+
function getMicrosoftProfileName(profile) {
|
|
7
|
+
return profile.name ?? (`${profile.given_name ?? profile.givenname ?? ""} ${profile.family_name ?? profile.familyname ?? ""}`.trim() || void 0);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Microsoft Entra ID (Azure AD) OAuth provider helper
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { genericOAuth, microsoftEntraId } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
15
|
+
*
|
|
16
|
+
* export const auth = entroAuth({
|
|
17
|
+
* plugins: [
|
|
18
|
+
* genericOAuth({
|
|
19
|
+
* config: [
|
|
20
|
+
* microsoftEntraId({
|
|
21
|
+
* clientId: process.env.MS_APP_ID,
|
|
22
|
+
* clientSecret: process.env.MS_CLIENT_SECRET,
|
|
23
|
+
* tenantId: process.env.MS_TENANT_ID,
|
|
24
|
+
* }),
|
|
25
|
+
* ],
|
|
26
|
+
* }),
|
|
27
|
+
* ],
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function microsoftEntraId(options) {
|
|
32
|
+
const defaultScopes = [
|
|
33
|
+
"openid",
|
|
34
|
+
"profile",
|
|
35
|
+
"email"
|
|
36
|
+
];
|
|
37
|
+
const tenantId = typeof options.tenantId === "string" ? options.tenantId.toLowerCase() : "";
|
|
38
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(tenantId)) throw new Error("The generic microsoftEntraId helper requires a concrete Microsoft Entra tenant GUID. Use the built-in Microsoft provider for common, organizations, or consumers.");
|
|
39
|
+
const authorizationUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/authorize`;
|
|
40
|
+
const tokenUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;
|
|
41
|
+
const discoveryUrl = `https://login.microsoftonline.com/${tenantId}/v2.0/.well-known/openid-configuration`;
|
|
42
|
+
const userInfoUrl = "https://graph.microsoft.com/oidc/userinfo";
|
|
43
|
+
const getUserInfo = async (tokens) => {
|
|
44
|
+
if (!tokens.idToken) return null;
|
|
45
|
+
let tokenProfile;
|
|
46
|
+
try {
|
|
47
|
+
tokenProfile = decodeJwt(tokens.idToken);
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const oid = typeof tokenProfile.oid === "string" && tokenProfile.oid.trim().length > 0 ? tokenProfile.oid : void 0;
|
|
52
|
+
if (!oid) return null;
|
|
53
|
+
const tokenEmail = tokenProfile.email;
|
|
54
|
+
const tokenUserInfo = {
|
|
55
|
+
...tokenProfile,
|
|
56
|
+
name: getMicrosoftProfileName(tokenProfile),
|
|
57
|
+
email: tokenEmail ?? createPlaceholderEmail({
|
|
58
|
+
identifier: oid,
|
|
59
|
+
namespace: "microsoft-entra-id"
|
|
60
|
+
}),
|
|
61
|
+
image: tokenProfile.picture,
|
|
62
|
+
emailVerified: tokenEmail ? tokenProfile.email_verified ?? false : false
|
|
63
|
+
};
|
|
64
|
+
if (!tokens.accessToken) return tokenUserInfo;
|
|
65
|
+
const { data: profile, error } = await betterFetch(userInfoUrl, { headers: { Authorization: `Bearer ${tokens.accessToken}` } });
|
|
66
|
+
if (error || !profile) return tokenUserInfo;
|
|
67
|
+
if (typeof tokenProfile.sub !== "string" || profile.sub !== tokenProfile.sub) return tokenUserInfo;
|
|
68
|
+
const emailClaim = tokenProfile.email ?? profile.email;
|
|
69
|
+
return {
|
|
70
|
+
...profile,
|
|
71
|
+
...tokenProfile,
|
|
72
|
+
name: getMicrosoftProfileName(tokenProfile) ?? getMicrosoftProfileName(profile),
|
|
73
|
+
email: emailClaim ?? createPlaceholderEmail({
|
|
74
|
+
identifier: oid,
|
|
75
|
+
namespace: "microsoft-entra-id"
|
|
76
|
+
}),
|
|
77
|
+
image: tokenProfile.picture ?? profile.picture,
|
|
78
|
+
emailVerified: emailClaim != null ? tokenProfile.email_verified ?? profile.email_verified ?? false : false
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
providerId: "microsoft-entra-id",
|
|
83
|
+
accountSubject: ({ profile }) => typeof profile.oid === "string" ? profile.oid : "",
|
|
84
|
+
discoveryUrl,
|
|
85
|
+
requireIdTokenVerification: true,
|
|
86
|
+
authorizationUrl,
|
|
87
|
+
tokenUrl,
|
|
88
|
+
userInfoUrl,
|
|
89
|
+
clientId: options.clientId,
|
|
90
|
+
clientSecret: options.clientSecret,
|
|
91
|
+
tokenEndpointAuth: signForTokenEndpoint(options.tokenEndpointAuth),
|
|
92
|
+
scopes: options.scopes ?? defaultScopes,
|
|
93
|
+
redirectURI: options.redirectURI,
|
|
94
|
+
endSessionEndpoint: options.endSessionEndpoint,
|
|
95
|
+
postLogoutRedirectURI: options.postLogoutRedirectURI,
|
|
96
|
+
disableProviderLogout: options.disableProviderLogout,
|
|
97
|
+
pkce: options.pkce,
|
|
98
|
+
disableImplicitSignUp: options.disableImplicitSignUp,
|
|
99
|
+
disableSignUp: options.disableSignUp,
|
|
100
|
+
overrideUserInfo: options.overrideUserInfo,
|
|
101
|
+
getUserInfo
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export { microsoftEntraId };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GenericOAuthConfig } from "../types.mjs";
|
|
2
|
+
import { BaseOAuthProviderOptions } from "../index.mjs";
|
|
3
|
+
export interface OktaOptions extends BaseOAuthProviderOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Okta issuer URL (e.g., https://dev-xxxxx.okta.com/oauth2/default)
|
|
6
|
+
* This will be used to construct the discovery URL.
|
|
7
|
+
*/
|
|
8
|
+
issuer: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Okta OAuth provider helper
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { genericOAuth, okta } from "@entro314labs/entro-auth/plugins/generic-oauth";
|
|
16
|
+
*
|
|
17
|
+
* export const auth = entroAuth({
|
|
18
|
+
* plugins: [
|
|
19
|
+
* genericOAuth({
|
|
20
|
+
* config: [
|
|
21
|
+
* okta({
|
|
22
|
+
* clientId: process.env.OKTA_CLIENT_ID,
|
|
23
|
+
* clientSecret: process.env.OKTA_CLIENT_SECRET,
|
|
24
|
+
* issuer: process.env.OKTA_ISSUER,
|
|
25
|
+
* }),
|
|
26
|
+
* ],
|
|
27
|
+
* }),
|
|
28
|
+
* ],
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function okta(options: OktaOptions): GenericOAuthConfig<"okta">;
|