@better-auth/core 1.6.24 → 1.6.26

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.
@@ -2,7 +2,7 @@
2
2
  const symbol = Symbol.for("better-auth:global");
3
3
  let bind = null;
4
4
  const __context = {};
5
- const __betterAuthVersion = "1.6.24";
5
+ const __betterAuthVersion = "1.6.26";
6
6
  /**
7
7
  * We store context instance in the globalThis.
8
8
  *
@@ -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.24";
5
+ const INSTRUMENTATION_VERSION = "1.6.26";
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
@@ -70,7 +70,7 @@ interface AppleOptions extends ProviderOptions<AppleProfile> {
70
70
  declare const apple: (options: AppleOptions) => {
71
71
  id: "apple";
72
72
  name: string;
73
- createAuthorizationURL({ state, scopes, redirectURI }: {
73
+ createAuthorizationURL({ state, scopes, redirectURI, codeVerifier }: {
74
74
  state: string;
75
75
  codeVerifier: string;
76
76
  scopes?: string[] | undefined;
@@ -22,7 +22,7 @@ const apple = (options) => {
22
22
  return {
23
23
  id: "apple",
24
24
  name: "Apple",
25
- async createAuthorizationURL({ state, scopes, redirectURI }) {
25
+ async createAuthorizationURL({ state, scopes, redirectURI, codeVerifier }) {
26
26
  if (!getPrimaryClientId(options.clientId) || !options.clientSecret) {
27
27
  logger.error("Client ID and client secret are required for Apple. Make sure to provide them in the options.");
28
28
  throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
@@ -37,6 +37,7 @@ const apple = (options) => {
37
37
  scopes: _scope,
38
38
  state,
39
39
  redirectURI,
40
+ codeVerifier,
40
41
  responseMode: "form_post",
41
42
  responseType: "code id_token"
42
43
  });
@@ -43,7 +43,7 @@ declare const socialProviders: {
43
43
  apple: (options: AppleOptions) => {
44
44
  id: "apple";
45
45
  name: string;
46
- createAuthorizationURL({ state, scopes, redirectURI }: {
46
+ createAuthorizationURL({ state, scopes, redirectURI, codeVerifier }: {
47
47
  state: string;
48
48
  codeVerifier: string;
49
49
  scopes?: string[] | undefined;
@@ -0,0 +1,19 @@
1
+ //#region src/utils/email.d.ts
2
+ interface PlaceholderEmailOptions {
3
+ /**
4
+ * A stable identifier that distinguishes the account within the namespace.
5
+ */
6
+ identifier: string;
7
+ /**
8
+ * A namespace that distinguishes identical identifiers from different sources.
9
+ */
10
+ namespace: string;
11
+ }
12
+ /**
13
+ * Creates a stable, non-routable email address for an account without an email.
14
+ *
15
+ * @throws TypeError if the generated email is invalid.
16
+ */
17
+ declare function createPlaceholderEmail({ identifier, namespace }: PlaceholderEmailOptions): string;
18
+ //#endregion
19
+ export { PlaceholderEmailOptions, createPlaceholderEmail };
@@ -0,0 +1,18 @@
1
+ import * as z from "zod";
2
+ //#region src/utils/email.ts
3
+ /**
4
+ * @see https://www.rfc-editor.org/rfc/rfc6761.html#section-6.4
5
+ */
6
+ const PLACEHOLDER_EMAIL_DOMAIN = "placeholder.invalid";
7
+ /**
8
+ * Creates a stable, non-routable email address for an account without an email.
9
+ *
10
+ * @throws TypeError if the generated email is invalid.
11
+ */
12
+ function createPlaceholderEmail({ identifier, namespace }) {
13
+ const result = z.email().safeParse(`${identifier}@${namespace}.${PLACEHOLDER_EMAIL_DOMAIN}`);
14
+ if (!result.success) throw new TypeError("Invalid placeholder email");
15
+ return result.data;
16
+ }
17
+ //#endregion
18
+ export { createPlaceholderEmail };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/core",
3
- "version": "1.6.24",
3
+ "version": "1.6.26",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -155,8 +155,8 @@
155
155
  "@better-auth/utils": "0.4.2",
156
156
  "@better-fetch/fetch": "1.3.1",
157
157
  "@opentelemetry/api": "^1.9.0",
158
- "@opentelemetry/sdk-trace-base": "^1.30.0",
159
- "@opentelemetry/sdk-trace-node": "^1.30.0",
158
+ "@opentelemetry/sdk-trace-base": "^2.10.0",
159
+ "@opentelemetry/sdk-trace-node": "^2.10.0",
160
160
  "better-call": "1.3.7",
161
161
  "@cloudflare/workers-types": "^4.20250121.0",
162
162
  "jose": "^6.1.3",
@@ -101,7 +101,7 @@ export const apple = (options: AppleOptions) => {
101
101
  return {
102
102
  id: "apple",
103
103
  name: "Apple",
104
- async createAuthorizationURL({ state, scopes, redirectURI }) {
104
+ async createAuthorizationURL({ state, scopes, redirectURI, codeVerifier }) {
105
105
  if (!getPrimaryClientId(options.clientId) || !options.clientSecret) {
106
106
  logger.error(
107
107
  "Client ID and client secret are required for Apple. Make sure to provide them in the options.",
@@ -118,6 +118,7 @@ export const apple = (options: AppleOptions) => {
118
118
  scopes: _scope,
119
119
  state,
120
120
  redirectURI,
121
+ codeVerifier,
121
122
  responseMode: "form_post",
122
123
  responseType: "code id_token",
123
124
  });
@@ -0,0 +1,36 @@
1
+ import * as z from "zod";
2
+
3
+ /**
4
+ * @see https://www.rfc-editor.org/rfc/rfc6761.html#section-6.4
5
+ */
6
+ const PLACEHOLDER_EMAIL_DOMAIN = "placeholder.invalid";
7
+
8
+ export interface PlaceholderEmailOptions {
9
+ /**
10
+ * A stable identifier that distinguishes the account within the namespace.
11
+ */
12
+ identifier: string;
13
+ /**
14
+ * A namespace that distinguishes identical identifiers from different sources.
15
+ */
16
+ namespace: string;
17
+ }
18
+
19
+ /**
20
+ * Creates a stable, non-routable email address for an account without an email.
21
+ *
22
+ * @throws TypeError if the generated email is invalid.
23
+ */
24
+ export function createPlaceholderEmail({
25
+ identifier,
26
+ namespace,
27
+ }: PlaceholderEmailOptions): string {
28
+ const result = z
29
+ .email()
30
+ .safeParse(`${identifier}@${namespace}.${PLACEHOLDER_EMAIL_DOMAIN}`);
31
+ if (!result.success) {
32
+ throw new TypeError("Invalid placeholder email");
33
+ }
34
+
35
+ return result.data;
36
+ }