@sonicjs-cms/core 2.10.1 → 2.12.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.
- package/dist/{app-Ozl9agJG.d.cts → app-COElO4Rm.d.cts} +6 -1
- package/dist/{app-Ozl9agJG.d.ts → app-COElO4Rm.d.ts} +6 -1
- package/dist/{chunk-CJYFSKH7.js → chunk-2MXF4RYZ.js} +3 -3
- package/dist/{chunk-CJYFSKH7.js.map → chunk-2MXF4RYZ.js.map} +1 -1
- package/dist/{chunk-MNFY6DWY.cjs → chunk-56GUBLJE.cjs} +7 -7
- package/dist/{chunk-MNFY6DWY.cjs.map → chunk-56GUBLJE.cjs.map} +1 -1
- package/dist/{chunk-YXTFJPMN.js → chunk-6R6LAUR7.js} +3 -3
- package/dist/{chunk-YXTFJPMN.js.map → chunk-6R6LAUR7.js.map} +1 -1
- package/dist/{chunk-JJS7JZCH.js → chunk-76TX6XND.js} +4 -2
- package/dist/chunk-76TX6XND.js.map +1 -0
- package/dist/{chunk-EAJJHE5F.cjs → chunk-AG3SIPP7.cjs} +9 -2
- package/dist/chunk-AG3SIPP7.cjs.map +1 -0
- package/dist/{chunk-74XCYEI7.js → chunk-BWZBKLOC.js} +3 -3
- package/dist/{chunk-74XCYEI7.js.map → chunk-BWZBKLOC.js.map} +1 -1
- package/dist/{chunk-BUPNX3ZM.js → chunk-H3XXBAMO.js} +50 -2
- package/dist/chunk-H3XXBAMO.js.map +1 -0
- package/dist/{chunk-LTKV7AE5.cjs → chunk-H4NHRZ6Y.cjs} +4 -2
- package/dist/chunk-H4NHRZ6Y.cjs.map +1 -0
- package/dist/{chunk-JFMBYQTC.js → chunk-HXIYYE57.js} +6 -6
- package/dist/{chunk-JFMBYQTC.js.map → chunk-HXIYYE57.js.map} +1 -1
- package/dist/{chunk-TWCQVJ6M.cjs → chunk-I6FFGQIT.cjs} +50 -2
- package/dist/chunk-I6FFGQIT.cjs.map +1 -0
- package/dist/{chunk-SDAGUFOF.js → chunk-NDFHQOPP.js} +4318 -3820
- package/dist/chunk-NDFHQOPP.js.map +1 -0
- package/dist/{chunk-LFAQUR7P.cjs → chunk-NZWFCUDA.cjs} +26 -2
- package/dist/chunk-NZWFCUDA.cjs.map +1 -0
- package/dist/{chunk-KYGRJCZM.cjs → chunk-QTFKZBLC.cjs} +3 -2
- package/dist/chunk-QTFKZBLC.cjs.map +1 -0
- package/dist/{chunk-LOUJRBXV.js → chunk-QXOZI5Q2.js} +3 -2
- package/dist/chunk-QXOZI5Q2.js.map +1 -0
- package/dist/{chunk-3G7XX4UI.cjs → chunk-RBXFXT7H.cjs} +9 -9
- package/dist/{chunk-3G7XX4UI.cjs.map → chunk-RBXFXT7H.cjs.map} +1 -1
- package/dist/{chunk-E2GKK5HX.cjs → chunk-RXNLGINR.cjs} +3 -3
- package/dist/{chunk-E2GKK5HX.cjs.map → chunk-RXNLGINR.cjs.map} +1 -1
- package/dist/{chunk-VJCLJH3X.js → chunk-TBJY2FF7.js} +26 -2
- package/dist/chunk-TBJY2FF7.js.map +1 -0
- package/dist/{chunk-FW5CGNM2.js → chunk-U3ZMGBVC.js} +9 -2
- package/dist/chunk-U3ZMGBVC.js.map +1 -0
- package/dist/{chunk-5GO3AMON.cjs → chunk-VHNTCB2X.cjs} +10 -10
- package/dist/{chunk-5GO3AMON.cjs.map → chunk-VHNTCB2X.cjs.map} +1 -1
- package/dist/{chunk-HGKBMUYY.cjs → chunk-ZV6ZCJ74.cjs} +4498 -3996
- package/dist/chunk-ZV6ZCJ74.cjs.map +1 -0
- package/dist/index.cjs +2469 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -7
- package/dist/index.d.ts +175 -7
- package/dist/index.js +2294 -84
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +29 -29
- package/dist/middleware.d.cts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +3 -3
- package/dist/migrations-USSEHJC7.js +4 -0
- package/dist/{migrations-ADK6YNM2.js.map → migrations-USSEHJC7.js.map} +1 -1
- package/dist/migrations-ZE6IZNLB.cjs +13 -0
- package/dist/{migrations-EM2D6EG2.cjs.map → migrations-ZE6IZNLB.cjs.map} +1 -1
- package/dist/{plugin-0Xogrln-.d.cts → plugin-DDYetMF-.d.cts} +1 -0
- package/dist/{plugin-0Xogrln-.d.ts → plugin-DDYetMF-.d.ts} +1 -0
- package/dist/{plugin-bootstrap-CD63DZ-p.d.ts → plugin-bootstrap-CZ1GDum7.d.ts} +803 -2
- package/dist/{plugin-bootstrap-B8PXeGj_.d.cts → plugin-bootstrap-DVGLQrcO.d.cts} +803 -2
- package/dist/{plugin-manager-GcIeb226.d.cts → plugin-manager-BoM3Q7o7.d.cts} +1 -1
- package/dist/{plugin-manager-Clf2gXwj.d.ts → plugin-manager-Efx9RyDX.d.ts} +1 -1
- package/dist/plugins.cjs +10 -10
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +2 -2
- package/dist/routes.cjs +30 -30
- package/dist/routes.d.cts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +7 -7
- package/dist/services.cjs +39 -39
- package/dist/services.d.cts +1 -1
- package/dist/services.d.ts +1 -1
- package/dist/services.js +3 -3
- package/dist/templates.cjs +19 -19
- package/dist/templates.js +2 -2
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/migrations/034_security_audit_plugin.sql +27 -0
- package/package.json +1 -1
- package/dist/chunk-BUPNX3ZM.js.map +0 -1
- package/dist/chunk-EAJJHE5F.cjs.map +0 -1
- package/dist/chunk-FW5CGNM2.js.map +0 -1
- package/dist/chunk-HGKBMUYY.cjs.map +0 -1
- package/dist/chunk-JJS7JZCH.js.map +0 -1
- package/dist/chunk-KYGRJCZM.cjs.map +0 -1
- package/dist/chunk-LFAQUR7P.cjs.map +0 -1
- package/dist/chunk-LOUJRBXV.js.map +0 -1
- package/dist/chunk-LTKV7AE5.cjs.map +0 -1
- package/dist/chunk-SDAGUFOF.js.map +0 -1
- package/dist/chunk-TWCQVJ6M.cjs.map +0 -1
- package/dist/chunk-VJCLJH3X.js.map +0 -1
- package/dist/migrations-ADK6YNM2.js +0 -4
- package/dist/migrations-EM2D6EG2.cjs +0 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { B as Bindings,
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
export { B as Bindings, a as SonicJSApp, S as SonicJSConfig, V as Variables, c as createSonicJSApp, s as setupCoreMiddleware, b as setupCoreRoutes } from './app-COElO4Rm.cjs';
|
|
2
|
+
import { B as schema } from './plugin-bootstrap-DVGLQrcO.cjs';
|
|
3
|
+
export { D as Collection, E as Content, C as CorePlugin, F as DbPlugin, G as DbPluginHook, L as LogCategory, H as LogConfig, a as LogEntry, b as LogFilter, c as LogLevel, d as Logger, I as Media, M as Migration, e as MigrationService, f as MigrationStatus, N as NewCollection, J as NewContent, K as NewLogConfig, O as NewMedia, Q as NewPlugin, R as NewPluginActivityLog, S as NewPluginAsset, T as NewPluginHook, U as NewPluginRoute, V as NewSystemLog, W as NewUser, X as NewWorkflowHistory, Y as PluginActivityLog, Z as PluginAsset, P as PluginBootstrapService, _ as PluginRoute, g as PluginServiceClass, $ as SystemLog, a0 as User, a1 as WorkflowHistory, a2 as apiTokens, h as backfillFormSubmissions, i as cleanupRemovedCollections, a3 as collections, a4 as content, a5 as contentVersions, j as createContentFromSubmission, k as deriveCollectionSchemaFromFormio, l as deriveSubmissionTitle, m as fullCollectionSync, n as getAvailableCollectionNames, o as getLogger, p as getManagedCollections, q as initLogger, a6 as insertCollectionSchema, a7 as insertContentSchema, a8 as insertLogConfigSchema, a9 as insertMediaSchema, aa as insertPluginActivityLogSchema, ab as insertPluginAssetSchema, ac as insertPluginHookSchema, ad as insertPluginRouteSchema, ae as insertPluginSchema, af as insertSystemLogSchema, ag as insertUserSchema, ah as insertWorkflowHistorySchema, r as isCollectionManaged, s as loadCollectionConfig, t as loadCollectionConfigs, ai as logConfig, u as mapFormStatusToContentStatus, aj as media, ak as pluginActivityLog, al as pluginAssets, am as pluginHooks, an as pluginRoutes, ao as plugins, v as registerCollections, ap as selectCollectionSchema, aq as selectContentSchema, ar as selectLogConfigSchema, as as selectMediaSchema, at as selectPluginActivityLogSchema, au as selectPluginAssetSchema, av as selectPluginHookSchema, aw as selectPluginRouteSchema, ax as selectPluginSchema, ay as selectSystemLogSchema, az as selectUserSchema, aA as selectWorkflowHistorySchema, w as syncAllFormCollections, x as syncCollection, y as syncCollections, z as syncFormCollection, aB as systemLogs, aC as users, A as validateCollectionConfig, aD as workflowHistory } from './plugin-bootstrap-DVGLQrcO.cjs';
|
|
4
4
|
export { AuthManager, Permission, PermissionManager, UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './middleware.cjs';
|
|
5
|
-
export { H as HookSystemImpl, a as HookUtils, P as PluginManagerClass, b as PluginRegistryImpl, c as PluginValidatorClass, S as ScopedHookSystemClass } from './plugin-manager-
|
|
5
|
+
export { H as HookSystemImpl, a as HookUtils, P as PluginManagerClass, b as PluginRegistryImpl, c as PluginValidatorClass, S as ScopedHookSystemClass } from './plugin-manager-BoM3Q7o7.cjs';
|
|
6
6
|
export { ROUTES_INFO, adminApiRoutes, adminCheckboxRoutes, adminCodeExamplesRoutes, adminCollectionsRoutes, adminContentRoutes, adminDashboardRoutes, adminDesignRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, adminTestimonialsRoutes, adminUsersRoutes, apiContentCrudRoutes, apiMediaRoutes, apiRoutes, apiSystemRoutes, authRoutes } from './routes.cjs';
|
|
7
7
|
export { A as AlertData, C as ConfirmationDialogOptions, F as Filter, a as FilterBarData, b as FilterOption, c as FormData, d as FormField, P as PaginationData, T as TableColumn, e as TableData, g as getConfirmationDialogScript, r as renderAlert, f as renderConfirmationDialog, h as renderFilterBar, i as renderForm, j as renderFormField, k as renderPagination, l as renderTable } from './filter-bar.template-DlVYMk-T.cjs';
|
|
8
|
-
|
|
9
|
-
export {
|
|
8
|
+
import { e as FieldType } from './collection-config-B4PG-AaF.cjs';
|
|
9
|
+
export { C as CollectionConfig, b as CollectionConfigModule, c as CollectionSchema, d as CollectionSyncResult, F as FieldConfig } from './collection-config-B4PG-AaF.cjs';
|
|
10
|
+
export { A as AuthService, C as ContentService, H as HOOKS, a as HookContext, b as HookHandler, c as HookName, d as HookSystem, M as MediaService, P as Plugin, f as PluginAdminPage, g as PluginBuilderOptions, h as PluginComponent, i as PluginConfig, j as PluginContext, k as PluginHook, l as PluginLogger, m as PluginManager, n as PluginMenuItem, o as PluginMiddleware, p as PluginModel, q as PluginRegistry, r as PluginRoutes, s as PluginService, t as PluginStatus, u as PluginValidationResult, v as PluginValidator, S as ScopedHookSystem } from './plugin-DDYetMF-.cjs';
|
|
10
11
|
export { P as PluginManifest } from './plugin-manifest-Dpy8wxIB.cjs';
|
|
11
12
|
export { F as FilterCondition, a as FilterGroup, b as FilterOperator, Q as QueryFilter, c as QueryFilterBuilder, d as QueryResult, S as SONICJS_VERSION, T as TemplateRenderer, e as buildQuery, f as escapeHtml, g as getCoreVersion, m as metricsTracker, r as renderTemplate, s as sanitizeInput, h as sanitizeObject, t as templateRenderer } from './version-ChpccWQ1.cjs';
|
|
12
13
|
import * as drizzle_orm_d1 from 'drizzle-orm/d1';
|
|
@@ -516,6 +517,173 @@ declare class PluginHelpers {
|
|
|
516
517
|
}>): z.ZodSchema;
|
|
517
518
|
}
|
|
518
519
|
|
|
520
|
+
/**
|
|
521
|
+
* OAuth Providers Plugin
|
|
522
|
+
*
|
|
523
|
+
* OAuth2/OIDC social login support for SonicJS.
|
|
524
|
+
* Phase 1: Core OAuth2 authorization code flow with GitHub and Google providers.
|
|
525
|
+
*
|
|
526
|
+
* Routes:
|
|
527
|
+
* GET /auth/oauth/:provider → Redirect to provider authorization
|
|
528
|
+
* GET /auth/oauth/:provider/callback → Handle OAuth callback
|
|
529
|
+
* POST /auth/oauth/link → Link OAuth provider to logged-in account
|
|
530
|
+
* POST /auth/oauth/unlink → Unlink OAuth provider from account
|
|
531
|
+
* GET /auth/oauth/accounts → List linked OAuth accounts for current user
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
declare function createOAuthProvidersPlugin(): Plugin;
|
|
535
|
+
declare const oauthProvidersPlugin: Plugin;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* OAuth Service
|
|
539
|
+
* Handles OAuth2 authorization code flow, token exchange, and user info fetching.
|
|
540
|
+
* Provider-agnostic — each provider is a simple config object.
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
interface OAuthProviderConfig {
|
|
544
|
+
id: string;
|
|
545
|
+
name: string;
|
|
546
|
+
authorizeUrl: string;
|
|
547
|
+
tokenUrl: string;
|
|
548
|
+
userInfoUrl: string;
|
|
549
|
+
scopes: string[];
|
|
550
|
+
/** Map provider profile JSON to a normalized user profile */
|
|
551
|
+
mapProfile: (profile: Record<string, any>) => OAuthUserProfile;
|
|
552
|
+
}
|
|
553
|
+
interface OAuthUserProfile {
|
|
554
|
+
providerAccountId: string;
|
|
555
|
+
email: string;
|
|
556
|
+
name: string;
|
|
557
|
+
avatar?: string;
|
|
558
|
+
}
|
|
559
|
+
declare const BUILT_IN_PROVIDERS: Record<string, OAuthProviderConfig>;
|
|
560
|
+
interface OAuthAccount {
|
|
561
|
+
id: string;
|
|
562
|
+
user_id: string;
|
|
563
|
+
provider: string;
|
|
564
|
+
provider_account_id: string;
|
|
565
|
+
access_token: string | null;
|
|
566
|
+
refresh_token: string | null;
|
|
567
|
+
token_expires_at: number | null;
|
|
568
|
+
profile_data: string | null;
|
|
569
|
+
created_at: number;
|
|
570
|
+
updated_at: number;
|
|
571
|
+
}
|
|
572
|
+
declare class OAuthService {
|
|
573
|
+
private db;
|
|
574
|
+
constructor(db: D1Database$1);
|
|
575
|
+
/**
|
|
576
|
+
* Build the authorization redirect URL for a provider.
|
|
577
|
+
*/
|
|
578
|
+
buildAuthorizeUrl(provider: OAuthProviderConfig, clientId: string, redirectUri: string, state: string): string;
|
|
579
|
+
/**
|
|
580
|
+
* Exchange authorization code for tokens using native fetch.
|
|
581
|
+
*/
|
|
582
|
+
exchangeCode(provider: OAuthProviderConfig, clientId: string, clientSecret: string, code: string, redirectUri: string): Promise<{
|
|
583
|
+
access_token: string;
|
|
584
|
+
refresh_token?: string;
|
|
585
|
+
expires_in?: number;
|
|
586
|
+
}>;
|
|
587
|
+
/**
|
|
588
|
+
* Fetch user profile from the provider's userinfo endpoint.
|
|
589
|
+
*/
|
|
590
|
+
fetchUserProfile(provider: OAuthProviderConfig, accessToken: string): Promise<OAuthUserProfile>;
|
|
591
|
+
/**
|
|
592
|
+
* Find an existing OAuth account link.
|
|
593
|
+
*/
|
|
594
|
+
findOAuthAccount(provider: string, providerAccountId: string): Promise<OAuthAccount | null>;
|
|
595
|
+
/**
|
|
596
|
+
* Find all OAuth accounts for a user.
|
|
597
|
+
*/
|
|
598
|
+
findUserOAuthAccounts(userId: string): Promise<OAuthAccount[]>;
|
|
599
|
+
/**
|
|
600
|
+
* Create a new OAuth account link.
|
|
601
|
+
*/
|
|
602
|
+
createOAuthAccount(params: {
|
|
603
|
+
userId: string;
|
|
604
|
+
provider: string;
|
|
605
|
+
providerAccountId: string;
|
|
606
|
+
accessToken: string;
|
|
607
|
+
refreshToken?: string;
|
|
608
|
+
tokenExpiresAt?: number;
|
|
609
|
+
profileData?: string;
|
|
610
|
+
}): Promise<OAuthAccount>;
|
|
611
|
+
/**
|
|
612
|
+
* Update tokens for an existing OAuth account.
|
|
613
|
+
*/
|
|
614
|
+
updateOAuthTokens(id: string, accessToken: string, refreshToken?: string, tokenExpiresAt?: number): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Unlink an OAuth account from a user (only if they have another auth method).
|
|
617
|
+
*/
|
|
618
|
+
unlinkOAuthAccount(userId: string, provider: string): Promise<boolean>;
|
|
619
|
+
/**
|
|
620
|
+
* Find a user by email.
|
|
621
|
+
*/
|
|
622
|
+
findUserByEmail(email: string): Promise<{
|
|
623
|
+
id: string;
|
|
624
|
+
email: string;
|
|
625
|
+
role: string;
|
|
626
|
+
is_active: number;
|
|
627
|
+
first_name: string;
|
|
628
|
+
last_name: string;
|
|
629
|
+
} | null>;
|
|
630
|
+
/**
|
|
631
|
+
* Create a new user from an OAuth profile.
|
|
632
|
+
*/
|
|
633
|
+
createUserFromOAuth(profile: OAuthUserProfile): Promise<string>;
|
|
634
|
+
/**
|
|
635
|
+
* Generate a cryptographically random state parameter for CSRF protection.
|
|
636
|
+
*/
|
|
637
|
+
generateState(): string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* User Profile Config Registry
|
|
642
|
+
*
|
|
643
|
+
* Global singleton storing developer-defined custom profile field definitions.
|
|
644
|
+
* Set once at app boot via defineUserProfile(), queried by routes and templates.
|
|
645
|
+
*/
|
|
646
|
+
|
|
647
|
+
interface ProfileFieldDefinition {
|
|
648
|
+
name: string;
|
|
649
|
+
label: string;
|
|
650
|
+
type: FieldType;
|
|
651
|
+
options?: string[];
|
|
652
|
+
default?: any;
|
|
653
|
+
required?: boolean;
|
|
654
|
+
placeholder?: string;
|
|
655
|
+
helpText?: string;
|
|
656
|
+
hidden?: boolean;
|
|
657
|
+
fields?: ProfileFieldDefinition[];
|
|
658
|
+
validation?: {
|
|
659
|
+
min?: number;
|
|
660
|
+
max?: number;
|
|
661
|
+
pattern?: string;
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
interface UserProfileConfig {
|
|
665
|
+
fields: ProfileFieldDefinition[];
|
|
666
|
+
registrationFields?: string[];
|
|
667
|
+
}
|
|
668
|
+
declare function defineUserProfile(config: UserProfileConfig): void;
|
|
669
|
+
declare function getUserProfileConfig(): UserProfileConfig | null;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* User Profiles Plugin
|
|
673
|
+
*
|
|
674
|
+
* Configurable custom profile fields for users.
|
|
675
|
+
* Developers call defineUserProfile() at app boot to declare custom fields
|
|
676
|
+
* that are stored as JSON in user_profiles.data and rendered in the admin UI.
|
|
677
|
+
*
|
|
678
|
+
* API Routes:
|
|
679
|
+
* GET /api/user-profiles/schema → Public field definitions
|
|
680
|
+
* GET /api/user-profiles/:userId → Get custom data for a user (auth required)
|
|
681
|
+
* PUT /api/user-profiles/:userId → Update custom data for a user (auth required)
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
declare function createUserProfilesPlugin(): Plugin;
|
|
685
|
+
declare const userProfilesPlugin: Plugin;
|
|
686
|
+
|
|
519
687
|
/**
|
|
520
688
|
* @sonicjs/core - Main Entry Point
|
|
521
689
|
*
|
|
@@ -536,4 +704,4 @@ declare class PluginHelpers {
|
|
|
536
704
|
|
|
537
705
|
declare const VERSION: string;
|
|
538
706
|
|
|
539
|
-
export { PluginBuilder, PluginHelpers, VERSION, createDb };
|
|
707
|
+
export { BUILT_IN_PROVIDERS, FieldType, OAuthService, PluginBuilder, PluginHelpers, type ProfileFieldDefinition, type UserProfileConfig, VERSION, createDb, createOAuthProvidersPlugin, createUserProfilesPlugin, defineUserProfile, getUserProfileConfig, oauthProvidersPlugin, userProfilesPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { B as Bindings,
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
export { B as Bindings, a as SonicJSApp, S as SonicJSConfig, V as Variables, c as createSonicJSApp, s as setupCoreMiddleware, b as setupCoreRoutes } from './app-COElO4Rm.js';
|
|
2
|
+
import { B as schema } from './plugin-bootstrap-CZ1GDum7.js';
|
|
3
|
+
export { D as Collection, E as Content, C as CorePlugin, F as DbPlugin, G as DbPluginHook, L as LogCategory, H as LogConfig, a as LogEntry, b as LogFilter, c as LogLevel, d as Logger, I as Media, M as Migration, e as MigrationService, f as MigrationStatus, N as NewCollection, J as NewContent, K as NewLogConfig, O as NewMedia, Q as NewPlugin, R as NewPluginActivityLog, S as NewPluginAsset, T as NewPluginHook, U as NewPluginRoute, V as NewSystemLog, W as NewUser, X as NewWorkflowHistory, Y as PluginActivityLog, Z as PluginAsset, P as PluginBootstrapService, _ as PluginRoute, g as PluginServiceClass, $ as SystemLog, a0 as User, a1 as WorkflowHistory, a2 as apiTokens, h as backfillFormSubmissions, i as cleanupRemovedCollections, a3 as collections, a4 as content, a5 as contentVersions, j as createContentFromSubmission, k as deriveCollectionSchemaFromFormio, l as deriveSubmissionTitle, m as fullCollectionSync, n as getAvailableCollectionNames, o as getLogger, p as getManagedCollections, q as initLogger, a6 as insertCollectionSchema, a7 as insertContentSchema, a8 as insertLogConfigSchema, a9 as insertMediaSchema, aa as insertPluginActivityLogSchema, ab as insertPluginAssetSchema, ac as insertPluginHookSchema, ad as insertPluginRouteSchema, ae as insertPluginSchema, af as insertSystemLogSchema, ag as insertUserSchema, ah as insertWorkflowHistorySchema, r as isCollectionManaged, s as loadCollectionConfig, t as loadCollectionConfigs, ai as logConfig, u as mapFormStatusToContentStatus, aj as media, ak as pluginActivityLog, al as pluginAssets, am as pluginHooks, an as pluginRoutes, ao as plugins, v as registerCollections, ap as selectCollectionSchema, aq as selectContentSchema, ar as selectLogConfigSchema, as as selectMediaSchema, at as selectPluginActivityLogSchema, au as selectPluginAssetSchema, av as selectPluginHookSchema, aw as selectPluginRouteSchema, ax as selectPluginSchema, ay as selectSystemLogSchema, az as selectUserSchema, aA as selectWorkflowHistorySchema, w as syncAllFormCollections, x as syncCollection, y as syncCollections, z as syncFormCollection, aB as systemLogs, aC as users, A as validateCollectionConfig, aD as workflowHistory } from './plugin-bootstrap-CZ1GDum7.js';
|
|
4
4
|
export { AuthManager, Permission, PermissionManager, UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './middleware.js';
|
|
5
|
-
export { H as HookSystemImpl, a as HookUtils, P as PluginManagerClass, b as PluginRegistryImpl, c as PluginValidatorClass, S as ScopedHookSystemClass } from './plugin-manager-
|
|
5
|
+
export { H as HookSystemImpl, a as HookUtils, P as PluginManagerClass, b as PluginRegistryImpl, c as PluginValidatorClass, S as ScopedHookSystemClass } from './plugin-manager-Efx9RyDX.js';
|
|
6
6
|
export { ROUTES_INFO, adminApiRoutes, adminCheckboxRoutes, adminCodeExamplesRoutes, adminCollectionsRoutes, adminContentRoutes, adminDashboardRoutes, adminDesignRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, adminTestimonialsRoutes, adminUsersRoutes, apiContentCrudRoutes, apiMediaRoutes, apiRoutes, apiSystemRoutes, authRoutes } from './routes.js';
|
|
7
7
|
export { A as AlertData, C as ConfirmationDialogOptions, F as Filter, a as FilterBarData, b as FilterOption, c as FormData, d as FormField, P as PaginationData, T as TableColumn, e as TableData, g as getConfirmationDialogScript, r as renderAlert, f as renderConfirmationDialog, h as renderFilterBar, i as renderForm, j as renderFormField, k as renderPagination, l as renderTable } from './filter-bar.template-DlVYMk-T.js';
|
|
8
|
-
|
|
9
|
-
export {
|
|
8
|
+
import { e as FieldType } from './collection-config-B4PG-AaF.js';
|
|
9
|
+
export { C as CollectionConfig, b as CollectionConfigModule, c as CollectionSchema, d as CollectionSyncResult, F as FieldConfig } from './collection-config-B4PG-AaF.js';
|
|
10
|
+
export { A as AuthService, C as ContentService, H as HOOKS, a as HookContext, b as HookHandler, c as HookName, d as HookSystem, M as MediaService, P as Plugin, f as PluginAdminPage, g as PluginBuilderOptions, h as PluginComponent, i as PluginConfig, j as PluginContext, k as PluginHook, l as PluginLogger, m as PluginManager, n as PluginMenuItem, o as PluginMiddleware, p as PluginModel, q as PluginRegistry, r as PluginRoutes, s as PluginService, t as PluginStatus, u as PluginValidationResult, v as PluginValidator, S as ScopedHookSystem } from './plugin-DDYetMF-.js';
|
|
10
11
|
export { P as PluginManifest } from './plugin-manifest-Dpy8wxIB.js';
|
|
11
12
|
export { F as FilterCondition, a as FilterGroup, b as FilterOperator, Q as QueryFilter, c as QueryFilterBuilder, d as QueryResult, S as SONICJS_VERSION, T as TemplateRenderer, e as buildQuery, f as escapeHtml, g as getCoreVersion, m as metricsTracker, r as renderTemplate, s as sanitizeInput, h as sanitizeObject, t as templateRenderer } from './version-ChpccWQ1.js';
|
|
12
13
|
import * as drizzle_orm_d1 from 'drizzle-orm/d1';
|
|
@@ -516,6 +517,173 @@ declare class PluginHelpers {
|
|
|
516
517
|
}>): z.ZodSchema;
|
|
517
518
|
}
|
|
518
519
|
|
|
520
|
+
/**
|
|
521
|
+
* OAuth Providers Plugin
|
|
522
|
+
*
|
|
523
|
+
* OAuth2/OIDC social login support for SonicJS.
|
|
524
|
+
* Phase 1: Core OAuth2 authorization code flow with GitHub and Google providers.
|
|
525
|
+
*
|
|
526
|
+
* Routes:
|
|
527
|
+
* GET /auth/oauth/:provider → Redirect to provider authorization
|
|
528
|
+
* GET /auth/oauth/:provider/callback → Handle OAuth callback
|
|
529
|
+
* POST /auth/oauth/link → Link OAuth provider to logged-in account
|
|
530
|
+
* POST /auth/oauth/unlink → Unlink OAuth provider from account
|
|
531
|
+
* GET /auth/oauth/accounts → List linked OAuth accounts for current user
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
declare function createOAuthProvidersPlugin(): Plugin;
|
|
535
|
+
declare const oauthProvidersPlugin: Plugin;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* OAuth Service
|
|
539
|
+
* Handles OAuth2 authorization code flow, token exchange, and user info fetching.
|
|
540
|
+
* Provider-agnostic — each provider is a simple config object.
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
interface OAuthProviderConfig {
|
|
544
|
+
id: string;
|
|
545
|
+
name: string;
|
|
546
|
+
authorizeUrl: string;
|
|
547
|
+
tokenUrl: string;
|
|
548
|
+
userInfoUrl: string;
|
|
549
|
+
scopes: string[];
|
|
550
|
+
/** Map provider profile JSON to a normalized user profile */
|
|
551
|
+
mapProfile: (profile: Record<string, any>) => OAuthUserProfile;
|
|
552
|
+
}
|
|
553
|
+
interface OAuthUserProfile {
|
|
554
|
+
providerAccountId: string;
|
|
555
|
+
email: string;
|
|
556
|
+
name: string;
|
|
557
|
+
avatar?: string;
|
|
558
|
+
}
|
|
559
|
+
declare const BUILT_IN_PROVIDERS: Record<string, OAuthProviderConfig>;
|
|
560
|
+
interface OAuthAccount {
|
|
561
|
+
id: string;
|
|
562
|
+
user_id: string;
|
|
563
|
+
provider: string;
|
|
564
|
+
provider_account_id: string;
|
|
565
|
+
access_token: string | null;
|
|
566
|
+
refresh_token: string | null;
|
|
567
|
+
token_expires_at: number | null;
|
|
568
|
+
profile_data: string | null;
|
|
569
|
+
created_at: number;
|
|
570
|
+
updated_at: number;
|
|
571
|
+
}
|
|
572
|
+
declare class OAuthService {
|
|
573
|
+
private db;
|
|
574
|
+
constructor(db: D1Database$1);
|
|
575
|
+
/**
|
|
576
|
+
* Build the authorization redirect URL for a provider.
|
|
577
|
+
*/
|
|
578
|
+
buildAuthorizeUrl(provider: OAuthProviderConfig, clientId: string, redirectUri: string, state: string): string;
|
|
579
|
+
/**
|
|
580
|
+
* Exchange authorization code for tokens using native fetch.
|
|
581
|
+
*/
|
|
582
|
+
exchangeCode(provider: OAuthProviderConfig, clientId: string, clientSecret: string, code: string, redirectUri: string): Promise<{
|
|
583
|
+
access_token: string;
|
|
584
|
+
refresh_token?: string;
|
|
585
|
+
expires_in?: number;
|
|
586
|
+
}>;
|
|
587
|
+
/**
|
|
588
|
+
* Fetch user profile from the provider's userinfo endpoint.
|
|
589
|
+
*/
|
|
590
|
+
fetchUserProfile(provider: OAuthProviderConfig, accessToken: string): Promise<OAuthUserProfile>;
|
|
591
|
+
/**
|
|
592
|
+
* Find an existing OAuth account link.
|
|
593
|
+
*/
|
|
594
|
+
findOAuthAccount(provider: string, providerAccountId: string): Promise<OAuthAccount | null>;
|
|
595
|
+
/**
|
|
596
|
+
* Find all OAuth accounts for a user.
|
|
597
|
+
*/
|
|
598
|
+
findUserOAuthAccounts(userId: string): Promise<OAuthAccount[]>;
|
|
599
|
+
/**
|
|
600
|
+
* Create a new OAuth account link.
|
|
601
|
+
*/
|
|
602
|
+
createOAuthAccount(params: {
|
|
603
|
+
userId: string;
|
|
604
|
+
provider: string;
|
|
605
|
+
providerAccountId: string;
|
|
606
|
+
accessToken: string;
|
|
607
|
+
refreshToken?: string;
|
|
608
|
+
tokenExpiresAt?: number;
|
|
609
|
+
profileData?: string;
|
|
610
|
+
}): Promise<OAuthAccount>;
|
|
611
|
+
/**
|
|
612
|
+
* Update tokens for an existing OAuth account.
|
|
613
|
+
*/
|
|
614
|
+
updateOAuthTokens(id: string, accessToken: string, refreshToken?: string, tokenExpiresAt?: number): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Unlink an OAuth account from a user (only if they have another auth method).
|
|
617
|
+
*/
|
|
618
|
+
unlinkOAuthAccount(userId: string, provider: string): Promise<boolean>;
|
|
619
|
+
/**
|
|
620
|
+
* Find a user by email.
|
|
621
|
+
*/
|
|
622
|
+
findUserByEmail(email: string): Promise<{
|
|
623
|
+
id: string;
|
|
624
|
+
email: string;
|
|
625
|
+
role: string;
|
|
626
|
+
is_active: number;
|
|
627
|
+
first_name: string;
|
|
628
|
+
last_name: string;
|
|
629
|
+
} | null>;
|
|
630
|
+
/**
|
|
631
|
+
* Create a new user from an OAuth profile.
|
|
632
|
+
*/
|
|
633
|
+
createUserFromOAuth(profile: OAuthUserProfile): Promise<string>;
|
|
634
|
+
/**
|
|
635
|
+
* Generate a cryptographically random state parameter for CSRF protection.
|
|
636
|
+
*/
|
|
637
|
+
generateState(): string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* User Profile Config Registry
|
|
642
|
+
*
|
|
643
|
+
* Global singleton storing developer-defined custom profile field definitions.
|
|
644
|
+
* Set once at app boot via defineUserProfile(), queried by routes and templates.
|
|
645
|
+
*/
|
|
646
|
+
|
|
647
|
+
interface ProfileFieldDefinition {
|
|
648
|
+
name: string;
|
|
649
|
+
label: string;
|
|
650
|
+
type: FieldType;
|
|
651
|
+
options?: string[];
|
|
652
|
+
default?: any;
|
|
653
|
+
required?: boolean;
|
|
654
|
+
placeholder?: string;
|
|
655
|
+
helpText?: string;
|
|
656
|
+
hidden?: boolean;
|
|
657
|
+
fields?: ProfileFieldDefinition[];
|
|
658
|
+
validation?: {
|
|
659
|
+
min?: number;
|
|
660
|
+
max?: number;
|
|
661
|
+
pattern?: string;
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
interface UserProfileConfig {
|
|
665
|
+
fields: ProfileFieldDefinition[];
|
|
666
|
+
registrationFields?: string[];
|
|
667
|
+
}
|
|
668
|
+
declare function defineUserProfile(config: UserProfileConfig): void;
|
|
669
|
+
declare function getUserProfileConfig(): UserProfileConfig | null;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* User Profiles Plugin
|
|
673
|
+
*
|
|
674
|
+
* Configurable custom profile fields for users.
|
|
675
|
+
* Developers call defineUserProfile() at app boot to declare custom fields
|
|
676
|
+
* that are stored as JSON in user_profiles.data and rendered in the admin UI.
|
|
677
|
+
*
|
|
678
|
+
* API Routes:
|
|
679
|
+
* GET /api/user-profiles/schema → Public field definitions
|
|
680
|
+
* GET /api/user-profiles/:userId → Get custom data for a user (auth required)
|
|
681
|
+
* PUT /api/user-profiles/:userId → Update custom data for a user (auth required)
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
declare function createUserProfilesPlugin(): Plugin;
|
|
685
|
+
declare const userProfilesPlugin: Plugin;
|
|
686
|
+
|
|
519
687
|
/**
|
|
520
688
|
* @sonicjs/core - Main Entry Point
|
|
521
689
|
*
|
|
@@ -536,4 +704,4 @@ declare class PluginHelpers {
|
|
|
536
704
|
|
|
537
705
|
declare const VERSION: string;
|
|
538
706
|
|
|
539
|
-
export { PluginBuilder, PluginHelpers, VERSION, createDb };
|
|
707
|
+
export { BUILT_IN_PROVIDERS, FieldType, OAuthService, PluginBuilder, PluginHelpers, type ProfileFieldDefinition, type UserProfileConfig, VERSION, createDb, createOAuthProvidersPlugin, createUserProfilesPlugin, defineUserProfile, getUserProfileConfig, oauthProvidersPlugin, userProfilesPlugin };
|