@sonicjs-cms/core 2.10.1 → 2.11.0

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.
Files changed (71) hide show
  1. package/dist/{chunk-CJYFSKH7.js → chunk-2MXF4RYZ.js} +3 -3
  2. package/dist/{chunk-CJYFSKH7.js.map → chunk-2MXF4RYZ.js.map} +1 -1
  3. package/dist/{chunk-MNFY6DWY.cjs → chunk-56GUBLJE.cjs} +7 -7
  4. package/dist/{chunk-MNFY6DWY.cjs.map → chunk-56GUBLJE.cjs.map} +1 -1
  5. package/dist/{chunk-TWCQVJ6M.cjs → chunk-6BVLPACH.cjs} +37 -2
  6. package/dist/chunk-6BVLPACH.cjs.map +1 -0
  7. package/dist/{chunk-HGKBMUYY.cjs → chunk-ASAEJ4B7.cjs} +252 -125
  8. package/dist/chunk-ASAEJ4B7.cjs.map +1 -0
  9. package/dist/{chunk-5GO3AMON.cjs → chunk-B2ASV5RD.cjs} +8 -8
  10. package/dist/{chunk-5GO3AMON.cjs.map → chunk-B2ASV5RD.cjs.map} +1 -1
  11. package/dist/{chunk-YXTFJPMN.js → chunk-BUU2US2Z.js} +3 -3
  12. package/dist/{chunk-YXTFJPMN.js.map → chunk-BUU2US2Z.js.map} +1 -1
  13. package/dist/{chunk-EAJJHE5F.cjs → chunk-DE5YTNCD.cjs} +2 -2
  14. package/dist/{chunk-EAJJHE5F.cjs.map → chunk-DE5YTNCD.cjs.map} +1 -1
  15. package/dist/{chunk-JFMBYQTC.js → chunk-GKRGDJGG.js} +4 -4
  16. package/dist/{chunk-JFMBYQTC.js.map → chunk-GKRGDJGG.js.map} +1 -1
  17. package/dist/{chunk-FW5CGNM2.js → chunk-H55AYIRI.js} +2 -2
  18. package/dist/{chunk-FW5CGNM2.js.map → chunk-H55AYIRI.js.map} +1 -1
  19. package/dist/{chunk-SDAGUFOF.js → chunk-JTQBNSZX.js} +151 -24
  20. package/dist/chunk-JTQBNSZX.js.map +1 -0
  21. package/dist/{chunk-BUPNX3ZM.js → chunk-NMLFKXWW.js} +37 -2
  22. package/dist/chunk-NMLFKXWW.js.map +1 -0
  23. package/dist/{chunk-E2GKK5HX.cjs → chunk-QLPFENZ2.cjs} +3 -3
  24. package/dist/{chunk-E2GKK5HX.cjs.map → chunk-QLPFENZ2.cjs.map} +1 -1
  25. package/dist/{chunk-KYGRJCZM.cjs → chunk-QTFKZBLC.cjs} +3 -2
  26. package/dist/chunk-QTFKZBLC.cjs.map +1 -0
  27. package/dist/{chunk-LOUJRBXV.js → chunk-QXOZI5Q2.js} +3 -2
  28. package/dist/chunk-QXOZI5Q2.js.map +1 -0
  29. package/dist/index.cjs +685 -114
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +125 -5
  32. package/dist/index.d.ts +125 -5
  33. package/dist/index.js +580 -13
  34. package/dist/index.js.map +1 -1
  35. package/dist/middleware.cjs +29 -29
  36. package/dist/middleware.js +3 -3
  37. package/dist/migrations-UFVJTPVT.js +4 -0
  38. package/dist/{migrations-ADK6YNM2.js.map → migrations-UFVJTPVT.js.map} +1 -1
  39. package/dist/migrations-VNYOSUNE.cjs +13 -0
  40. package/dist/{migrations-EM2D6EG2.cjs.map → migrations-VNYOSUNE.cjs.map} +1 -1
  41. package/dist/{plugin-0Xogrln-.d.cts → plugin-DDYetMF-.d.cts} +1 -0
  42. package/dist/{plugin-0Xogrln-.d.ts → plugin-DDYetMF-.d.ts} +1 -0
  43. package/dist/{plugin-bootstrap-B8PXeGj_.d.cts → plugin-bootstrap-DCXpeQVb.d.cts} +1 -1
  44. package/dist/{plugin-bootstrap-CD63DZ-p.d.ts → plugin-bootstrap-DXBAYaqM.d.ts} +1 -1
  45. package/dist/{plugin-manager-GcIeb226.d.cts → plugin-manager-BoM3Q7o7.d.cts} +1 -1
  46. package/dist/{plugin-manager-Clf2gXwj.d.ts → plugin-manager-Efx9RyDX.d.ts} +1 -1
  47. package/dist/plugins.cjs +10 -10
  48. package/dist/plugins.d.cts +2 -2
  49. package/dist/plugins.d.ts +2 -2
  50. package/dist/plugins.js +2 -2
  51. package/dist/routes.cjs +28 -28
  52. package/dist/routes.js +5 -5
  53. package/dist/services.cjs +23 -23
  54. package/dist/services.d.cts +1 -1
  55. package/dist/services.d.ts +1 -1
  56. package/dist/services.js +2 -2
  57. package/dist/types.cjs +2 -2
  58. package/dist/types.d.cts +1 -1
  59. package/dist/types.d.ts +1 -1
  60. package/dist/types.js +1 -1
  61. package/dist/utils.cjs +11 -11
  62. package/dist/utils.js +1 -1
  63. package/package.json +1 -1
  64. package/dist/chunk-BUPNX3ZM.js.map +0 -1
  65. package/dist/chunk-HGKBMUYY.cjs.map +0 -1
  66. package/dist/chunk-KYGRJCZM.cjs.map +0 -1
  67. package/dist/chunk-LOUJRBXV.js.map +0 -1
  68. package/dist/chunk-SDAGUFOF.js.map +0 -1
  69. package/dist/chunk-TWCQVJ6M.cjs.map +0 -1
  70. package/dist/migrations-ADK6YNM2.js +0 -4
  71. package/dist/migrations-EM2D6EG2.cjs +0 -13
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkHGKBMUYY_cjs = require('./chunk-HGKBMUYY.cjs');
3
+ var chunkASAEJ4B7_cjs = require('./chunk-ASAEJ4B7.cjs');
4
4
  var chunkLFAQUR7P_cjs = require('./chunk-LFAQUR7P.cjs');
5
- var chunk5GO3AMON_cjs = require('./chunk-5GO3AMON.cjs');
6
- var chunkTWCQVJ6M_cjs = require('./chunk-TWCQVJ6M.cjs');
7
- var chunkEAJJHE5F_cjs = require('./chunk-EAJJHE5F.cjs');
5
+ var chunkB2ASV5RD_cjs = require('./chunk-B2ASV5RD.cjs');
6
+ var chunk6BVLPACH_cjs = require('./chunk-6BVLPACH.cjs');
7
+ var chunkDE5YTNCD_cjs = require('./chunk-DE5YTNCD.cjs');
8
8
  var chunk3G7XX4UI_cjs = require('./chunk-3G7XX4UI.cjs');
9
9
  var chunkLTKV7AE5_cjs = require('./chunk-LTKV7AE5.cjs');
10
- var chunkMNFY6DWY_cjs = require('./chunk-MNFY6DWY.cjs');
10
+ var chunk56GUBLJE_cjs = require('./chunk-56GUBLJE.cjs');
11
11
  var chunk6FHNRRJ3_cjs = require('./chunk-6FHNRRJ3.cjs');
12
- var chunkE2GKK5HX_cjs = require('./chunk-E2GKK5HX.cjs');
12
+ var chunkQLPFENZ2_cjs = require('./chunk-QLPFENZ2.cjs');
13
13
  require('./chunk-P3XDZL6Q.cjs');
14
14
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
15
15
  var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
16
- var chunkKYGRJCZM_cjs = require('./chunk-KYGRJCZM.cjs');
16
+ var chunkQTFKZBLC_cjs = require('./chunk-QTFKZBLC.cjs');
17
17
  require('./chunk-IGJUBJBW.cjs');
18
18
  var hono = require('hono');
19
19
  var cookie = require('hono/cookie');
@@ -559,7 +559,7 @@ function formatCellValue(value) {
559
559
  // src/plugins/core-plugins/database-tools-plugin/admin-routes.ts
560
560
  function createDatabaseToolsAdminRoutes() {
561
561
  const router3 = new hono.Hono();
562
- router3.use("*", chunk5GO3AMON_cjs.requireAuth());
562
+ router3.use("*", chunkB2ASV5RD_cjs.requireAuth());
563
563
  router3.get("/api/stats", async (c) => {
564
564
  try {
565
565
  const user = c.get("user");
@@ -1822,7 +1822,8 @@ function createOTPLoginPlugin() {
1822
1822
  email: normalizedEmail,
1823
1823
  ipAddress,
1824
1824
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1825
- appName: siteName
1825
+ appName: siteName,
1826
+ logoUrl: settings.logoUrl || ""
1826
1827
  });
1827
1828
  const emailPlugin2 = await db.prepare(`
1828
1829
  SELECT settings FROM plugins WHERE id = 'email'
@@ -1925,7 +1926,7 @@ function createOTPLoginPlugin() {
1925
1926
  error: "Account is deactivated"
1926
1927
  }, 403);
1927
1928
  }
1928
- const token = await chunk5GO3AMON_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET);
1929
+ const token = await chunkB2ASV5RD_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET);
1929
1930
  cookie.setCookie(c, "auth_token", token, {
1930
1931
  httpOnly: true,
1931
1932
  secure: true,
@@ -1997,6 +1998,567 @@ function createOTPLoginPlugin() {
1997
1998
  }
1998
1999
  var otpLoginPlugin = createOTPLoginPlugin();
1999
2000
 
2001
+ // src/plugins/core-plugins/oauth-providers/oauth-service.ts
2002
+ var GITHUB_PROVIDER = {
2003
+ id: "github",
2004
+ name: "GitHub",
2005
+ authorizeUrl: "https://github.com/login/oauth/authorize",
2006
+ tokenUrl: "https://github.com/login/oauth/access_token",
2007
+ userInfoUrl: "https://api.github.com/user",
2008
+ scopes: ["read:user", "user:email"],
2009
+ mapProfile: (profile) => ({
2010
+ providerAccountId: String(profile.id),
2011
+ email: profile.email || "",
2012
+ name: profile.name || profile.login || "",
2013
+ avatar: profile.avatar_url || void 0
2014
+ })
2015
+ };
2016
+ var GOOGLE_PROVIDER = {
2017
+ id: "google",
2018
+ name: "Google",
2019
+ authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
2020
+ tokenUrl: "https://oauth2.googleapis.com/token",
2021
+ userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
2022
+ scopes: ["openid", "email", "profile"],
2023
+ mapProfile: (profile) => ({
2024
+ providerAccountId: String(profile.id),
2025
+ email: profile.email || "",
2026
+ name: profile.name || "",
2027
+ avatar: profile.picture || void 0
2028
+ })
2029
+ };
2030
+ var BUILT_IN_PROVIDERS = {
2031
+ github: GITHUB_PROVIDER,
2032
+ google: GOOGLE_PROVIDER
2033
+ };
2034
+ var OAuthService = class {
2035
+ constructor(db) {
2036
+ this.db = db;
2037
+ }
2038
+ /**
2039
+ * Build the authorization redirect URL for a provider.
2040
+ */
2041
+ buildAuthorizeUrl(provider, clientId, redirectUri, state) {
2042
+ const params = new URLSearchParams({
2043
+ client_id: clientId,
2044
+ redirect_uri: redirectUri,
2045
+ response_type: "code",
2046
+ scope: provider.scopes.join(" "),
2047
+ state
2048
+ });
2049
+ if (provider.id === "google") {
2050
+ params.set("access_type", "offline");
2051
+ params.set("prompt", "consent");
2052
+ }
2053
+ return `${provider.authorizeUrl}?${params.toString()}`;
2054
+ }
2055
+ /**
2056
+ * Exchange authorization code for tokens using native fetch.
2057
+ */
2058
+ async exchangeCode(provider, clientId, clientSecret, code, redirectUri) {
2059
+ const body = {
2060
+ client_id: clientId,
2061
+ client_secret: clientSecret,
2062
+ code,
2063
+ redirect_uri: redirectUri,
2064
+ grant_type: "authorization_code"
2065
+ };
2066
+ const response = await fetch(provider.tokenUrl, {
2067
+ method: "POST",
2068
+ headers: {
2069
+ "Content-Type": "application/x-www-form-urlencoded",
2070
+ "Accept": "application/json"
2071
+ },
2072
+ body: new URLSearchParams(body).toString()
2073
+ });
2074
+ if (!response.ok) {
2075
+ const errorText = await response.text();
2076
+ throw new Error(`Token exchange failed (${response.status}): ${errorText}`);
2077
+ }
2078
+ const data = await response.json();
2079
+ if (data.error) {
2080
+ throw new Error(`Token exchange error: ${data.error_description || data.error}`);
2081
+ }
2082
+ return {
2083
+ access_token: data.access_token,
2084
+ refresh_token: data.refresh_token,
2085
+ expires_in: data.expires_in ? Number(data.expires_in) : void 0
2086
+ };
2087
+ }
2088
+ /**
2089
+ * Fetch user profile from the provider's userinfo endpoint.
2090
+ */
2091
+ async fetchUserProfile(provider, accessToken) {
2092
+ const headers = {
2093
+ "Authorization": `Bearer ${accessToken}`,
2094
+ "Accept": "application/json"
2095
+ };
2096
+ if (provider.id === "github") {
2097
+ headers["Authorization"] = `token ${accessToken}`;
2098
+ }
2099
+ const response = await fetch(provider.userInfoUrl, { headers });
2100
+ if (!response.ok) {
2101
+ throw new Error(`Failed to fetch user profile (${response.status})`);
2102
+ }
2103
+ const profile = await response.json();
2104
+ if (provider.id === "github" && !profile.email) {
2105
+ const emailResponse = await fetch("https://api.github.com/user/emails", {
2106
+ headers: {
2107
+ "Authorization": `token ${accessToken}`,
2108
+ "Accept": "application/json"
2109
+ }
2110
+ });
2111
+ if (emailResponse.ok) {
2112
+ const emails = await emailResponse.json();
2113
+ const primaryEmail = emails.find((e) => e.primary && e.verified);
2114
+ if (primaryEmail) {
2115
+ profile.email = primaryEmail.email;
2116
+ }
2117
+ }
2118
+ }
2119
+ return provider.mapProfile(profile);
2120
+ }
2121
+ // ─── Database Operations ────────────────────────────────────────────────
2122
+ /**
2123
+ * Find an existing OAuth account link.
2124
+ */
2125
+ async findOAuthAccount(provider, providerAccountId) {
2126
+ return await this.db.prepare(`
2127
+ SELECT * FROM oauth_accounts
2128
+ WHERE provider = ? AND provider_account_id = ?
2129
+ `).bind(provider, providerAccountId).first();
2130
+ }
2131
+ /**
2132
+ * Find all OAuth accounts for a user.
2133
+ */
2134
+ async findUserOAuthAccounts(userId) {
2135
+ const result = await this.db.prepare(`
2136
+ SELECT * FROM oauth_accounts WHERE user_id = ?
2137
+ `).bind(userId).all();
2138
+ return result.results || [];
2139
+ }
2140
+ /**
2141
+ * Create a new OAuth account link.
2142
+ */
2143
+ async createOAuthAccount(params) {
2144
+ const id = crypto.randomUUID();
2145
+ const now = Date.now();
2146
+ await this.db.prepare(`
2147
+ INSERT INTO oauth_accounts (
2148
+ id, user_id, provider, provider_account_id,
2149
+ access_token, refresh_token, token_expires_at,
2150
+ profile_data, created_at, updated_at
2151
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2152
+ `).bind(
2153
+ id,
2154
+ params.userId,
2155
+ params.provider,
2156
+ params.providerAccountId,
2157
+ params.accessToken,
2158
+ params.refreshToken || null,
2159
+ params.tokenExpiresAt || null,
2160
+ params.profileData || null,
2161
+ now,
2162
+ now
2163
+ ).run();
2164
+ return {
2165
+ id,
2166
+ user_id: params.userId,
2167
+ provider: params.provider,
2168
+ provider_account_id: params.providerAccountId,
2169
+ access_token: params.accessToken,
2170
+ refresh_token: params.refreshToken || null,
2171
+ token_expires_at: params.tokenExpiresAt || null,
2172
+ profile_data: params.profileData || null,
2173
+ created_at: now,
2174
+ updated_at: now
2175
+ };
2176
+ }
2177
+ /**
2178
+ * Update tokens for an existing OAuth account.
2179
+ */
2180
+ async updateOAuthTokens(id, accessToken, refreshToken, tokenExpiresAt) {
2181
+ await this.db.prepare(`
2182
+ UPDATE oauth_accounts
2183
+ SET access_token = ?, refresh_token = ?, token_expires_at = ?, updated_at = ?
2184
+ WHERE id = ?
2185
+ `).bind(accessToken, refreshToken || null, tokenExpiresAt || null, Date.now(), id).run();
2186
+ }
2187
+ /**
2188
+ * Unlink an OAuth account from a user (only if they have another auth method).
2189
+ */
2190
+ async unlinkOAuthAccount(userId, provider) {
2191
+ const user = await this.db.prepare(`
2192
+ SELECT password_hash FROM users WHERE id = ?
2193
+ `).bind(userId).first();
2194
+ const otherLinks = await this.db.prepare(`
2195
+ SELECT COUNT(*) as count FROM oauth_accounts
2196
+ WHERE user_id = ? AND provider != ?
2197
+ `).bind(userId, provider).first();
2198
+ const hasPassword = !!user?.password_hash;
2199
+ const hasOtherLinks = (otherLinks?.count || 0) > 0;
2200
+ if (!hasPassword && !hasOtherLinks) {
2201
+ return false;
2202
+ }
2203
+ await this.db.prepare(`
2204
+ DELETE FROM oauth_accounts WHERE user_id = ? AND provider = ?
2205
+ `).bind(userId, provider).run();
2206
+ return true;
2207
+ }
2208
+ /**
2209
+ * Find a user by email.
2210
+ */
2211
+ async findUserByEmail(email) {
2212
+ return await this.db.prepare(`
2213
+ SELECT id, email, role, is_active, first_name, last_name
2214
+ FROM users WHERE email = ?
2215
+ `).bind(email.toLowerCase()).first();
2216
+ }
2217
+ /**
2218
+ * Create a new user from an OAuth profile.
2219
+ */
2220
+ async createUserFromOAuth(profile) {
2221
+ const id = crypto.randomUUID();
2222
+ const now = Date.now();
2223
+ const email = profile.email.toLowerCase();
2224
+ const nameParts = (profile.name || email.split("@")[0] || "User").split(" ");
2225
+ const firstName = nameParts[0] || "User";
2226
+ const lastName = nameParts.slice(1).join(" ") || "";
2227
+ const username = email.split("@")[0] || id.substring(0, 8);
2228
+ const existing = await this.db.prepare(
2229
+ "SELECT id FROM users WHERE username = ?"
2230
+ ).bind(username).first();
2231
+ const finalUsername = existing ? `${username}-${id.substring(0, 6)}` : username;
2232
+ await this.db.prepare(`
2233
+ INSERT INTO users (
2234
+ id, email, username, first_name, last_name,
2235
+ password_hash, role, avatar, is_active, created_at, updated_at
2236
+ ) VALUES (?, ?, ?, ?, ?, NULL, 'viewer', ?, 1, ?, ?)
2237
+ `).bind(
2238
+ id,
2239
+ email,
2240
+ finalUsername,
2241
+ firstName,
2242
+ lastName,
2243
+ profile.avatar || null,
2244
+ now,
2245
+ now
2246
+ ).run();
2247
+ return id;
2248
+ }
2249
+ /**
2250
+ * Generate a cryptographically random state parameter for CSRF protection.
2251
+ */
2252
+ generateState() {
2253
+ const bytes = new Uint8Array(32);
2254
+ crypto.getRandomValues(bytes);
2255
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
2256
+ }
2257
+ };
2258
+
2259
+ // src/plugins/core-plugins/oauth-providers/index.ts
2260
+ var STATE_COOKIE_NAME = "oauth_state";
2261
+ var STATE_COOKIE_MAX_AGE = 600;
2262
+ function createOAuthProvidersPlugin() {
2263
+ const builder = chunk6FHNRRJ3_cjs.PluginBuilder.create({
2264
+ name: "oauth-providers",
2265
+ version: "1.0.0-beta.1",
2266
+ description: "OAuth2/OIDC social login with GitHub, Google, and more"
2267
+ });
2268
+ builder.metadata({
2269
+ author: {
2270
+ name: "SonicJS Team",
2271
+ email: "team@sonicjs.com"
2272
+ },
2273
+ license: "MIT",
2274
+ compatibility: "^2.0.0"
2275
+ });
2276
+ function getCallbackUrl(c, provider) {
2277
+ const proto = c.req.header("x-forwarded-proto") || "https";
2278
+ const host = c.req.header("host") || "localhost";
2279
+ return `${proto}://${host}/auth/oauth/${provider}/callback`;
2280
+ }
2281
+ async function loadSettings(db) {
2282
+ const row = await db.prepare(
2283
+ `SELECT settings FROM plugins WHERE id = 'oauth-providers'`
2284
+ ).first();
2285
+ if (!row?.settings) return null;
2286
+ try {
2287
+ return JSON.parse(row.settings);
2288
+ } catch {
2289
+ return null;
2290
+ }
2291
+ }
2292
+ function getProviderCredentials(settings, providerId) {
2293
+ if (!settings?.providers?.[providerId]) return null;
2294
+ const p = settings.providers[providerId];
2295
+ if (!p.enabled || !p.clientId || !p.clientSecret) return null;
2296
+ return { clientId: p.clientId, clientSecret: p.clientSecret };
2297
+ }
2298
+ const oauthAPI = new hono.Hono();
2299
+ oauthAPI.get("/:provider", async (c) => {
2300
+ try {
2301
+ const providerId = c.req.param("provider");
2302
+ const providerConfig = BUILT_IN_PROVIDERS[providerId];
2303
+ if (!providerConfig) {
2304
+ return c.json({ error: `Unknown OAuth provider: ${providerId}` }, 400);
2305
+ }
2306
+ const db = c.env.DB;
2307
+ const settings = await loadSettings(db);
2308
+ const creds = getProviderCredentials(settings, providerId);
2309
+ if (!creds) {
2310
+ return c.json({
2311
+ error: `OAuth provider "${providerId}" is not configured or not enabled`
2312
+ }, 400);
2313
+ }
2314
+ const oauthService = new OAuthService(db);
2315
+ const state = oauthService.generateState();
2316
+ const redirectUri = getCallbackUrl(c, providerId);
2317
+ cookie.setCookie(c, STATE_COOKIE_NAME, state, {
2318
+ httpOnly: true,
2319
+ secure: true,
2320
+ sameSite: "Lax",
2321
+ // Lax required for OAuth redirect flow
2322
+ maxAge: STATE_COOKIE_MAX_AGE,
2323
+ path: "/auth/oauth"
2324
+ });
2325
+ const authorizeUrl = oauthService.buildAuthorizeUrl(
2326
+ providerConfig,
2327
+ creds.clientId,
2328
+ redirectUri,
2329
+ state
2330
+ );
2331
+ return c.redirect(authorizeUrl);
2332
+ } catch (error) {
2333
+ console.error("OAuth authorize error:", error);
2334
+ return c.json({ error: "Failed to initiate OAuth flow" }, 500);
2335
+ }
2336
+ });
2337
+ oauthAPI.get("/:provider/callback", async (c) => {
2338
+ try {
2339
+ const providerId = c.req.param("provider");
2340
+ const providerConfig = BUILT_IN_PROVIDERS[providerId];
2341
+ if (!providerConfig) {
2342
+ return c.redirect("/auth/login?error=Unknown OAuth provider");
2343
+ }
2344
+ const stateParam = c.req.query("state");
2345
+ const stateCookie = cookie.getCookie(c, STATE_COOKIE_NAME);
2346
+ if (!stateParam || !stateCookie || stateParam !== stateCookie) {
2347
+ return c.redirect("/auth/login?error=Invalid OAuth state. Please try again.");
2348
+ }
2349
+ cookie.setCookie(c, STATE_COOKIE_NAME, "", {
2350
+ httpOnly: true,
2351
+ secure: true,
2352
+ sameSite: "Lax",
2353
+ maxAge: 0,
2354
+ path: "/auth/oauth"
2355
+ });
2356
+ const errorParam = c.req.query("error");
2357
+ if (errorParam) {
2358
+ const errorDesc = c.req.query("error_description") || errorParam;
2359
+ return c.redirect(`/auth/login?error=${encodeURIComponent(errorDesc)}`);
2360
+ }
2361
+ const code = c.req.query("code");
2362
+ if (!code) {
2363
+ return c.redirect("/auth/login?error=No authorization code received");
2364
+ }
2365
+ const db = c.env.DB;
2366
+ const settings = await loadSettings(db);
2367
+ const creds = getProviderCredentials(settings, providerId);
2368
+ if (!creds) {
2369
+ return c.redirect("/auth/login?error=OAuth provider not configured");
2370
+ }
2371
+ const oauthService = new OAuthService(db);
2372
+ const redirectUri = getCallbackUrl(c, providerId);
2373
+ const tokens = await oauthService.exchangeCode(
2374
+ providerConfig,
2375
+ creds.clientId,
2376
+ creds.clientSecret,
2377
+ code,
2378
+ redirectUri
2379
+ );
2380
+ const profile = await oauthService.fetchUserProfile(providerConfig, tokens.access_token);
2381
+ if (!profile.email) {
2382
+ return c.redirect("/auth/login?error=Could not retrieve email from OAuth provider. Please ensure your email is public or grant email permission.");
2383
+ }
2384
+ const tokenExpiresAt = tokens.expires_in ? Date.now() + tokens.expires_in * 1e3 : null;
2385
+ const existingOAuth = await oauthService.findOAuthAccount(providerId, profile.providerAccountId);
2386
+ if (existingOAuth) {
2387
+ await oauthService.updateOAuthTokens(
2388
+ existingOAuth.id,
2389
+ tokens.access_token,
2390
+ tokens.refresh_token,
2391
+ tokenExpiresAt ?? void 0
2392
+ );
2393
+ const user = await db.prepare(
2394
+ "SELECT id, email, role, is_active FROM users WHERE id = ?"
2395
+ ).bind(existingOAuth.user_id).first();
2396
+ if (!user || !user.is_active) {
2397
+ return c.redirect("/auth/login?error=Account is deactivated");
2398
+ }
2399
+ const jwt2 = await chunkB2ASV5RD_cjs.AuthManager.generateToken(
2400
+ user.id,
2401
+ user.email,
2402
+ user.role,
2403
+ c.env.JWT_SECRET
2404
+ );
2405
+ chunkB2ASV5RD_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax" });
2406
+ return c.redirect("/admin");
2407
+ }
2408
+ const existingUser = await oauthService.findUserByEmail(profile.email);
2409
+ if (existingUser) {
2410
+ if (!existingUser.is_active) {
2411
+ return c.redirect("/auth/login?error=Account is deactivated");
2412
+ }
2413
+ await oauthService.createOAuthAccount({
2414
+ userId: existingUser.id,
2415
+ provider: providerId,
2416
+ providerAccountId: profile.providerAccountId,
2417
+ accessToken: tokens.access_token,
2418
+ refreshToken: tokens.refresh_token,
2419
+ tokenExpiresAt: tokenExpiresAt ?? void 0,
2420
+ profileData: JSON.stringify(profile)
2421
+ });
2422
+ const jwt2 = await chunkB2ASV5RD_cjs.AuthManager.generateToken(
2423
+ existingUser.id,
2424
+ existingUser.email,
2425
+ existingUser.role,
2426
+ c.env.JWT_SECRET
2427
+ );
2428
+ chunkB2ASV5RD_cjs.AuthManager.setAuthCookie(c, jwt2, { sameSite: "Lax" });
2429
+ return c.redirect("/admin");
2430
+ }
2431
+ const newUserId = await oauthService.createUserFromOAuth(profile);
2432
+ await oauthService.createOAuthAccount({
2433
+ userId: newUserId,
2434
+ provider: providerId,
2435
+ providerAccountId: profile.providerAccountId,
2436
+ accessToken: tokens.access_token,
2437
+ refreshToken: tokens.refresh_token,
2438
+ tokenExpiresAt: tokenExpiresAt ?? void 0,
2439
+ profileData: JSON.stringify(profile)
2440
+ });
2441
+ const jwt = await chunkB2ASV5RD_cjs.AuthManager.generateToken(
2442
+ newUserId,
2443
+ profile.email.toLowerCase(),
2444
+ "viewer",
2445
+ c.env.JWT_SECRET
2446
+ );
2447
+ chunkB2ASV5RD_cjs.AuthManager.setAuthCookie(c, jwt, { sameSite: "Lax" });
2448
+ return c.redirect("/admin");
2449
+ } catch (error) {
2450
+ console.error("OAuth callback error:", error);
2451
+ const message = error instanceof Error ? error.message : "OAuth authentication failed";
2452
+ return c.redirect(`/auth/login?error=${encodeURIComponent(message)}`);
2453
+ }
2454
+ });
2455
+ oauthAPI.post("/link", async (c) => {
2456
+ try {
2457
+ const user = c.get("user");
2458
+ if (!user) {
2459
+ return c.json({ error: "Authentication required" }, 401);
2460
+ }
2461
+ const body = await c.req.json();
2462
+ const { provider } = body;
2463
+ if (!provider || !BUILT_IN_PROVIDERS[provider]) {
2464
+ return c.json({ error: "Invalid provider" }, 400);
2465
+ }
2466
+ const db = c.env.DB;
2467
+ const settings = await loadSettings(db);
2468
+ const creds = getProviderCredentials(settings, provider);
2469
+ if (!creds) {
2470
+ return c.json({ error: `OAuth provider "${provider}" is not configured` }, 400);
2471
+ }
2472
+ const oauthService = new OAuthService(db);
2473
+ const state = oauthService.generateState();
2474
+ const redirectUri = getCallbackUrl(c, provider);
2475
+ cookie.setCookie(c, STATE_COOKIE_NAME, state, {
2476
+ httpOnly: true,
2477
+ secure: true,
2478
+ sameSite: "Lax",
2479
+ maxAge: STATE_COOKIE_MAX_AGE,
2480
+ path: "/auth/oauth"
2481
+ });
2482
+ const authorizeUrl = oauthService.buildAuthorizeUrl(
2483
+ BUILT_IN_PROVIDERS[provider],
2484
+ creds.clientId,
2485
+ redirectUri,
2486
+ state
2487
+ );
2488
+ return c.json({ redirectUrl: authorizeUrl });
2489
+ } catch (error) {
2490
+ console.error("OAuth link error:", error);
2491
+ return c.json({ error: "Failed to initiate account linking" }, 500);
2492
+ }
2493
+ });
2494
+ oauthAPI.post("/unlink", async (c) => {
2495
+ try {
2496
+ const user = c.get("user");
2497
+ if (!user) {
2498
+ return c.json({ error: "Authentication required" }, 401);
2499
+ }
2500
+ const body = await c.req.json();
2501
+ const { provider } = body;
2502
+ if (!provider) {
2503
+ return c.json({ error: "Provider is required" }, 400);
2504
+ }
2505
+ const db = c.env.DB;
2506
+ const oauthService = new OAuthService(db);
2507
+ const success = await oauthService.unlinkOAuthAccount(user.userId, provider);
2508
+ if (!success) {
2509
+ return c.json({
2510
+ error: "Cannot unlink the only authentication method. Set a password first."
2511
+ }, 400);
2512
+ }
2513
+ return c.json({ success: true, message: `${provider} account unlinked` });
2514
+ } catch (error) {
2515
+ console.error("OAuth unlink error:", error);
2516
+ return c.json({ error: "Failed to unlink account" }, 500);
2517
+ }
2518
+ });
2519
+ oauthAPI.get("/accounts", async (c) => {
2520
+ try {
2521
+ const user = c.get("user");
2522
+ if (!user) {
2523
+ return c.json({ error: "Authentication required" }, 401);
2524
+ }
2525
+ const db = c.env.DB;
2526
+ const oauthService = new OAuthService(db);
2527
+ const accounts = await oauthService.findUserOAuthAccounts(user.userId);
2528
+ return c.json({
2529
+ accounts: accounts.map((a) => ({
2530
+ provider: a.provider,
2531
+ providerAccountId: a.provider_account_id,
2532
+ linkedAt: a.created_at
2533
+ }))
2534
+ });
2535
+ } catch (error) {
2536
+ console.error("OAuth accounts error:", error);
2537
+ return c.json({ error: "Failed to fetch linked accounts" }, 500);
2538
+ }
2539
+ });
2540
+ builder.addRoute("/auth/oauth", oauthAPI, {
2541
+ description: "OAuth2 social login endpoints",
2542
+ requiresAuth: false,
2543
+ priority: 100
2544
+ });
2545
+ builder.addMenuItem("OAuth Providers", "/admin/plugins/oauth-providers", {
2546
+ icon: "shield",
2547
+ order: 86,
2548
+ permissions: ["oauth:manage"]
2549
+ });
2550
+ builder.lifecycle({
2551
+ activate: async () => {
2552
+ console.info("\u2705 OAuth Providers plugin activated");
2553
+ },
2554
+ deactivate: async () => {
2555
+ console.info("\u274C OAuth Providers plugin deactivated");
2556
+ }
2557
+ });
2558
+ return builder.build();
2559
+ }
2560
+ var oauthProvidersPlugin = createOAuthProvidersPlugin();
2561
+
2000
2562
  // src/plugins/core-plugins/ai-search-plugin/services/embedding.service.ts
2001
2563
  var EmbeddingService = class {
2002
2564
  constructor(ai) {
@@ -3575,7 +4137,7 @@ function renderSettingsPage(data) {
3575
4137
 
3576
4138
  // src/plugins/core-plugins/ai-search-plugin/routes/admin.ts
3577
4139
  var adminRoutes = new hono.Hono();
3578
- adminRoutes.use("*", chunk5GO3AMON_cjs.requireAuth());
4140
+ adminRoutes.use("*", chunkB2ASV5RD_cjs.requireAuth());
3579
4141
  adminRoutes.get("/", async (c) => {
3580
4142
  try {
3581
4143
  const user = c.get("user");
@@ -3976,13 +4538,13 @@ function createMagicLinkAuthPlugin() {
3976
4538
  SET used = 1, used_at = ?
3977
4539
  WHERE id = ?
3978
4540
  `).bind(Date.now(), magicLink.id).run();
3979
- const jwtToken = await chunk5GO3AMON_cjs.AuthManager.generateToken(
4541
+ const jwtToken = await chunkB2ASV5RD_cjs.AuthManager.generateToken(
3980
4542
  user.id,
3981
4543
  user.email,
3982
4544
  user.role,
3983
4545
  c.env.JWT_SECRET
3984
4546
  );
3985
- chunk5GO3AMON_cjs.AuthManager.setAuthCookie(c, jwtToken);
4547
+ chunkB2ASV5RD_cjs.AuthManager.setAuthCookie(c, jwtToken);
3986
4548
  await db.prepare(`
3987
4549
  UPDATE users SET last_login_at = ? WHERE id = ?
3988
4550
  `).bind(Date.now(), user.id).run();
@@ -5268,7 +5830,7 @@ function renderCacheDashboard(data) {
5268
5830
  </script>
5269
5831
 
5270
5832
  <!-- Confirmation Dialogs -->
5271
- ${chunkHGKBMUYY_cjs.renderConfirmationDialog({
5833
+ ${chunkASAEJ4B7_cjs.renderConfirmationDialog({
5272
5834
  id: "clear-all-cache-confirm",
5273
5835
  title: "Clear All Cache",
5274
5836
  message: "Are you sure you want to clear all cache entries? This cannot be undone.",
@@ -5279,7 +5841,7 @@ function renderCacheDashboard(data) {
5279
5841
  onConfirm: "performClearAllCaches()"
5280
5842
  })}
5281
5843
 
5282
- ${chunkHGKBMUYY_cjs.renderConfirmationDialog({
5844
+ ${chunkASAEJ4B7_cjs.renderConfirmationDialog({
5283
5845
  id: "clear-namespace-cache-confirm",
5284
5846
  title: "Clear Namespace Cache",
5285
5847
  message: "Clear cache for this namespace?",
@@ -5290,7 +5852,7 @@ function renderCacheDashboard(data) {
5290
5852
  onConfirm: "performClearNamespaceCache()"
5291
5853
  })}
5292
5854
 
5293
- ${chunkHGKBMUYY_cjs.getConfirmationDialogScript()}
5855
+ ${chunkASAEJ4B7_cjs.getConfirmationDialogScript()}
5294
5856
  `;
5295
5857
  const layoutData = {
5296
5858
  title: "Cache System",
@@ -5976,14 +6538,14 @@ var faviconSvg = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
5976
6538
  // src/app.ts
5977
6539
  function createSonicJSApp(config = {}) {
5978
6540
  const app2 = new hono.Hono();
5979
- const appVersion = config.version || chunkE2GKK5HX_cjs.getCoreVersion();
6541
+ const appVersion = config.version || chunkQLPFENZ2_cjs.getCoreVersion();
5980
6542
  const appName = config.name || "SonicJS AI";
5981
6543
  app2.use("*", async (c, next) => {
5982
6544
  c.set("appVersion", appVersion);
5983
6545
  await next();
5984
6546
  });
5985
- app2.use("*", chunk5GO3AMON_cjs.metricsMiddleware());
5986
- app2.use("*", chunk5GO3AMON_cjs.bootstrapMiddleware(config));
6547
+ app2.use("*", chunkB2ASV5RD_cjs.metricsMiddleware());
6548
+ app2.use("*", chunkB2ASV5RD_cjs.bootstrapMiddleware(config));
5987
6549
  if (config.middleware?.beforeAuth) {
5988
6550
  for (const middleware of config.middleware.beforeAuth) {
5989
6551
  app2.use("*", middleware);
@@ -5992,44 +6554,49 @@ function createSonicJSApp(config = {}) {
5992
6554
  app2.use("*", async (_c, next) => {
5993
6555
  await next();
5994
6556
  });
5995
- app2.use("*", chunk5GO3AMON_cjs.securityHeadersMiddleware());
5996
- app2.use("*", chunk5GO3AMON_cjs.csrfProtection());
6557
+ app2.use("*", chunkB2ASV5RD_cjs.securityHeadersMiddleware());
6558
+ app2.use("*", chunkB2ASV5RD_cjs.csrfProtection());
5997
6559
  if (config.middleware?.afterAuth) {
5998
6560
  for (const middleware of config.middleware.afterAuth) {
5999
6561
  app2.use("*", middleware);
6000
6562
  }
6001
6563
  }
6002
- app2.route("/api", chunkHGKBMUYY_cjs.api_default);
6003
- app2.route("/api/media", chunkHGKBMUYY_cjs.api_media_default);
6004
- app2.route("/api/system", chunkHGKBMUYY_cjs.api_system_default);
6005
- app2.route("/admin/api", chunkHGKBMUYY_cjs.admin_api_default);
6006
- app2.route("/admin/dashboard", chunkHGKBMUYY_cjs.router);
6007
- app2.route("/admin/collections", chunkHGKBMUYY_cjs.adminCollectionsRoutes);
6008
- app2.route("/admin/forms", chunkHGKBMUYY_cjs.adminFormsRoutes);
6009
- app2.route("/admin/settings", chunkHGKBMUYY_cjs.adminSettingsRoutes);
6010
- app2.route("/forms", chunkHGKBMUYY_cjs.public_forms_default);
6011
- app2.route("/api/forms", chunkHGKBMUYY_cjs.public_forms_default);
6012
- app2.route("/admin/api-reference", chunkHGKBMUYY_cjs.router2);
6564
+ app2.route("/api", chunkASAEJ4B7_cjs.api_default);
6565
+ app2.route("/api/media", chunkASAEJ4B7_cjs.api_media_default);
6566
+ app2.route("/api/system", chunkASAEJ4B7_cjs.api_system_default);
6567
+ app2.route("/admin/api", chunkASAEJ4B7_cjs.admin_api_default);
6568
+ app2.route("/admin/dashboard", chunkASAEJ4B7_cjs.router);
6569
+ app2.route("/admin/collections", chunkASAEJ4B7_cjs.adminCollectionsRoutes);
6570
+ app2.route("/admin/forms", chunkASAEJ4B7_cjs.adminFormsRoutes);
6571
+ app2.route("/admin/settings", chunkASAEJ4B7_cjs.adminSettingsRoutes);
6572
+ app2.route("/forms", chunkASAEJ4B7_cjs.public_forms_default);
6573
+ app2.route("/api/forms", chunkASAEJ4B7_cjs.public_forms_default);
6574
+ app2.route("/admin/api-reference", chunkASAEJ4B7_cjs.router2);
6013
6575
  app2.route("/admin/database-tools", createDatabaseToolsAdminRoutes());
6014
6576
  app2.route("/admin/seed-data", createSeedDataAdminRoutes());
6015
- app2.route("/admin/content", chunkHGKBMUYY_cjs.admin_content_default);
6016
- app2.route("/admin/media", chunkHGKBMUYY_cjs.adminMediaRoutes);
6577
+ app2.route("/admin/content", chunkASAEJ4B7_cjs.admin_content_default);
6578
+ app2.route("/admin/media", chunkASAEJ4B7_cjs.adminMediaRoutes);
6017
6579
  if (aiSearchPlugin.routes && aiSearchPlugin.routes.length > 0) {
6018
6580
  for (const route of aiSearchPlugin.routes) {
6019
6581
  app2.route(route.path, route.handler);
6020
6582
  }
6021
6583
  }
6022
6584
  app2.route("/admin/cache", cache_default.getRoutes());
6585
+ if (oauthProvidersPlugin.routes && oauthProvidersPlugin.routes.length > 0) {
6586
+ for (const route of oauthProvidersPlugin.routes) {
6587
+ app2.route(route.path, route.handler);
6588
+ }
6589
+ }
6023
6590
  if (otpLoginPlugin.routes && otpLoginPlugin.routes.length > 0) {
6024
6591
  for (const route of otpLoginPlugin.routes) {
6025
6592
  app2.route(route.path, route.handler);
6026
6593
  }
6027
6594
  }
6028
- app2.route("/admin/plugins", chunkHGKBMUYY_cjs.adminPluginRoutes);
6029
- app2.route("/admin/logs", chunkHGKBMUYY_cjs.adminLogsRoutes);
6030
- app2.route("/admin", chunkHGKBMUYY_cjs.userRoutes);
6031
- app2.route("/auth", chunkHGKBMUYY_cjs.auth_default);
6032
- app2.route("/", chunkHGKBMUYY_cjs.test_cleanup_default);
6595
+ app2.route("/admin/plugins", chunkASAEJ4B7_cjs.adminPluginRoutes);
6596
+ app2.route("/admin/logs", chunkASAEJ4B7_cjs.adminLogsRoutes);
6597
+ app2.route("/admin", chunkASAEJ4B7_cjs.userRoutes);
6598
+ app2.route("/auth", chunkASAEJ4B7_cjs.auth_default);
6599
+ app2.route("/", chunkASAEJ4B7_cjs.test_cleanup_default);
6033
6600
  if (emailPlugin.routes && emailPlugin.routes.length > 0) {
6034
6601
  for (const route of emailPlugin.routes) {
6035
6602
  app2.route(route.path, route.handler);
@@ -6113,83 +6680,83 @@ function createDb(d1$1) {
6113
6680
  }
6114
6681
 
6115
6682
  // src/index.ts
6116
- var VERSION = chunkE2GKK5HX_cjs.package_default.version;
6683
+ var VERSION = chunkQLPFENZ2_cjs.package_default.version;
6117
6684
 
6118
6685
  Object.defineProperty(exports, "ROUTES_INFO", {
6119
6686
  enumerable: true,
6120
- get: function () { return chunkHGKBMUYY_cjs.ROUTES_INFO; }
6687
+ get: function () { return chunkASAEJ4B7_cjs.ROUTES_INFO; }
6121
6688
  });
6122
6689
  Object.defineProperty(exports, "adminApiRoutes", {
6123
6690
  enumerable: true,
6124
- get: function () { return chunkHGKBMUYY_cjs.admin_api_default; }
6691
+ get: function () { return chunkASAEJ4B7_cjs.admin_api_default; }
6125
6692
  });
6126
6693
  Object.defineProperty(exports, "adminCheckboxRoutes", {
6127
6694
  enumerable: true,
6128
- get: function () { return chunkHGKBMUYY_cjs.adminCheckboxRoutes; }
6695
+ get: function () { return chunkASAEJ4B7_cjs.adminCheckboxRoutes; }
6129
6696
  });
6130
6697
  Object.defineProperty(exports, "adminCodeExamplesRoutes", {
6131
6698
  enumerable: true,
6132
- get: function () { return chunkHGKBMUYY_cjs.admin_code_examples_default; }
6699
+ get: function () { return chunkASAEJ4B7_cjs.admin_code_examples_default; }
6133
6700
  });
6134
6701
  Object.defineProperty(exports, "adminCollectionsRoutes", {
6135
6702
  enumerable: true,
6136
- get: function () { return chunkHGKBMUYY_cjs.adminCollectionsRoutes; }
6703
+ get: function () { return chunkASAEJ4B7_cjs.adminCollectionsRoutes; }
6137
6704
  });
6138
6705
  Object.defineProperty(exports, "adminContentRoutes", {
6139
6706
  enumerable: true,
6140
- get: function () { return chunkHGKBMUYY_cjs.admin_content_default; }
6707
+ get: function () { return chunkASAEJ4B7_cjs.admin_content_default; }
6141
6708
  });
6142
6709
  Object.defineProperty(exports, "adminDashboardRoutes", {
6143
6710
  enumerable: true,
6144
- get: function () { return chunkHGKBMUYY_cjs.router; }
6711
+ get: function () { return chunkASAEJ4B7_cjs.router; }
6145
6712
  });
6146
6713
  Object.defineProperty(exports, "adminDesignRoutes", {
6147
6714
  enumerable: true,
6148
- get: function () { return chunkHGKBMUYY_cjs.adminDesignRoutes; }
6715
+ get: function () { return chunkASAEJ4B7_cjs.adminDesignRoutes; }
6149
6716
  });
6150
6717
  Object.defineProperty(exports, "adminLogsRoutes", {
6151
6718
  enumerable: true,
6152
- get: function () { return chunkHGKBMUYY_cjs.adminLogsRoutes; }
6719
+ get: function () { return chunkASAEJ4B7_cjs.adminLogsRoutes; }
6153
6720
  });
6154
6721
  Object.defineProperty(exports, "adminMediaRoutes", {
6155
6722
  enumerable: true,
6156
- get: function () { return chunkHGKBMUYY_cjs.adminMediaRoutes; }
6723
+ get: function () { return chunkASAEJ4B7_cjs.adminMediaRoutes; }
6157
6724
  });
6158
6725
  Object.defineProperty(exports, "adminPluginRoutes", {
6159
6726
  enumerable: true,
6160
- get: function () { return chunkHGKBMUYY_cjs.adminPluginRoutes; }
6727
+ get: function () { return chunkASAEJ4B7_cjs.adminPluginRoutes; }
6161
6728
  });
6162
6729
  Object.defineProperty(exports, "adminSettingsRoutes", {
6163
6730
  enumerable: true,
6164
- get: function () { return chunkHGKBMUYY_cjs.adminSettingsRoutes; }
6731
+ get: function () { return chunkASAEJ4B7_cjs.adminSettingsRoutes; }
6165
6732
  });
6166
6733
  Object.defineProperty(exports, "adminTestimonialsRoutes", {
6167
6734
  enumerable: true,
6168
- get: function () { return chunkHGKBMUYY_cjs.admin_testimonials_default; }
6735
+ get: function () { return chunkASAEJ4B7_cjs.admin_testimonials_default; }
6169
6736
  });
6170
6737
  Object.defineProperty(exports, "adminUsersRoutes", {
6171
6738
  enumerable: true,
6172
- get: function () { return chunkHGKBMUYY_cjs.userRoutes; }
6739
+ get: function () { return chunkASAEJ4B7_cjs.userRoutes; }
6173
6740
  });
6174
6741
  Object.defineProperty(exports, "apiContentCrudRoutes", {
6175
6742
  enumerable: true,
6176
- get: function () { return chunkHGKBMUYY_cjs.api_content_crud_default; }
6743
+ get: function () { return chunkASAEJ4B7_cjs.api_content_crud_default; }
6177
6744
  });
6178
6745
  Object.defineProperty(exports, "apiMediaRoutes", {
6179
6746
  enumerable: true,
6180
- get: function () { return chunkHGKBMUYY_cjs.api_media_default; }
6747
+ get: function () { return chunkASAEJ4B7_cjs.api_media_default; }
6181
6748
  });
6182
6749
  Object.defineProperty(exports, "apiRoutes", {
6183
6750
  enumerable: true,
6184
- get: function () { return chunkHGKBMUYY_cjs.api_default; }
6751
+ get: function () { return chunkASAEJ4B7_cjs.api_default; }
6185
6752
  });
6186
6753
  Object.defineProperty(exports, "apiSystemRoutes", {
6187
6754
  enumerable: true,
6188
- get: function () { return chunkHGKBMUYY_cjs.api_system_default; }
6755
+ get: function () { return chunkASAEJ4B7_cjs.api_system_default; }
6189
6756
  });
6190
6757
  Object.defineProperty(exports, "authRoutes", {
6191
6758
  enumerable: true,
6192
- get: function () { return chunkHGKBMUYY_cjs.auth_default; }
6759
+ get: function () { return chunkASAEJ4B7_cjs.auth_default; }
6193
6760
  });
6194
6761
  Object.defineProperty(exports, "Logger", {
6195
6762
  enumerable: true,
@@ -6357,167 +6924,167 @@ Object.defineProperty(exports, "workflowHistory", {
6357
6924
  });
6358
6925
  Object.defineProperty(exports, "AuthManager", {
6359
6926
  enumerable: true,
6360
- get: function () { return chunk5GO3AMON_cjs.AuthManager; }
6927
+ get: function () { return chunkB2ASV5RD_cjs.AuthManager; }
6361
6928
  });
6362
6929
  Object.defineProperty(exports, "PermissionManager", {
6363
6930
  enumerable: true,
6364
- get: function () { return chunk5GO3AMON_cjs.PermissionManager; }
6931
+ get: function () { return chunkB2ASV5RD_cjs.PermissionManager; }
6365
6932
  });
6366
6933
  Object.defineProperty(exports, "bootstrapMiddleware", {
6367
6934
  enumerable: true,
6368
- get: function () { return chunk5GO3AMON_cjs.bootstrapMiddleware; }
6935
+ get: function () { return chunkB2ASV5RD_cjs.bootstrapMiddleware; }
6369
6936
  });
6370
6937
  Object.defineProperty(exports, "cacheHeaders", {
6371
6938
  enumerable: true,
6372
- get: function () { return chunk5GO3AMON_cjs.cacheHeaders; }
6939
+ get: function () { return chunkB2ASV5RD_cjs.cacheHeaders; }
6373
6940
  });
6374
6941
  Object.defineProperty(exports, "compressionMiddleware", {
6375
6942
  enumerable: true,
6376
- get: function () { return chunk5GO3AMON_cjs.compressionMiddleware; }
6943
+ get: function () { return chunkB2ASV5RD_cjs.compressionMiddleware; }
6377
6944
  });
6378
6945
  Object.defineProperty(exports, "detailedLoggingMiddleware", {
6379
6946
  enumerable: true,
6380
- get: function () { return chunk5GO3AMON_cjs.detailedLoggingMiddleware; }
6947
+ get: function () { return chunkB2ASV5RD_cjs.detailedLoggingMiddleware; }
6381
6948
  });
6382
6949
  Object.defineProperty(exports, "getActivePlugins", {
6383
6950
  enumerable: true,
6384
- get: function () { return chunk5GO3AMON_cjs.getActivePlugins; }
6951
+ get: function () { return chunkB2ASV5RD_cjs.getActivePlugins; }
6385
6952
  });
6386
6953
  Object.defineProperty(exports, "isPluginActive", {
6387
6954
  enumerable: true,
6388
- get: function () { return chunk5GO3AMON_cjs.isPluginActive; }
6955
+ get: function () { return chunkB2ASV5RD_cjs.isPluginActive; }
6389
6956
  });
6390
6957
  Object.defineProperty(exports, "logActivity", {
6391
6958
  enumerable: true,
6392
- get: function () { return chunk5GO3AMON_cjs.logActivity; }
6959
+ get: function () { return chunkB2ASV5RD_cjs.logActivity; }
6393
6960
  });
6394
6961
  Object.defineProperty(exports, "loggingMiddleware", {
6395
6962
  enumerable: true,
6396
- get: function () { return chunk5GO3AMON_cjs.loggingMiddleware; }
6963
+ get: function () { return chunkB2ASV5RD_cjs.loggingMiddleware; }
6397
6964
  });
6398
6965
  Object.defineProperty(exports, "optionalAuth", {
6399
6966
  enumerable: true,
6400
- get: function () { return chunk5GO3AMON_cjs.optionalAuth; }
6967
+ get: function () { return chunkB2ASV5RD_cjs.optionalAuth; }
6401
6968
  });
6402
6969
  Object.defineProperty(exports, "performanceLoggingMiddleware", {
6403
6970
  enumerable: true,
6404
- get: function () { return chunk5GO3AMON_cjs.performanceLoggingMiddleware; }
6971
+ get: function () { return chunkB2ASV5RD_cjs.performanceLoggingMiddleware; }
6405
6972
  });
6406
6973
  Object.defineProperty(exports, "requireActivePlugin", {
6407
6974
  enumerable: true,
6408
- get: function () { return chunk5GO3AMON_cjs.requireActivePlugin; }
6975
+ get: function () { return chunkB2ASV5RD_cjs.requireActivePlugin; }
6409
6976
  });
6410
6977
  Object.defineProperty(exports, "requireActivePlugins", {
6411
6978
  enumerable: true,
6412
- get: function () { return chunk5GO3AMON_cjs.requireActivePlugins; }
6979
+ get: function () { return chunkB2ASV5RD_cjs.requireActivePlugins; }
6413
6980
  });
6414
6981
  Object.defineProperty(exports, "requireAnyPermission", {
6415
6982
  enumerable: true,
6416
- get: function () { return chunk5GO3AMON_cjs.requireAnyPermission; }
6983
+ get: function () { return chunkB2ASV5RD_cjs.requireAnyPermission; }
6417
6984
  });
6418
6985
  Object.defineProperty(exports, "requireAuth", {
6419
6986
  enumerable: true,
6420
- get: function () { return chunk5GO3AMON_cjs.requireAuth; }
6987
+ get: function () { return chunkB2ASV5RD_cjs.requireAuth; }
6421
6988
  });
6422
6989
  Object.defineProperty(exports, "requirePermission", {
6423
6990
  enumerable: true,
6424
- get: function () { return chunk5GO3AMON_cjs.requirePermission; }
6991
+ get: function () { return chunkB2ASV5RD_cjs.requirePermission; }
6425
6992
  });
6426
6993
  Object.defineProperty(exports, "requireRole", {
6427
6994
  enumerable: true,
6428
- get: function () { return chunk5GO3AMON_cjs.requireRole; }
6995
+ get: function () { return chunkB2ASV5RD_cjs.requireRole; }
6429
6996
  });
6430
6997
  Object.defineProperty(exports, "securityHeaders", {
6431
6998
  enumerable: true,
6432
- get: function () { return chunk5GO3AMON_cjs.securityHeadersMiddleware; }
6999
+ get: function () { return chunkB2ASV5RD_cjs.securityHeadersMiddleware; }
6433
7000
  });
6434
7001
  Object.defineProperty(exports, "securityLoggingMiddleware", {
6435
7002
  enumerable: true,
6436
- get: function () { return chunk5GO3AMON_cjs.securityLoggingMiddleware; }
7003
+ get: function () { return chunkB2ASV5RD_cjs.securityLoggingMiddleware; }
6437
7004
  });
6438
7005
  Object.defineProperty(exports, "PluginBootstrapService", {
6439
7006
  enumerable: true,
6440
- get: function () { return chunkTWCQVJ6M_cjs.PluginBootstrapService; }
7007
+ get: function () { return chunk6BVLPACH_cjs.PluginBootstrapService; }
6441
7008
  });
6442
7009
  Object.defineProperty(exports, "PluginServiceClass", {
6443
7010
  enumerable: true,
6444
- get: function () { return chunkTWCQVJ6M_cjs.PluginService; }
7011
+ get: function () { return chunk6BVLPACH_cjs.PluginService; }
6445
7012
  });
6446
7013
  Object.defineProperty(exports, "backfillFormSubmissions", {
6447
7014
  enumerable: true,
6448
- get: function () { return chunkTWCQVJ6M_cjs.backfillFormSubmissions; }
7015
+ get: function () { return chunk6BVLPACH_cjs.backfillFormSubmissions; }
6449
7016
  });
6450
7017
  Object.defineProperty(exports, "cleanupRemovedCollections", {
6451
7018
  enumerable: true,
6452
- get: function () { return chunkTWCQVJ6M_cjs.cleanupRemovedCollections; }
7019
+ get: function () { return chunk6BVLPACH_cjs.cleanupRemovedCollections; }
6453
7020
  });
6454
7021
  Object.defineProperty(exports, "createContentFromSubmission", {
6455
7022
  enumerable: true,
6456
- get: function () { return chunkTWCQVJ6M_cjs.createContentFromSubmission; }
7023
+ get: function () { return chunk6BVLPACH_cjs.createContentFromSubmission; }
6457
7024
  });
6458
7025
  Object.defineProperty(exports, "deriveCollectionSchemaFromFormio", {
6459
7026
  enumerable: true,
6460
- get: function () { return chunkTWCQVJ6M_cjs.deriveCollectionSchemaFromFormio; }
7027
+ get: function () { return chunk6BVLPACH_cjs.deriveCollectionSchemaFromFormio; }
6461
7028
  });
6462
7029
  Object.defineProperty(exports, "deriveSubmissionTitle", {
6463
7030
  enumerable: true,
6464
- get: function () { return chunkTWCQVJ6M_cjs.deriveSubmissionTitle; }
7031
+ get: function () { return chunk6BVLPACH_cjs.deriveSubmissionTitle; }
6465
7032
  });
6466
7033
  Object.defineProperty(exports, "fullCollectionSync", {
6467
7034
  enumerable: true,
6468
- get: function () { return chunkTWCQVJ6M_cjs.fullCollectionSync; }
7035
+ get: function () { return chunk6BVLPACH_cjs.fullCollectionSync; }
6469
7036
  });
6470
7037
  Object.defineProperty(exports, "getAvailableCollectionNames", {
6471
7038
  enumerable: true,
6472
- get: function () { return chunkTWCQVJ6M_cjs.getAvailableCollectionNames; }
7039
+ get: function () { return chunk6BVLPACH_cjs.getAvailableCollectionNames; }
6473
7040
  });
6474
7041
  Object.defineProperty(exports, "getManagedCollections", {
6475
7042
  enumerable: true,
6476
- get: function () { return chunkTWCQVJ6M_cjs.getManagedCollections; }
7043
+ get: function () { return chunk6BVLPACH_cjs.getManagedCollections; }
6477
7044
  });
6478
7045
  Object.defineProperty(exports, "isCollectionManaged", {
6479
7046
  enumerable: true,
6480
- get: function () { return chunkTWCQVJ6M_cjs.isCollectionManaged; }
7047
+ get: function () { return chunk6BVLPACH_cjs.isCollectionManaged; }
6481
7048
  });
6482
7049
  Object.defineProperty(exports, "loadCollectionConfig", {
6483
7050
  enumerable: true,
6484
- get: function () { return chunkTWCQVJ6M_cjs.loadCollectionConfig; }
7051
+ get: function () { return chunk6BVLPACH_cjs.loadCollectionConfig; }
6485
7052
  });
6486
7053
  Object.defineProperty(exports, "loadCollectionConfigs", {
6487
7054
  enumerable: true,
6488
- get: function () { return chunkTWCQVJ6M_cjs.loadCollectionConfigs; }
7055
+ get: function () { return chunk6BVLPACH_cjs.loadCollectionConfigs; }
6489
7056
  });
6490
7057
  Object.defineProperty(exports, "mapFormStatusToContentStatus", {
6491
7058
  enumerable: true,
6492
- get: function () { return chunkTWCQVJ6M_cjs.mapFormStatusToContentStatus; }
7059
+ get: function () { return chunk6BVLPACH_cjs.mapFormStatusToContentStatus; }
6493
7060
  });
6494
7061
  Object.defineProperty(exports, "registerCollections", {
6495
7062
  enumerable: true,
6496
- get: function () { return chunkTWCQVJ6M_cjs.registerCollections; }
7063
+ get: function () { return chunk6BVLPACH_cjs.registerCollections; }
6497
7064
  });
6498
7065
  Object.defineProperty(exports, "syncAllFormCollections", {
6499
7066
  enumerable: true,
6500
- get: function () { return chunkTWCQVJ6M_cjs.syncAllFormCollections; }
7067
+ get: function () { return chunk6BVLPACH_cjs.syncAllFormCollections; }
6501
7068
  });
6502
7069
  Object.defineProperty(exports, "syncCollection", {
6503
7070
  enumerable: true,
6504
- get: function () { return chunkTWCQVJ6M_cjs.syncCollection; }
7071
+ get: function () { return chunk6BVLPACH_cjs.syncCollection; }
6505
7072
  });
6506
7073
  Object.defineProperty(exports, "syncCollections", {
6507
7074
  enumerable: true,
6508
- get: function () { return chunkTWCQVJ6M_cjs.syncCollections; }
7075
+ get: function () { return chunk6BVLPACH_cjs.syncCollections; }
6509
7076
  });
6510
7077
  Object.defineProperty(exports, "syncFormCollection", {
6511
7078
  enumerable: true,
6512
- get: function () { return chunkTWCQVJ6M_cjs.syncFormCollection; }
7079
+ get: function () { return chunk6BVLPACH_cjs.syncFormCollection; }
6513
7080
  });
6514
7081
  Object.defineProperty(exports, "validateCollectionConfig", {
6515
7082
  enumerable: true,
6516
- get: function () { return chunkTWCQVJ6M_cjs.validateCollectionConfig; }
7083
+ get: function () { return chunk6BVLPACH_cjs.validateCollectionConfig; }
6517
7084
  });
6518
7085
  Object.defineProperty(exports, "MigrationService", {
6519
7086
  enumerable: true,
6520
- get: function () { return chunkEAJJHE5F_cjs.MigrationService; }
7087
+ get: function () { return chunkDE5YTNCD_cjs.MigrationService; }
6521
7088
  });
6522
7089
  Object.defineProperty(exports, "renderFilterBar", {
6523
7090
  enumerable: true,
@@ -6553,27 +7120,27 @@ Object.defineProperty(exports, "renderTable", {
6553
7120
  });
6554
7121
  Object.defineProperty(exports, "HookSystemImpl", {
6555
7122
  enumerable: true,
6556
- get: function () { return chunkMNFY6DWY_cjs.HookSystemImpl; }
7123
+ get: function () { return chunk56GUBLJE_cjs.HookSystemImpl; }
6557
7124
  });
6558
7125
  Object.defineProperty(exports, "HookUtils", {
6559
7126
  enumerable: true,
6560
- get: function () { return chunkMNFY6DWY_cjs.HookUtils; }
7127
+ get: function () { return chunk56GUBLJE_cjs.HookUtils; }
6561
7128
  });
6562
7129
  Object.defineProperty(exports, "PluginManagerClass", {
6563
7130
  enumerable: true,
6564
- get: function () { return chunkMNFY6DWY_cjs.PluginManager; }
7131
+ get: function () { return chunk56GUBLJE_cjs.PluginManager; }
6565
7132
  });
6566
7133
  Object.defineProperty(exports, "PluginRegistryImpl", {
6567
7134
  enumerable: true,
6568
- get: function () { return chunkMNFY6DWY_cjs.PluginRegistryImpl; }
7135
+ get: function () { return chunk56GUBLJE_cjs.PluginRegistryImpl; }
6569
7136
  });
6570
7137
  Object.defineProperty(exports, "PluginValidatorClass", {
6571
7138
  enumerable: true,
6572
- get: function () { return chunkMNFY6DWY_cjs.PluginValidator; }
7139
+ get: function () { return chunk56GUBLJE_cjs.PluginValidator; }
6573
7140
  });
6574
7141
  Object.defineProperty(exports, "ScopedHookSystemClass", {
6575
7142
  enumerable: true,
6576
- get: function () { return chunkMNFY6DWY_cjs.ScopedHookSystem; }
7143
+ get: function () { return chunk56GUBLJE_cjs.ScopedHookSystem; }
6577
7144
  });
6578
7145
  Object.defineProperty(exports, "PluginBuilder", {
6579
7146
  enumerable: true,
@@ -6585,31 +7152,31 @@ Object.defineProperty(exports, "PluginHelpers", {
6585
7152
  });
6586
7153
  Object.defineProperty(exports, "QueryFilterBuilder", {
6587
7154
  enumerable: true,
6588
- get: function () { return chunkE2GKK5HX_cjs.QueryFilterBuilder; }
7155
+ get: function () { return chunkQLPFENZ2_cjs.QueryFilterBuilder; }
6589
7156
  });
6590
7157
  Object.defineProperty(exports, "SONICJS_VERSION", {
6591
7158
  enumerable: true,
6592
- get: function () { return chunkE2GKK5HX_cjs.SONICJS_VERSION; }
7159
+ get: function () { return chunkQLPFENZ2_cjs.SONICJS_VERSION; }
6593
7160
  });
6594
7161
  Object.defineProperty(exports, "TemplateRenderer", {
6595
7162
  enumerable: true,
6596
- get: function () { return chunkE2GKK5HX_cjs.TemplateRenderer; }
7163
+ get: function () { return chunkQLPFENZ2_cjs.TemplateRenderer; }
6597
7164
  });
6598
7165
  Object.defineProperty(exports, "buildQuery", {
6599
7166
  enumerable: true,
6600
- get: function () { return chunkE2GKK5HX_cjs.buildQuery; }
7167
+ get: function () { return chunkQLPFENZ2_cjs.buildQuery; }
6601
7168
  });
6602
7169
  Object.defineProperty(exports, "getCoreVersion", {
6603
7170
  enumerable: true,
6604
- get: function () { return chunkE2GKK5HX_cjs.getCoreVersion; }
7171
+ get: function () { return chunkQLPFENZ2_cjs.getCoreVersion; }
6605
7172
  });
6606
7173
  Object.defineProperty(exports, "renderTemplate", {
6607
7174
  enumerable: true,
6608
- get: function () { return chunkE2GKK5HX_cjs.renderTemplate; }
7175
+ get: function () { return chunkQLPFENZ2_cjs.renderTemplate; }
6609
7176
  });
6610
7177
  Object.defineProperty(exports, "templateRenderer", {
6611
7178
  enumerable: true,
6612
- get: function () { return chunkE2GKK5HX_cjs.templateRenderer; }
7179
+ get: function () { return chunkQLPFENZ2_cjs.templateRenderer; }
6613
7180
  });
6614
7181
  Object.defineProperty(exports, "metricsTracker", {
6615
7182
  enumerable: true,
@@ -6629,11 +7196,15 @@ Object.defineProperty(exports, "sanitizeObject", {
6629
7196
  });
6630
7197
  Object.defineProperty(exports, "HOOKS", {
6631
7198
  enumerable: true,
6632
- get: function () { return chunkKYGRJCZM_cjs.HOOKS; }
7199
+ get: function () { return chunkQTFKZBLC_cjs.HOOKS; }
6633
7200
  });
7201
+ exports.BUILT_IN_PROVIDERS = BUILT_IN_PROVIDERS;
7202
+ exports.OAuthService = OAuthService;
6634
7203
  exports.VERSION = VERSION;
6635
7204
  exports.createDb = createDb;
7205
+ exports.createOAuthProvidersPlugin = createOAuthProvidersPlugin;
6636
7206
  exports.createSonicJSApp = createSonicJSApp;
7207
+ exports.oauthProvidersPlugin = oauthProvidersPlugin;
6637
7208
  exports.setupCoreMiddleware = setupCoreMiddleware;
6638
7209
  exports.setupCoreRoutes = setupCoreRoutes;
6639
7210
  //# sourceMappingURL=index.cjs.map