@eloxiv/testing 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Admin.d.ts +20 -0
- package/dist/Admin.d.ts.map +1 -0
- package/dist/Admin.js +61 -0
- package/dist/Admin.js.map +1 -0
- package/dist/Agent.d.ts +97 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +210 -0
- package/dist/Agent.js.map +1 -0
- package/dist/AgentSurface.d.ts +20 -0
- package/dist/AgentSurface.d.ts.map +1 -0
- package/dist/AgentSurface.js +36 -0
- package/dist/AgentSurface.js.map +1 -0
- package/dist/Embedder.d.ts +21 -0
- package/dist/Embedder.d.ts.map +1 -0
- package/dist/Embedder.js +54 -0
- package/dist/Embedder.js.map +1 -0
- package/dist/EvalMain.d.ts +2 -0
- package/dist/EvalMain.d.ts.map +1 -0
- package/dist/EvalMain.js +80 -0
- package/dist/EvalMain.js.map +1 -0
- package/dist/Evals.d.ts +95 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +389 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Kernel.d.ts +88 -0
- package/dist/Kernel.d.ts.map +1 -0
- package/dist/Kernel.js +108 -0
- package/dist/Kernel.js.map +1 -0
- package/dist/Launch.d.ts +86 -0
- package/dist/Launch.d.ts.map +1 -0
- package/dist/Launch.js +370 -0
- package/dist/Launch.js.map +1 -0
- package/dist/Locks.d.ts +39 -0
- package/dist/Locks.d.ts.map +1 -0
- package/dist/Locks.js +94 -0
- package/dist/Locks.js.map +1 -0
- package/dist/Routes.d.ts +19 -0
- package/dist/Routes.d.ts.map +1 -0
- package/dist/Routes.js +38 -0
- package/dist/Routes.js.map +1 -0
- package/dist/ScriptedChatModel.d.ts +51 -0
- package/dist/ScriptedChatModel.d.ts.map +1 -0
- package/dist/ScriptedChatModel.js +135 -0
- package/dist/ScriptedChatModel.js.map +1 -0
- package/dist/SmtpSink.d.ts +36 -0
- package/dist/SmtpSink.d.ts.map +1 -0
- package/dist/SmtpSink.js +185 -0
- package/dist/SmtpSink.js.map +1 -0
- package/dist/System.d.ts +271 -0
- package/dist/System.d.ts.map +1 -0
- package/dist/System.js +905 -0
- package/dist/System.js.map +1 -0
- package/dist/TcpProxy.d.ts +17 -0
- package/dist/TcpProxy.d.ts.map +1 -0
- package/dist/TcpProxy.js +100 -0
- package/dist/TcpProxy.js.map +1 -0
- package/dist/auth/TrustedProxyAuth.d.ts +28 -0
- package/dist/auth/TrustedProxyAuth.d.ts.map +1 -0
- package/dist/auth/TrustedProxyAuth.js +128 -0
- package/dist/auth/TrustedProxyAuth.js.map +1 -0
- package/dist/conformance/ActionConsent.d.ts +3 -0
- package/dist/conformance/ActionConsent.d.ts.map +1 -0
- package/dist/conformance/ActionConsent.js +347 -0
- package/dist/conformance/ActionConsent.js.map +1 -0
- package/dist/conformance/ActionRegistry.d.ts +64 -0
- package/dist/conformance/ActionRegistry.d.ts.map +1 -0
- package/dist/conformance/ActionRegistry.js +136 -0
- package/dist/conformance/ActionRegistry.js.map +1 -0
- package/dist/conformance/Actor.d.ts +43 -0
- package/dist/conformance/Actor.d.ts.map +1 -0
- package/dist/conformance/Actor.js +171 -0
- package/dist/conformance/Actor.js.map +1 -0
- package/dist/conformance/AgentReference.d.ts +30 -0
- package/dist/conformance/AgentReference.d.ts.map +1 -0
- package/dist/conformance/AgentReference.js +137 -0
- package/dist/conformance/AgentReference.js.map +1 -0
- package/dist/conformance/AgentResources.d.ts +3 -0
- package/dist/conformance/AgentResources.d.ts.map +1 -0
- package/dist/conformance/AgentResources.js +454 -0
- package/dist/conformance/AgentResources.js.map +1 -0
- package/dist/conformance/AgentRuntime.d.ts +3 -0
- package/dist/conformance/AgentRuntime.d.ts.map +1 -0
- package/dist/conformance/AgentRuntime.js +302 -0
- package/dist/conformance/AgentRuntime.js.map +1 -0
- package/dist/conformance/AgentSubject.d.ts +87 -0
- package/dist/conformance/AgentSubject.d.ts.map +1 -0
- package/dist/conformance/AgentSubject.js +18 -0
- package/dist/conformance/AgentSubject.js.map +1 -0
- package/dist/conformance/Approvals.d.ts +3 -0
- package/dist/conformance/Approvals.d.ts.map +1 -0
- package/dist/conformance/Approvals.js +258 -0
- package/dist/conformance/Approvals.js.map +1 -0
- package/dist/conformance/Audit.d.ts +3 -0
- package/dist/conformance/Audit.d.ts.map +1 -0
- package/dist/conformance/Audit.js +221 -0
- package/dist/conformance/Audit.js.map +1 -0
- package/dist/conformance/CalendarProvider.d.ts +4 -0
- package/dist/conformance/CalendarProvider.d.ts.map +1 -0
- package/dist/conformance/CalendarProvider.js +108 -0
- package/dist/conformance/CalendarProvider.js.map +1 -0
- package/dist/conformance/CapabilityKit.d.ts +191 -0
- package/dist/conformance/CapabilityKit.d.ts.map +1 -0
- package/dist/conformance/CapabilityKit.js +375 -0
- package/dist/conformance/CapabilityKit.js.map +1 -0
- package/dist/conformance/ClientSDK.d.ts +78 -0
- package/dist/conformance/ClientSDK.d.ts.map +1 -0
- package/dist/conformance/ClientSDK.js +163 -0
- package/dist/conformance/ClientSDK.js.map +1 -0
- package/dist/conformance/CollabDocument.d.ts +3 -0
- package/dist/conformance/CollabDocument.d.ts.map +1 -0
- package/dist/conformance/CollabDocument.js +934 -0
- package/dist/conformance/CollabDocument.js.map +1 -0
- package/dist/conformance/CollabReference.d.ts +8 -0
- package/dist/conformance/CollabReference.d.ts.map +1 -0
- package/dist/conformance/CollabReference.js +138 -0
- package/dist/conformance/CollabReference.js.map +1 -0
- package/dist/conformance/CollabSubject.d.ts +68 -0
- package/dist/conformance/CollabSubject.d.ts.map +1 -0
- package/dist/conformance/CollabSubject.js +2 -0
- package/dist/conformance/CollabSubject.js.map +1 -0
- package/dist/conformance/Command.d.ts +3 -0
- package/dist/conformance/Command.d.ts.map +1 -0
- package/dist/conformance/Command.js +73 -0
- package/dist/conformance/Command.js.map +1 -0
- package/dist/conformance/Connections.d.ts +4 -0
- package/dist/conformance/Connections.d.ts.map +1 -0
- package/dist/conformance/Connections.js +308 -0
- package/dist/conformance/Connections.js.map +1 -0
- package/dist/conformance/ConnectionsReference.d.ts +56 -0
- package/dist/conformance/ConnectionsReference.d.ts.map +1 -0
- package/dist/conformance/ConnectionsReference.js +74 -0
- package/dist/conformance/ConnectionsReference.js.map +1 -0
- package/dist/conformance/ConnectorReference.d.ts +86 -0
- package/dist/conformance/ConnectorReference.d.ts.map +1 -0
- package/dist/conformance/ConnectorReference.js +185 -0
- package/dist/conformance/ConnectorReference.js.map +1 -0
- package/dist/conformance/ContextAccounting.d.ts +8 -0
- package/dist/conformance/ContextAccounting.d.ts.map +1 -0
- package/dist/conformance/ContextAccounting.js +125 -0
- package/dist/conformance/ContextAccounting.js.map +1 -0
- package/dist/conformance/Daemon.d.ts +150 -0
- package/dist/conformance/Daemon.d.ts.map +1 -0
- package/dist/conformance/Daemon.js +718 -0
- package/dist/conformance/Daemon.js.map +1 -0
- package/dist/conformance/DaemonReference.d.ts +15 -0
- package/dist/conformance/DaemonReference.d.ts.map +1 -0
- package/dist/conformance/DaemonReference.js +163 -0
- package/dist/conformance/DaemonReference.js.map +1 -0
- package/dist/conformance/DbTx.d.ts +17 -0
- package/dist/conformance/DbTx.d.ts.map +1 -0
- package/dist/conformance/DbTx.js +184 -0
- package/dist/conformance/DbTx.js.map +1 -0
- package/dist/conformance/DecisionTokens.d.ts +3 -0
- package/dist/conformance/DecisionTokens.d.ts.map +1 -0
- package/dist/conformance/DecisionTokens.js +551 -0
- package/dist/conformance/DecisionTokens.js.map +1 -0
- package/dist/conformance/Delegation.d.ts +3 -0
- package/dist/conformance/Delegation.d.ts.map +1 -0
- package/dist/conformance/Delegation.js +149 -0
- package/dist/conformance/Delegation.js.map +1 -0
- package/dist/conformance/DeskReference.d.ts +21 -0
- package/dist/conformance/DeskReference.d.ts.map +1 -0
- package/dist/conformance/DeskReference.js +47 -0
- package/dist/conformance/DeskReference.js.map +1 -0
- package/dist/conformance/DeviceControl.d.ts +3 -0
- package/dist/conformance/DeviceControl.d.ts.map +1 -0
- package/dist/conformance/DeviceControl.js +579 -0
- package/dist/conformance/DeviceControl.js.map +1 -0
- package/dist/conformance/Directory.d.ts +36 -0
- package/dist/conformance/Directory.d.ts.map +1 -0
- package/dist/conformance/Directory.js +253 -0
- package/dist/conformance/Directory.js.map +1 -0
- package/dist/conformance/DirectoryProvider.d.ts +4 -0
- package/dist/conformance/DirectoryProvider.d.ts.map +1 -0
- package/dist/conformance/DirectoryProvider.js +58 -0
- package/dist/conformance/DirectoryProvider.js.map +1 -0
- package/dist/conformance/DocumentSource.d.ts +4 -0
- package/dist/conformance/DocumentSource.d.ts.map +1 -0
- package/dist/conformance/DocumentSource.js +43 -0
- package/dist/conformance/DocumentSource.js.map +1 -0
- package/dist/conformance/EndpointReference.d.ts +40 -0
- package/dist/conformance/EndpointReference.d.ts.map +1 -0
- package/dist/conformance/EndpointReference.js +67 -0
- package/dist/conformance/EndpointReference.js.map +1 -0
- package/dist/conformance/Files.d.ts +40 -0
- package/dist/conformance/Files.d.ts.map +1 -0
- package/dist/conformance/Files.js +592 -0
- package/dist/conformance/Files.js.map +1 -0
- package/dist/conformance/FilesReference.d.ts +31 -0
- package/dist/conformance/FilesReference.d.ts.map +1 -0
- package/dist/conformance/FilesReference.js +116 -0
- package/dist/conformance/FilesReference.js.map +1 -0
- package/dist/conformance/FilesSubject.d.ts +46 -0
- package/dist/conformance/FilesSubject.d.ts.map +1 -0
- package/dist/conformance/FilesSubject.js +3 -0
- package/dist/conformance/FilesSubject.js.map +1 -0
- package/dist/conformance/Flags.d.ts +3 -0
- package/dist/conformance/Flags.d.ts.map +1 -0
- package/dist/conformance/Flags.js +183 -0
- package/dist/conformance/Flags.js.map +1 -0
- package/dist/conformance/Host.d.ts +64 -0
- package/dist/conformance/Host.d.ts.map +1 -0
- package/dist/conformance/Host.js +152 -0
- package/dist/conformance/Host.js.map +1 -0
- package/dist/conformance/HttpApi.d.ts +5 -0
- package/dist/conformance/HttpApi.d.ts.map +1 -0
- package/dist/conformance/HttpApi.js +131 -0
- package/dist/conformance/HttpApi.js.map +1 -0
- package/dist/conformance/InboxReference.d.ts +28 -0
- package/dist/conformance/InboxReference.d.ts.map +1 -0
- package/dist/conformance/InboxReference.js +331 -0
- package/dist/conformance/InboxReference.js.map +1 -0
- package/dist/conformance/InboxSubject.d.ts +92 -0
- package/dist/conformance/InboxSubject.d.ts.map +1 -0
- package/dist/conformance/InboxSubject.js +16 -0
- package/dist/conformance/InboxSubject.js.map +1 -0
- package/dist/conformance/Ingestion.d.ts +10 -0
- package/dist/conformance/Ingestion.d.ts.map +1 -0
- package/dist/conformance/Ingestion.js +335 -0
- package/dist/conformance/Ingestion.js.map +1 -0
- package/dist/conformance/Ingress.d.ts +62 -0
- package/dist/conformance/Ingress.d.ts.map +1 -0
- package/dist/conformance/Ingress.js +346 -0
- package/dist/conformance/Ingress.js.map +1 -0
- package/dist/conformance/Invocation.d.ts +3 -0
- package/dist/conformance/Invocation.d.ts.map +1 -0
- package/dist/conformance/Invocation.js +665 -0
- package/dist/conformance/Invocation.js.map +1 -0
- package/dist/conformance/IsolationMatrix.d.ts +60 -0
- package/dist/conformance/IsolationMatrix.d.ts.map +1 -0
- package/dist/conformance/IsolationMatrix.js +196 -0
- package/dist/conformance/IsolationMatrix.js.map +1 -0
- package/dist/conformance/LiveConnection.d.ts +72 -0
- package/dist/conformance/LiveConnection.d.ts.map +1 -0
- package/dist/conformance/LiveConnection.js +125 -0
- package/dist/conformance/LiveConnection.js.map +1 -0
- package/dist/conformance/LocalClient.d.ts +62 -0
- package/dist/conformance/LocalClient.d.ts.map +1 -0
- package/dist/conformance/LocalClient.js +526 -0
- package/dist/conformance/LocalClient.js.map +1 -0
- package/dist/conformance/Locale.d.ts +28 -0
- package/dist/conformance/Locale.d.ts.map +1 -0
- package/dist/conformance/Locale.js +115 -0
- package/dist/conformance/Locale.js.map +1 -0
- package/dist/conformance/MachineIdentity.d.ts +39 -0
- package/dist/conformance/MachineIdentity.d.ts.map +1 -0
- package/dist/conformance/MachineIdentity.js +595 -0
- package/dist/conformance/MachineIdentity.js.map +1 -0
- package/dist/conformance/MailProvider.d.ts +4 -0
- package/dist/conformance/MailProvider.d.ts.map +1 -0
- package/dist/conformance/MailProvider.js +167 -0
- package/dist/conformance/MailProvider.js.map +1 -0
- package/dist/conformance/Memory.d.ts +10 -0
- package/dist/conformance/Memory.d.ts.map +1 -0
- package/dist/conformance/Memory.js +179 -0
- package/dist/conformance/Memory.js.map +1 -0
- package/dist/conformance/Messaging.d.ts +49 -0
- package/dist/conformance/Messaging.d.ts.map +1 -0
- package/dist/conformance/Messaging.js +117 -0
- package/dist/conformance/Messaging.js.map +1 -0
- package/dist/conformance/Metering.d.ts +26 -0
- package/dist/conformance/Metering.d.ts.map +1 -0
- package/dist/conformance/Metering.js +236 -0
- package/dist/conformance/Metering.js.map +1 -0
- package/dist/conformance/ModelProvider.d.ts +32 -0
- package/dist/conformance/ModelProvider.d.ts.map +1 -0
- package/dist/conformance/ModelProvider.js +100 -0
- package/dist/conformance/ModelProvider.js.map +1 -0
- package/dist/conformance/ModuleManifest.d.ts +9 -0
- package/dist/conformance/ModuleManifest.d.ts.map +1 -0
- package/dist/conformance/ModuleManifest.js +542 -0
- package/dist/conformance/ModuleManifest.js.map +1 -0
- package/dist/conformance/NotebookAgent.d.ts +32 -0
- package/dist/conformance/NotebookAgent.d.ts.map +1 -0
- package/dist/conformance/NotebookAgent.js +31 -0
- package/dist/conformance/NotebookAgent.js.map +1 -0
- package/dist/conformance/NotificationChannel.d.ts +40 -0
- package/dist/conformance/NotificationChannel.d.ts.map +1 -0
- package/dist/conformance/NotificationChannel.js +78 -0
- package/dist/conformance/NotificationChannel.js.map +1 -0
- package/dist/conformance/Notifications.d.ts +3 -0
- package/dist/conformance/Notifications.d.ts.map +1 -0
- package/dist/conformance/Notifications.js +240 -0
- package/dist/conformance/Notifications.js.map +1 -0
- package/dist/conformance/OAuthClient.d.ts +123 -0
- package/dist/conformance/OAuthClient.d.ts.map +1 -0
- package/dist/conformance/OAuthClient.js +204 -0
- package/dist/conformance/OAuthClient.js.map +1 -0
- package/dist/conformance/Outbox.d.ts +3 -0
- package/dist/conformance/Outbox.d.ts.map +1 -0
- package/dist/conformance/Outbox.js +266 -0
- package/dist/conformance/Outbox.js.map +1 -0
- package/dist/conformance/PlatformReference.d.ts +5 -0
- package/dist/conformance/PlatformReference.d.ts.map +1 -0
- package/dist/conformance/PlatformReference.js +66 -0
- package/dist/conformance/PlatformReference.js.map +1 -0
- package/dist/conformance/PlatformSubject.d.ts +45 -0
- package/dist/conformance/PlatformSubject.d.ts.map +1 -0
- package/dist/conformance/PlatformSubject.js +3 -0
- package/dist/conformance/PlatformSubject.js.map +1 -0
- package/dist/conformance/Privacy.d.ts +3 -0
- package/dist/conformance/Privacy.d.ts.map +1 -0
- package/dist/conformance/Privacy.js +437 -0
- package/dist/conformance/Privacy.js.map +1 -0
- package/dist/conformance/Progress.d.ts +3 -0
- package/dist/conformance/Progress.d.ts.map +1 -0
- package/dist/conformance/Progress.js +153 -0
- package/dist/conformance/Progress.js.map +1 -0
- package/dist/conformance/Push.d.ts +38 -0
- package/dist/conformance/Push.d.ts.map +1 -0
- package/dist/conformance/Push.js +649 -0
- package/dist/conformance/Push.js.map +1 -0
- package/dist/conformance/PushReference.d.ts +3 -0
- package/dist/conformance/PushReference.d.ts.map +1 -0
- package/dist/conformance/PushReference.js +97 -0
- package/dist/conformance/PushReference.js.map +1 -0
- package/dist/conformance/QuerySurface.d.ts +9 -0
- package/dist/conformance/QuerySurface.d.ts.map +1 -0
- package/dist/conformance/QuerySurface.js +349 -0
- package/dist/conformance/QuerySurface.js.map +1 -0
- package/dist/conformance/Readiness.d.ts +23 -0
- package/dist/conformance/Readiness.d.ts.map +1 -0
- package/dist/conformance/Readiness.js +110 -0
- package/dist/conformance/Readiness.js.map +1 -0
- package/dist/conformance/Reference.d.ts +17 -0
- package/dist/conformance/Reference.d.ts.map +1 -0
- package/dist/conformance/Reference.js +246 -0
- package/dist/conformance/Reference.js.map +1 -0
- package/dist/conformance/Release.d.ts +73 -0
- package/dist/conformance/Release.d.ts.map +1 -0
- package/dist/conformance/Release.js +556 -0
- package/dist/conformance/Release.js.map +1 -0
- package/dist/conformance/ReleaseReference.d.ts +5 -0
- package/dist/conformance/ReleaseReference.d.ts.map +1 -0
- package/dist/conformance/ReleaseReference.js +124 -0
- package/dist/conformance/ReleaseReference.js.map +1 -0
- package/dist/conformance/ResultRendering.d.ts +3 -0
- package/dist/conformance/ResultRendering.d.ts.map +1 -0
- package/dist/conformance/ResultRendering.js +120 -0
- package/dist/conformance/ResultRendering.js.map +1 -0
- package/dist/conformance/Sandbox.d.ts +58 -0
- package/dist/conformance/Sandbox.d.ts.map +1 -0
- package/dist/conformance/Sandbox.js +213 -0
- package/dist/conformance/Sandbox.js.map +1 -0
- package/dist/conformance/SandboxReference.d.ts +3 -0
- package/dist/conformance/SandboxReference.d.ts.map +1 -0
- package/dist/conformance/SandboxReference.js +44 -0
- package/dist/conformance/SandboxReference.js.map +1 -0
- package/dist/conformance/Scheduler.d.ts +106 -0
- package/dist/conformance/Scheduler.d.ts.map +1 -0
- package/dist/conformance/Scheduler.js +576 -0
- package/dist/conformance/Scheduler.js.map +1 -0
- package/dist/conformance/ScreenContext.d.ts +84 -0
- package/dist/conformance/ScreenContext.d.ts.map +1 -0
- package/dist/conformance/ScreenContext.js +290 -0
- package/dist/conformance/ScreenContext.js.map +1 -0
- package/dist/conformance/Search.d.ts +3 -0
- package/dist/conformance/Search.d.ts.map +1 -0
- package/dist/conformance/Search.js +333 -0
- package/dist/conformance/Search.js.map +1 -0
- package/dist/conformance/Secrets.d.ts +8 -0
- package/dist/conformance/Secrets.d.ts.map +1 -0
- package/dist/conformance/Secrets.js +231 -0
- package/dist/conformance/Secrets.js.map +1 -0
- package/dist/conformance/SecretsReference.d.ts +44 -0
- package/dist/conformance/SecretsReference.d.ts.map +1 -0
- package/dist/conformance/SecretsReference.js +73 -0
- package/dist/conformance/SecretsReference.js.map +1 -0
- package/dist/conformance/ServicesReference.d.ts +8 -0
- package/dist/conformance/ServicesReference.d.ts.map +1 -0
- package/dist/conformance/ServicesReference.js +273 -0
- package/dist/conformance/ServicesReference.js.map +1 -0
- package/dist/conformance/ServicesSubject.d.ts +104 -0
- package/dist/conformance/ServicesSubject.d.ts.map +1 -0
- package/dist/conformance/ServicesSubject.js +2 -0
- package/dist/conformance/ServicesSubject.js.map +1 -0
- package/dist/conformance/Settings.d.ts +3 -0
- package/dist/conformance/Settings.d.ts.map +1 -0
- package/dist/conformance/Settings.js +177 -0
- package/dist/conformance/Settings.js.map +1 -0
- package/dist/conformance/Sharing.d.ts +3 -0
- package/dist/conformance/Sharing.d.ts.map +1 -0
- package/dist/conformance/Sharing.js +368 -0
- package/dist/conformance/Sharing.js.map +1 -0
- package/dist/conformance/ShellSubject.d.ts +29 -0
- package/dist/conformance/ShellSubject.d.ts.map +1 -0
- package/dist/conformance/ShellSubject.js +13 -0
- package/dist/conformance/ShellSubject.js.map +1 -0
- package/dist/conformance/SignOutRace.d.ts +23 -0
- package/dist/conformance/SignOutRace.d.ts.map +1 -0
- package/dist/conformance/SignOutRace.js +49 -0
- package/dist/conformance/SignOutRace.js.map +1 -0
- package/dist/conformance/Slot.d.ts +3 -0
- package/dist/conformance/Slot.d.ts.map +1 -0
- package/dist/conformance/Slot.js +79 -0
- package/dist/conformance/Slot.js.map +1 -0
- package/dist/conformance/Space.d.ts +63 -0
- package/dist/conformance/Space.d.ts.map +1 -0
- package/dist/conformance/Space.js +294 -0
- package/dist/conformance/Space.js.map +1 -0
- package/dist/conformance/StorageAdapter.d.ts +76 -0
- package/dist/conformance/StorageAdapter.d.ts.map +1 -0
- package/dist/conformance/StorageAdapter.js +181 -0
- package/dist/conformance/StorageAdapter.js.map +1 -0
- package/dist/conformance/StorageBackend.d.ts +23 -0
- package/dist/conformance/StorageBackend.d.ts.map +1 -0
- package/dist/conformance/StorageBackend.js +274 -0
- package/dist/conformance/StorageBackend.js.map +1 -0
- package/dist/conformance/Subject.d.ts +198 -0
- package/dist/conformance/Subject.d.ts.map +1 -0
- package/dist/conformance/Subject.js +26 -0
- package/dist/conformance/Subject.js.map +1 -0
- package/dist/conformance/Sync.d.ts +3 -0
- package/dist/conformance/Sync.d.ts.map +1 -0
- package/dist/conformance/Sync.js +190 -0
- package/dist/conformance/Sync.js.map +1 -0
- package/dist/conformance/Telemetry.d.ts +3 -0
- package/dist/conformance/Telemetry.d.ts.map +1 -0
- package/dist/conformance/Telemetry.js +218 -0
- package/dist/conformance/Telemetry.js.map +1 -0
- package/dist/conformance/ThemeTokens.d.ts +22 -0
- package/dist/conformance/ThemeTokens.d.ts.map +1 -0
- package/dist/conformance/ThemeTokens.js +121 -0
- package/dist/conformance/ThemeTokens.js.map +1 -0
- package/dist/conformance/ToolSource.d.ts +5 -0
- package/dist/conformance/ToolSource.d.ts.map +1 -0
- package/dist/conformance/ToolSource.js +520 -0
- package/dist/conformance/ToolSource.js.map +1 -0
- package/dist/conformance/Versioning.d.ts +3 -0
- package/dist/conformance/Versioning.d.ts.map +1 -0
- package/dist/conformance/Versioning.js +160 -0
- package/dist/conformance/Versioning.js.map +1 -0
- package/dist/conformance/View.d.ts +3 -0
- package/dist/conformance/View.d.ts.map +1 -0
- package/dist/conformance/View.js +121 -0
- package/dist/conformance/View.js.map +1 -0
- package/dist/conformance/WorkItems.d.ts +3 -0
- package/dist/conformance/WorkItems.d.ts.map +1 -0
- package/dist/conformance/WorkItems.js +152 -0
- package/dist/conformance/WorkItems.js.map +1 -0
- package/dist/conformance/Workflow.d.ts +63 -0
- package/dist/conformance/Workflow.d.ts.map +1 -0
- package/dist/conformance/Workflow.js +235 -0
- package/dist/conformance/Workflow.js.map +1 -0
- package/dist/conformance/acme/chatlog.d.ts +591 -0
- package/dist/conformance/acme/chatlog.d.ts.map +1 -0
- package/dist/conformance/acme/chatlog.js +101 -0
- package/dist/conformance/acme/chatlog.js.map +1 -0
- package/dist/conformance/acme/connector.d.ts +12 -0
- package/dist/conformance/acme/connector.d.ts.map +1 -0
- package/dist/conformance/acme/connector.js +123 -0
- package/dist/conformance/acme/connector.js.map +1 -0
- package/dist/conformance/acme/migrations/0000_messages.sql +8 -0
- package/dist/conformance/archive/app.d.ts +728 -0
- package/dist/conformance/archive/app.d.ts.map +1 -0
- package/dist/conformance/archive/app.js +30 -0
- package/dist/conformance/archive/app.js.map +1 -0
- package/dist/conformance/archive/contract.d.ts +467 -0
- package/dist/conformance/archive/contract.d.ts.map +1 -0
- package/dist/conformance/archive/contract.js +187 -0
- package/dist/conformance/archive/contract.js.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts +148 -0
- package/dist/conformance/archive/memo.sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/memo.sync.gen.js +23 -0
- package/dist/conformance/archive/memo.sync.gen.js.map +1 -0
- package/dist/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/dist/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/dist/conformance/archive/schema.d.ts +185 -0
- package/dist/conformance/archive/schema.d.ts.map +1 -0
- package/dist/conformance/archive/schema.js +22 -0
- package/dist/conformance/archive/schema.js.map +1 -0
- package/dist/conformance/archive/server.d.ts +273 -0
- package/dist/conformance/archive/server.d.ts.map +1 -0
- package/dist/conformance/archive/server.js +127 -0
- package/dist/conformance/archive/server.js.map +1 -0
- package/dist/conformance/archive/sync.gen.d.ts +319 -0
- package/dist/conformance/archive/sync.gen.d.ts.map +1 -0
- package/dist/conformance/archive/sync.gen.js +29 -0
- package/dist/conformance/archive/sync.gen.js.map +1 -0
- package/dist/conformance/atlas/app.d.ts +3 -0
- package/dist/conformance/atlas/app.d.ts.map +1 -0
- package/dist/conformance/atlas/app.js +15 -0
- package/dist/conformance/atlas/app.js.map +1 -0
- package/dist/conformance/atlas/contract.d.ts +489 -0
- package/dist/conformance/atlas/contract.d.ts.map +1 -0
- package/dist/conformance/atlas/contract.js +114 -0
- package/dist/conformance/atlas/contract.js.map +1 -0
- package/dist/conformance/crm/app.d.ts +304 -0
- package/dist/conformance/crm/app.d.ts.map +1 -0
- package/dist/conformance/crm/app.js +95 -0
- package/dist/conformance/crm/app.js.map +1 -0
- package/dist/conformance/crm/contract.d.ts +586 -0
- package/dist/conformance/crm/contract.d.ts.map +1 -0
- package/dist/conformance/crm/contract.js +153 -0
- package/dist/conformance/crm/contract.js.map +1 -0
- package/dist/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/dist/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/dist/conformance/crm/schema.d.ts +261 -0
- package/dist/conformance/crm/schema.d.ts.map +1 -0
- package/dist/conformance/crm/schema.js +25 -0
- package/dist/conformance/crm/schema.js.map +1 -0
- package/dist/conformance/crm/sync.gen.d.ts +188 -0
- package/dist/conformance/crm/sync.gen.d.ts.map +1 -0
- package/dist/conformance/crm/sync.gen.js +25 -0
- package/dist/conformance/crm/sync.gen.js.map +1 -0
- package/dist/conformance/desk/contract.d.ts +306 -0
- package/dist/conformance/desk/contract.d.ts.map +1 -0
- package/dist/conformance/desk/contract.js +56 -0
- package/dist/conformance/desk/contract.js.map +1 -0
- package/dist/conformance/desk/migrations/0000_notes.sql +7 -0
- package/dist/conformance/desk/server.d.ts +231 -0
- package/dist/conformance/desk/server.d.ts.map +1 -0
- package/dist/conformance/desk/server.js +123 -0
- package/dist/conformance/desk/server.js.map +1 -0
- package/dist/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/dist/conformance/drafts/module.d.ts +571 -0
- package/dist/conformance/drafts/module.d.ts.map +1 -0
- package/dist/conformance/drafts/module.js +190 -0
- package/dist/conformance/drafts/module.js.map +1 -0
- package/dist/conformance/fixture/app.d.ts +24 -0
- package/dist/conformance/fixture/app.d.ts.map +1 -0
- package/dist/conformance/fixture/app.js +26 -0
- package/dist/conformance/fixture/app.js.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts +105 -0
- package/dist/conformance/fixture/docs/bad-sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/bad-sync.js +22 -0
- package/dist/conformance/fixture/docs/bad-sync.js.map +1 -0
- package/dist/conformance/fixture/docs/contract.d.ts +1091 -0
- package/dist/conformance/fixture/docs/contract.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/contract.js +277 -0
- package/dist/conformance/fixture/docs/contract.js.map +1 -0
- package/dist/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/dist/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/dist/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/dist/conformance/fixture/docs/policy.cedar +110 -0
- package/dist/conformance/fixture/docs/schema.d.ts +308 -0
- package/dist/conformance/fixture/docs/schema.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/schema.js +36 -0
- package/dist/conformance/fixture/docs/schema.js.map +1 -0
- package/dist/conformance/fixture/docs/server.d.ts +552 -0
- package/dist/conformance/fixture/docs/server.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/server.js +192 -0
- package/dist/conformance/fixture/docs/server.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.d.ts +402 -0
- package/dist/conformance/fixture/docs/sync.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts +574 -0
- package/dist/conformance/fixture/docs/sync.gen.d.ts.map +1 -0
- package/dist/conformance/fixture/docs/sync.gen.js +48 -0
- package/dist/conformance/fixture/docs/sync.gen.js.map +1 -0
- package/dist/conformance/fixture/docs/sync.js +23 -0
- package/dist/conformance/fixture/docs/sync.js.map +1 -0
- package/dist/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/dist/conformance/fixture/peer/module.d.ts +306 -0
- package/dist/conformance/fixture/peer/module.d.ts.map +1 -0
- package/dist/conformance/fixture/peer/module.js +44 -0
- package/dist/conformance/fixture/peer/module.js.map +1 -0
- package/dist/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/dist/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/dist/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/dist/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/dist/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/module.d.ts +1878 -0
- package/dist/conformance/fixture/release/module.d.ts.map +1 -0
- package/dist/conformance/fixture/release/module.js +102 -0
- package/dist/conformance/fixture/release/module.js.map +1 -0
- package/dist/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/dist/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/dist/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/dist/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/dist/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/dist/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/dist/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/dist/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/dist/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/dist/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/dist/conformance/kit-hash.d.ts +8 -0
- package/dist/conformance/kit-hash.d.ts.map +1 -0
- package/dist/conformance/kit-hash.js +20 -0
- package/dist/conformance/kit-hash.js.map +1 -0
- package/dist/conformance/ledger/contract.d.ts +380 -0
- package/dist/conformance/ledger/contract.d.ts.map +1 -0
- package/dist/conformance/ledger/contract.js +81 -0
- package/dist/conformance/ledger/contract.js.map +1 -0
- package/dist/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/dist/conformance/ledger/server.d.ts +312 -0
- package/dist/conformance/ledger/server.d.ts.map +1 -0
- package/dist/conformance/ledger/server.js +152 -0
- package/dist/conformance/ledger/server.js.map +1 -0
- package/dist/conformance/library/app.d.ts +616 -0
- package/dist/conformance/library/app.d.ts.map +1 -0
- package/dist/conformance/library/app.js +35 -0
- package/dist/conformance/library/app.js.map +1 -0
- package/dist/conformance/library/contract.d.ts +377 -0
- package/dist/conformance/library/contract.d.ts.map +1 -0
- package/dist/conformance/library/contract.js +63 -0
- package/dist/conformance/library/contract.js.map +1 -0
- package/dist/conformance/library/migrations/0000_library.sql +14 -0
- package/dist/conformance/library/schema.d.ts +174 -0
- package/dist/conformance/library/schema.d.ts.map +1 -0
- package/dist/conformance/library/schema.js +24 -0
- package/dist/conformance/library/schema.js.map +1 -0
- package/dist/conformance/library/server.d.ts +191 -0
- package/dist/conformance/library/server.d.ts.map +1 -0
- package/dist/conformance/library/server.js +52 -0
- package/dist/conformance/library/server.js.map +1 -0
- package/dist/conformance/library/sync.gen.d.ts +519 -0
- package/dist/conformance/library/sync.gen.d.ts.map +1 -0
- package/dist/conformance/library/sync.gen.js +42 -0
- package/dist/conformance/library/sync.gen.js.map +1 -0
- package/dist/conformance/locale/catalog.d.ts +93 -0
- package/dist/conformance/locale/catalog.d.ts.map +1 -0
- package/dist/conformance/locale/catalog.js +104 -0
- package/dist/conformance/locale/catalog.js.map +1 -0
- package/dist/conformance/notebook/app.d.ts +1039 -0
- package/dist/conformance/notebook/app.d.ts.map +1 -0
- package/dist/conformance/notebook/app.js +88 -0
- package/dist/conformance/notebook/app.js.map +1 -0
- package/dist/conformance/notebook/evals/pages.evals.json +94 -0
- package/dist/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/dist/conformance/notebook/module.d.ts +717 -0
- package/dist/conformance/notebook/module.d.ts.map +1 -0
- package/dist/conformance/notebook/module.js +188 -0
- package/dist/conformance/notebook/module.js.map +1 -0
- package/dist/conformance/pad/app.d.ts +9 -0
- package/dist/conformance/pad/app.d.ts.map +1 -0
- package/dist/conformance/pad/app.js +13 -0
- package/dist/conformance/pad/app.js.map +1 -0
- package/dist/conformance/pad/contract.d.ts +281 -0
- package/dist/conformance/pad/contract.d.ts.map +1 -0
- package/dist/conformance/pad/contract.js +66 -0
- package/dist/conformance/pad/contract.js.map +1 -0
- package/dist/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/dist/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/dist/conformance/pad/schema.d.ts +127 -0
- package/dist/conformance/pad/schema.d.ts.map +1 -0
- package/dist/conformance/pad/schema.js +17 -0
- package/dist/conformance/pad/schema.js.map +1 -0
- package/dist/conformance/pad/server.d.ts +149 -0
- package/dist/conformance/pad/server.d.ts.map +1 -0
- package/dist/conformance/pad/server.js +81 -0
- package/dist/conformance/pad/server.js.map +1 -0
- package/dist/conformance/purchases/app.d.ts +480 -0
- package/dist/conformance/purchases/app.d.ts.map +1 -0
- package/dist/conformance/purchases/app.js +32 -0
- package/dist/conformance/purchases/app.js.map +1 -0
- package/dist/conformance/purchases/contract.d.ts +720 -0
- package/dist/conformance/purchases/contract.d.ts.map +1 -0
- package/dist/conformance/purchases/contract.js +148 -0
- package/dist/conformance/purchases/contract.js.map +1 -0
- package/dist/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/dist/conformance/purchases/server.d.ts +250 -0
- package/dist/conformance/purchases/server.d.ts.map +1 -0
- package/dist/conformance/purchases/server.js +85 -0
- package/dist/conformance/purchases/server.js.map +1 -0
- package/dist/conformance/studio/app.d.ts +996 -0
- package/dist/conformance/studio/app.d.ts.map +1 -0
- package/dist/conformance/studio/app.js +251 -0
- package/dist/conformance/studio/app.js.map +1 -0
- package/dist/conformance/studio/contract.d.ts +1318 -0
- package/dist/conformance/studio/contract.d.ts.map +1 -0
- package/dist/conformance/studio/contract.js +280 -0
- package/dist/conformance/studio/contract.js.map +1 -0
- package/dist/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/dist/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/dist/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/dist/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/dist/conformance/workshop/app.d.ts +8 -0
- package/dist/conformance/workshop/app.d.ts.map +1 -0
- package/dist/conformance/workshop/app.js +13 -0
- package/dist/conformance/workshop/app.js.map +1 -0
- package/dist/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/dist/conformance/workshop/module.d.ts +407 -0
- package/dist/conformance/workshop/module.d.ts.map +1 -0
- package/dist/conformance/workshop/module.js +71 -0
- package/dist/conformance/workshop/module.js.map +1 -0
- package/dist/fakes/AcmeFake.d.ts +46 -0
- package/dist/fakes/AcmeFake.d.ts.map +1 -0
- package/dist/fakes/AcmeFake.js +131 -0
- package/dist/fakes/AcmeFake.js.map +1 -0
- package/dist/fakes/ApnsFake.d.ts +79 -0
- package/dist/fakes/ApnsFake.d.ts.map +1 -0
- package/dist/fakes/ApnsFake.js +220 -0
- package/dist/fakes/ApnsFake.js.map +1 -0
- package/dist/fakes/FcmFake.d.ts +46 -0
- package/dist/fakes/FcmFake.d.ts.map +1 -0
- package/dist/fakes/FcmFake.js +185 -0
- package/dist/fakes/FcmFake.js.map +1 -0
- package/dist/fakes/GoogleFake.d.ts +221 -0
- package/dist/fakes/GoogleFake.d.ts.map +1 -0
- package/dist/fakes/GoogleFake.js +1035 -0
- package/dist/fakes/GoogleFake.js.map +1 -0
- package/dist/fakes/HttpApiFake.d.ts +22 -0
- package/dist/fakes/HttpApiFake.d.ts.map +1 -0
- package/dist/fakes/HttpApiFake.js +74 -0
- package/dist/fakes/HttpApiFake.js.map +1 -0
- package/dist/fakes/McpFake.d.ts +80 -0
- package/dist/fakes/McpFake.d.ts.map +1 -0
- package/dist/fakes/McpFake.js +312 -0
- package/dist/fakes/McpFake.js.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts +254 -0
- package/dist/fakes/MicrosoftGraphFake.d.ts.map +1 -0
- package/dist/fakes/MicrosoftGraphFake.js +850 -0
- package/dist/fakes/MicrosoftGraphFake.js.map +1 -0
- package/dist/fakes/S3Fake.d.ts +29 -0
- package/dist/fakes/S3Fake.d.ts.map +1 -0
- package/dist/fakes/S3Fake.js +347 -0
- package/dist/fakes/S3Fake.js.map +1 -0
- package/dist/fakes/Server.d.ts +137 -0
- package/dist/fakes/Server.d.ts.map +1 -0
- package/dist/fakes/Server.js +357 -0
- package/dist/fakes/Server.js.map +1 -0
- package/dist/fakes/SignInProviderFake.d.ts +21 -0
- package/dist/fakes/SignInProviderFake.d.ts.map +1 -0
- package/dist/fakes/SignInProviderFake.js +56 -0
- package/dist/fakes/SignInProviderFake.js.map +1 -0
- package/dist/fakes/SlackFake.d.ts +136 -0
- package/dist/fakes/SlackFake.d.ts.map +1 -0
- package/dist/fakes/SlackFake.js +787 -0
- package/dist/fakes/SlackFake.js.map +1 -0
- package/dist/fakes/Store.d.ts +40 -0
- package/dist/fakes/Store.d.ts.map +1 -0
- package/dist/fakes/Store.js +82 -0
- package/dist/fakes/Store.js.map +1 -0
- package/dist/fakes/TelemetryFakes.d.ts +77 -0
- package/dist/fakes/TelemetryFakes.d.ts.map +1 -0
- package/dist/fakes/TelemetryFakes.js +121 -0
- package/dist/fakes/TelemetryFakes.js.map +1 -0
- package/dist/fakes/TestCa.d.ts +11 -0
- package/dist/fakes/TestCa.d.ts.map +1 -0
- package/dist/fakes/TestCa.js +115 -0
- package/dist/fakes/TestCa.js.map +1 -0
- package/dist/fakes/WorkOsFake.d.ts +40 -0
- package/dist/fakes/WorkOsFake.d.ts.map +1 -0
- package/dist/fakes/WorkOsFake.js +103 -0
- package/dist/fakes/WorkOsFake.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/make/reference.d.ts +520 -0
- package/dist/make/reference.d.ts.map +1 -0
- package/dist/make/reference.js +182 -0
- package/dist/make/reference.js.map +1 -0
- package/dist/make/sources.d.ts +48 -0
- package/dist/make/sources.d.ts.map +1 -0
- package/dist/make/sources.js +806 -0
- package/dist/make/sources.js.map +1 -0
- package/package.json +77 -3
- package/src/Admin.ts +82 -0
- package/src/Agent.ts +289 -0
- package/src/AgentSurface.ts +51 -0
- package/src/Embedder.ts +69 -0
- package/src/EvalMain.ts +81 -0
- package/src/Evals.ts +490 -0
- package/src/Kernel.ts +228 -0
- package/src/Launch.ts +428 -0
- package/src/Locks.ts +123 -0
- package/src/Routes.ts +65 -0
- package/src/ScriptedChatModel.ts +189 -0
- package/src/SmtpSink.ts +205 -0
- package/src/System.ts +1072 -0
- package/src/TcpProxy.ts +102 -0
- package/src/auth/TrustedProxyAuth.ts +173 -0
- package/src/conformance/ActionConsent.ts +437 -0
- package/src/conformance/ActionRegistry.ts +174 -0
- package/src/conformance/Actor.ts +216 -0
- package/src/conformance/AgentReference.ts +171 -0
- package/src/conformance/AgentResources.ts +548 -0
- package/src/conformance/AgentRuntime.ts +388 -0
- package/src/conformance/AgentSubject.ts +103 -0
- package/src/conformance/Approvals.ts +363 -0
- package/src/conformance/Audit.ts +257 -0
- package/src/conformance/CalendarProvider.ts +156 -0
- package/src/conformance/CapabilityKit.ts +564 -0
- package/src/conformance/ClientSDK.ts +233 -0
- package/src/conformance/CollabDocument.ts +1203 -0
- package/src/conformance/CollabReference.ts +152 -0
- package/src/conformance/CollabSubject.ts +64 -0
- package/src/conformance/Command.ts +75 -0
- package/src/conformance/Connections.ts +357 -0
- package/src/conformance/ConnectionsReference.ts +172 -0
- package/src/conformance/ConnectorReference.ts +280 -0
- package/src/conformance/ContextAccounting.ts +169 -0
- package/src/conformance/Daemon.ts +936 -0
- package/src/conformance/DaemonReference.ts +189 -0
- package/src/conformance/DbTx.ts +253 -0
- package/src/conformance/DecisionTokens.ts +652 -0
- package/src/conformance/Delegation.ts +177 -0
- package/src/conformance/DeskReference.ts +73 -0
- package/src/conformance/DeviceControl.ts +700 -0
- package/src/conformance/Directory.ts +315 -0
- package/src/conformance/DirectoryProvider.ts +72 -0
- package/src/conformance/DocumentSource.ts +62 -0
- package/src/conformance/EndpointReference.ts +117 -0
- package/src/conformance/Files.ts +685 -0
- package/src/conformance/FilesReference.ts +154 -0
- package/src/conformance/FilesSubject.ts +50 -0
- package/src/conformance/Flags.ts +215 -0
- package/src/conformance/Host.ts +197 -0
- package/src/conformance/HttpApi.ts +169 -0
- package/src/conformance/InboxReference.ts +401 -0
- package/src/conformance/InboxSubject.ts +101 -0
- package/src/conformance/Ingestion.ts +425 -0
- package/src/conformance/Ingress.ts +498 -0
- package/src/conformance/Invocation.ts +780 -0
- package/src/conformance/IsolationMatrix.ts +215 -0
- package/src/conformance/LiveConnection.ts +197 -0
- package/src/conformance/LocalClient.ts +651 -0
- package/src/conformance/Locale.ts +141 -0
- package/src/conformance/MachineIdentity.ts +828 -0
- package/src/conformance/MailProvider.ts +217 -0
- package/src/conformance/Memory.ts +223 -0
- package/src/conformance/Messaging.ts +185 -0
- package/src/conformance/Metering.ts +293 -0
- package/src/conformance/ModelProvider.ts +139 -0
- package/src/conformance/ModuleManifest.ts +630 -0
- package/src/conformance/NotebookAgent.ts +41 -0
- package/src/conformance/NotificationChannel.ts +122 -0
- package/src/conformance/Notifications.ts +316 -0
- package/src/conformance/OAuthClient.ts +240 -0
- package/src/conformance/Outbox.ts +342 -0
- package/src/conformance/PlatformReference.ts +73 -0
- package/src/conformance/PlatformSubject.ts +50 -0
- package/src/conformance/Privacy.ts +577 -0
- package/src/conformance/Progress.ts +244 -0
- package/src/conformance/Push.ts +820 -0
- package/src/conformance/PushReference.ts +101 -0
- package/src/conformance/QuerySurface.ts +408 -0
- package/src/conformance/Readiness.ts +157 -0
- package/src/conformance/Reference.ts +326 -0
- package/src/conformance/Release.ts +690 -0
- package/src/conformance/ReleaseReference.ts +179 -0
- package/src/conformance/ResultRendering.ts +149 -0
- package/src/conformance/Sandbox.ts +313 -0
- package/src/conformance/SandboxReference.ts +52 -0
- package/src/conformance/Scheduler.ts +764 -0
- package/src/conformance/ScreenContext.ts +402 -0
- package/src/conformance/Search.ts +419 -0
- package/src/conformance/Secrets.ts +277 -0
- package/src/conformance/SecretsReference.ts +131 -0
- package/src/conformance/ServicesReference.ts +330 -0
- package/src/conformance/ServicesSubject.ts +105 -0
- package/src/conformance/Settings.ts +204 -0
- package/src/conformance/Sharing.ts +486 -0
- package/src/conformance/ShellSubject.ts +47 -0
- package/src/conformance/SignOutRace.ts +77 -0
- package/src/conformance/Slot.ts +84 -0
- package/src/conformance/Space.ts +432 -0
- package/src/conformance/StorageAdapter.ts +253 -0
- package/src/conformance/StorageBackend.ts +327 -0
- package/src/conformance/Subject.ts +208 -0
- package/src/conformance/Sync.ts +215 -0
- package/src/conformance/Telemetry.ts +287 -0
- package/src/conformance/ThemeTokens.ts +163 -0
- package/src/conformance/ToolSource.ts +632 -0
- package/src/conformance/Versioning.ts +199 -0
- package/src/conformance/View.ts +143 -0
- package/src/conformance/WorkItems.ts +186 -0
- package/src/conformance/Workflow.ts +304 -0
- package/src/conformance/acme/chatlog.ts +115 -0
- package/src/conformance/acme/connector.ts +151 -0
- package/src/conformance/acme/migrations/0000_messages.sql +8 -0
- package/src/conformance/archive/app.ts +33 -0
- package/src/conformance/archive/contract.ts +191 -0
- package/src/conformance/archive/memo.sync.gen.ts +25 -0
- package/src/conformance/archive/migrations/archive/0000_archive.sql +9 -0
- package/src/conformance/archive/migrations/memo/0000_memo.sql +6 -0
- package/src/conformance/archive/schema.ts +25 -0
- package/src/conformance/archive/server.ts +146 -0
- package/src/conformance/archive/sync.gen.ts +32 -0
- package/src/conformance/atlas/app.ts +16 -0
- package/src/conformance/atlas/contract.ts +118 -0
- package/src/conformance/crm/app.ts +107 -0
- package/src/conformance/crm/contract.ts +163 -0
- package/src/conformance/crm/migrations/crm/0000_crm.sql +18 -0
- package/src/conformance/crm/migrations/team/0000_team.sql +6 -0
- package/src/conformance/crm/schema.ts +28 -0
- package/src/conformance/crm/sync.gen.ts +27 -0
- package/src/conformance/desk/contract.ts +61 -0
- package/src/conformance/desk/migrations/0000_notes.sql +7 -0
- package/src/conformance/desk/server.ts +131 -0
- package/src/conformance/drafts/migrations/0000_drafts.sql +8 -0
- package/src/conformance/drafts/module.ts +211 -0
- package/src/conformance/fixture/app.ts +37 -0
- package/src/conformance/fixture/docs/bad-sync.ts +34 -0
- package/src/conformance/fixture/docs/contract.ts +297 -0
- package/src/conformance/fixture/docs/migrations/0000_docs.sql +9 -0
- package/src/conformance/fixture/docs/migrations/0001_seen.sql +12 -0
- package/src/conformance/fixture/docs/migrations/0002_attachment.sql +6 -0
- package/src/conformance/fixture/docs/policy.cedar +110 -0
- package/src/conformance/fixture/docs/schema.ts +41 -0
- package/src/conformance/fixture/docs/server.ts +292 -0
- package/src/conformance/fixture/docs/sync.gen.ts +54 -0
- package/src/conformance/fixture/docs/sync.ts +24 -0
- package/src/conformance/fixture/peer/migrations/0000_peer.sql +8 -0
- package/src/conformance/fixture/peer/module.ts +51 -0
- package/src/conformance/fixture/release/blocking/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking/0001_wait.sql +2 -0
- package/src/conformance/fixture/release/blocking-renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/blocking-renamed/0001_wait.sql +5 -0
- package/src/conformance/fixture/release/broken/0000_item.sql +3 -0
- package/src/conformance/fixture/release/broken/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/broken/0002_label.sql +3 -0
- package/src/conformance/fixture/release/drift/escalate/0000_item.sql +5 -0
- package/src/conformance/fixture/release/drift/escalate/0001_escalate.sql +8 -0
- package/src/conformance/fixture/release/drift/v1/0000_item.sql +5 -0
- package/src/conformance/fixture/release/escape/0000_item.sql +3 -0
- package/src/conformance/fixture/release/escape/0001_escape.sql +5 -0
- package/src/conformance/fixture/release/misnamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/misnamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/module.ts +119 -0
- package/src/conformance/fixture/release/outside/0000_item.sql +3 -0
- package/src/conformance/fixture/release/outside/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/outside/0002_index.sql +4 -0
- package/src/conformance/fixture/release/outside/0003_later.sql +1 -0
- package/src/conformance/fixture/release/renamed/0000_item.sql +3 -0
- package/src/conformance/fixture/release/renamed/0001_misname.sql +10 -0
- package/src/conformance/fixture/release/renamed/0002_restore.sql +1 -0
- package/src/conformance/fixture/release/rogue/0000_item.sql +3 -0
- package/src/conformance/fixture/release/rogue/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/rogue/0002_definer.sql +1 -0
- package/src/conformance/fixture/release/slow/0000_item.sql +5 -0
- package/src/conformance/fixture/release/undeclared/0000_item.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/undeclared/0002_index.sql +1 -0
- package/src/conformance/fixture/release/v1/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0000_item.sql +3 -0
- package/src/conformance/fixture/release/v2/0001_extra.sql +3 -0
- package/src/conformance/fixture/release/v2/0002_label.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0000_item.sql +3 -0
- package/src/conformance/fixture/release/viewed-retyped/0001_retype.sql +1 -0
- package/src/conformance/kit-hash.ts +18 -0
- package/src/conformance/ledger/contract.ts +92 -0
- package/src/conformance/ledger/migrations/0000_entries.sql +8 -0
- package/src/conformance/ledger/server.ts +174 -0
- package/src/conformance/library/app.ts +38 -0
- package/src/conformance/library/contract.ts +66 -0
- package/src/conformance/library/migrations/0000_library.sql +14 -0
- package/src/conformance/library/schema.ts +27 -0
- package/src/conformance/library/server.ts +65 -0
- package/src/conformance/library/sync.gen.ts +47 -0
- package/src/conformance/locale/catalog.ts +111 -0
- package/src/conformance/notebook/app.ts +115 -0
- package/src/conformance/notebook/evals/pages.evals.json +94 -0
- package/src/conformance/notebook/migrations/0000_notebook.sql +10 -0
- package/src/conformance/notebook/module.ts +215 -0
- package/src/conformance/notebook/skills/meeting-notes.md +4 -0
- package/src/conformance/pad/app.ts +21 -0
- package/src/conformance/pad/contract.ts +69 -0
- package/src/conformance/pad/migrations/pad/0000_pad.sql +8 -0
- package/src/conformance/pad/migrations/pad/0001_live_copy.sql +2 -0
- package/src/conformance/pad/schema.ts +18 -0
- package/src/conformance/pad/server.ts +102 -0
- package/src/conformance/purchases/app.ts +34 -0
- package/src/conformance/purchases/contract.ts +161 -0
- package/src/conformance/purchases/migrations/0000_purchases.sql +17 -0
- package/src/conformance/purchases/server.ts +95 -0
- package/src/conformance/replica-search.mjs +22 -0
- package/src/conformance/studio/app.ts +298 -0
- package/src/conformance/studio/contract.ts +319 -0
- package/src/conformance/studio/migrations/billing/0000_billing.sql +6 -0
- package/src/conformance/studio/migrations/journal/0000_journal.sql +9 -0
- package/src/conformance/studio/migrations/mailbox/0000_mailbox.sql +7 -0
- package/src/conformance/studio/migrations/tasks/0000_tasks.sql +7 -0
- package/src/conformance/workshop/app.ts +14 -0
- package/src/conformance/workshop/migrations/0000_notes.sql +7 -0
- package/src/conformance/workshop/module.ts +79 -0
- package/src/fakes/AcmeFake.ts +182 -0
- package/src/fakes/ApnsFake.ts +245 -0
- package/src/fakes/FcmFake.ts +231 -0
- package/src/fakes/GoogleFake.ts +1346 -0
- package/src/fakes/HttpApiFake.ts +116 -0
- package/src/fakes/McpFake.ts +355 -0
- package/src/fakes/MicrosoftGraphFake.ts +1191 -0
- package/src/fakes/S3Fake.ts +376 -0
- package/src/fakes/Server.ts +445 -0
- package/src/fakes/SignInProviderFake.ts +70 -0
- package/src/fakes/SlackFake.ts +893 -0
- package/src/fakes/Store.ts +96 -0
- package/src/fakes/TelemetryFakes.ts +197 -0
- package/src/fakes/TestCa.ts +166 -0
- package/src/fakes/WorkOsFake.ts +136 -0
- package/src/index.ts +9 -0
- package/src/make/reference.ts +259 -0
- package/src/make/sources.ts +836 -0
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A protocol fake of Slack: the OAuth v2 install flow, the Web API methods the `slack` connector uses, and the
|
|
3
|
+
* Events API's signed deliveries to a Request URL, following Slack's documentation (docs.slack.dev, read
|
|
4
|
+
* 2026-11-04):
|
|
5
|
+
*
|
|
6
|
+
* - OAuth v2: `GET /oauth/v2/authorize` (bot scopes in `scope`, comma-separated; `redirect_uri` must be HTTPS or
|
|
7
|
+
* localhost; the install is per workspace, and each consent adds its scopes to the workspace's grant) and
|
|
8
|
+
* `POST /api/oauth.v2.access` (client credentials by HTTP Basic or in the form; `grant_type=authorization_code`
|
|
9
|
+
* or `refresh_token`; the answer names the workspace in `team`, the bot in `bot_user_id` and the installing
|
|
10
|
+
* person in `authed_user`, and lists the scopes comma-separated in `scope`; PKCE arguments from an app that is
|
|
11
|
+
* not a public client are `pkce_not_allowed`). Without token rotation the bot token never expires and no
|
|
12
|
+
* refresh token is issued; with it (`tokenRotation`), access tokens expire after `expires_in` (43,200 s by
|
|
13
|
+
* default) and every refresh token works once.
|
|
14
|
+
* - Web API: every answer is HTTP 200 with `ok`, errors as `{ ok: false, error }` (`not_authed`, `invalid_auth`,
|
|
15
|
+
* `token_expired`, `token_revoked`, `missing_scope` with `needed` and `provided`, `channel_not_found`,
|
|
16
|
+
* `not_in_channel`, `thread_not_found`, `invalid_cursor`, `no_text`, `invalid_arguments`), except rate limits:
|
|
17
|
+
* HTTP 429 with `Retry-After` (seconds) and `{ ok: false, error: "ratelimited" }`. Responses carry
|
|
18
|
+
* `x-oauth-scopes`. Methods take a query string or a form or JSON body.
|
|
19
|
+
* - `auth.test`; `conversations.list` (`types`, the scope each type needs, `exclude_archived`, `limit`,
|
|
20
|
+
* cursors in `response_metadata.next_cursor`, empty at the end); `conversations.history` (newest first,
|
|
21
|
+
* thread replies left out, `latest`, `oldest`, `inclusive`, `limit`, `has_more` and cursors);
|
|
22
|
+
* `conversations.replies` (the parent first, then its replies oldest first, `limit` a page by cursor); `chat.postMessage` (`thread_ts`
|
|
23
|
+
* replies into the parent's thread; a bot must be in the channel unless it has `chat:write.public`).
|
|
24
|
+
* - Events API: a Request URL is verified with a signed `url_verification` whose `challenge` must come back
|
|
25
|
+
* (plain text, form or JSON) before it is used. Every message in a conversation the bot is in, for the bot
|
|
26
|
+
* events subscribed (`message.channels`, `message.groups`, `message.im`, `message.mpim`), is POSTed as an
|
|
27
|
+
* `event_callback` envelope (`event_id`, `team_id`, `api_app_id`, `authorizations`, `event_time`) signed with
|
|
28
|
+
* the signing secret (`x-slack-signature: v0=<hex>` over `v0:<timestamp>:<body>`). A delivery that is not
|
|
29
|
+
* answered 2xx within three seconds is retried three times with `x-slack-retry-num` and
|
|
30
|
+
* `x-slack-retry-reason`, each attempt signed afresh; `x-slack-no-retry: 1` on a failed answer stops the
|
|
31
|
+
* retries. The bot's own posts are delivered too, with `bot_id`.
|
|
32
|
+
*
|
|
33
|
+
* Not modelled: Slack's own per-method rate tiers (rate limits are injected), Enterprise Grid, Slack Connect,
|
|
34
|
+
* user tokens, edits, deletions, reactions, files, blocks, and the retry schedule's real delays (one minute and
|
|
35
|
+
* five minutes, shortened here to `retryDelaysMs`).
|
|
36
|
+
*
|
|
37
|
+
* Proven against a protocol fake, not the real service.
|
|
38
|
+
*/
|
|
39
|
+
import { createHmac, randomBytes } from "node:crypto"
|
|
40
|
+
import { json, Router, serve, token, type FakeRequest, type FakeResponse } from "./Server.ts"
|
|
41
|
+
|
|
42
|
+
export type SlackChannelType = "public_channel" | "private_channel" | "im" | "mpim"
|
|
43
|
+
|
|
44
|
+
export interface SlackChannel {
|
|
45
|
+
readonly id: string
|
|
46
|
+
readonly name: string
|
|
47
|
+
readonly type: SlackChannelType
|
|
48
|
+
readonly members: Set<string>
|
|
49
|
+
readonly archived: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SlackMessage {
|
|
53
|
+
readonly ts: string
|
|
54
|
+
readonly channel: string
|
|
55
|
+
readonly user: string
|
|
56
|
+
readonly team: string
|
|
57
|
+
readonly text: string
|
|
58
|
+
readonly thread_ts: string | undefined
|
|
59
|
+
readonly bot_id: string | undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface Team {
|
|
63
|
+
readonly id: string
|
|
64
|
+
readonly name: string
|
|
65
|
+
readonly domain: string
|
|
66
|
+
readonly users: Map<string, { readonly id: string; readonly name: string }>
|
|
67
|
+
readonly channels: Map<string, SlackChannel>
|
|
68
|
+
readonly messages: Array<SlackMessage>
|
|
69
|
+
/** The bot scopes granted to the app in this workspace (each consent adds to it). */
|
|
70
|
+
readonly scopes: Set<string>
|
|
71
|
+
installed: boolean
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface BotToken {
|
|
75
|
+
readonly team: string
|
|
76
|
+
expiresAt: number | null
|
|
77
|
+
valid: boolean
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface Code {
|
|
81
|
+
readonly team: string
|
|
82
|
+
readonly user: string
|
|
83
|
+
readonly redirectUri: string | undefined
|
|
84
|
+
readonly pkce: boolean
|
|
85
|
+
readonly expiresAt: number
|
|
86
|
+
used: boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const BOT_USER = "U0BOT0001"
|
|
90
|
+
const BOT_ID = "B0BOT0001"
|
|
91
|
+
const APP_ID = "A0FAKE0001"
|
|
92
|
+
/** A bot token's posts carry the app's bot profile, naming its bot user (as a real workspace delivers them). */
|
|
93
|
+
const botProfile = { id: "B0BOT0001", app_id: "A0FAKE0001", name: "eloxiv", deleted: false, user_id: "U0BOT0001" }
|
|
94
|
+
|
|
95
|
+
/** Where the scopes a conversation type needs (to list it, to read its history) come from. */
|
|
96
|
+
const READ_SCOPE: Record<SlackChannelType, string> = {
|
|
97
|
+
public_channel: "channels:read",
|
|
98
|
+
private_channel: "groups:read",
|
|
99
|
+
im: "im:read",
|
|
100
|
+
mpim: "mpim:read",
|
|
101
|
+
}
|
|
102
|
+
const HISTORY_SCOPE: Record<SlackChannelType, string> = {
|
|
103
|
+
public_channel: "channels:history",
|
|
104
|
+
private_channel: "groups:history",
|
|
105
|
+
im: "im:history",
|
|
106
|
+
mpim: "mpim:history",
|
|
107
|
+
}
|
|
108
|
+
const EVENT: Record<SlackChannelType, string> = {
|
|
109
|
+
public_channel: "message.channels",
|
|
110
|
+
private_channel: "message.groups",
|
|
111
|
+
im: "message.im",
|
|
112
|
+
mpim: "message.mpim",
|
|
113
|
+
}
|
|
114
|
+
const CHANNEL_TYPE: Record<SlackChannelType, string> = {
|
|
115
|
+
public_channel: "channel",
|
|
116
|
+
private_channel: "group",
|
|
117
|
+
im: "im",
|
|
118
|
+
mpim: "mpim",
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const cursorOf = (value: string) => Buffer.from(value, "utf8").toString("base64")
|
|
122
|
+
const readCursor = (cursor: string, prefix: string) => {
|
|
123
|
+
const decoded = Buffer.from(cursor, "base64").toString("utf8")
|
|
124
|
+
return decoded.startsWith(prefix) ? decoded.slice(prefix.length) : undefined
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Message timestamps: seconds and microseconds, unique and increasing in the workspace. */
|
|
128
|
+
let lastMicros = 0
|
|
129
|
+
const nextTs = () => {
|
|
130
|
+
lastMicros = Math.max(lastMicros + 1, Date.now() * 1000)
|
|
131
|
+
return `${Math.floor(lastMicros / 1_000_000)}.${String(lastMicros % 1_000_000).padStart(6, "0")}`
|
|
132
|
+
}
|
|
133
|
+
const compareTs = (a: string, b: string) => {
|
|
134
|
+
const [as, au] = a.split(".").map(Number)
|
|
135
|
+
const [bs, bu] = b.split(".").map(Number)
|
|
136
|
+
return as! - bs! || au! - bu!
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface SlackFakeOptions {
|
|
140
|
+
/** Token rotation on (access tokens expire, refresh tokens rotate). Default false, Slack's default. */
|
|
141
|
+
readonly tokenRotation?: boolean | undefined
|
|
142
|
+
/** The access tokens' lifetime with rotation (Slack: 43,200 s). */
|
|
143
|
+
readonly accessTtlS?: number | undefined
|
|
144
|
+
/** The waits before the second and third retries of a failed delivery (Slack: one and five minutes). */
|
|
145
|
+
readonly retryDelaysMs?: readonly [number, number, number] | undefined
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const startSlackFake = async (options: SlackFakeOptions = {}) => {
|
|
149
|
+
const clientId = "1111111111.2222222222"
|
|
150
|
+
const clientSecret = randomBytes(16).toString("hex")
|
|
151
|
+
const signingSecret = randomBytes(16).toString("hex")
|
|
152
|
+
const rotation = options.tokenRotation ?? false
|
|
153
|
+
const accessTtlS = options.accessTtlS ?? 43_200
|
|
154
|
+
const retryDelaysMs = options.retryDelaysMs ?? [0, 200, 400]
|
|
155
|
+
|
|
156
|
+
const teams = new Map<string, Team>()
|
|
157
|
+
const addTeam = (id: string, name: string) => {
|
|
158
|
+
const team: Team = {
|
|
159
|
+
id,
|
|
160
|
+
name,
|
|
161
|
+
domain: name.toLowerCase().replaceAll(/[^a-z0-9]+/gu, "-"),
|
|
162
|
+
users: new Map(),
|
|
163
|
+
channels: new Map(),
|
|
164
|
+
messages: [],
|
|
165
|
+
scopes: new Set(),
|
|
166
|
+
installed: false,
|
|
167
|
+
}
|
|
168
|
+
teams.set(id, team)
|
|
169
|
+
return team
|
|
170
|
+
}
|
|
171
|
+
const channel = (team: Team, id: string, name: string, type: SlackChannelType, members: ReadonlyArray<string>) =>
|
|
172
|
+
team.channels.set(id, { id, name, type, members: new Set(members), archived: false })
|
|
173
|
+
|
|
174
|
+
// The main workspace: two people, the bot in #general, the private #ops and a DM with Ada; not in #random.
|
|
175
|
+
const main = addTeam("T0ELOXIV1", "Eloxiv Test")
|
|
176
|
+
for (const [id, name] of [
|
|
177
|
+
["U0ADA0001", "ada"],
|
|
178
|
+
["U0BEN0001", "ben"],
|
|
179
|
+
] as const) {
|
|
180
|
+
main.users.set(id, { id, name })
|
|
181
|
+
}
|
|
182
|
+
channel(main, "C0GENERAL1", "general", "public_channel", ["U0ADA0001", "U0BEN0001", BOT_USER])
|
|
183
|
+
channel(main, "C0RANDOM01", "random", "public_channel", ["U0ADA0001"])
|
|
184
|
+
channel(main, "G0OPS00001", "ops", "private_channel", ["U0ADA0001", BOT_USER])
|
|
185
|
+
channel(main, "G0SECRET01", "secret", "private_channel", ["U0BEN0001"])
|
|
186
|
+
channel(main, "D0ADA00001", "", "im", ["U0ADA0001", BOT_USER])
|
|
187
|
+
for (let i = 1; i <= 5; i++) channel(main, `C0MORE0000${i}`, `more-${i}`, "public_channel", [BOT_USER])
|
|
188
|
+
channel(main, "C0OLD00001", "old", "public_channel", [BOT_USER])
|
|
189
|
+
;(main.channels.get("C0OLD00001") as { archived: boolean }).archived = true
|
|
190
|
+
// A second workspace, for one Connection per workspace.
|
|
191
|
+
const other = addTeam("T0OTHER01", "Other Test")
|
|
192
|
+
other.users.set("U0ADA0002", { id: "U0ADA0002", name: "ada" })
|
|
193
|
+
channel(other, "C0OTHERGEN", "general", "public_channel", ["U0ADA0002", BOT_USER])
|
|
194
|
+
// A partner workspace sharing a Slack Connect channel with the main one: its people post as members of their own
|
|
195
|
+
// team (`user_team`), while the delivery names the workspace that received it.
|
|
196
|
+
const partner = addTeam("T0PARTNER1", "Partner Test")
|
|
197
|
+
partner.users.set("U0PAT00001", { id: "U0PAT00001", name: "pat" })
|
|
198
|
+
channel(partner, "C0SHARED01", "shared", "public_channel", ["U0PAT00001", "U0ADA0001", BOT_USER])
|
|
199
|
+
|
|
200
|
+
/** Who approves the next install: the person signed in to Slack, in the workspace they picked. */
|
|
201
|
+
const signedIn = { team: main.id, user: "U0ADA0001" }
|
|
202
|
+
let denyNext = false
|
|
203
|
+
let pkceEnabled = false
|
|
204
|
+
|
|
205
|
+
const codes = new Map<string, Code>()
|
|
206
|
+
const bots = new Map<string, BotToken>()
|
|
207
|
+
const refreshTokens = new Map<string, { team: string; valid: boolean }>()
|
|
208
|
+
/** Without rotation, one bot token per workspace for the life of the install. */
|
|
209
|
+
const standing = new Map<string, string>()
|
|
210
|
+
const authorizations: Array<Readonly<Record<string, string>>> = []
|
|
211
|
+
const stats = { codeExchanges: 0, refreshes: 0, refreshFailures: 0, apiRequests: 0 }
|
|
212
|
+
const issued: Array<string> = []
|
|
213
|
+
/** Injected rate limits: the next requests to a method (or any, `*`) answered 429 with Retry-After. */
|
|
214
|
+
const limits: Array<{ method: string; retryAfter: string }> = []
|
|
215
|
+
/** Injected answers: the next requests to a method answered with this raw body (malformed answers, for tests). */
|
|
216
|
+
const scripted: Array<{ method: string; status: number; body: string }> = []
|
|
217
|
+
|
|
218
|
+
// Events API ------------------------------------------------------------------------------------------------
|
|
219
|
+
|
|
220
|
+
let requestUrl: string | undefined
|
|
221
|
+
const botEvents = new Set(["message.channels", "message.groups", "message.im", "message.mpim"])
|
|
222
|
+
/** Deliveries whose first attempts are treated as failed (Slack timed out or lost the answer). */
|
|
223
|
+
let failAttempts = 0
|
|
224
|
+
const deliveries: Array<{
|
|
225
|
+
readonly eventId: string
|
|
226
|
+
readonly attempt: number
|
|
227
|
+
readonly status: number | "timeout" | "error"
|
|
228
|
+
readonly retryNum: string | null
|
|
229
|
+
}> = []
|
|
230
|
+
const pending = new Set<Promise<void>>()
|
|
231
|
+
|
|
232
|
+
const sign = (body: string, at = Math.floor(Date.now() / 1000)) => ({
|
|
233
|
+
"content-type": "application/json",
|
|
234
|
+
"x-slack-request-timestamp": String(at),
|
|
235
|
+
"x-slack-signature": `v0=${createHmac("sha256", signingSecret).update(`v0:${at}:${body}`).digest("hex")}`,
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
const post = async (url: string, body: string, headers: Record<string, string>) => {
|
|
239
|
+
const controller = new AbortController()
|
|
240
|
+
const timer = setTimeout(() => controller.abort(), 3_000)
|
|
241
|
+
try {
|
|
242
|
+
const response = await fetch(url, {
|
|
243
|
+
method: "POST",
|
|
244
|
+
body,
|
|
245
|
+
headers: { ...sign(body), ...headers },
|
|
246
|
+
signal: controller.signal,
|
|
247
|
+
})
|
|
248
|
+
return { status: response.status, text: await response.text(), headers: response.headers }
|
|
249
|
+
} catch (e) {
|
|
250
|
+
return {
|
|
251
|
+
status: controller.signal.aborted ? ("timeout" as const) : ("error" as const),
|
|
252
|
+
text: String(e),
|
|
253
|
+
headers: new Headers(),
|
|
254
|
+
}
|
|
255
|
+
} finally {
|
|
256
|
+
clearTimeout(timer)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** POST an event envelope, retrying a failed attempt three times as Slack does. */
|
|
261
|
+
const deliver = (body: string, eventId: string) => {
|
|
262
|
+
const run = (async () => {
|
|
263
|
+
let previous: number | "timeout" | "error" = 200
|
|
264
|
+
for (let attempt = 0; attempt <= 3; attempt++) {
|
|
265
|
+
const url = requestUrl
|
|
266
|
+
if (url === undefined) return
|
|
267
|
+
if (attempt > 0) await new Promise((r) => setTimeout(r, retryDelaysMs[attempt - 1]))
|
|
268
|
+
const reason = previous === "timeout" ? "http_timeout" : "http_error"
|
|
269
|
+
const answer = await post(
|
|
270
|
+
url,
|
|
271
|
+
body,
|
|
272
|
+
attempt === 0 ? {} : { "x-slack-retry-num": String(attempt), "x-slack-retry-reason": reason },
|
|
273
|
+
)
|
|
274
|
+
const forced = failAttempts > 0
|
|
275
|
+
if (forced) failAttempts--
|
|
276
|
+
previous = forced ? "timeout" : answer.status
|
|
277
|
+
deliveries.push({ eventId, attempt, status: previous, retryNum: attempt === 0 ? null : String(attempt) })
|
|
278
|
+
if (!forced && typeof answer.status === "number" && answer.status >= 200 && answer.status < 300) return
|
|
279
|
+
if (answer.headers.get("x-slack-no-retry") === "1") return
|
|
280
|
+
}
|
|
281
|
+
})()
|
|
282
|
+
pending.add(run)
|
|
283
|
+
void run.finally(() => pending.delete(run))
|
|
284
|
+
return run
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const envelope = (team: Team, message: SlackMessage, channelType: SlackChannelType) => {
|
|
288
|
+
const eventId = `Ev${randomBytes(5).toString("hex").toUpperCase()}`
|
|
289
|
+
const event: Record<string, unknown> = {
|
|
290
|
+
type: "message",
|
|
291
|
+
channel: message.channel,
|
|
292
|
+
user: message.user,
|
|
293
|
+
text: message.text,
|
|
294
|
+
ts: message.ts,
|
|
295
|
+
event_ts: message.ts,
|
|
296
|
+
channel_type: CHANNEL_TYPE[channelType],
|
|
297
|
+
team: message.team,
|
|
298
|
+
user_team: message.team,
|
|
299
|
+
...(message.team === team.id ? {} : { source_team: message.team }),
|
|
300
|
+
...(message.thread_ts === undefined ? {} : { thread_ts: message.thread_ts }),
|
|
301
|
+
...(message.bot_id === undefined ? {} : { bot_id: message.bot_id, app_id: APP_ID, bot_profile: botProfile }),
|
|
302
|
+
}
|
|
303
|
+
const body = JSON.stringify({
|
|
304
|
+
token: "deprecated-verification-token",
|
|
305
|
+
team_id: team.id,
|
|
306
|
+
context_team_id: team.id,
|
|
307
|
+
context_enterprise_id: null,
|
|
308
|
+
api_app_id: APP_ID,
|
|
309
|
+
event,
|
|
310
|
+
type: "event_callback",
|
|
311
|
+
event_id: eventId,
|
|
312
|
+
event_time: Math.floor(Date.now() / 1000),
|
|
313
|
+
authorizations: [
|
|
314
|
+
{ enterprise_id: null, team_id: team.id, user_id: BOT_USER, is_bot: true, is_enterprise_install: false },
|
|
315
|
+
],
|
|
316
|
+
is_ext_shared_channel: message.team !== team.id,
|
|
317
|
+
event_context: `EC${randomBytes(6).toString("hex")}`,
|
|
318
|
+
})
|
|
319
|
+
return { body, eventId }
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** A new message: stored, and delivered to the Request URL if the bot sees the conversation and subscribed. */
|
|
323
|
+
const record = (team: Team, message: SlackMessage) => {
|
|
324
|
+
team.messages.push(message)
|
|
325
|
+
const where = team.channels.get(message.channel)!
|
|
326
|
+
if (!team.installed || !where.members.has(BOT_USER) || !botEvents.has(EVENT[where.type])) return undefined
|
|
327
|
+
const { body, eventId } = envelope(team, message, where.type)
|
|
328
|
+
return { eventId, delivered: deliver(body, eventId) }
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// OAuth v2 ----------------------------------------------------------------------------------------------------
|
|
332
|
+
|
|
333
|
+
const slackError = (error: string, extra: Record<string, unknown> = {}, headers: Record<string, string> = {}) =>
|
|
334
|
+
json(200, { ok: false, error, ...extra }, headers)
|
|
335
|
+
|
|
336
|
+
const authorize = (request: FakeRequest): FakeResponse => {
|
|
337
|
+
const q = Object.fromEntries(request.url.searchParams)
|
|
338
|
+
authorizations.push(q)
|
|
339
|
+
if (q["client_id"] !== clientId)
|
|
340
|
+
return { status: 400, headers: { "content-type": "text/html" }, body: "invalid_client_id" }
|
|
341
|
+
const redirect = q["redirect_uri"]
|
|
342
|
+
if (redirect === undefined)
|
|
343
|
+
return { status: 400, headers: { "content-type": "text/html" }, body: "bad_redirect_uri" }
|
|
344
|
+
const back = new URL(redirect)
|
|
345
|
+
const local = back.hostname === "localhost" || back.hostname === "127.0.0.1"
|
|
346
|
+
if (back.protocol !== "https:" && !local) {
|
|
347
|
+
return { status: 400, headers: { "content-type": "text/html" }, body: "bad_redirect_uri: must use HTTPS" }
|
|
348
|
+
}
|
|
349
|
+
if (q["state"] !== undefined) back.searchParams.set("state", q["state"])
|
|
350
|
+
const fail = (error: string) => {
|
|
351
|
+
back.searchParams.set("error", error)
|
|
352
|
+
return { status: 302, headers: { location: back.toString() } }
|
|
353
|
+
}
|
|
354
|
+
const requested = (q["scope"] ?? "")
|
|
355
|
+
.split(",")
|
|
356
|
+
.map((s) => s.trim())
|
|
357
|
+
.filter((s) => s.length > 0)
|
|
358
|
+
if (requested.length === 0 && (q["user_scope"] ?? "") === "") return fail("invalid_scope")
|
|
359
|
+
if (requested.some((s) => !/^[a-z][a-z0-9_.-]*(:[a-z0-9_.-]+)*$/u.test(s))) return fail("invalid_scope")
|
|
360
|
+
if (denyNext) {
|
|
361
|
+
denyNext = false
|
|
362
|
+
return fail("access_denied")
|
|
363
|
+
}
|
|
364
|
+
const team = teams.get(signedIn.team)!
|
|
365
|
+
for (const scope of requested) team.scopes.add(scope)
|
|
366
|
+
team.installed = true
|
|
367
|
+
const code = `${Date.now()}.${randomBytes(12).toString("hex")}`
|
|
368
|
+
codes.set(code, {
|
|
369
|
+
team: team.id,
|
|
370
|
+
user: signedIn.user,
|
|
371
|
+
redirectUri: redirect,
|
|
372
|
+
pkce: q["code_challenge"] !== undefined,
|
|
373
|
+
expiresAt: Date.now() + 600_000,
|
|
374
|
+
used: false,
|
|
375
|
+
})
|
|
376
|
+
back.searchParams.set("code", code)
|
|
377
|
+
return { status: 302, headers: { location: back.toString() } }
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const grant = (team: Team, user: string | undefined) => {
|
|
381
|
+
let access: string
|
|
382
|
+
let refresh: string | undefined
|
|
383
|
+
if (rotation) {
|
|
384
|
+
access = token("xoxe.xoxb-1-")
|
|
385
|
+
refresh = token("xoxe-1-")
|
|
386
|
+
bots.set(access, { team: team.id, expiresAt: Date.now() + accessTtlS * 1000, valid: true })
|
|
387
|
+
refreshTokens.set(refresh, { team: team.id, valid: true })
|
|
388
|
+
issued.push(access, refresh)
|
|
389
|
+
} else {
|
|
390
|
+
access = standing.get(team.id) ?? token(`xoxb-${team.id}-`)
|
|
391
|
+
if (!standing.has(team.id)) {
|
|
392
|
+
standing.set(team.id, access)
|
|
393
|
+
bots.set(access, { team: team.id, expiresAt: null, valid: true })
|
|
394
|
+
issued.push(access)
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return json(200, {
|
|
398
|
+
ok: true,
|
|
399
|
+
access_token: access,
|
|
400
|
+
token_type: "bot",
|
|
401
|
+
scope: [...team.scopes].join(","),
|
|
402
|
+
bot_user_id: BOT_USER,
|
|
403
|
+
app_id: APP_ID,
|
|
404
|
+
team: { name: team.name, id: team.id },
|
|
405
|
+
enterprise: null,
|
|
406
|
+
is_enterprise_install: false,
|
|
407
|
+
...(user === undefined ? {} : { authed_user: { id: user } }),
|
|
408
|
+
...(refresh === undefined ? {} : { expires_in: accessTtlS, refresh_token: refresh }),
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const access = (request: FakeRequest): FakeResponse => {
|
|
413
|
+
const form = new URLSearchParams(request.body)
|
|
414
|
+
let id = form.get("client_id")
|
|
415
|
+
let secret = form.get("client_secret")
|
|
416
|
+
const basic = request.headers["authorization"] ?? ""
|
|
417
|
+
if (basic.startsWith("Basic ")) {
|
|
418
|
+
const [user, pass] = Buffer.from(basic.slice(6), "base64").toString("utf8").split(":")
|
|
419
|
+
id = decodeURIComponent(user ?? "")
|
|
420
|
+
secret = decodeURIComponent(pass ?? "")
|
|
421
|
+
}
|
|
422
|
+
if (id !== clientId) return slackError("invalid_client_id")
|
|
423
|
+
if (secret !== clientSecret) return slackError("bad_client_secret")
|
|
424
|
+
const grantType = form.get("grant_type") ?? "authorization_code"
|
|
425
|
+
if (grantType === "refresh_token") {
|
|
426
|
+
stats.refreshes++
|
|
427
|
+
const presented = refreshTokens.get(form.get("refresh_token") ?? "")
|
|
428
|
+
if (!rotation || presented === undefined || !presented.valid) {
|
|
429
|
+
stats.refreshFailures++
|
|
430
|
+
return slackError("invalid_refresh_token")
|
|
431
|
+
}
|
|
432
|
+
// Refresh tokens are designed to be used once.
|
|
433
|
+
presented.valid = false
|
|
434
|
+
const team = teams.get(presented.team)!
|
|
435
|
+
if (!team.installed) {
|
|
436
|
+
stats.refreshFailures++
|
|
437
|
+
return slackError("invalid_refresh_token")
|
|
438
|
+
}
|
|
439
|
+
return grant(team, undefined)
|
|
440
|
+
}
|
|
441
|
+
if (grantType !== "authorization_code") return slackError("invalid_grant_type")
|
|
442
|
+
stats.codeExchanges++
|
|
443
|
+
const code = codes.get(form.get("code") ?? "")
|
|
444
|
+
if (code === undefined || code.used || code.expiresAt < Date.now()) return slackError("invalid_code")
|
|
445
|
+
code.used = true
|
|
446
|
+
if ((code.pkce || form.has("code_verifier")) && !pkceEnabled) return slackError("pkce_not_allowed")
|
|
447
|
+
if (code.redirectUri !== undefined && form.get("redirect_uri") !== code.redirectUri) {
|
|
448
|
+
return slackError("bad_redirect_uri")
|
|
449
|
+
}
|
|
450
|
+
return grant(teams.get(code.team)!, code.user)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Web API -----------------------------------------------------------------------------------------------------
|
|
454
|
+
|
|
455
|
+
type Caller = { readonly team: Team }
|
|
456
|
+
const params = (request: FakeRequest): Record<string, string> => {
|
|
457
|
+
const out: Record<string, string> = Object.fromEntries(request.url.searchParams)
|
|
458
|
+
const type = request.headers["content-type"] ?? ""
|
|
459
|
+
if (type.startsWith("application/json") && request.json !== null && typeof request.json === "object") {
|
|
460
|
+
for (const [k, v] of Object.entries(request.json as Record<string, unknown>)) {
|
|
461
|
+
if (v !== undefined && v !== null) out[k] = typeof v === "string" ? v : JSON.stringify(v)
|
|
462
|
+
}
|
|
463
|
+
} else if (type.startsWith("application/x-www-form-urlencoded")) {
|
|
464
|
+
for (const [k, v] of new URLSearchParams(request.body)) out[k] = v
|
|
465
|
+
}
|
|
466
|
+
return out
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const method =
|
|
470
|
+
(
|
|
471
|
+
name: string,
|
|
472
|
+
needs: ((p: Record<string, string>, caller: Caller) => string | undefined) | undefined,
|
|
473
|
+
handler: (p: Record<string, string>, caller: Caller) => FakeResponse,
|
|
474
|
+
) =>
|
|
475
|
+
(request: FakeRequest): FakeResponse => {
|
|
476
|
+
stats.apiRequests++
|
|
477
|
+
const limited = limits.findIndex((l) => l.method === name || l.method === "*")
|
|
478
|
+
if (limited >= 0) {
|
|
479
|
+
const [hit] = limits.splice(limited, 1)
|
|
480
|
+
return json(429, { ok: false, error: "ratelimited" }, { "retry-after": hit!.retryAfter })
|
|
481
|
+
}
|
|
482
|
+
const injected = scripted.findIndex((s) => s.method === name)
|
|
483
|
+
if (injected >= 0) {
|
|
484
|
+
const [hit] = scripted.splice(injected, 1)
|
|
485
|
+
return { status: hit!.status, headers: { "content-type": "application/json; charset=utf-8" }, body: hit!.body }
|
|
486
|
+
}
|
|
487
|
+
const header = request.headers["authorization"] ?? ""
|
|
488
|
+
const p = params(request)
|
|
489
|
+
const presented = header.startsWith("Bearer ") ? header.slice(7) : p["token"]
|
|
490
|
+
if (presented === undefined || presented === "") return slackError("not_authed")
|
|
491
|
+
const bot = bots.get(presented)
|
|
492
|
+
if (bot === undefined) return slackError("invalid_auth")
|
|
493
|
+
if (!bot.valid) return slackError("token_revoked")
|
|
494
|
+
if (bot.expiresAt !== null && bot.expiresAt < Date.now()) return slackError("token_expired")
|
|
495
|
+
const team = teams.get(bot.team)!
|
|
496
|
+
const scopes = { "x-oauth-scopes": [...team.scopes].join(",") }
|
|
497
|
+
const caller = { team }
|
|
498
|
+
const needed = needs?.(p, caller)
|
|
499
|
+
if (needed !== undefined && !team.scopes.has(needed)) {
|
|
500
|
+
return slackError("missing_scope", { needed, provided: [...team.scopes].join(",") }, scopes)
|
|
501
|
+
}
|
|
502
|
+
const answer = handler(p, caller)
|
|
503
|
+
return { ...answer, headers: { ...answer.headers, ...scopes, "x-accepted-oauth-scopes": needed ?? "" } }
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** The conversations the bot can see: every public channel, and the others it is a member of. */
|
|
507
|
+
const visible = (team: Team, id: string | undefined) => {
|
|
508
|
+
const found = id === undefined ? undefined : team.channels.get(id)
|
|
509
|
+
if (found === undefined) return undefined
|
|
510
|
+
return found.type === "public_channel" || found.members.has(BOT_USER) ? found : undefined
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const toApi = (team: Team, m: SlackMessage) => {
|
|
514
|
+
const replies = team.messages.filter((r) => r.channel === m.channel && r.thread_ts === m.ts && r.ts !== m.ts)
|
|
515
|
+
return {
|
|
516
|
+
type: "message",
|
|
517
|
+
user: m.user,
|
|
518
|
+
text: m.text,
|
|
519
|
+
ts: m.ts,
|
|
520
|
+
team: m.team,
|
|
521
|
+
...(m.bot_id === undefined ? {} : { bot_id: m.bot_id, app_id: APP_ID, bot_profile: botProfile }),
|
|
522
|
+
...(m.thread_ts === undefined ? {} : { thread_ts: m.thread_ts }),
|
|
523
|
+
...(m.thread_ts !== undefined && m.thread_ts !== m.ts
|
|
524
|
+
? { parent_user_id: team.messages.find((p) => p.ts === m.thread_ts)?.user }
|
|
525
|
+
: {}),
|
|
526
|
+
...(replies.length === 0
|
|
527
|
+
? {}
|
|
528
|
+
: {
|
|
529
|
+
reply_count: replies.length,
|
|
530
|
+
latest_reply: replies.at(-1)!.ts,
|
|
531
|
+
reply_users: [...new Set(replies.map((r) => r.user))],
|
|
532
|
+
}),
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const limitOf = (p: Record<string, string>, fallback: number, max: number) => {
|
|
537
|
+
const n = p["limit"] === undefined ? fallback : Number(p["limit"])
|
|
538
|
+
return Number.isInteger(n) && n > 0 ? Math.min(n, max) : fallback
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const router = new Router()
|
|
542
|
+
router.add("GET", "/oauth/v2/authorize", authorize)
|
|
543
|
+
router.add("POST", "/api/oauth.v2.access", access)
|
|
544
|
+
const both = (name: string, handler: (request: FakeRequest) => FakeResponse) => {
|
|
545
|
+
router.add("GET", `/api/${name}`, handler)
|
|
546
|
+
router.add("POST", `/api/${name}`, handler)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
both(
|
|
550
|
+
"auth.test",
|
|
551
|
+
method("auth.test", undefined, (_p, { team }) =>
|
|
552
|
+
json(200, {
|
|
553
|
+
ok: true,
|
|
554
|
+
url: `https://${team.domain}.slack.com/`,
|
|
555
|
+
team: team.name,
|
|
556
|
+
user: "eloxiv",
|
|
557
|
+
team_id: team.id,
|
|
558
|
+
user_id: BOT_USER,
|
|
559
|
+
bot_id: BOT_ID,
|
|
560
|
+
is_enterprise_install: false,
|
|
561
|
+
}),
|
|
562
|
+
),
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
const typesOf = (p: Record<string, string>) =>
|
|
566
|
+
(p["types"] ?? "public_channel").split(",").map((t) => t.trim()) as Array<SlackChannelType>
|
|
567
|
+
both(
|
|
568
|
+
"conversations.list",
|
|
569
|
+
method(
|
|
570
|
+
"conversations.list",
|
|
571
|
+
(p, { team }) =>
|
|
572
|
+
typesOf(p)
|
|
573
|
+
.map((t) => READ_SCOPE[t])
|
|
574
|
+
.find((s) => s !== undefined && !team.scopes.has(s)),
|
|
575
|
+
(p, { team }) => {
|
|
576
|
+
const types = typesOf(p)
|
|
577
|
+
if (types.some((t) => READ_SCOPE[t] === undefined)) return slackError("invalid_types")
|
|
578
|
+
const all = [...team.channels.values()]
|
|
579
|
+
.filter((c) => types.includes(c.type) && visible(team, c.id) !== undefined)
|
|
580
|
+
.filter((c) => !(p["exclude_archived"] === "true" && c.archived))
|
|
581
|
+
.sort((a, b) => (a.id < b.id ? -1 : 1))
|
|
582
|
+
let start = 0
|
|
583
|
+
if (p["cursor"] !== undefined && p["cursor"] !== "") {
|
|
584
|
+
const after = readCursor(p["cursor"], "team:")
|
|
585
|
+
const at = after === undefined ? -1 : all.findIndex((c) => c.id === after)
|
|
586
|
+
if (at < 0) return slackError("invalid_cursor")
|
|
587
|
+
start = at
|
|
588
|
+
}
|
|
589
|
+
const limit = limitOf(p, 100, 1000)
|
|
590
|
+
const page = all.slice(start, start + limit)
|
|
591
|
+
const next = all[start + limit]
|
|
592
|
+
return json(200, {
|
|
593
|
+
ok: true,
|
|
594
|
+
channels: page.map((c) => ({
|
|
595
|
+
id: c.id,
|
|
596
|
+
name: c.type === "im" ? undefined : c.name,
|
|
597
|
+
is_channel: c.type === "public_channel",
|
|
598
|
+
is_group: c.type === "private_channel",
|
|
599
|
+
is_im: c.type === "im",
|
|
600
|
+
is_mpim: c.type === "mpim",
|
|
601
|
+
is_private: c.type !== "public_channel",
|
|
602
|
+
is_archived: c.archived,
|
|
603
|
+
is_member: c.members.has(BOT_USER),
|
|
604
|
+
user: c.type === "im" ? [...c.members].find((m) => m !== BOT_USER) : undefined,
|
|
605
|
+
})),
|
|
606
|
+
response_metadata: { next_cursor: next === undefined ? "" : cursorOf(`team:${next.id}`) },
|
|
607
|
+
})
|
|
608
|
+
},
|
|
609
|
+
),
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
const readable = (p: Record<string, string>, team: Team): FakeResponse | SlackChannel => {
|
|
613
|
+
const where = visible(team, p["channel"])
|
|
614
|
+
if (where === undefined) return slackError("channel_not_found")
|
|
615
|
+
if (!where.members.has(BOT_USER)) return slackError("not_in_channel")
|
|
616
|
+
return where
|
|
617
|
+
}
|
|
618
|
+
const historyScope = (p: Record<string, string>, { team }: Caller) => {
|
|
619
|
+
const where = team.channels.get(p["channel"] ?? "")
|
|
620
|
+
return where === undefined ? "channels:history" : HISTORY_SCOPE[where.type]
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
both(
|
|
624
|
+
"conversations.history",
|
|
625
|
+
method("conversations.history", historyScope, (p, { team }) => {
|
|
626
|
+
const where = readable(p, team)
|
|
627
|
+
if (!("members" in where)) return where
|
|
628
|
+
const inclusive = p["inclusive"] === "true" || p["inclusive"] === "1"
|
|
629
|
+
const after = (ts: string, bound: string | undefined) =>
|
|
630
|
+
bound === undefined || (inclusive ? compareTs(ts, bound) >= 0 : compareTs(ts, bound) > 0)
|
|
631
|
+
const before = (ts: string, bound: string | undefined) =>
|
|
632
|
+
bound === undefined || (inclusive ? compareTs(ts, bound) <= 0 : compareTs(ts, bound) < 0)
|
|
633
|
+
// Thread replies stay in their thread; the most recent messages come first.
|
|
634
|
+
const all = team.messages
|
|
635
|
+
.filter((m) => m.channel === where.id && (m.thread_ts === undefined || m.thread_ts === m.ts))
|
|
636
|
+
.filter((m) => after(m.ts, p["oldest"]) && before(m.ts, p["latest"]))
|
|
637
|
+
.sort((a, b) => compareTs(b.ts, a.ts))
|
|
638
|
+
let start = 0
|
|
639
|
+
if (p["cursor"] !== undefined && p["cursor"] !== "") {
|
|
640
|
+
const from = readCursor(p["cursor"], "next_ts:")
|
|
641
|
+
const at = from === undefined ? -1 : all.findIndex((m) => m.ts === from)
|
|
642
|
+
if (at < 0) return slackError("invalid_cursor")
|
|
643
|
+
start = at
|
|
644
|
+
}
|
|
645
|
+
const limit = limitOf(p, 100, 999)
|
|
646
|
+
const page = all.slice(start, start + limit)
|
|
647
|
+
const next = all[start + limit]
|
|
648
|
+
return json(200, {
|
|
649
|
+
ok: true,
|
|
650
|
+
messages: page.map((m) => toApi(team, m)),
|
|
651
|
+
has_more: next !== undefined,
|
|
652
|
+
pin_count: 0,
|
|
653
|
+
...(next === undefined ? {} : { response_metadata: { next_cursor: cursorOf(`next_ts:${next.ts}`) } }),
|
|
654
|
+
})
|
|
655
|
+
}),
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
both(
|
|
659
|
+
"conversations.replies",
|
|
660
|
+
method("conversations.replies", historyScope, (p, { team }) => {
|
|
661
|
+
const where = readable(p, team)
|
|
662
|
+
if (!("members" in where)) return where
|
|
663
|
+
const found = team.messages.find((m) => m.channel === where.id && m.ts === p["ts"])
|
|
664
|
+
if (found === undefined) return slackError("thread_not_found")
|
|
665
|
+
const root = found.thread_ts ?? found.ts
|
|
666
|
+
const all = team.messages
|
|
667
|
+
.filter((m) => m.channel === where.id && (m.ts === root || m.thread_ts === root))
|
|
668
|
+
.sort((a, b) => compareTs(a.ts, b.ts))
|
|
669
|
+
let start = 0
|
|
670
|
+
if (p["cursor"] !== undefined && p["cursor"] !== "") {
|
|
671
|
+
const from = readCursor(p["cursor"], "replies_ts:")
|
|
672
|
+
const at = from === undefined ? -1 : all.findIndex((m) => m.ts === from)
|
|
673
|
+
if (at < 0) return slackError("invalid_cursor")
|
|
674
|
+
start = at
|
|
675
|
+
}
|
|
676
|
+
// Cursor pagination as documented: `limit` messages a page, earliest first, the parent only on the first.
|
|
677
|
+
const limit = limitOf(p, 1000, 1000)
|
|
678
|
+
const page = all.slice(start, start + limit)
|
|
679
|
+
const next = all[start + limit]
|
|
680
|
+
return json(200, {
|
|
681
|
+
ok: true,
|
|
682
|
+
messages: page.map((m) => toApi(team, m)),
|
|
683
|
+
has_more: next !== undefined,
|
|
684
|
+
...(next === undefined ? {} : { response_metadata: { next_cursor: cursorOf(`replies_ts:${next.ts}`) } }),
|
|
685
|
+
})
|
|
686
|
+
}),
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
let lastPosted: { eventId: string; delivered: Promise<void> } | undefined
|
|
690
|
+
both(
|
|
691
|
+
"chat.postMessage",
|
|
692
|
+
method(
|
|
693
|
+
"chat.postMessage",
|
|
694
|
+
() => "chat:write",
|
|
695
|
+
(p, { team }) => {
|
|
696
|
+
const found = team.channels.get(p["channel"] ?? "")
|
|
697
|
+
const where = visible(team, p["channel"])
|
|
698
|
+
if (found === undefined || where === undefined) return slackError("channel_not_found")
|
|
699
|
+
if (where.archived) return slackError("is_archived")
|
|
700
|
+
if (
|
|
701
|
+
!where.members.has(BOT_USER) &&
|
|
702
|
+
!(where.type === "public_channel" && team.scopes.has("chat:write.public"))
|
|
703
|
+
) {
|
|
704
|
+
return slackError("not_in_channel")
|
|
705
|
+
}
|
|
706
|
+
const text = p["text"] ?? ""
|
|
707
|
+
if (text.length === 0 && p["blocks"] === undefined && p["attachments"] === undefined)
|
|
708
|
+
return slackError("no_text")
|
|
709
|
+
if (text.length > 40_000) return slackError("msg_too_long")
|
|
710
|
+
let thread: string | undefined
|
|
711
|
+
if (p["thread_ts"] !== undefined && p["thread_ts"] !== "") {
|
|
712
|
+
const parent = team.messages.find((m) => m.channel === where.id && m.ts === p["thread_ts"])
|
|
713
|
+
if (parent === undefined) return slackError("thread_not_found")
|
|
714
|
+
thread = parent.thread_ts ?? parent.ts
|
|
715
|
+
}
|
|
716
|
+
const ts = nextTs()
|
|
717
|
+
const message: SlackMessage = {
|
|
718
|
+
ts,
|
|
719
|
+
channel: where.id,
|
|
720
|
+
user: BOT_USER,
|
|
721
|
+
team: team.id,
|
|
722
|
+
text,
|
|
723
|
+
thread_ts: thread,
|
|
724
|
+
bot_id: BOT_ID,
|
|
725
|
+
}
|
|
726
|
+
lastPosted = record(team, message)
|
|
727
|
+
return json(200, { ok: true, channel: where.id, ts, message: { ...toApi(team, message), type: "message" } })
|
|
728
|
+
},
|
|
729
|
+
),
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
const running = await serve(router)
|
|
733
|
+
|
|
734
|
+
return {
|
|
735
|
+
url: running.url,
|
|
736
|
+
clientId,
|
|
737
|
+
clientSecret,
|
|
738
|
+
signingSecret,
|
|
739
|
+
appId: APP_ID,
|
|
740
|
+
botUserId: BOT_USER,
|
|
741
|
+
botId: BOT_ID,
|
|
742
|
+
team: main.id,
|
|
743
|
+
otherTeam: other.id,
|
|
744
|
+
partnerTeam: partner.id,
|
|
745
|
+
/** The connector's settings pointing here. */
|
|
746
|
+
settings: {
|
|
747
|
+
clientId,
|
|
748
|
+
clientSecret,
|
|
749
|
+
authorizeUrl: `${running.url}/oauth/v2/authorize`,
|
|
750
|
+
tokenUrl: `${running.url}/api/oauth.v2.access`,
|
|
751
|
+
apiUrl: `${running.url}/api`,
|
|
752
|
+
} as Record<string, string>,
|
|
753
|
+
authorizations,
|
|
754
|
+
stats,
|
|
755
|
+
issued,
|
|
756
|
+
deliveries,
|
|
757
|
+
channels: (team = main.id) => teams.get(team)!.channels,
|
|
758
|
+
messages: (team = main.id) => teams.get(team)!.messages,
|
|
759
|
+
scopes: (team = main.id) => teams.get(team)!.scopes,
|
|
760
|
+
lastPosted: () => lastPosted,
|
|
761
|
+
|
|
762
|
+
// Controls --------------------------------------------------------------------------------------------------
|
|
763
|
+
/** Who installs next: a person in a workspace. */
|
|
764
|
+
signIn: (team: string, user: string) => {
|
|
765
|
+
signedIn.team = team
|
|
766
|
+
signedIn.user = user
|
|
767
|
+
},
|
|
768
|
+
denyNext: () => {
|
|
769
|
+
denyNext = true
|
|
770
|
+
},
|
|
771
|
+
enablePkce: () => {
|
|
772
|
+
pkceEnabled = true
|
|
773
|
+
},
|
|
774
|
+
/** The next requests to `method` (`*` for any) are answered 429 with this Retry-After. */
|
|
775
|
+
rateLimit: (options: { readonly method: string; readonly retryAfter: string; readonly times: number }) => {
|
|
776
|
+
for (let i = 0; i < options.times; i++) limits.push({ method: options.method, retryAfter: options.retryAfter })
|
|
777
|
+
},
|
|
778
|
+
clearRateLimits: () => {
|
|
779
|
+
limits.length = 0
|
|
780
|
+
scripted.length = 0
|
|
781
|
+
},
|
|
782
|
+
/** The next request to `method` is answered with this raw body (an answer Slack does not document). */
|
|
783
|
+
answerNext: (options: { readonly method: string; readonly body: string; readonly status?: number }) => {
|
|
784
|
+
scripted.push({ method: options.method, status: options.status ?? 200, body: options.body })
|
|
785
|
+
},
|
|
786
|
+
/** Every access token of the workspace stops working (expired: `token_expired`). */
|
|
787
|
+
expireAccessTokens: (team = main.id) => {
|
|
788
|
+
for (const bot of bots.values()) if (bot.team === team && bot.expiresAt !== null) bot.expiresAt = 0
|
|
789
|
+
},
|
|
790
|
+
/** The app is uninstalled from the workspace: its tokens are revoked, its refresh tokens refused. */
|
|
791
|
+
uninstall: (team = main.id) => {
|
|
792
|
+
const found = teams.get(team)!
|
|
793
|
+
found.installed = false
|
|
794
|
+
found.scopes.clear()
|
|
795
|
+
standing.delete(team)
|
|
796
|
+
for (const bot of bots.values()) if (bot.team === team) bot.valid = false
|
|
797
|
+
for (const refresh of refreshTokens.values()) if (refresh.team === team) refresh.valid = false
|
|
798
|
+
},
|
|
799
|
+
/** An administrator removes scopes from the workspace's grant. */
|
|
800
|
+
revokeScopes: (scopes: ReadonlyArray<string>, team = main.id) => {
|
|
801
|
+
for (const scope of scopes) teams.get(team)!.scopes.delete(scope)
|
|
802
|
+
},
|
|
803
|
+
/** A person posts a message (delivered as an event if the bot is in the conversation). */
|
|
804
|
+
userPosts: (message: {
|
|
805
|
+
readonly user: string
|
|
806
|
+
readonly channel: string
|
|
807
|
+
readonly text: string
|
|
808
|
+
readonly thread?: string | null | undefined
|
|
809
|
+
readonly team?: string | undefined
|
|
810
|
+
}) => {
|
|
811
|
+
const team = teams.get(message.team ?? main.id)!
|
|
812
|
+
if (!team.users.has(message.user)) team.users.set(message.user, { id: message.user, name: message.user })
|
|
813
|
+
const posted: SlackMessage = {
|
|
814
|
+
ts: nextTs(),
|
|
815
|
+
channel: message.channel,
|
|
816
|
+
user: message.user,
|
|
817
|
+
team: team.id,
|
|
818
|
+
text: message.text,
|
|
819
|
+
thread_ts: message.thread ?? undefined,
|
|
820
|
+
bot_id: undefined,
|
|
821
|
+
}
|
|
822
|
+
const delivery = record(team, posted)
|
|
823
|
+
return { ts: posted.ts, eventId: delivery?.eventId, delivered: delivery?.delivered ?? Promise.resolve() }
|
|
824
|
+
},
|
|
825
|
+
/** Set the Events API Request URL: Slack sends a signed url_verification and keeps the URL only if answered. */
|
|
826
|
+
setRequestUrl: async (url: string) => {
|
|
827
|
+
const challenge = randomBytes(24).toString("base64url")
|
|
828
|
+
const body = JSON.stringify({ token: "deprecated-verification-token", challenge, type: "url_verification" })
|
|
829
|
+
const answer = await post(url, body, {})
|
|
830
|
+
const type = answer.headers.get("content-type") ?? ""
|
|
831
|
+
let echoed: string | undefined
|
|
832
|
+
if (type.startsWith("application/json")) {
|
|
833
|
+
try {
|
|
834
|
+
echoed = (JSON.parse(answer.text) as { challenge?: string }).challenge
|
|
835
|
+
} catch {
|
|
836
|
+
echoed = undefined
|
|
837
|
+
}
|
|
838
|
+
} else if (type.startsWith("application/x-www-form-urlencoded")) {
|
|
839
|
+
echoed = new URLSearchParams(answer.text).get("challenge") ?? undefined
|
|
840
|
+
} else {
|
|
841
|
+
echoed = answer.text
|
|
842
|
+
}
|
|
843
|
+
const verified = answer.status === 200 && echoed === challenge
|
|
844
|
+
if (verified) requestUrl = url
|
|
845
|
+
return { verified, status: answer.status, body: answer.text }
|
|
846
|
+
},
|
|
847
|
+
/** Treat the next `n` delivery attempts as failed (Slack timed out), so they are retried. */
|
|
848
|
+
failNextAttempts: (n: number) => {
|
|
849
|
+
failAttempts = n
|
|
850
|
+
},
|
|
851
|
+
/** Wait until every delivery in flight (with its retries) has finished. */
|
|
852
|
+
settled: async () => {
|
|
853
|
+
while (pending.size > 0) await Promise.all(pending)
|
|
854
|
+
},
|
|
855
|
+
/** A signed event delivery for a message, as Slack would POST it (without storing the message). */
|
|
856
|
+
event: (event: {
|
|
857
|
+
readonly user: string
|
|
858
|
+
readonly channel: string
|
|
859
|
+
readonly text: string
|
|
860
|
+
readonly thread?: string | null
|
|
861
|
+
/** The workspace that receives the delivery (default the main one). */
|
|
862
|
+
readonly team?: string
|
|
863
|
+
/** The sender's own workspace, for a Slack Connect channel (default the receiving one). */
|
|
864
|
+
readonly userTeam?: string
|
|
865
|
+
/** Also keep the message in its channel (so the app can reply in its thread), without delivering it. */
|
|
866
|
+
readonly store?: boolean
|
|
867
|
+
}) => {
|
|
868
|
+
// A workspace the fake does not know yet is one where the app is not installed.
|
|
869
|
+
const team = teams.get(event.team ?? main.id) ?? addTeam(event.team!, event.team!)
|
|
870
|
+
const where = team.channels.get(event.channel)
|
|
871
|
+
const message: SlackMessage = {
|
|
872
|
+
ts: nextTs(),
|
|
873
|
+
channel: event.channel,
|
|
874
|
+
user: event.user,
|
|
875
|
+
team: event.userTeam ?? team.id,
|
|
876
|
+
text: event.text,
|
|
877
|
+
thread_ts: event.thread ?? undefined,
|
|
878
|
+
bot_id: undefined,
|
|
879
|
+
}
|
|
880
|
+
if (event.store === true) team.messages.push(message)
|
|
881
|
+
const { body, eventId } = envelope(team, message, where?.type ?? "public_channel")
|
|
882
|
+
return { body, eventId, ts: message.ts, headers: sign(body) }
|
|
883
|
+
},
|
|
884
|
+
/** Sign a body as Slack does (for hand-made deliveries), at `at` (unix seconds). */
|
|
885
|
+
sign,
|
|
886
|
+
close: async () => {
|
|
887
|
+
await Promise.allSettled(pending)
|
|
888
|
+
await running.close()
|
|
889
|
+
},
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
export type SlackFake = Awaited<ReturnType<typeof startSlackFake>>
|