better-auth
Advanced tools
| import { GenericOAuthConfig } from "../types.mjs"; | ||
| import { BaseOAuthProviderOptions } from "../index.mjs"; | ||
| //#region src/plugins/generic-oauth/providers/yandex.d.ts | ||
| interface YandexOptions extends BaseOAuthProviderOptions {} | ||
| /** | ||
| * Yandex OAuth provider helper | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { genericOAuth, yandex } from "better-auth/plugins/generic-oauth"; | ||
| * | ||
| * export const auth = betterAuth({ | ||
| * plugins: [ | ||
| * genericOAuth({ | ||
| * config: [ | ||
| * yandex({ | ||
| * clientId: process.env.YANDEX_CLIENT_ID, | ||
| * clientSecret: process.env.YANDEX_CLIENT_SECRET, | ||
| * }), | ||
| * ], | ||
| * }), | ||
| * ], | ||
| * }); | ||
| * ``` | ||
| */ | ||
| declare function yandex(options: YandexOptions): GenericOAuthConfig; | ||
| //#endregion | ||
| export { YandexOptions, yandex }; |
| import { betterFetch } from "@better-fetch/fetch"; | ||
| //#region src/plugins/generic-oauth/providers/yandex.ts | ||
| /** | ||
| * Yandex OAuth provider helper | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { genericOAuth, yandex } from "better-auth/plugins/generic-oauth"; | ||
| * | ||
| * export const auth = betterAuth({ | ||
| * plugins: [ | ||
| * genericOAuth({ | ||
| * config: [ | ||
| * yandex({ | ||
| * clientId: process.env.YANDEX_CLIENT_ID, | ||
| * clientSecret: process.env.YANDEX_CLIENT_SECRET, | ||
| * }), | ||
| * ], | ||
| * }), | ||
| * ], | ||
| * }); | ||
| * ``` | ||
| */ | ||
| function yandex(options) { | ||
| const defaultScopes = [ | ||
| "login:info", | ||
| "login:email", | ||
| "login:avatar" | ||
| ]; | ||
| const getUserInfo = async (tokens) => { | ||
| const { data: profile, error } = await betterFetch("https://login.yandex.ru/info?format=json", { | ||
| method: "GET", | ||
| headers: { Authorization: `OAuth ${tokens.accessToken}` } | ||
| }); | ||
| if (error || !profile) return null; | ||
| const email = profile.default_email ?? profile.emails?.[0]; | ||
| if (!email) return null; | ||
| return { | ||
| id: profile.id, | ||
| name: profile.display_name ?? profile.real_name ?? profile.first_name ?? profile.login, | ||
| email, | ||
| emailVerified: false, | ||
| image: !profile.is_avatar_empty && profile.default_avatar_id ? `https://avatars.yandex.net/get-yapic/${profile.default_avatar_id}/islands-200` : void 0 | ||
| }; | ||
| }; | ||
| return { | ||
| providerId: "yandex", | ||
| authorizationUrl: "https://oauth.yandex.com/authorize", | ||
| tokenUrl: "https://oauth.yandex.com/token", | ||
| clientId: options.clientId, | ||
| clientSecret: options.clientSecret, | ||
| tokenEndpointAuth: options.tokenEndpointAuth, | ||
| scopes: options.scopes ?? defaultScopes, | ||
| redirectURI: options.redirectURI, | ||
| pkce: options.pkce, | ||
| disableImplicitSignUp: options.disableImplicitSignUp, | ||
| disableSignUp: options.disableSignUp, | ||
| overrideUserInfo: options.overrideUserInfo, | ||
| getUserInfo | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { yandex }; |
@@ -277,6 +277,11 @@ import { getSchema } from "./get-schema.mjs"; | ||
| const builder = db.schema.alterTable(table.table); | ||
| if (field.index) { | ||
| if (field.index || field.unique) { | ||
| const indexName = `${table.table}_${fieldName}_${field.unique ? "uidx" : "idx"}`; | ||
| const indexBuilder = db.schema.createIndex(indexName).on(table.table).columns([fieldName]); | ||
| deferredIndexes.push(field.unique ? indexBuilder.unique() : indexBuilder); | ||
| let indexBuilder = db.schema.createIndex(indexName).on(table.table).columns([fieldName]); | ||
| if (field.unique) { | ||
| indexBuilder = indexBuilder.unique(); | ||
| if (field.required === false && dbType === "mssql") indexBuilder = indexBuilder.where(fieldName, "is not", null); | ||
| if (field.required !== false && field.defaultValue !== void 0 && field.defaultValue !== null && typeof field.defaultValue !== "function") logger.warn(`Adding unique column "${fieldName}" to existing table "${table.table}" backfills every existing row with its default value. If the table has more than one row, creating the unique index "${indexName}" will fail; backfill distinct values manually, then re-run the migration or create the index yourself.`); | ||
| } | ||
| deferredIndexes.push(indexBuilder); | ||
| } | ||
@@ -286,5 +291,5 @@ const built = builder.addColumn(fieldName, type, (col) => { | ||
| if (field.references) col = col.references(getReferencePath(field.references.model, field.references.field)).onDelete(field.references.onDelete || "cascade"); | ||
| if (field.unique) col = col.unique(); | ||
| if (field.type === "date" && typeof field.defaultValue === "function" && (dbType === "postgres" || dbType === "mysql" || dbType === "mssql")) if (dbType === "mysql") col = col.defaultTo(sql`CURRENT_TIMESTAMP(3)`); | ||
| else col = col.defaultTo(sql`CURRENT_TIMESTAMP`); | ||
| else if (!(field.unique && field.required === false) && (field.type === "string" || field.type === "number" || field.type === "boolean") && field.defaultValue !== void 0 && field.defaultValue !== null && typeof field.defaultValue !== "function") col = col.defaultTo(typeof field.defaultValue === "boolean" && (dbType === "sqlite" || dbType === "mssql") ? field.defaultValue ? 1 : 0 : field.defaultValue); | ||
| return col; | ||
@@ -291,0 +296,0 @@ }); |
+1
-1
| //#region package.json | ||
| var version = "1.7.0-rc.0"; | ||
| var version = "1.7.0-rc.1"; | ||
| //#endregion | ||
| export { version }; |
@@ -11,2 +11,3 @@ import { GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo } from "./types.mjs"; | ||
| import { SlackOptions, slack } from "./providers/slack.mjs"; | ||
| import { YandexOptions, yandex } from "./providers/yandex.mjs"; | ||
| import { AuthContext } from "@better-auth/core"; | ||
@@ -52,2 +53,2 @@ import * as _better_auth_core_oauth20 from "@better-auth/core/oauth2"; | ||
| //#endregion | ||
| export { Auth0Options, BaseOAuthProviderOptions, type GenericOAuthConfig, type GenericOAuthOptions, type GenericOAuthUserInfo, GumroadOptions, HubSpotOptions, KeycloakOptions, LineOptions, MicrosoftEntraIdOptions, OktaOptions, PatreonOptions, SlackOptions, auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack }; | ||
| export { Auth0Options, BaseOAuthProviderOptions, type GenericOAuthConfig, type GenericOAuthOptions, type GenericOAuthUserInfo, GumroadOptions, HubSpotOptions, KeycloakOptions, LineOptions, MicrosoftEntraIdOptions, OktaOptions, PatreonOptions, SlackOptions, YandexOptions, auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex }; |
@@ -12,2 +12,3 @@ import { PACKAGE_VERSION } from "../../version.mjs"; | ||
| import { slack } from "./providers/slack.mjs"; | ||
| import { yandex } from "./providers/yandex.mjs"; | ||
| import { APIError } from "@better-auth/core/error"; | ||
@@ -242,2 +243,2 @@ import { applyDefaultAccessTokenExpiry, createAuthorizationURL, refreshAccessToken, validateAuthorizationCode, verifyProviderIdToken } from "@better-auth/core/oauth2"; | ||
| //#endregion | ||
| export { auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack }; | ||
| export { auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex }; |
@@ -9,2 +9,3 @@ import { Auth0Options, auth0 } from "./auth0.mjs"; | ||
| import { PatreonOptions, patreon } from "./patreon.mjs"; | ||
| import { SlackOptions, slack } from "./slack.mjs"; | ||
| import { SlackOptions, slack } from "./slack.mjs"; | ||
| import { YandexOptions, yandex } from "./yandex.mjs"; |
@@ -30,2 +30,3 @@ import { InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginIDs } from "../types/plugins.mjs"; | ||
| import { SlackOptions, slack } from "./generic-oauth/providers/slack.mjs"; | ||
| import { YandexOptions, yandex } from "./generic-oauth/providers/yandex.mjs"; | ||
| import { BaseOAuthProviderOptions, genericOAuth } from "./generic-oauth/index.mjs"; | ||
@@ -67,2 +68,2 @@ import { HaveIBeenPwnedOptions, haveIBeenPwned } from "./haveibeenpwned/index.mjs"; | ||
| import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "./organization/organization.mjs"; | ||
| export { AccessControl, AdminOptions, AnonymousOptions, AnonymousSession, ArrayElement, Auth0Options, AuthorizeResponse, BackupCodeOptions, BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationOptions, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, EmailOTPOptions, ExactRoleStatements, FieldSchema, GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo, GoogleRecaptchaOptions, GumroadOptions, HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOptionSchema, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, InferTeam, Invitation, InvitationInput, InvitationStatus, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodOptions, LineOptions, LoginResult, MagicLinkOptions, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, OAuthPopupData, OAuthPopupMessage, OAuthProxyOptions, OTPOptions, OktaOptions, OneTapOptions, OneTimeTokenOptions, OpenAPIModelSchema, OpenAPIOptions, OpenAPIParameter, OpenAPISchema, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, POPUP_MARKER_COOKIE, Path, PatreonOptions, PhoneNumberOptions, Provider, ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, SessionWithImpersonatedBy, SlackOptions, Statements, SubArray, Subset, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, TestCookie, TestHelpers, TestUtilsOptions, TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameOptions, admin, anonymous, auth0, backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, encodeBackupCodes, generateBackupCodes, generateExportedKeyPair, generator, genericOAuth, getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, invitationSchema, invitationStatus, jwt, keycloak, lastLoginMethod, line, magicLink, memberSchema, microsoftEntraId, ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, organizationRoleSchema, organizationSchema, otp2fa, parseRoles, patreon, phoneNumber, resolveSigningKey, role, roleSchema, sec, signJWT, siwe, slack, teamMemberSchema, teamSchema, testUtils, toExpJWT, totp2fa, twoFactor, twoFactorClient, username, verifyBackupCode, verifyJWT }; | ||
| export { AccessControl, AdminOptions, AnonymousOptions, AnonymousSession, ArrayElement, Auth0Options, AuthorizeResponse, BackupCodeOptions, BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationOptions, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, EmailOTPOptions, ExactRoleStatements, FieldSchema, GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo, GoogleRecaptchaOptions, GumroadOptions, HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOptionSchema, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, InferTeam, Invitation, InvitationInput, InvitationStatus, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodOptions, LineOptions, LoginResult, MagicLinkOptions, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, OAuthPopupData, OAuthPopupMessage, OAuthProxyOptions, OTPOptions, OktaOptions, OneTapOptions, OneTimeTokenOptions, OpenAPIModelSchema, OpenAPIOptions, OpenAPIParameter, OpenAPISchema, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, POPUP_MARKER_COOKIE, Path, PatreonOptions, PhoneNumberOptions, Provider, ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, SessionWithImpersonatedBy, SlackOptions, Statements, SubArray, Subset, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, TestCookie, TestHelpers, TestUtilsOptions, TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameOptions, YandexOptions, admin, anonymous, auth0, backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, encodeBackupCodes, generateBackupCodes, generateExportedKeyPair, generator, genericOAuth, getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, invitationSchema, invitationStatus, jwt, keycloak, lastLoginMethod, line, magicLink, memberSchema, microsoftEntraId, ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, organizationRoleSchema, organizationSchema, otp2fa, parseRoles, patreon, phoneNumber, resolveSigningKey, role, roleSchema, sec, signJWT, siwe, slack, teamMemberSchema, teamSchema, testUtils, toExpJWT, totp2fa, twoFactor, twoFactorClient, username, verifyBackupCode, verifyJWT, yandex }; |
@@ -27,2 +27,3 @@ import { createJwk, generateExportedKeyPair, toExpJWT } from "./jwt/utils.mjs"; | ||
| import { slack } from "./generic-oauth/providers/slack.mjs"; | ||
| import { yandex } from "./generic-oauth/providers/yandex.mjs"; | ||
| import { genericOAuth } from "./generic-oauth/index.mjs"; | ||
@@ -48,2 +49,2 @@ import { haveIBeenPwned } from "./haveibeenpwned/index.mjs"; | ||
| import { username } from "./username/index.mjs"; | ||
| export { MULTI_SESSION_ERROR_CODES as ERROR_CODES, HIDE_METADATA, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, POPUP_MARKER_COOKIE, TWO_FACTOR_ERROR_CODES, USERNAME_ERROR_CODES, admin, anonymous, auth0, bearer, captcha, createAccessControl, createJwk, customSession, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, generateExportedKeyPair, genericOAuth, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, jwt, keycloak, lastLoginMethod, line, magicLink, microsoftEntraId, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, parseRoles, patreon, phoneNumber, resolveSigningKey, role, signJWT, siwe, slack, testUtils, toExpJWT, twoFactor, twoFactorClient, username, verifyJWT }; | ||
| export { MULTI_SESSION_ERROR_CODES as ERROR_CODES, HIDE_METADATA, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, POPUP_MARKER_COOKIE, TWO_FACTOR_ERROR_CODES, USERNAME_ERROR_CODES, admin, anonymous, auth0, bearer, captcha, createAccessControl, createJwk, customSession, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, generateExportedKeyPair, genericOAuth, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, jwt, keycloak, lastLoginMethod, line, magicLink, microsoftEntraId, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, parseRoles, patreon, phoneNumber, resolveSigningKey, role, signJWT, siwe, slack, testUtils, toExpJWT, twoFactor, twoFactorClient, username, verifyJWT, yandex }; |
+8
-8
| { | ||
| "name": "better-auth", | ||
| "version": "1.7.0-rc.0", | ||
| "version": "1.7.0-rc.1", | ||
| "description": "The most comprehensive authentication framework for TypeScript.", | ||
@@ -468,9 +468,9 @@ "type": "module", | ||
| "zod": "^4.3.6", | ||
| "@better-auth/core": "1.7.0-rc.0", | ||
| "@better-auth/drizzle-adapter": "1.7.0-rc.0", | ||
| "@better-auth/kysely-adapter": "1.7.0-rc.0", | ||
| "@better-auth/memory-adapter": "1.7.0-rc.0", | ||
| "@better-auth/mongo-adapter": "1.7.0-rc.0", | ||
| "@better-auth/prisma-adapter": "1.7.0-rc.0", | ||
| "@better-auth/telemetry": "1.7.0-rc.0" | ||
| "@better-auth/core": "1.7.0-rc.1", | ||
| "@better-auth/drizzle-adapter": "1.7.0-rc.1", | ||
| "@better-auth/kysely-adapter": "1.7.0-rc.1", | ||
| "@better-auth/memory-adapter": "1.7.0-rc.1", | ||
| "@better-auth/mongo-adapter": "1.7.0-rc.1", | ||
| "@better-auth/prisma-adapter": "1.7.0-rc.1", | ||
| "@better-auth/telemetry": "1.7.0-rc.1" | ||
| }, | ||
@@ -477,0 +477,0 @@ "devDependencies": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1912797
0.21%457
0.44%26279
0.27%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated