@better-auth/electron 1.7.0-beta.0 → 1.7.0-beta.2

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/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as PACKAGE_VERSION } from "./version-CzfTSPRz.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-BVHIqaH7.mjs";
2
2
  import { n as isProcessType, r as parseProtocolScheme, t as getChannelPrefixWithDelimiter } from "./utils-DxDKRT6e.mjs";
3
3
  import { BetterAuthError } from "@better-auth/core/error";
4
4
  import { base64, base64Url } from "@better-auth/utils/base64";
@@ -11,6 +11,7 @@ import { signInSocial } from "better-auth/api";
11
11
  import { parseSetCookieHeader } from "better-auth/cookies";
12
12
  import electron, { shell } from "electron";
13
13
  import { isDevelopment as isDevelopment$1 } from "@better-auth/core/env";
14
+ import { isPublicRoutableHost } from "@better-auth/core/utils/host";
14
15
  import { resolve } from "node:path";
15
16
  //#region src/user.ts
16
17
  const { net } = electron;
@@ -37,7 +38,7 @@ async function fetchUserImage(baseURL, url, options) {
37
38
  parsed = new URL(relative, base);
38
39
  }
39
40
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
40
- if (!isDevelopment$1() && isLocalOrigin(parsed)) return null;
41
+ if (!isDevelopment$1() && !isPublicRoutableHost(parsed.hostname)) return null;
41
42
  resolvedUrl = parsed.href;
42
43
  } catch {
43
44
  return null;
@@ -116,25 +117,6 @@ async function decodeDataImageUrl(url, options) {
116
117
  return null;
117
118
  }
118
119
  }
119
- function isLocalOrigin(parsed) {
120
- const hostname = parsed.hostname.toLowerCase();
121
- if (hostname === "localhost") return true;
122
- const m = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
123
- if (m) {
124
- const a = Number(m[1]);
125
- const b = Number(m[2]);
126
- if (a === 127) return true;
127
- if (a === 10) return true;
128
- if (a === 172 && b >= 16 && b <= 31) return true;
129
- if (a === 192 && b === 168) return true;
130
- if (a === 169 && b === 254) return true;
131
- return false;
132
- }
133
- const h = hostname.replace(/^\[|\]$/g, "");
134
- if (h === "::1" || /^(0:){7}1$/.test(h) || h === "0:0:0:0:0:0:0:1") return true;
135
- if (/^fe[89ab][0-9a-f]/i.test(h)) return true;
136
- return false;
137
- }
138
120
  function detectImageType(bytes) {
139
121
  if (bytes.length < 12) return null;
140
122
  if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10) return "image/png";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as PACKAGE_VERSION } from "./version-CzfTSPRz.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-BVHIqaH7.mjs";
2
2
  import { createAuthMiddleware } from "@better-auth/core/api";
3
3
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
4
4
  import { base64Url } from "@better-auth/utils/base64";
@@ -7,7 +7,6 @@ import { generateRandomString } from "better-auth/crypto";
7
7
  import * as z from "zod";
8
8
  import { Buffer } from "node:buffer";
9
9
  import { timingSafeEqual } from "node:crypto";
10
- import { SocialProviderListEnum } from "@better-auth/core/social-providers";
11
10
  import { safeJSONParse as safeJSONParse$1 } from "@better-auth/core/utils/json";
12
11
  import { createHash } from "@better-auth/utils/hash";
13
12
  import { betterFetch } from "@better-fetch/fetch";
@@ -117,8 +116,6 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
117
116
  }
118
117
  }
119
118
  }, async (ctx) => {
120
- const isSocialProvider = SocialProviderListEnum.safeParse(ctx.query.provider);
121
- if (!isSocialProvider && !ctx.context.getPlugin("generic-oauth")) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.PROVIDER_NOT_FOUND);
122
119
  const headers = new Headers(ctx.request?.headers);
123
120
  headers.set("origin", new URL(ctx.context.baseURL).origin);
124
121
  let setCookie = null;
