@memberjunction/server 6.2.0-edge.5 → 6.2.0-edge.6
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/README.md +27 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/agentSessions/SessionJanitor.d.ts +3 -3
- package/dist/agentSessions/SessionJanitor.js +3 -3
- package/dist/agentSessions/SessionManager.d.ts +15 -5
- package/dist/agentSessions/SessionManager.d.ts.map +1 -1
- package/dist/agentSessions/SessionManager.js +34 -12
- package/dist/agentSessions/SessionManager.js.map +1 -1
- package/dist/auth/AuthProviderCatalogRouter.d.ts.map +1 -1
- package/dist/auth/AuthProviderCatalogRouter.js +2 -0
- package/dist/auth/AuthProviderCatalogRouter.js.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +51 -10
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/initializeProviders.d.ts +10 -0
- package/dist/auth/initializeProviders.d.ts.map +1 -1
- package/dist/auth/initializeProviders.js +37 -1
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/auth/localDevAuth.d.ts +79 -0
- package/dist/auth/localDevAuth.d.ts.map +1 -0
- package/dist/auth/localDevAuth.js +439 -0
- package/dist/auth/localDevAuth.js.map +1 -0
- package/dist/auth/magicLink/MagicLinkKeys.d.ts +2 -2
- package/dist/auth/magicLink/MagicLinkKeys.d.ts.map +1 -1
- package/dist/auth/magicLink/MagicLinkKeys.js +1 -1
- package/dist/auth/magicLink/MagicLinkKeys.js.map +1 -1
- package/dist/auth/magicLink/types.d.ts +12 -0
- package/dist/auth/magicLink/types.d.ts.map +1 -1
- package/dist/auth/sessionUserClone.d.ts +1 -1
- package/dist/auth/sessionUserClone.d.ts.map +1 -1
- package/dist/auth/sessionUserClone.js +3 -2
- package/dist/auth/sessionUserClone.js.map +1 -1
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.d.ts +292 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.js +442 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.js.map +1 -0
- package/dist/broadcast/index.d.ts +6 -0
- package/dist/broadcast/index.d.ts.map +1 -0
- package/dist/broadcast/index.js +6 -0
- package/dist/broadcast/index.js.map +1 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.d.ts +43 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.js +144 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.d.ts +46 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.js +149 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.d.ts +49 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.js +131 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.d.ts +24 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.js +51 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.js.map +1 -0
- package/dist/cache.d.ts +3 -2
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/config.d.ts +496 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +3 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +29 -8
- package/dist/context.js.map +1 -1
- package/dist/coreRoutes.d.ts.map +1 -1
- package/dist/coreRoutes.js +14 -0
- package/dist/coreRoutes.js.map +1 -1
- package/dist/generated/graphql-schemas/__mj.d.ts +635 -14
- package/dist/generated/graphql-schemas/__mj.d.ts.map +1 -1
- package/dist/generated/graphql-schemas/__mj.js +3366 -418
- package/dist/generated/graphql-schemas/__mj.js.map +1 -1
- package/dist/generic/CacheInvalidationResolver.d.ts +50 -30
- package/dist/generic/CacheInvalidationResolver.d.ts.map +1 -1
- package/dist/generic/CacheInvalidationResolver.js +154 -79
- package/dist/generic/CacheInvalidationResolver.js.map +1 -1
- package/dist/generic/OrphanedConversationDetailReconciler.d.ts.map +1 -1
- package/dist/generic/OrphanedConversationDetailReconciler.js +2 -0
- package/dist/generic/OrphanedConversationDetailReconciler.js.map +1 -1
- package/dist/generic/PubSubManager.d.ts +10 -0
- package/dist/generic/PubSubManager.d.ts.map +1 -1
- package/dist/generic/PubSubManager.js +44 -1
- package/dist/generic/PubSubManager.js.map +1 -1
- package/dist/generic/PushStatusResolver.d.ts +39 -6
- package/dist/generic/PushStatusResolver.d.ts.map +1 -1
- package/dist/generic/PushStatusResolver.js +93 -11
- package/dist/generic/PushStatusResolver.js.map +1 -1
- package/dist/generic/ResolverBase.d.ts +65 -25
- package/dist/generic/ResolverBase.d.ts.map +1 -1
- package/dist/generic/ResolverBase.js +201 -101
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.d.ts +11 -3
- package/dist/generic/RunViewResolver.d.ts.map +1 -1
- package/dist/generic/RunViewResolver.js +79 -13
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/generic/actionOutputFieldSecurity.d.ts +26 -0
- package/dist/generic/actionOutputFieldSecurity.d.ts.map +1 -0
- package/dist/generic/actionOutputFieldSecurity.js +47 -0
- package/dist/generic/actionOutputFieldSecurity.js.map +1 -0
- package/dist/generic/fieldSecurityTransport.d.ts +30 -0
- package/dist/generic/fieldSecurityTransport.d.ts.map +1 -0
- package/dist/generic/fieldSecurityTransport.js +30 -0
- package/dist/generic/fieldSecurityTransport.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -66
- package/dist/index.js.map +1 -1
- package/dist/integration/CustomColumnPromoter.d.ts.map +1 -1
- package/dist/integration/CustomColumnPromoter.js +6 -1
- package/dist/integration/CustomColumnPromoter.js.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.d.ts +12 -0
- package/dist/logging/variablesLoggingMiddleware.d.ts.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.js +50 -1
- package/dist/logging/variablesLoggingMiddleware.js.map +1 -1
- package/dist/realtimeSessions/SessionVerificationPortsBase.d.ts.map +1 -1
- package/dist/realtimeSessions/SessionVerificationPortsBase.js +1 -0
- package/dist/realtimeSessions/SessionVerificationPortsBase.js.map +1 -1
- package/dist/realtimeSessions/ownedRealtimeSession.d.ts +8 -6
- package/dist/realtimeSessions/ownedRealtimeSession.d.ts.map +1 -1
- package/dist/realtimeSessions/ownedRealtimeSession.js +15 -6
- package/dist/realtimeSessions/ownedRealtimeSession.js.map +1 -1
- package/dist/realtimeSessions/sessionAccess.d.ts +88 -11
- package/dist/realtimeSessions/sessionAccess.d.ts.map +1 -1
- package/dist/realtimeSessions/sessionAccess.js +125 -22
- package/dist/realtimeSessions/sessionAccess.js.map +1 -1
- package/dist/realtimeSessions/sessionConfigStamps.js +1 -1
- package/dist/realtimeSessions/sessionConfigStamps.js.map +1 -1
- package/dist/realtimeSessions/subscriptionAuthorization.d.ts.map +1 -1
- package/dist/realtimeSessions/subscriptionAuthorization.js +5 -2
- package/dist/realtimeSessions/subscriptionAuthorization.js.map +1 -1
- package/dist/realtimeSessions/verificationWorkflow.d.ts +2 -0
- package/dist/realtimeSessions/verificationWorkflow.d.ts.map +1 -1
- package/dist/realtimeSessions/verificationWorkflow.js +1 -1
- package/dist/realtimeSessions/verificationWorkflow.js.map +1 -1
- package/dist/realtimeWidget/WidgetRouter.d.ts.map +1 -1
- package/dist/realtimeWidget/WidgetRouter.js +19 -3
- package/dist/realtimeWidget/WidgetRouter.js.map +1 -1
- package/dist/realtimeWidget/WidgetSessionService.d.ts +67 -7
- package/dist/realtimeWidget/WidgetSessionService.d.ts.map +1 -1
- package/dist/realtimeWidget/WidgetSessionService.js +201 -19
- package/dist/realtimeWidget/WidgetSessionService.js.map +1 -1
- package/dist/realtimeWidget/host-identity.d.ts +1 -1
- package/dist/realtimeWidget/host-identity.js +1 -1
- package/dist/realtimeWidget/widgetCore.d.ts +20 -1
- package/dist/realtimeWidget/widgetCore.d.ts.map +1 -1
- package/dist/realtimeWidget/widgetCore.js +17 -1
- package/dist/realtimeWidget/widgetCore.js.map +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.d.ts +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.d.ts.map +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.js +2 -1
- package/dist/realtimeWidget/widgetGuestElevation.js.map +1 -1
- package/dist/resolvers/ActionResolver.d.ts +19 -1
- package/dist/resolvers/ActionResolver.d.ts.map +1 -1
- package/dist/resolvers/ActionResolver.js +63 -12
- package/dist/resolvers/ActionResolver.js.map +1 -1
- package/dist/resolvers/AdhocQueryResolver.d.ts.map +1 -1
- package/dist/resolvers/AdhocQueryResolver.js +1 -0
- package/dist/resolvers/AdhocQueryResolver.js.map +1 -1
- package/dist/resolvers/AgentRunStatusPublisher.d.ts +18 -4
- package/dist/resolvers/AgentRunStatusPublisher.d.ts.map +1 -1
- package/dist/resolvers/AgentRunStatusPublisher.js +32 -8
- package/dist/resolvers/AgentRunStatusPublisher.js.map +1 -1
- package/dist/resolvers/AgentSessionResolver.d.ts +10 -4
- package/dist/resolvers/AgentSessionResolver.d.ts.map +1 -1
- package/dist/resolvers/AgentSessionResolver.js +40 -17
- package/dist/resolvers/AgentSessionResolver.js.map +1 -1
- package/dist/resolvers/EntityCommunicationsResolver.d.ts +13 -1
- package/dist/resolvers/EntityCommunicationsResolver.d.ts.map +1 -1
- package/dist/resolvers/EntityCommunicationsResolver.js +50 -14
- package/dist/resolvers/EntityCommunicationsResolver.js.map +1 -1
- package/dist/resolvers/FetchEntityVectorsResolver.d.ts +28 -0
- package/dist/resolvers/FetchEntityVectorsResolver.d.ts.map +1 -1
- package/dist/resolvers/FetchEntityVectorsResolver.js +117 -21
- package/dist/resolvers/FetchEntityVectorsResolver.js.map +1 -1
- package/dist/resolvers/FileCategoryResolver.d.ts.map +1 -1
- package/dist/resolvers/FileCategoryResolver.js +1 -0
- package/dist/resolvers/FileCategoryResolver.js.map +1 -1
- package/dist/resolvers/FileResolver.d.ts +5 -0
- package/dist/resolvers/FileResolver.d.ts.map +1 -1
- package/dist/resolvers/FileResolver.js +13 -4
- package/dist/resolvers/FileResolver.js.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.js +45 -7
- package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
- package/dist/resolvers/MergeRecordsResolver.d.ts +8 -1
- package/dist/resolvers/MergeRecordsResolver.d.ts.map +1 -1
- package/dist/resolvers/MergeRecordsResolver.js +31 -3
- package/dist/resolvers/MergeRecordsResolver.js.map +1 -1
- package/dist/resolvers/PipelineProgressResolver.d.ts +6 -0
- package/dist/resolvers/PipelineProgressResolver.d.ts.map +1 -1
- package/dist/resolvers/PipelineProgressResolver.js +5 -3
- package/dist/resolvers/PipelineProgressResolver.js.map +1 -1
- package/dist/resolvers/QueryResolver.d.ts.map +1 -1
- package/dist/resolvers/QueryResolver.js +20 -6
- package/dist/resolvers/QueryResolver.js.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.d.ts +2 -0
- package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.js +15 -6
- package/dist/resolvers/QuerySystemUserResolver.js.map +1 -1
- package/dist/resolvers/RSUResolver.d.ts.map +1 -1
- package/dist/resolvers/RSUResolver.js +12 -0
- package/dist/resolvers/RSUResolver.js.map +1 -1
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts +16 -2
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -1
- package/dist/resolvers/RealtimeClientSessionResolver.js +82 -28
- package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -1
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts.map +1 -1
- package/dist/resolvers/RemoteBrowserActionResolver.js +11 -9
- package/dist/resolvers/RemoteBrowserActionResolver.js.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.d.ts +56 -8
- package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.js +209 -64
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/resolvers/RunTemplateResolver.d.ts.map +1 -1
- package/dist/resolvers/RunTemplateResolver.js +4 -4
- package/dist/resolvers/RunTemplateResolver.js.map +1 -1
- package/dist/resolvers/RunTestResolver.d.ts.map +1 -1
- package/dist/resolvers/RunTestResolver.js +3 -1
- package/dist/resolvers/RunTestResolver.js.map +1 -1
- package/dist/resolvers/SyncDataResolver.d.ts.map +1 -1
- package/dist/resolvers/SyncDataResolver.js +4 -0
- package/dist/resolvers/SyncDataResolver.js.map +1 -1
- package/dist/resolvers/TestQuerySQLResolver.d.ts.map +1 -1
- package/dist/resolvers/TestQuerySQLResolver.js +1 -0
- package/dist/resolvers/TestQuerySQLResolver.js.map +1 -1
- package/dist/resolvers/TransactionGroupResolver.d.ts +17 -2
- package/dist/resolvers/TransactionGroupResolver.d.ts.map +1 -1
- package/dist/resolvers/TransactionGroupResolver.js +60 -15
- package/dist/resolvers/TransactionGroupResolver.js.map +1 -1
- package/dist/resolvers/UserViewResolver.d.ts +1 -1
- package/dist/resolvers/UserViewResolver.d.ts.map +1 -1
- package/dist/resolvers/UserViewResolver.js +2 -1
- package/dist/resolvers/UserViewResolver.js.map +1 -1
- package/dist/rest/EntityCRUDHandler.d.ts +6 -0
- package/dist/rest/EntityCRUDHandler.d.ts.map +1 -1
- package/dist/rest/EntityCRUDHandler.js +19 -5
- package/dist/rest/EntityCRUDHandler.js.map +1 -1
- package/dist/rest/RESTEndpointHandler.d.ts.map +1 -1
- package/dist/rest/RESTEndpointHandler.js +8 -5
- package/dist/rest/RESTEndpointHandler.js.map +1 -1
- package/dist/rest/RealtimeRecordingHandler.d.ts +3 -3
- package/dist/rest/RealtimeRecordingHandler.d.ts.map +1 -1
- package/dist/rest/RealtimeRecordingHandler.js +7 -7
- package/dist/rest/RealtimeRecordingHandler.js.map +1 -1
- package/dist/rest/ViewOperationsHandler.d.ts +6 -0
- package/dist/rest/ViewOperationsHandler.d.ts.map +1 -1
- package/dist/rest/ViewOperationsHandler.js +22 -5
- package/dist/rest/ViewOperationsHandler.js.map +1 -1
- package/dist/serverRoleConfigUnits.d.ts +29 -0
- package/dist/serverRoleConfigUnits.d.ts.map +1 -0
- package/dist/serverRoleConfigUnits.js +33 -0
- package/dist/serverRoleConfigUnits.js.map +1 -0
- package/dist/services/TaskGraphContinuationDeliverer.d.ts +5 -0
- package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -1
- package/dist/services/TaskGraphContinuationDeliverer.js +42 -15
- package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -1
- package/dist/types.d.ts +23 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +98 -98
- package/src/__tests__/ActionResolver.fieldSecurity.test.ts +237 -0
- package/src/__tests__/AdhocQueryResolver.dialect.test.ts +137 -0
- package/src/__tests__/AgentRunStatusPublisher.test.ts +49 -0
- package/src/__tests__/AgentSessionResolver.ownership.test.ts +137 -0
- package/src/__tests__/CustomColumnPromoterOnePass.test.ts +15 -1
- package/src/__tests__/EntityCommunicationsResolver.actingUser.test.ts +151 -0
- package/src/__tests__/EvolutionActsOnWhatItDetects.test.ts +113 -0
- package/src/__tests__/FetchEntityVectorsResolver.test.ts +206 -3
- package/src/__tests__/FileResolver.fieldSecurity.test.ts +82 -0
- package/src/__tests__/PipelineProgressResolver.filter.test.ts +58 -0
- package/src/__tests__/QuerySystemUserResolver.fieldSecurity.test.ts +49 -0
- package/src/__tests__/RESTEndpointHandler.test.ts +25 -0
- package/src/__tests__/RealtimeClientSessionResolver.configTamper.test.ts +23 -3
- package/src/__tests__/RealtimeClientSessionResolver.test.ts +324 -46
- package/src/__tests__/RemoteBrowserActionResolver.ownership.test.ts +98 -0
- package/src/__tests__/ResolverBase.clientOldValues.test.ts +37 -4
- package/src/__tests__/ResolverBase.deleteReturnProjection.test.ts +52 -0
- package/src/__tests__/ResolverBase.entityMessageRelay.test.ts +176 -0
- package/src/__tests__/ResolverBase.includeBinaryFields.test.ts +23 -1
- package/src/__tests__/ResolverBase.publishStatusUpdate.test.ts +68 -0
- package/src/__tests__/ResolverBase.userViewCacheAndDedup.test.ts +130 -0
- package/src/__tests__/RunAIAgentResolver.branch.test.ts +68 -13
- package/src/__tests__/RunAIAgentResolver.conversationWriter.test.ts +210 -0
- package/src/__tests__/RunAIAgentResolver.fireAndForgetCompletion.test.ts +209 -0
- package/src/__tests__/RunAIAgentResolver.historyFrom.test.ts +17 -27
- package/src/__tests__/RunAIAgentResolver.runDataGuard.test.ts +8 -2
- package/src/__tests__/RunAIAgentResolver.serverReply.test.ts +358 -0
- package/src/__tests__/RunAIAgentResolver.stoppedPredecessor.test.ts +4 -1
- package/src/__tests__/RunTemplateResolver.test.ts +35 -2
- package/src/__tests__/RunViewResolver.cacheCheckForwarding.test.ts +11 -0
- package/src/__tests__/SessionManager.test.ts +95 -0
- package/src/__tests__/TaskGraphContinuationDeliverer.test.ts +114 -3
- package/src/__tests__/TransactionGroupResolver.fieldSecurity.test.ts +199 -0
- package/src/__tests__/UserViewResolver.updateWhereClause.test.ts +15 -0
- package/src/__tests__/ViewOperationsHandler.test.ts +7 -2
- package/src/__tests__/WidgetSessionService.test.ts +583 -4
- package/src/__tests__/apiRootBoot.test.ts +1 -1
- package/src/__tests__/buildMagicLinkSessionUser.test.ts +96 -0
- package/src/__tests__/cacheBroadcastProviders.test.ts +403 -0
- package/src/__tests__/cacheInvalidationRecordData.test.ts +45 -0
- package/src/__tests__/fieldSecurityFixtures.ts +91 -0
- package/src/__tests__/globalCors.test.ts +3 -3
- package/src/__tests__/localDevAuth.test.ts +196 -0
- package/src/__tests__/orphanedConversationDetailReconciler.test.ts +10 -0
- package/src/__tests__/pushStatusResolver.filter.test.ts +57 -1
- package/src/__tests__/realtimeRecordingHandler.test.ts +19 -2
- package/src/__tests__/realtimeSessions/RealtimeSessionEventsResolver.test.ts +29 -1
- package/src/__tests__/realtimeSessions/ownedRealtimeSession.anonymous.test.ts +31 -0
- package/src/__tests__/realtimeSessions/ownedRealtimeSession.namedScoped.test.ts +37 -0
- package/src/__tests__/realtimeSessions/sessionAccess.test.ts +146 -7
- package/src/__tests__/realtimeSessions/sessionConfigStamps.test.ts +1 -1
- package/src/__tests__/realtimeSessions/verificationWorkflow.test.ts +25 -4
- package/src/__tests__/resolverBase.cloudEventChangedFields.test.ts +157 -0
- package/src/__tests__/resolverBase.fieldSecurityTransport.test.ts +222 -0
- package/src/__tests__/resolverBase.fls.test.ts +146 -97
- package/src/__tests__/restTransport.fieldSecurity.test.ts +148 -0
- package/src/__tests__/runParamsTimeZone.test.ts +179 -0
- package/src/__tests__/runStreams.fieldSecurity.test.ts +100 -0
- package/src/__tests__/runViewProperties.test.ts +114 -0
- package/src/__tests__/scalabilityBenchmarks.test.ts +765 -0
- package/src/__tests__/scalabilityDatabaseIntegration.test.ts +207 -0
- package/src/__tests__/sessionUserClone.test.ts +5 -1
- package/src/__tests__/startupSweepOrder.test.ts +40 -0
- package/src/__tests__/unifiedAuth.test.ts +28 -0
- package/src/__tests__/widgetGuestElevation.test.ts +2 -0
- package/src/agentSessions/SessionJanitor.ts +3 -3
- package/src/agentSessions/SessionManager.ts +35 -12
- package/src/auth/AuthProviderCatalogRouter.ts +3 -0
- package/src/auth/index.ts +56 -12
- package/src/auth/initializeProviders.ts +43 -1
- package/src/auth/localDevAuth.ts +528 -0
- package/src/auth/magicLink/MagicLinkKeys.ts +2 -2
- package/src/auth/magicLink/types.ts +10 -0
- package/src/auth/sessionUserClone.ts +3 -2
- package/src/broadcast/BaseCacheInvalidationBroadcastProvider.ts +674 -0
- package/src/broadcast/index.ts +5 -0
- package/src/broadcast/providers/AWSIoTCoreBroadcastProvider.ts +180 -0
- package/src/broadcast/providers/AzureWebPubSubBroadcastProvider.ts +182 -0
- package/src/broadcast/providers/GCPPubSubBroadcastProvider.ts +169 -0
- package/src/broadcast/providers/SequencedRoleBucketBroadcastProvider.ts +57 -0
- package/src/cache.ts +2 -1
- package/src/config.ts +69 -0
- package/src/context.ts +32 -8
- package/src/coreRoutes.ts +15 -0
- package/src/generated/graphql-schemas/__mj.ts +2239 -102
- package/src/generic/CacheInvalidationResolver.ts +135 -78
- package/src/generic/OrphanedConversationDetailReconciler.ts +4 -2
- package/src/generic/PubSubManager.ts +54 -1
- package/src/generic/PushStatusResolver.ts +108 -11
- package/src/generic/ResolverBase.ts +237 -107
- package/src/generic/RunViewResolver.ts +80 -15
- package/src/generic/actionOutputFieldSecurity.ts +75 -0
- package/src/generic/fieldSecurityTransport.ts +62 -0
- package/src/index.ts +127 -68
- package/src/integration/CustomColumnPromoter.ts +6 -1
- package/src/logging/variablesLoggingMiddleware.ts +59 -3
- package/src/realtimeSessions/README.md +7 -3
- package/src/realtimeSessions/SessionVerificationPortsBase.ts +1 -0
- package/src/realtimeSessions/ownedRealtimeSession.ts +20 -6
- package/src/realtimeSessions/sessionAccess.ts +181 -25
- package/src/realtimeSessions/sessionConfigStamps.ts +1 -1
- package/src/realtimeSessions/subscriptionAuthorization.ts +4 -2
- package/src/realtimeSessions/verificationWorkflow.ts +3 -1
- package/src/realtimeWidget/WidgetRouter.ts +22 -4
- package/src/realtimeWidget/WidgetSessionService.ts +252 -17
- package/src/realtimeWidget/host-identity.ts +1 -1
- package/src/realtimeWidget/widgetCore.ts +30 -1
- package/src/realtimeWidget/widgetGuestElevation.ts +2 -1
- package/src/resolvers/ActionResolver.ts +78 -15
- package/src/resolvers/AdhocQueryResolver.ts +1 -0
- package/src/resolvers/AgentRunStatusPublisher.ts +36 -8
- package/src/resolvers/AgentSessionResolver.ts +46 -18
- package/src/resolvers/EntityCommunicationsResolver.ts +56 -15
- package/src/resolvers/FetchEntityVectorsResolver.ts +132 -21
- package/src/resolvers/FileCategoryResolver.ts +1 -0
- package/src/resolvers/FileResolver.ts +14 -4
- package/src/resolvers/IntegrationDiscoveryResolver.ts +49 -7
- package/src/resolvers/MergeRecordsResolver.ts +23 -2
- package/src/resolvers/PipelineProgressResolver.ts +12 -3
- package/src/resolvers/QueryResolver.ts +20 -6
- package/src/resolvers/QuerySystemUserResolver.ts +15 -6
- package/src/resolvers/RSUResolver.ts +12 -0
- package/src/resolvers/RealtimeClientSessionResolver.ts +104 -33
- package/src/resolvers/RemoteBrowserActionResolver.ts +15 -10
- package/src/resolvers/RunAIAgentResolver.ts +258 -82
- package/src/resolvers/RunTemplateResolver.ts +6 -4
- package/src/resolvers/RunTestResolver.ts +3 -1
- package/src/resolvers/SyncDataResolver.ts +4 -0
- package/src/resolvers/TestQuerySQLResolver.ts +1 -0
- package/src/resolvers/TransactionGroupResolver.ts +66 -15
- package/src/resolvers/UserViewResolver.ts +2 -1
- package/src/resolvers/__tests__/MergeRecordsResolver.test.ts +43 -0
- package/src/rest/EntityCRUDHandler.ts +22 -5
- package/src/rest/RESTEndpointHandler.ts +8 -5
- package/src/rest/RealtimeRecordingHandler.ts +13 -10
- package/src/rest/ViewOperationsHandler.ts +24 -6
- package/src/serverRoleConfigUnits.ts +48 -0
- package/src/services/TaskGraphContinuationDeliverer.ts +52 -20
- package/src/types.ts +23 -1
|
@@ -9,20 +9,22 @@
|
|
|
9
9
|
* widget guest is ephemeral). Forensics ride the opaque per-session id (`mj_sid`)
|
|
10
10
|
* carried in the token, plus best-effort structured audit logging. The minted
|
|
11
11
|
* token is validated by the SAME `magic-link` auth provider (same issuer/audience/
|
|
12
|
-
* JWKS) and synthesized into a constrained guest principal by `
|
|
12
|
+
* JWKS) and synthesized into a constrained guest principal by `BuildMagicLinkSessionUser`.
|
|
13
13
|
*
|
|
14
14
|
* @module @memberjunction/server/widget
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { createPublicKey } from 'node:crypto';
|
|
18
|
+
import jwt from 'jsonwebtoken';
|
|
17
19
|
import { Metadata, RunView, UserInfo, LogError, LogStatus } from '@memberjunction/core';
|
|
18
|
-
import { MJLruCache, UUIDsEqual } from '@memberjunction/global';
|
|
20
|
+
import { ComputeJwkThumbprint, MJLruCache, ToProofPublicJwk, UUIDsEqual, VerifyProofOfPossessionJwt, type ProofPublicJwk } from '@memberjunction/global';
|
|
19
21
|
import type { MJConversationWidgetInstanceEntity, MJConversationEntity } from '@memberjunction/core-entities';
|
|
20
22
|
import { ResolveConfiguredPrincipal } from '../auth/principals.js';
|
|
21
23
|
import { MagicLinkKeyManager } from '../auth/magicLink/MagicLinkKeys.js';
|
|
22
24
|
import { GenerateSessionId } from '../auth/magicLink/magicLinkCore.js';
|
|
23
25
|
import { MagicLinkService } from '../auth/magicLink/MagicLinkService.js';
|
|
24
26
|
import { configInfo, type WidgetConfig } from '../config.js';
|
|
25
|
-
import { BuildWidgetGuestClaims, EvaluateWidgetMint, ParseEnabledChannels, type WidgetMintErrorCode } from './widgetCore.js';
|
|
27
|
+
import { BuildWidgetGuestClaims, EvaluateWidgetMint, IsIsolatedGuestRole, ParseEnabledChannels, type GuestRolePolicy, type WidgetMintErrorCode } from './widgetCore.js';
|
|
26
28
|
import { VerifyHostAssertion, type HostAssertedIdentity } from './host-identity.js';
|
|
27
29
|
import { WriteReturningVisitorRecap } from '../agentSessions/ReturningVisitorRecap.js';
|
|
28
30
|
import { ResolveIdentityByEmail, MergeVisitorIdentity, ForgetVisitor, type ResolvedVisitorIdentity } from './visitorIdentity.js';
|
|
@@ -33,6 +35,43 @@ const CONVERSATIONS_ENTITY = 'MJ: Conversations';
|
|
|
33
35
|
/** Shape of the durable visitor anchor key (opaque base64url, same alphabet as generateSessionId). */
|
|
34
36
|
const VISITOR_KEY_PATTERN = /^[A-Za-z0-9_-]{16,128}$/;
|
|
35
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Maximum clock-skew / late-timer grace window (seconds) after `exp` during which
|
|
40
|
+
* `RefreshGuestSession` still accepts a widget guest Bearer token and preserves its `mj_sid`.
|
|
41
|
+
*/
|
|
42
|
+
export const REFRESH_GRACE_SECONDS = 300;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Hard end of a widget guest session (seconds after its first mint, `mj_sid_iat`). Refresh keeps the
|
|
46
|
+
* visitor's `mj_sid`, so without an end a token captured once could be renewed forever and keep reading
|
|
47
|
+
* that visitor's conversations; past this point refresh is refused and no token outlives it.
|
|
48
|
+
*/
|
|
49
|
+
export const MAX_GUEST_SESSION_SECONDS = 12 * 3600;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The least lifetime a refreshed token may have. Refresh is refused once less than this remains before the hard end,
|
|
53
|
+
* so the last refresh gets the 403 that makes the widget start a new session. It must exceed the widget's refresh
|
|
54
|
+
* lead (60 s before `exp`): a token issued with less would be due for refresh at once, every time, until the rate
|
|
55
|
+
* limiter answered 429 instead. It also keeps a re-minted token's `exp` after its `iat`.
|
|
56
|
+
*/
|
|
57
|
+
export const MIN_REFRESHED_TOKEN_SECONDS = 120;
|
|
58
|
+
|
|
59
|
+
/** The refresh route's path under the widget mount; the refresh proof must name it (`htu`). */
|
|
60
|
+
export const WIDGET_REFRESH_PATH = '/session/refresh';
|
|
61
|
+
|
|
62
|
+
/** How far a refresh proof's signing time (`iat`) may be from the server clock, either way. */
|
|
63
|
+
export const REFRESH_PROOF_MAX_SKEW_SECONDS = 60;
|
|
64
|
+
|
|
65
|
+
/** The session a valid refresh token belongs to, carried into the re-minted token unchanged. */
|
|
66
|
+
interface RefreshableGuestSession {
|
|
67
|
+
/** `mj_sid`. */
|
|
68
|
+
SessionId: string;
|
|
69
|
+
/** `mj_sid_iat`: when the session was first minted, epoch seconds. */
|
|
70
|
+
StartedAtSeconds: number;
|
|
71
|
+
/** `cnf.jkt`: the thumbprint of the key the session is bound to. */
|
|
72
|
+
KeyThumbprint: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
36
75
|
/** Resolved returning-visitor anchor for a mint: the durable key + the prior conversation to chain from. */
|
|
37
76
|
interface ReturningVisitorResolution {
|
|
38
77
|
/** The durable VisitorKey to persist as a cookie (validated-presented or freshly minted). */
|
|
@@ -67,6 +106,19 @@ export interface MintGuestSessionInput {
|
|
|
67
106
|
* server mints a fresh one. Ignored entirely when remembering is off.
|
|
68
107
|
*/
|
|
69
108
|
visitorKey?: string; // case-violation-ok-legacy-back-compat: optional, and the old name is also read off a value the checker cannot type; renaming it stays assignable and silently yields undefined
|
|
109
|
+
/**
|
|
110
|
+
* The caller's current guest session JWT (`Authorization: Bearer <token>`), required by
|
|
111
|
+
* `RefreshGuestSession` so a refresh proves possession of the session being renewed and
|
|
112
|
+
* preserves its `mj_sid` (`sessionId`).
|
|
113
|
+
*/
|
|
114
|
+
BearerToken?: string;
|
|
115
|
+
/**
|
|
116
|
+
* The widget's proof key (public P-256 JWK, from the mint body's `proofKey`). Its thumbprint is signed into
|
|
117
|
+
* the token as `cnf.jkt`; a token minted without one cannot be refreshed.
|
|
118
|
+
*/
|
|
119
|
+
ProofKey?: ProofPublicJwk;
|
|
120
|
+
/** The refresh proof (`DPoP` header), signed by the key registered at mint. Required by `RefreshGuestSession`. */
|
|
121
|
+
Proof?: string;
|
|
70
122
|
audit?: WidgetMintAuditContext; // case-violation-ok-legacy-back-compat: optional, and the old name is also read off a value the checker cannot type; renaming it stays assignable and silently yields undefined
|
|
71
123
|
}
|
|
72
124
|
|
|
@@ -210,6 +262,8 @@ export class WidgetSessionService {
|
|
|
210
262
|
constructor(
|
|
211
263
|
private readonly publicUrl: string,
|
|
212
264
|
private readonly config: WidgetConfig,
|
|
265
|
+
/** Which roles a widget may hand to an anonymous guest; by default only the scope-isolated `Widget Guest`. */
|
|
266
|
+
private readonly guestRolePolicy: GuestRolePolicy = { GrantableRoleNames: [] },
|
|
213
267
|
) {}
|
|
214
268
|
|
|
215
269
|
/**
|
|
@@ -237,11 +291,11 @@ export class WidgetSessionService {
|
|
|
237
291
|
return this.audited({ success: false, errorCode: eligibility.errorCode, error: 'Widget mint rejected.' }, input, widget);
|
|
238
292
|
}
|
|
239
293
|
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
return this.audited({ success: false, errorCode: 'server_error', error: 'Guest role not resolvable.' }, input, widget);
|
|
294
|
+
const guestRole = this.resolveIsolatedGuestRole(widget);
|
|
295
|
+
if (guestRole.ok === false) {
|
|
296
|
+
return this.audited(guestRole.refusal, input, widget);
|
|
244
297
|
}
|
|
298
|
+
const guestRoleName = guestRole.name;
|
|
245
299
|
|
|
246
300
|
// D1 host-identity strategy: a HostIdentity widget MUST present a valid host assertion.
|
|
247
301
|
let hostIdentity: HostAssertedIdentity | undefined;
|
|
@@ -267,7 +321,21 @@ export class WidgetSessionService {
|
|
|
267
321
|
// anonymous trail to that record and surface the pair so the client stamps the new conversation.
|
|
268
322
|
const resolvedIdentity = await this.resolveHostIdentityIfApplicable(widget, hostIdentity, returningVisitor, contextUser);
|
|
269
323
|
|
|
270
|
-
|
|
324
|
+
let proofKeyThumbprint: string | undefined;
|
|
325
|
+
if (input.ProofKey !== undefined) {
|
|
326
|
+
const proofKey = ToProofPublicJwk(input.ProofKey);
|
|
327
|
+
if (!proofKey) {
|
|
328
|
+
LogError(`[Widget] Mint for widget ${widget.ID} refused: the proof key is not a public P-256 JWK.`);
|
|
329
|
+
return this.audited({ success: false, errorCode: 'not_found', error: 'Widget mint rejected.' }, input, widget);
|
|
330
|
+
}
|
|
331
|
+
proofKeyThumbprint = await ComputeJwkThumbprint(proofKey);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return this.audited(
|
|
335
|
+
this.mintToken(widget, guestRoleName, hostIdentity, returningVisitor, resolvedIdentity, undefined, proofKeyThumbprint),
|
|
336
|
+
input,
|
|
337
|
+
widget,
|
|
338
|
+
);
|
|
271
339
|
} catch (e) {
|
|
272
340
|
LogError(e);
|
|
273
341
|
return { success: false, errorCode: 'server_error', error: e instanceof Error ? e.message : String(e) };
|
|
@@ -275,12 +343,147 @@ export class WidgetSessionService {
|
|
|
275
343
|
}
|
|
276
344
|
|
|
277
345
|
/**
|
|
278
|
-
* Refreshes a live guest session
|
|
279
|
-
*
|
|
280
|
-
*
|
|
346
|
+
* Refreshes a live guest session while preserving its per-visitor `sessionId` (`mj_sid`).
|
|
347
|
+
* Requires the caller's current widget guest JWT (`input.BearerToken`), verified against the
|
|
348
|
+
* magic-link signing key with a {@link REFRESH_GRACE_SECONDS} post-expiry grace window, and
|
|
349
|
+
* bound to the resolved widget instance (`mj_widget_id === widget.ID`, `mj_anon === true`,
|
|
350
|
+
* `mj_magic_link === true`). Any failure returns the same uniform 403 shape as an unknown widget key.
|
|
281
351
|
*/
|
|
282
352
|
public async RefreshGuestSession(input: MintGuestSessionInput): Promise<MintGuestSessionResult> {
|
|
283
|
-
|
|
353
|
+
try {
|
|
354
|
+
const contextUser = this.resolveLookupUser();
|
|
355
|
+
if (!contextUser) {
|
|
356
|
+
LogError('[Widget] No lookup context user available; server not configured.');
|
|
357
|
+
return { success: false, errorCode: 'server_error', error: 'Server not configured for widget sessions.' };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const widget = await this.loadWidgetByKey(input.widgetKey, contextUser);
|
|
361
|
+
if (!widget) {
|
|
362
|
+
return this.audited({ success: false, errorCode: 'not_found', error: 'Unknown widget key.' }, input, undefined);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const eligibility = EvaluateWidgetMint(
|
|
366
|
+
{ Status: widget.Status, AllowedOrigins: widget.AllowedOrigins, Modality: widget.Modality },
|
|
367
|
+
input.origin,
|
|
368
|
+
);
|
|
369
|
+
if (!eligibility.ok) {
|
|
370
|
+
return this.audited({ success: false, errorCode: eligibility.errorCode, error: 'Widget mint rejected.' }, input, widget);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const guestRole = this.resolveIsolatedGuestRole(widget);
|
|
374
|
+
if (guestRole.ok === false) {
|
|
375
|
+
return this.audited(guestRole.refusal, input, widget);
|
|
376
|
+
}
|
|
377
|
+
const guestRoleName = guestRole.name;
|
|
378
|
+
|
|
379
|
+
let hostIdentity: HostAssertedIdentity | undefined;
|
|
380
|
+
if (widget.AuthStrategy === 'HostIdentity') {
|
|
381
|
+
const verified = this.verifyHost(widget, input.hostAssertion);
|
|
382
|
+
if (!verified) {
|
|
383
|
+
return this.audited({ success: false, errorCode: 'host_assertion_invalid', error: 'Host identity assertion invalid.' }, input, widget);
|
|
384
|
+
}
|
|
385
|
+
hostIdentity = verified;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const existingSession = await this.verifyRefreshRequest(input.BearerToken, input.Proof, widget.ID);
|
|
389
|
+
if (!existingSession) {
|
|
390
|
+
return this.audited({ success: false, errorCode: 'not_found', error: 'Unknown widget key.' }, input, widget);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const returningVisitor = await this.resolveReturningVisitor(widget, input.visitorKey, contextUser);
|
|
394
|
+
const resolvedIdentity = await this.resolveHostIdentityIfApplicable(widget, hostIdentity, returningVisitor, contextUser);
|
|
395
|
+
|
|
396
|
+
return this.audited(
|
|
397
|
+
this.mintToken(widget, guestRoleName, hostIdentity, returningVisitor, resolvedIdentity, existingSession, existingSession.KeyThumbprint),
|
|
398
|
+
input,
|
|
399
|
+
widget,
|
|
400
|
+
);
|
|
401
|
+
} catch (e) {
|
|
402
|
+
LogError(e);
|
|
403
|
+
return { success: false, errorCode: 'server_error', error: e instanceof Error ? e.message : String(e) };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Verifies a `RefreshGuestSession` request: the caller's current widget guest JWT and the proof that the
|
|
409
|
+
* caller holds the key the token is bound to. Returns the session to carry forward, or `null` when the token
|
|
410
|
+
* is missing, tampered, expired past {@link REFRESH_GRACE_SECONDS}, past the session's hard end
|
|
411
|
+
* ({@link MAX_GUEST_SESSION_SECONDS}) or without a session start, non-anonymous, minted for a different
|
|
412
|
+
* widget, issued by another deployment, or not bound to a key; or when the proof is missing or not made by
|
|
413
|
+
* that key for this request and token.
|
|
414
|
+
*/
|
|
415
|
+
private async verifyRefreshRequest(bearerToken: string | undefined, proof: string | undefined, widgetId: string): Promise<RefreshableGuestSession | null> {
|
|
416
|
+
const session = this.verifyRefreshBearerToken(bearerToken, widgetId);
|
|
417
|
+
if (!session) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
const verification = await VerifyProofOfPossessionJwt(proof ?? '', {
|
|
421
|
+
Method: 'POST',
|
|
422
|
+
PathSuffix: WIDGET_REFRESH_PATH,
|
|
423
|
+
AccessToken: (bearerToken ?? '').trim(),
|
|
424
|
+
NowSeconds: Math.floor(Date.now() / 1000),
|
|
425
|
+
MaxSkewSeconds: REFRESH_PROOF_MAX_SKEW_SECONDS,
|
|
426
|
+
});
|
|
427
|
+
if (verification.Valid === false) {
|
|
428
|
+
LogError(`[Widget] Refresh proof refused for widget ${widgetId} (${verification.Reason}).`);
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
if (verification.Thumbprint !== session.KeyThumbprint) {
|
|
432
|
+
LogError(`[Widget] Refresh proof refused for widget ${widgetId}: signed by a key the token is not bound to.`);
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return session;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** The token half of {@link verifyRefreshRequest}: everything except the proof. */
|
|
439
|
+
private verifyRefreshBearerToken(bearerToken: string | undefined, widgetId: string): RefreshableGuestSession | null {
|
|
440
|
+
const token = (bearerToken ?? '').trim();
|
|
441
|
+
if (!token) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
const jwk = MagicLinkKeyManager.Instance.GetJWKS().keys[0];
|
|
446
|
+
if (!jwk) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
const publicKey = createPublicKey({ key: { ...jwk }, format: 'jwk' });
|
|
450
|
+
const verified = jwt.verify(token, publicKey, {
|
|
451
|
+
algorithms: ['RS256'],
|
|
452
|
+
audience: this.config.audience,
|
|
453
|
+
issuer: this.publicUrl,
|
|
454
|
+
ignoreExpiration: true,
|
|
455
|
+
});
|
|
456
|
+
if (typeof verified !== 'object' || verified === null) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
const payload = verified as jwt.JwtPayload;
|
|
460
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
461
|
+
if (typeof payload.exp !== 'number' || nowSeconds > payload.exp + REFRESH_GRACE_SECONDS) {
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
if (payload.mj_magic_link !== true || payload.mj_anon !== true) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (typeof payload.mj_widget_id !== 'string' || !UUIDsEqual(payload.mj_widget_id, widgetId)) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
const sid = typeof payload.mj_sid === 'string' ? payload.mj_sid.trim() : '';
|
|
471
|
+
if (sid.length === 0) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
const startedAt = payload.mj_sid_iat;
|
|
475
|
+
if (typeof startedAt !== 'number' || !Number.isFinite(startedAt) || startedAt + MAX_GUEST_SESSION_SECONDS - nowSeconds < MIN_REFRESHED_TOKEN_SECONDS) {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
const keyThumbprint = typeof payload.cnf?.jkt === 'string' ? payload.cnf.jkt : '';
|
|
479
|
+
if (keyThumbprint.length === 0) {
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
return { SessionId: sid, StartedAtSeconds: startedAt, KeyThumbprint: keyThumbprint };
|
|
483
|
+
} catch (e) {
|
|
484
|
+
LogError(`[Widget] Refresh token verification failed for widget ${widgetId}: ${e instanceof Error ? e.message : String(e)}`);
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
284
487
|
}
|
|
285
488
|
|
|
286
489
|
/**
|
|
@@ -343,7 +546,7 @@ export class WidgetSessionService {
|
|
|
343
546
|
* clicks the emailed link → the existing public `POST /magic-link/redeem` mints a VERIFIED session
|
|
344
547
|
* JWT → the widget swaps it in via `transport.UpdateToken`, preserving the live conversationId.
|
|
345
548
|
*
|
|
346
|
-
* This converges on the SAME `AuthProviderFactory` + `
|
|
549
|
+
* This converges on the SAME `AuthProviderFactory` + `BuildMagicLinkSessionUser` path as the guest
|
|
347
550
|
* mint (D1), so the verified session is just a more-privileged principal on the one pathway. Never
|
|
348
551
|
* throws for business failures — returns a structured result.
|
|
349
552
|
*/
|
|
@@ -412,12 +615,18 @@ export class WidgetSessionService {
|
|
|
412
615
|
hostIdentity?: HostAssertedIdentity,
|
|
413
616
|
returningVisitor?: ReturningVisitorResolution,
|
|
414
617
|
resolvedIdentity?: ResolvedVisitorIdentity,
|
|
618
|
+
existingSession?: RefreshableGuestSession,
|
|
619
|
+
proofKeyThumbprint?: string,
|
|
415
620
|
): MintGuestSessionResult {
|
|
416
621
|
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
417
622
|
const ttlMinutes = widget.SessionTTLMinutes || this.config.defaultSessionTtlMinutes;
|
|
418
|
-
// Generated once and
|
|
419
|
-
// this id so the Widget Guest RLS
|
|
420
|
-
|
|
623
|
+
// Generated once on initial mint and preserved across refreshes: the widget (and server-side
|
|
624
|
+
// voice session creation) stamps Conversation.ExternalID with this id so the Widget Guest RLS
|
|
625
|
+
// filters ({{ScopeResourceID}}) and AuthorizeSessionAccess isolate this guest's rows.
|
|
626
|
+
const sessionId = existingSession?.SessionId ?? GenerateSessionId();
|
|
627
|
+
const startedAtSeconds = existingSession?.StartedAtSeconds ?? nowSeconds;
|
|
628
|
+
// No token outlives the session's hard end, so the cap holds for API calls as well as for refresh.
|
|
629
|
+
const ttlSeconds = Math.min(ttlMinutes * 60, startedAtSeconds + MAX_GUEST_SESSION_SECONDS - nowSeconds);
|
|
421
630
|
const claims = BuildWidgetGuestClaims({
|
|
422
631
|
issuer: this.publicUrl,
|
|
423
632
|
audience: this.config.audience,
|
|
@@ -427,7 +636,9 @@ export class WidgetSessionService {
|
|
|
427
636
|
applicationId: widget.ApplicationID,
|
|
428
637
|
guestRoleName,
|
|
429
638
|
nowSeconds,
|
|
430
|
-
ttlSeconds
|
|
639
|
+
ttlSeconds,
|
|
640
|
+
sessionStartedAtSeconds: startedAtSeconds,
|
|
641
|
+
proofKeyThumbprint,
|
|
431
642
|
hostIdentity,
|
|
432
643
|
// RV1/RV2/RV4: carry the returning-visitor anchor + resolved identity as claims so the voice path
|
|
433
644
|
// (server-created conversation) stamps the same fields the text path stamps client-side.
|
|
@@ -692,6 +903,30 @@ export class WidgetSessionService {
|
|
|
692
903
|
return role?.Name ?? null;
|
|
693
904
|
}
|
|
694
905
|
|
|
906
|
+
/**
|
|
907
|
+
* The ONE decision, for mint and refresh alike, of which role a guest token carries: the widget's `GuestRoleID`
|
|
908
|
+
* must resolve, and it must be a role the deployment may hand to an anonymous visitor
|
|
909
|
+
* ({@link IsIsolatedGuestRole}). Both refusals are the admin's to fix, so both are logged with the widget id;
|
|
910
|
+
* the visitor gets a uniform rejection.
|
|
911
|
+
*/
|
|
912
|
+
private resolveIsolatedGuestRole(
|
|
913
|
+
widget: MJConversationWidgetInstanceEntity,
|
|
914
|
+
): { ok: true; name: string } | { ok: false; refusal: MintGuestSessionResult } {
|
|
915
|
+
const name = this.resolveGuestRoleName(widget.GuestRoleID);
|
|
916
|
+
if (!name) {
|
|
917
|
+
LogError(`[Widget] Guest role ${widget.GuestRoleID} for widget ${widget.ID} not found in metadata.`);
|
|
918
|
+
return { ok: false, refusal: { success: false, errorCode: 'server_error', error: 'Guest role not resolvable.' } };
|
|
919
|
+
}
|
|
920
|
+
if (!IsIsolatedGuestRole(name, this.guestRolePolicy)) {
|
|
921
|
+
LogError(
|
|
922
|
+
`[Widget] Widget ${widget.ID} grants guest role '${name}', whose row filters do not isolate anonymous visitors ` +
|
|
923
|
+
`from each other. Use the Widget Guest role, or list '${name}' in magicLink.grantableRoleNames to allow it (MJ#6043).`,
|
|
924
|
+
);
|
|
925
|
+
return { ok: false, refusal: { success: false, errorCode: 'guest_role_not_isolated', error: 'Widget mint rejected.' } };
|
|
926
|
+
}
|
|
927
|
+
return { ok: true, name };
|
|
928
|
+
}
|
|
929
|
+
|
|
695
930
|
/** Resolves the server-side context user used to READ widget config (not the guest principal). */
|
|
696
931
|
private resolveLookupUser(): UserInfo | null {
|
|
697
932
|
return ResolveConfiguredPrincipal(this.config.contextUserForLookup, 'Widget');
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `POST /widget/session`, which verifies it against the host's registered public key
|
|
6
6
|
* and folds the host-provided identity into the minted guest claims. The minted token
|
|
7
7
|
* is still validated by the same `magic-link` AuthProviderFactory path + synthesized by
|
|
8
|
-
* `
|
|
8
|
+
* `BuildMagicLinkSessionUser` — host-identity is a MINT-TIME strategy, not a second
|
|
9
9
|
* session-validation provider (it converges on the one pathway, per D1).
|
|
10
10
|
*
|
|
11
11
|
* Pure + unit-testable: verification takes the PEM as an argument.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @module @memberjunction/server/widget
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { BuildSessionClaims } from '../auth/magicLink/magicLinkCore.js';
|
|
15
|
+
import { BuildSessionClaims, IsRoleGrantable } from '../auth/magicLink/magicLinkCore.js';
|
|
16
16
|
import type { MagicLinkJWTClaims } from '../auth/magicLink/types.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -31,8 +31,29 @@ export type WidgetMintErrorCode =
|
|
|
31
31
|
| 'host_assertion_invalid'
|
|
32
32
|
| 'upgrade_not_enabled'
|
|
33
33
|
| 'invalid_email'
|
|
34
|
+
| 'guest_role_not_isolated'
|
|
34
35
|
| 'server_error';
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The one stock role whose row filters key on the per-visitor scope id (`{{ScopeResourceID}}`) rather than on
|
|
39
|
+
* `UserID`. Every anonymous widget guest authenticates as the ONE shared Anonymous user, so a role whose filters
|
|
40
|
+
* compare `UserID` (the stock `UI` role, for instance) lets every guest read and update every other guest's rows
|
|
41
|
+
* through the generic API (MJ#6043). A widget may therefore grant only this role, or a role the deployment has
|
|
42
|
+
* explicitly listed as safe for anonymous visitors — the same opt-in list magic-link invites use.
|
|
43
|
+
*/
|
|
44
|
+
export const WIDGET_GUEST_ROLE_NAME = 'Widget Guest';
|
|
45
|
+
|
|
46
|
+
/** Which roles, beyond {@link WIDGET_GUEST_ROLE_NAME}, a deployment allows a widget to hand to an anonymous guest. */
|
|
47
|
+
export interface GuestRolePolicy {
|
|
48
|
+
/** Role names (case-insensitive) the deployment has opted in, normally `magicLink.grantableRoleNames`. */
|
|
49
|
+
GrantableRoleNames: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Pure check: may a widget grant `roleName` to an anonymous guest under `policy`? See {@link WIDGET_GUEST_ROLE_NAME}. */
|
|
53
|
+
export function IsIsolatedGuestRole(roleName: string | null | undefined, policy: GuestRolePolicy): boolean {
|
|
54
|
+
return IsRoleGrantable(roleName, WIDGET_GUEST_ROLE_NAME, policy.GrantableRoleNames);
|
|
55
|
+
}
|
|
56
|
+
|
|
36
57
|
/** The minimal widget-instance shape the pure validators need (a subset of the entity). */
|
|
37
58
|
export interface WidgetInstanceEligibilityInput {
|
|
38
59
|
Status: string;
|
|
@@ -206,6 +227,10 @@ export function BuildWidgetGuestClaims(args: {
|
|
|
206
227
|
guestRoleName: string;
|
|
207
228
|
nowSeconds: number;
|
|
208
229
|
ttlSeconds: number;
|
|
230
|
+
/** When `sessionId` was first minted (`mj_sid_iat`); a refresh passes the original. Defaults to `nowSeconds`. */
|
|
231
|
+
sessionStartedAtSeconds?: number;
|
|
232
|
+
/** Thumbprint of the widget's proof key (`cnf.jkt`). Without it the token cannot be refreshed. */
|
|
233
|
+
proofKeyThumbprint?: string;
|
|
209
234
|
/**
|
|
210
235
|
* Host-asserted identity for a `host-identity` session. Its email/name are carried as
|
|
211
236
|
* INFORMATIONAL claims only — the principal-resolving `email`/`sub` remain the shared
|
|
@@ -248,6 +273,10 @@ export function BuildWidgetGuestClaims(args: {
|
|
|
248
273
|
});
|
|
249
274
|
// Additive widget claim — lets the synthesized principal be bound to one widget.
|
|
250
275
|
claims.mj_widget_id = args.widgetId;
|
|
276
|
+
claims.mj_sid_iat = args.sessionStartedAtSeconds ?? args.nowSeconds;
|
|
277
|
+
if (args.proofKeyThumbprint) {
|
|
278
|
+
claims.cnf = { jkt: args.proofKeyThumbprint };
|
|
279
|
+
}
|
|
251
280
|
if (args.hostIdentity) {
|
|
252
281
|
claims.given_name = args.hostIdentity.firstName ?? claims.given_name;
|
|
253
282
|
claims.family_name = args.hostIdentity.lastName ?? claims.family_name;
|
|
@@ -41,7 +41,7 @@ export interface WidgetGuestRunContext {
|
|
|
41
41
|
* Returns elevation context when the request is a public web-widget guest, else `null` (the common
|
|
42
42
|
* case — every non-widget request). A widget guest is identified by the synthesized principal's
|
|
43
43
|
* `IsMagicLinkAnonymous` flag plus a `WidgetGuestContext.WidgetID` (sourced from the signed
|
|
44
|
-
* `mj_widget_id` claim by `
|
|
44
|
+
* `mj_widget_id` claim by `BuildMagicLinkSessionUser`). The widget instance is loaded under the
|
|
45
45
|
* SYSTEM principal so resolving the pinned agent does not depend on the guest's narrow grants.
|
|
46
46
|
*
|
|
47
47
|
* Never throws: a resolution failure (no system user, widget not found, read error) returns `null`,
|
|
@@ -169,6 +169,7 @@ export function ElevateUserPayload(userPayload: UserPayload, elevatedUser: UserI
|
|
|
169
169
|
email: elevatedUser.Email,
|
|
170
170
|
userRecord: elevatedUser,
|
|
171
171
|
isSystemUser: true,
|
|
172
|
+
ElevatedFrom: userPayload.userRecord,
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
175
|
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Resolver, Mutation, Arg, Ctx } from "type-graphql";
|
|
2
2
|
import { ActionEngineServer } from "@memberjunction/actions";
|
|
3
3
|
import { EntityActionEngineServer } from "@memberjunction/actions";
|
|
4
|
-
import { Metadata, UserInfo, BaseEntity, CompositeKey, KeyValuePair, LogError, RunView, DatabaseProviderBase } from "@memberjunction/core";
|
|
5
|
-
import { ActionParam, ActionResult, MJActionEntityExtended } from "@memberjunction/actions-base";
|
|
4
|
+
import { Metadata, UserInfo, BaseEntity, CompositeKey, KeyValuePair, LogError, RunView, DatabaseProviderBase, EntityInfo, IMetadataProvider } from "@memberjunction/core";
|
|
5
|
+
import { ActionParam, ActionResult, MJActionEntityExtended, ProjectActionParamValuesForUser } from "@memberjunction/actions-base";
|
|
6
6
|
import { UserCache } from "@memberjunction/generic-database-provider";
|
|
7
7
|
import { Field, InputType, ObjectType } from "type-graphql";
|
|
8
8
|
import { KeyValuePairInput } from "../generic/KeyValuePairInput.js";
|
|
9
9
|
import { AppContext, ProviderInfo } from "../types.js";
|
|
10
|
-
import { CopyScalarsAndArrays, EscapeSQLString, UUIDsEqual } from "@memberjunction/global";
|
|
10
|
+
import { CopyScalarsAndArrays, EscapeSQLString, IndexByUUID, UUIDsEqual } from "@memberjunction/global";
|
|
11
11
|
import { GetReadOnlyProvider, GetReadWriteProvider } from "../util.js";
|
|
12
12
|
import { ResolverBase } from "../generic/ResolverBase.js";
|
|
13
13
|
import { IsScopeLimitedPrincipal } from "../auth/scopeLimitedPrincipal.js";
|
|
14
14
|
import { EvaluateActionRunAuthorization, IsOwner } from "../auth/actionAuthorization.js";
|
|
15
|
+
import { EntityObjectDataBinding, ProjectActionParamsForCaller } from "../generic/actionOutputFieldSecurity.js";
|
|
16
|
+
import type { EntityActionResult } from "@memberjunction/actions-base";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Input type for action parameters
|
|
@@ -213,8 +215,8 @@ export class ActionResolver extends ResolverBase {
|
|
|
213
215
|
// params.Provider.SearchEntity) run against the caller's metadata layer.
|
|
214
216
|
const result = await this.executeAction(action, user, params, ctx.providers);
|
|
215
217
|
|
|
216
|
-
// Return the result
|
|
217
|
-
return this.createActionResult(result);
|
|
218
|
+
// Return the result, its output parameters projected for the caller
|
|
219
|
+
return this.createActionResult(result, user, ctx.providers);
|
|
218
220
|
} catch (e) {
|
|
219
221
|
return this.handleActionError(e);
|
|
220
222
|
}
|
|
@@ -357,20 +359,29 @@ export class ActionResolver extends ResolverBase {
|
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
/**
|
|
360
|
-
* Creates an action result from the execution result
|
|
362
|
+
* Creates an action result from the execution result. The output parameters are projected for
|
|
363
|
+
* the caller first (see {@link ProjectActionParamValuesForUser}): an action may return rows it
|
|
364
|
+
* did not load as the caller, such as engine-cached or system-user rows, so an entity object is
|
|
365
|
+
* sent as its field values projected for the caller and a plain row of a field-secured entity
|
|
366
|
+
* loses the keys the caller is denied. An entity object of an entity the caller cannot read is
|
|
367
|
+
* kept as it is, so `CopyScalarsAndArrays` drops it exactly as it always has.
|
|
361
368
|
* @param result The execution result
|
|
369
|
+
* @param user The caller the result is sent to
|
|
370
|
+
* @param providers The request's providers, for the entity metadata the projection reads
|
|
362
371
|
* @returns The formatted action result
|
|
363
372
|
* @private
|
|
364
373
|
*/
|
|
365
|
-
private createActionResult(result: ActionResult): ActionResultOutput {
|
|
366
|
-
const
|
|
374
|
+
private createActionResult(result: ActionResult, user: UserInfo, providers: Array<ProviderInfo>): ActionResultOutput {
|
|
375
|
+
const outputs = (result.Params || result.RunParams.Params || [])
|
|
367
376
|
.filter(p => p.Type.trim().toLowerCase() === 'output' ||
|
|
368
|
-
p.Type.trim().toLowerCase() === 'both')
|
|
377
|
+
p.Type.trim().toLowerCase() === 'both');
|
|
378
|
+
const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true }) ?? undefined;
|
|
379
|
+
const projected = ProjectActionParamValuesForUser(outputs, user, provider, { UnreadableEntityObjects: 'keep' }) ?? outputs;
|
|
369
380
|
return {
|
|
370
381
|
Success: result.Success,
|
|
371
382
|
Message: result.Message,
|
|
372
383
|
ResultCode: result.Result?.ResultCode,
|
|
373
|
-
ResultData:
|
|
384
|
+
ResultData: projected.length > 0 ? JSON.stringify(CopyScalarsAndArrays(projected)) : undefined
|
|
374
385
|
};
|
|
375
386
|
}
|
|
376
387
|
|
|
@@ -442,11 +453,11 @@ export class ActionResolver extends ResolverBase {
|
|
|
442
453
|
};
|
|
443
454
|
}
|
|
444
455
|
|
|
445
|
-
// Return the result
|
|
456
|
+
// Return the result, its echoed parameters projected for the caller
|
|
446
457
|
return {
|
|
447
458
|
Success: result.Success,
|
|
448
459
|
Message: result.Message,
|
|
449
|
-
ResultData: JSON.stringify(result)
|
|
460
|
+
ResultData: JSON.stringify(this.projectEntityActionResult(result, entityAction, params.EntityObject, user, ctx.providers))
|
|
450
461
|
};
|
|
451
462
|
} catch (e) {
|
|
452
463
|
return this.handleError(e);
|
|
@@ -513,13 +524,65 @@ export class ActionResolver extends ResolverBase {
|
|
|
513
524
|
throw new Error("Entity information is required");
|
|
514
525
|
}
|
|
515
526
|
|
|
516
|
-
// Create a composite key and load the entity object
|
|
527
|
+
// Create a composite key and load the entity object FOR THE CALLER: with no user the load
|
|
528
|
+
// falls back to the provider's current user, which on a server is the system user (every
|
|
529
|
+
// column, and none of the caller's row-level security).
|
|
517
530
|
const compositeKey = this.createCompositeKey(entity, input.PrimaryKey);
|
|
518
|
-
const entityObject = await md.GetEntityObject(entity.Name);
|
|
519
|
-
await entityObject.InnerLoad(compositeKey)
|
|
531
|
+
const entityObject = await md.GetEntityObject(entity.Name, user);
|
|
532
|
+
if (!await entityObject.InnerLoad(compositeKey)) {
|
|
533
|
+
// One message whether the record is missing or out of the caller's reach.
|
|
534
|
+
throw new Error('Record not found or access denied');
|
|
535
|
+
}
|
|
520
536
|
params['EntityObject'] = entityObject;
|
|
521
537
|
}
|
|
522
538
|
|
|
539
|
+
/**
|
|
540
|
+
* The entity action result as it may be sent to `user`: its parameters, which the result echoes
|
|
541
|
+
* (in `Params` and in `RunParams.Params`), projected for the caller wherever their entity is known.
|
|
542
|
+
* That is any entity object among them, and the parameters bound to the record's field values
|
|
543
|
+
* (`'Entity Object Data'`), whose entity is the bound record's. Any other value then passes the
|
|
544
|
+
* general backstop ({@link ProjectActionParamValuesForUser}), which narrows plain objects shaped
|
|
545
|
+
* like a row of a field-secured entity.
|
|
546
|
+
*/
|
|
547
|
+
private projectEntityActionResult(
|
|
548
|
+
result: EntityActionResult,
|
|
549
|
+
entityAction: { EntityID?: string; Params?: Array<{ ActionParamID: string; ValueType: string }> },
|
|
550
|
+
entityObject: BaseEntity | undefined,
|
|
551
|
+
user: UserInfo,
|
|
552
|
+
providers: Array<ProviderInfo>
|
|
553
|
+
): EntityActionResult {
|
|
554
|
+
const provider = GetReadOnlyProvider(providers, { allowFallbackToReadWrite: true }) ?? undefined;
|
|
555
|
+
const binding = this.entityObjectDataBinding(entityAction, entityObject, provider);
|
|
556
|
+
const project = (params: ActionParam[]) =>
|
|
557
|
+
ProjectActionParamValuesForUser(ProjectActionParamsForCaller(params, user, provider, binding), user, provider, { UnreadableEntityObjects: 'keep' });
|
|
558
|
+
const projected: EntityActionResult = { ...result, Params: project(result.Params) };
|
|
559
|
+
if (result.RunParams) {
|
|
560
|
+
projected.RunParams = { ...result.RunParams, Params: project(result.RunParams.Params) };
|
|
561
|
+
}
|
|
562
|
+
return projected;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/** The action parameters bound as `'Entity Object Data'`, with the entity their values belong to. */
|
|
566
|
+
private entityObjectDataBinding(
|
|
567
|
+
entityAction: { EntityID?: string; Params?: Array<{ ActionParamID: string; ValueType: string }> },
|
|
568
|
+
entityObject: BaseEntity | undefined,
|
|
569
|
+
provider: IMetadataProvider | undefined
|
|
570
|
+
): EntityObjectDataBinding | undefined {
|
|
571
|
+
const entityInfo: EntityInfo | undefined = entityObject?.EntityInfo
|
|
572
|
+
?? provider?.Entities?.find(e => UUIDsEqual(e.ID, entityAction?.EntityID));
|
|
573
|
+
if (!entityInfo) {
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
const names = new Set<string>();
|
|
577
|
+
const dataParams = (entityAction?.Params ?? []).filter(eap => eap.ValueType === 'Entity Object Data');
|
|
578
|
+
const actionParamsById = dataParams.length > 0 ? IndexByUUID(ActionEngineServer.Instance.ActionParams) : null;
|
|
579
|
+
for (const eap of dataParams) {
|
|
580
|
+
const param = actionParamsById?.Get(eap.ActionParamID);
|
|
581
|
+
if (param?.Name) names.add(param.Name.trim().toLowerCase());
|
|
582
|
+
}
|
|
583
|
+
return names.size > 0 ? { EntityInfo: entityInfo, ParamNames: names } : undefined;
|
|
584
|
+
}
|
|
585
|
+
|
|
523
586
|
/**
|
|
524
587
|
* Creates a composite key from the input
|
|
525
588
|
* @param entity The entity information
|
|
@@ -139,6 +139,7 @@ export class AdhocQueryResolver extends ResolverBase {
|
|
|
139
139
|
QueryID: '',
|
|
140
140
|
QueryName: 'Ad-Hoc Query',
|
|
141
141
|
Success: true,
|
|
142
|
+
// fls-guard: query rows; the SQL is refused before it runs if it reads a field the caller is denied
|
|
142
143
|
Results: JSON.stringify(result.Results),
|
|
143
144
|
RowCount: result.RowCount,
|
|
144
145
|
TotalRowCount: result.TotalRowCount,
|