@better-auth/core 1.6.7 → 1.6.9
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/dist/context/global.mjs +1 -1
- package/dist/db/adapter/factory.mjs +1 -2
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/social-providers/apple.d.mts +9 -2
- package/dist/social-providers/discord.d.mts +1 -1
- package/dist/social-providers/facebook.d.mts +2 -2
- package/dist/social-providers/facebook.mjs +1 -1
- package/dist/social-providers/github.d.mts +1 -1
- package/dist/social-providers/linkedin.d.mts +2 -2
- package/dist/social-providers/linkedin.mjs +1 -1
- package/dist/social-providers/microsoft-entra-id.d.mts +1 -1
- package/package.json +1 -1
- package/src/db/adapter/factory.ts +3 -3
- package/src/db/get-tables.ts +2 -0
- package/src/db/schema/user.ts +3 -0
- package/src/social-providers/apple.ts +1 -1
- package/src/social-providers/discord.ts +1 -1
- package/src/social-providers/facebook.ts +3 -3
- package/src/social-providers/github.ts +1 -1
- package/src/social-providers/linkedin.ts +3 -3
- package/src/social-providers/microsoft-entra-id.ts +1 -1
package/dist/context/global.mjs
CHANGED
|
@@ -2,8 +2,6 @@ import { BetterAuthError } from "../../error/index.mjs";
|
|
|
2
2
|
import { getAuthTables } from "../get-tables.mjs";
|
|
3
3
|
import { getColorDepth } from "../../env/color-depth.mjs";
|
|
4
4
|
import { TTY_COLORS, createLogger } from "../../env/logger.mjs";
|
|
5
|
-
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME } from "../../instrumentation/attributes.mjs";
|
|
6
|
-
import { withSpan } from "../../instrumentation/tracer.mjs";
|
|
7
5
|
import { safeJSONParse } from "../../utils/json.mjs";
|
|
8
6
|
import { initGetDefaultModelName } from "./get-default-model-name.mjs";
|
|
9
7
|
import { initGetDefaultFieldName } from "./get-default-field-name.mjs";
|
|
@@ -12,6 +10,7 @@ import { initGetFieldAttributes } from "./get-field-attributes.mjs";
|
|
|
12
10
|
import { initGetFieldName } from "./get-field-name.mjs";
|
|
13
11
|
import { initGetModelName } from "./get-model-name.mjs";
|
|
14
12
|
import { withApplyDefault } from "./utils.mjs";
|
|
13
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, withSpan } from "@better-auth/core/instrumentation";
|
|
15
14
|
//#region src/db/adapter/factory.ts
|
|
16
15
|
let debugLogs = [];
|
|
17
16
|
let transactionId = -1;
|
|
@@ -2,7 +2,7 @@ import { ATTR_HTTP_RESPONSE_STATUS_CODE } from "./attributes.mjs";
|
|
|
2
2
|
import { getOpenTelemetryAPI } from "./api.mjs";
|
|
3
3
|
//#region src/instrumentation/tracer.ts
|
|
4
4
|
const INSTRUMENTATION_SCOPE = "better-auth";
|
|
5
|
-
const INSTRUMENTATION_VERSION = "1.6.
|
|
5
|
+
const INSTRUMENTATION_VERSION = "1.6.9";
|
|
6
6
|
/**
|
|
7
7
|
* Better-auth uses `throw ctx.redirect(url)` for flow control (e.g. OAuth
|
|
8
8
|
* callbacks). These are APIErrors with 3xx status codes and should not be
|
|
@@ -12,7 +12,7 @@ interface AppleProfile {
|
|
|
12
12
|
* The email address is either the user's real email address or the proxy
|
|
13
13
|
* address, depending on their status private email relay service.
|
|
14
14
|
*/
|
|
15
|
-
email
|
|
15
|
+
email?: string;
|
|
16
16
|
/**
|
|
17
17
|
* A string or Boolean value that indicates whether the service verifies
|
|
18
18
|
* the email. The value can either be a string ("true" or "false") or a
|
|
@@ -93,7 +93,14 @@ declare const apple: (options: AppleOptions) => {
|
|
|
93
93
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
94
94
|
getUserInfo(token: OAuth2Tokens & {
|
|
95
95
|
user?: {
|
|
96
|
-
name
|
|
96
|
+
name /**
|
|
97
|
+
* An Integer value that indicates whether the user appears to be a real
|
|
98
|
+
* person. Use the value of this claim to mitigate fraud. The possible
|
|
99
|
+
* values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For
|
|
100
|
+
* more information, see ASUserDetectionStatus. This claim is present only
|
|
101
|
+
* in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14
|
|
102
|
+
* and later. The claim isn’t present or supported for web-based apps.
|
|
103
|
+
*/?
|
|
97
104
|
/**
|
|
98
105
|
* An Integer value that indicates whether the user appears to be a real
|
|
99
106
|
* person. Use the value of this claim to mitigate fraud. The possible
|
|
@@ -38,7 +38,7 @@ interface DiscordProfile extends Record<string, any> {
|
|
|
38
38
|
/** whether the email on this account has been verified */
|
|
39
39
|
verified: boolean;
|
|
40
40
|
/** the user's email */
|
|
41
|
-
email
|
|
41
|
+
email?: string | null;
|
|
42
42
|
/**
|
|
43
43
|
* the flags on a user's account:
|
|
44
44
|
* https://discord.com/developers/docs/resources/user#user-object-user-flags
|
|
@@ -3,8 +3,8 @@ import { OAuth2Tokens, ProviderOptions } from "../oauth2/oauth-provider.mjs";
|
|
|
3
3
|
interface FacebookProfile {
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
6
|
-
email
|
|
7
|
-
email_verified
|
|
6
|
+
email?: string;
|
|
7
|
+
email_verified?: boolean;
|
|
8
8
|
picture: {
|
|
9
9
|
data: {
|
|
10
10
|
height: number;
|
|
@@ -111,7 +111,7 @@ const facebook = (options) => {
|
|
|
111
111
|
name: profile.name,
|
|
112
112
|
email: profile.email,
|
|
113
113
|
image: profile.picture.data.url,
|
|
114
|
-
emailVerified: profile.email_verified,
|
|
114
|
+
emailVerified: profile.email_verified ?? false,
|
|
115
115
|
...userMap
|
|
116
116
|
},
|
|
117
117
|
data: profile
|
|
@@ -10,8 +10,8 @@ interface LinkedInProfile {
|
|
|
10
10
|
country: string;
|
|
11
11
|
language: string;
|
|
12
12
|
};
|
|
13
|
-
email
|
|
14
|
-
email_verified
|
|
13
|
+
email?: string;
|
|
14
|
+
email_verified?: boolean;
|
|
15
15
|
}
|
|
16
16
|
interface LinkedInOptions extends ProviderOptions<LinkedInProfile> {
|
|
17
17
|
clientId: string;
|
|
@@ -25,7 +25,7 @@ interface MicrosoftEntraIDProfile extends Record<string, any> {
|
|
|
25
25
|
/** The primary username that represents the user */
|
|
26
26
|
preferred_username: string;
|
|
27
27
|
/** User's email address */
|
|
28
|
-
email
|
|
28
|
+
email?: string;
|
|
29
29
|
/** Human-readable value that identifies the subject of the token */
|
|
30
30
|
name: string;
|
|
31
31
|
/** Matches the parameter included in the original authorize request */
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createLogger, getColorDepth, TTY_COLORS } from "../../env";
|
|
2
|
-
import { BetterAuthError } from "../../error";
|
|
3
1
|
import {
|
|
4
2
|
ATTR_DB_COLLECTION_NAME,
|
|
5
3
|
ATTR_DB_OPERATION_NAME,
|
|
6
4
|
withSpan,
|
|
7
|
-
} from "
|
|
5
|
+
} from "@better-auth/core/instrumentation";
|
|
6
|
+
import { createLogger, getColorDepth, TTY_COLORS } from "../../env";
|
|
7
|
+
import { BetterAuthError } from "../../error";
|
|
8
8
|
import type { BetterAuthOptions } from "../../types";
|
|
9
9
|
import { safeJSONParse } from "../../utils/json";
|
|
10
10
|
import { getAuthTables } from "../get-tables";
|
package/src/db/get-tables.ts
CHANGED
|
@@ -162,6 +162,8 @@ export const getAuthTables = (
|
|
|
162
162
|
},
|
|
163
163
|
email: {
|
|
164
164
|
type: "string",
|
|
165
|
+
// TODO(#9124): drop required+unique in v2; use a partial unique
|
|
166
|
+
// index where email is not null (see schema/user.ts).
|
|
165
167
|
unique: true,
|
|
166
168
|
required: true,
|
|
167
169
|
fieldName: options.user?.fields?.email || "email",
|
package/src/db/schema/user.ts
CHANGED
|
@@ -7,6 +7,9 @@ import type {
|
|
|
7
7
|
import { coreSchema } from "./shared";
|
|
8
8
|
|
|
9
9
|
export const userSchema = coreSchema.extend({
|
|
10
|
+
// TODO(#9124): widen to nullish in v2. OAuth providers (Discord phone-only,
|
|
11
|
+
// Apple subsequent sign-ins, etc.) can legitimately omit email; identity
|
|
12
|
+
// must key on (providerId, accountId) per OpenID Connect Core §5.7.
|
|
10
13
|
email: z.string().transform((val) => val.toLowerCase()),
|
|
11
14
|
emailVerified: z.boolean().default(false),
|
|
12
15
|
name: z.string(),
|
|
@@ -22,7 +22,7 @@ export interface AppleProfile {
|
|
|
22
22
|
* The email address is either the user's real email address or the proxy
|
|
23
23
|
* address, depending on their status private email relay service.
|
|
24
24
|
*/
|
|
25
|
-
email
|
|
25
|
+
email?: string;
|
|
26
26
|
/**
|
|
27
27
|
* A string or Boolean value that indicates whether the service verifies
|
|
28
28
|
* the email. The value can either be a string ("true" or "false") or a
|
|
@@ -41,7 +41,7 @@ export interface DiscordProfile extends Record<string, any> {
|
|
|
41
41
|
/** whether the email on this account has been verified */
|
|
42
42
|
verified: boolean;
|
|
43
43
|
/** the user's email */
|
|
44
|
-
email
|
|
44
|
+
email?: string | null;
|
|
45
45
|
/**
|
|
46
46
|
* the flags on a user's account:
|
|
47
47
|
* https://discord.com/developers/docs/resources/user#user-object-user-flags
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
export interface FacebookProfile {
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
15
|
-
email
|
|
16
|
-
email_verified
|
|
15
|
+
email?: string;
|
|
16
|
+
email_verified?: boolean;
|
|
17
17
|
picture: {
|
|
18
18
|
data: {
|
|
19
19
|
height: number;
|
|
@@ -204,7 +204,7 @@ export const facebook = (options: FacebookOptions) => {
|
|
|
204
204
|
name: profile.name,
|
|
205
205
|
email: profile.email,
|
|
206
206
|
image: profile.picture.data.url,
|
|
207
|
-
emailVerified: profile.email_verified,
|
|
207
|
+
emailVerified: profile.email_verified ?? false,
|
|
208
208
|
...userMap,
|
|
209
209
|
},
|
|
210
210
|
data: profile,
|
|
@@ -16,8 +16,8 @@ export interface LinkedInProfile {
|
|
|
16
16
|
country: string;
|
|
17
17
|
language: string;
|
|
18
18
|
};
|
|
19
|
-
email
|
|
20
|
-
email_verified
|
|
19
|
+
email?: string;
|
|
20
|
+
email_verified?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface LinkedInOptions extends ProviderOptions<LinkedInProfile> {
|
|
@@ -98,7 +98,7 @@ export const linkedin = (options: LinkedInOptions) => {
|
|
|
98
98
|
id: profile.sub,
|
|
99
99
|
name: profile.name,
|
|
100
100
|
email: profile.email,
|
|
101
|
-
emailVerified: profile.email_verified
|
|
101
|
+
emailVerified: profile.email_verified ?? false,
|
|
102
102
|
image: profile.picture,
|
|
103
103
|
...userMap,
|
|
104
104
|
},
|
|
@@ -36,7 +36,7 @@ export interface MicrosoftEntraIDProfile extends Record<string, any> {
|
|
|
36
36
|
/** The primary username that represents the user */
|
|
37
37
|
preferred_username: string;
|
|
38
38
|
/** User's email address */
|
|
39
|
-
email
|
|
39
|
+
email?: string;
|
|
40
40
|
/** Human-readable value that identifies the subject of the token */
|
|
41
41
|
name: string;
|
|
42
42
|
/** Matches the parameter included in the original authorize request */
|