@@ -127,7 +124,7 @@ const electronInitOAuthProxy = (opts) => createAuthEndpoint("/electron/init-oaut
127
124
  searchParams.set("code_challenge", ctx.query.code_challenge);
128
125
  searchParams.set("code_challenge_method", ctx.query.code_challenge_method || "plain");
129
126
  searchParams.set("state", ctx.query.state);
130
- const res = await betterFetch(`${isSocialProvider ? "/sign-in/social" : "/sign-in/oauth2"}?${searchParams.toString()}`, {
127
+ const res = await betterFetch(`/sign-in/social?${searchParams.toString()}`, {
131
128
  baseURL: ctx.context.baseURL,
132
129
  method: "POST",
133
130
  body: { provider: ctx.query.provider },
@@ -201,7 +198,7 @@ const electron = (options) => {
201
198
  ...options || {}
202
199
  };
203
200
  const hookMatcher = (ctx) => {
204
- return !!(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/verify-email") || ctx.path?.startsWith("/one-tap/callback") || ctx.path?.startsWith("/passkey/verify-authentication") || ctx.path?.startsWith("/phone-number/verify"));
201
+ return !!(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/verify-email") || ctx.path?.startsWith("/one-tap/callback") || ctx.path?.startsWith("/passkey/verify-authentication") || ctx.path?.startsWith("/phone-number/verify"));
205
202
  };
206
203
  const handleTransfer = async (ctx, payload) => {
207
204
  const { client_id, state, code_challenge, code_challenge_method = "plain" } = payload;
@@ -676,6 +676,12 @@ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O e
676
676
  * @returns True if the id token is valid, false otherwise
677
677
  */
678
678
  verifyIdToken?: ((token: string, nonce?: string) => Promise<boolean>) | undefined;
679
+ /**
680
+ * The expected issuer identifier for this provider (RFC 9207).
681
+ * When set, the callback handler validates the `iss` query parameter
682
+ * against this value to prevent authorization server mix-up attacks.
683
+ */
684
+ issuer?: string | undefined;
679
685
  /**
680
686
  * Disable implicit sign up for new users. When set to true for the provider,
681
687
  * sign-in need to be called with with requestSignUp as true to create new users.
@@ -861,7 +867,7 @@ interface AppleNonConformUser {
861
867
  email: string;
862
868
  }
863
869
  interface AppleOptions extends ProviderOptions<AppleProfile> {
864
- clientId: string;
870
+ clientId: string | string[];
865
871
  appBundleIdentifier?: string | undefined;
866
872
  audience?: (string | string[]) | undefined;
867
873
  }
@@ -908,7 +914,7 @@ interface CognitoProfile {
908
914
  [key: string]: any;
909
915
  }
910
916
  interface CognitoOptions extends ProviderOptions<CognitoProfile> {
911
- clientId: string;
917
+ clientId: string | string[];
912
918
  /**
913
919
  * The Cognito domain (e.g., "your-app.auth.us-east-1.amazoncognito.com")
914
920
  */
@@ -1015,7 +1021,7 @@ interface FacebookProfile {
1015
1021
  };
1016
1022
  }
1017
1023
  interface FacebookOptions extends ProviderOptions<FacebookProfile> {
1018
- clientId: string;
1024
+ clientId: string | string[];
1019
1025
  /**
1020
1026
  * Extend list of fields to retrieve from the Facebook user profile.
1021
1027
  *
@@ -1198,7 +1204,7 @@ interface MicrosoftEntraIDProfile extends Record<string, any> {
1198
1204
  given_name: string;
1199
1205
  }
1200
1206
  interface MicrosoftOptions extends ProviderOptions<MicrosoftEntraIDProfile> {
1201
- clientId: string;
1207
+ clientId: string | string[];
1202
1208
  /**
1203
1209
  * The tenant ID of the Microsoft account
1204
1210
  * @default "common"
@@ -1249,7 +1255,7 @@ interface GoogleProfile {
1249
1255
  sub: string;
1250
1256
  }
1251
1257
  interface GoogleOptions extends ProviderOptions<GoogleProfile> {
1252
- clientId: string;
1258
+ clientId: string | string[];
1253
1259
  /**
1254
1260
  * The access type to use for the authorization code request
1255
1261
  */
package/dist/proxy.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as PACKAGE_VERSION } from "./version-CzfTSPRz.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-BVHIqaH7.mjs";
2
2
  import { r as parseProtocolScheme } from "./utils-DxDKRT6e.mjs";
3
3
  import { parseCookies } from "better-auth/cookies";
4
4
  //#region src/proxy.ts
@@ -1,5 +1,5 @@
1
1
  //#endregion
2
2
  //#region src/version.ts
3
- const PACKAGE_VERSION = "1.7.0-beta.0";
3
+ const PACKAGE_VERSION = "1.7.0-beta.2";
4
4
  //#endregion
5
5
  export { PACKAGE_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/electron",
3
- "version": "1.7.0-beta.0",
3
+ "version": "1.7.0-beta.2",
4
4
  "description": "Better Auth integration for Electron applications.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -78,10 +78,10 @@
78
78
  "devDependencies": {
79
79
  "@types/better-sqlite3": "^7.6.13",
80
80
  "better-sqlite3": "^12.6.2",
81
- "electron": "^38.8.4",
81
+ "electron": "^41.2.2",
82
82
  "tsdown": "0.21.1",
83
- "@better-auth/core": "1.7.0-beta.0",
84
- "better-auth": "1.7.0-beta.0"
83
+ "@better-auth/core": "1.7.0-beta.2",
84
+ "better-auth": "1.7.0-beta.2"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@better-auth/utils": "0.4.0",
@@ -89,8 +89,8 @@
89
89
  "better-call": "1.3.5",
90
90
  "conf": "^15.0.2",
91
91
  "electron": ">=36.0.0",
92
- "@better-auth/core": "^1.7.0-beta.0",
93
- "better-auth": "^1.7.0-beta.0"
92
+ "@better-auth/core": "^1.7.0-beta.2",
93
+ "better-auth": "^1.7.0-beta.2"
94
94
  },
95
95
  "peerDependenciesMeta": {
96
96
  "electron": {