@fonoster/apiserver 0.27.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/applications/buildService.d.ts +5 -1
- package/dist/applications/buildService.js +10 -7
- package/dist/applications/createCreateApplication.d.ts +6 -2
- package/dist/applications/createCreateApplication.js +24 -16
- package/dist/applications/createCreateTestToken.d.ts +3 -1
- package/dist/applications/createCreateTestToken.js +18 -13
- package/dist/applications/createGetApplication.js +2 -2
- package/dist/applications/createGetFnUtil.d.ts +22 -18
- package/dist/applications/createGetFnUtil.js +3 -5
- package/dist/applications/createListApplications.js +3 -4
- package/dist/applications/createRotateSigningSecret.d.ts +9 -0
- package/dist/{calls/createFetchSingleCall.js → applications/createRotateSigningSecret.js} +23 -20
- package/dist/applications/createUpdateApplication.d.ts +6 -2
- package/dist/applications/createUpdateApplication.js +35 -36
- package/dist/applications/evalKeys.d.ts +9 -0
- package/dist/{voice/handlers/dial/recordChannel.js → applications/evalKeys.js} +17 -12
- package/dist/applications/session/appModel.d.ts +225 -0
- package/dist/applications/session/appModel.js +331 -0
- package/dist/applications/types.d.ts +1 -27
- package/dist/billing/buildService.d.ts +24 -0
- package/dist/billing/buildService.js +116 -0
- package/dist/bin/entrypoint.d.ts +1 -0
- package/dist/bin/entrypoint.js +180 -0
- package/dist/bin/healthcheck.d.ts +2 -0
- package/dist/{voice/utils/VoiceServiceClientConstructor.js → bin/healthcheck.js} +24 -9
- package/dist/bin/regionHubSetup.d.ts +2 -0
- package/dist/bin/regionHubSetup.js +67 -0
- package/dist/bin/usage.d.ts +2 -0
- package/dist/bin/usage.js +119 -0
- package/dist/calls/buildService.d.ts +1 -20
- package/dist/calls/buildService.js +59 -6
- package/dist/calls/createCall.d.ts +17 -2
- package/dist/calls/createCall.js +64 -11
- package/dist/calls/createCallPublisher.d.ts +40 -2
- package/dist/calls/createCallPublisher.js +43 -9
- package/dist/calls/createIsWorkspaceNumber.d.ts +41 -0
- package/dist/calls/createIsWorkspaceNumber.js +39 -0
- package/dist/calls/createTrackCall.d.ts +55 -2
- package/dist/calls/createTrackCall.js +230 -16
- package/dist/calls/getCall.d.ts +4 -2
- package/dist/calls/getCall.js +2 -3
- package/dist/calls/listCalls.d.ts +4 -2
- package/dist/calls/listCalls.js +2 -3
- package/dist/calls/types.d.ts +11 -2
- package/dist/calls/types.js +10 -0
- package/dist/{core/buildWelcomeDemoService.d.ts → capabilities/buildService.d.ts} +8 -8
- package/dist/capabilities/buildService.js +17 -0
- package/dist/capabilities/createGetCapabilities.d.ts +78 -0
- package/dist/capabilities/createGetCapabilities.js +98 -0
- package/dist/{voice/handlers/utils → capabilities}/index.d.ts +2 -3
- package/dist/{voice/handlers/utils → capabilities}/index.js +4 -3
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.js +102 -0
- package/dist/config/schema.d.ts +1919 -0
- package/dist/config/schema.js +357 -0
- package/dist/core/allowList.js +2 -1
- package/dist/core/applyCatalog.d.ts +10 -0
- package/dist/{voice/client/GrpcClientHandler.js → core/applyCatalog.js} +45 -51
- package/dist/core/db.d.ts +3 -1
- package/dist/core/db.js +2 -1
- package/dist/core/durableConsumer.d.ts +41 -0
- package/dist/core/durableConsumer.js +104 -0
- package/dist/core/httpBridge.d.ts +24 -6
- package/dist/core/httpBridge.js +3 -25
- package/dist/core/identityConfig.d.ts +2 -35
- package/dist/core/identityConfig.js +3 -36
- package/dist/core/regionHooks.d.ts +15 -0
- package/dist/{calls/influxdb.js → core/regionHooks.js} +4 -8
- package/dist/core/runServices.js +98 -15
- package/dist/core/services.d.ts +96 -6
- package/dist/core/services.js +49 -10
- package/dist/{voice/errors/index.d.ts → core/telemetry.d.ts} +2 -2
- package/dist/core/telemetry.js +42 -0
- package/dist/{applications/utils/convertToApplicationData.d.ts → core/telemetryInterceptor.d.ts} +10 -4
- package/dist/core/telemetryInterceptor.js +57 -0
- package/dist/core/testTokenConfig.js +4 -1
- package/dist/core/upsertRoomrPeer.d.ts +6 -0
- package/dist/core/{upsertDefaultPeer.js → upsertRoomrPeer.js} +31 -30
- package/dist/envs.d.ts +136 -23
- package/dist/envs.js +108 -143
- package/dist/index.js +39 -21
- package/dist/outbound/createNodeDirectory.d.ts +86 -0
- package/dist/outbound/createNodeDirectory.js +140 -0
- package/dist/{voice/integrations → outbound}/index.d.ts +4 -1
- package/dist/{voice/errors → outbound}/index.js +4 -2
- package/dist/outbound/placeOutboundCall.d.ts +96 -0
- package/dist/outbound/placeOutboundCall.js +172 -0
- package/dist/outbound/placementSweep.d.ts +56 -0
- package/dist/outbound/placementSweep.js +127 -0
- package/dist/outbound/runOutboundCalls.d.ts +52 -0
- package/dist/outbound/runOutboundCalls.js +171 -0
- package/dist/providers/createProvidersHandlers.d.ts +39 -0
- package/dist/providers/createProvidersHandlers.js +229 -0
- package/dist/providers/index.d.ts +47 -0
- package/dist/{voice/client → providers}/index.js +15 -6
- package/dist/providers/registryUsage.d.ts +48 -0
- package/dist/providers/registryUsage.js +236 -0
- package/dist/records/createIndexRecord.d.ts +42 -0
- package/dist/records/createIndexRecord.js +185 -0
- package/dist/records/createRecordsRouter.d.ts +61 -0
- package/dist/records/createRecordsRouter.js +330 -0
- package/dist/records/createSearchRecords.d.ts +51 -0
- package/dist/records/createSearchRecords.js +134 -0
- package/dist/{voice/filters → records}/index.d.ts +6 -6
- package/dist/{voice/filters → records}/index.js +6 -6
- package/dist/records/maintenance.d.ts +33 -0
- package/dist/records/maintenance.js +166 -0
- package/dist/records/runCallRecords.d.ts +48 -0
- package/dist/records/runCallRecords.js +49 -0
- package/dist/{events/createPerCallCache.d.ts → records/stores.d.ts} +4 -7
- package/dist/{voice/handlers/utils/isDtmf.js → records/stores.js} +9 -3
- package/dist/records/types.d.ts +104 -0
- package/dist/regions/configSync.d.ts +130 -0
- package/dist/regions/configSync.js +316 -0
- package/dist/regions/createRegionsRouter.d.ts +151 -0
- package/dist/regions/createRegionsRouter.js +391 -0
- package/dist/regions/endpoints.d.ts +41 -0
- package/dist/regions/endpoints.js +90 -0
- package/dist/regions/enrollmentToken.d.ts +41 -0
- package/dist/regions/enrollmentToken.js +94 -0
- package/dist/regions/httpAuth.d.ts +39 -0
- package/dist/regions/httpAuth.js +78 -0
- package/dist/regions/ids.d.ts +15 -0
- package/dist/regions/ids.js +81 -0
- package/dist/{voice/client → regions}/index.d.ts +17 -6
- package/dist/regions/index.js +51 -0
- package/dist/regions/link.d.ts +17 -0
- package/dist/regions/link.js +170 -0
- package/dist/regions/natsAuth.d.ts +41 -0
- package/dist/regions/natsAuth.js +64 -0
- package/dist/regions/natsJwt.d.ts +23 -0
- package/dist/regions/natsJwt.js +26 -0
- package/dist/regions/relay.d.ts +45 -0
- package/dist/regions/relay.js +203 -0
- package/dist/regions/relayHttp.d.ts +7 -0
- package/dist/regions/relayHttp.js +107 -0
- package/dist/regions/relaySlots.d.ts +18 -0
- package/dist/regions/relaySlots.js +118 -0
- package/dist/regions/runRegions.d.ts +111 -0
- package/dist/regions/runRegions.js +235 -0
- package/dist/regions/service.d.ts +129 -0
- package/dist/regions/service.js +558 -0
- package/dist/regions/sources.d.ts +20 -0
- package/dist/regions/sources.js +191 -0
- package/dist/regions/status.d.ts +35 -0
- package/dist/regions/status.js +63 -0
- package/dist/regions/types.d.ts +123 -0
- package/dist/regions/types.js +41 -0
- package/dist/{voice/integrations/getSttConfig.d.ts → regions/withConfigChangeHook.d.ts} +13 -7
- package/dist/regions/withConfigChangeHook.js +44 -0
- package/dist/secrets/createGetFnUtil.d.ts +2 -2
- package/dist/session/createSessionRouter.d.ts +49 -0
- package/dist/session/createSessionRouter.js +206 -0
- package/dist/{voice/handlers/dial → session}/index.d.ts +1 -1
- package/dist/{voice/handlers/dial → session}/index.js +1 -1
- package/dist/usage/buildService.d.ts +16 -0
- package/dist/{voice/integrations/getTtsConfig.js → usage/buildService.js} +13 -7
- package/dist/{voice/tts/utils/convertUlawToPCM16.d.ts → usage/createGetUsage.d.ts} +7 -6
- package/dist/usage/createGetUsage.js +118 -0
- package/dist/usage/ingestUsage.d.ts +7 -0
- package/dist/usage/ingestUsage.js +87 -0
- package/dist/usage/publishRecordedUsage.d.ts +52 -0
- package/dist/usage/publishRecordedUsage.js +103 -0
- package/dist/{utils/createHandleDialEventsWithNats.d.ts → usage/publishUsage.d.ts} +10 -4
- package/dist/usage/publishUsage.js +50 -0
- package/dist/usage/rebuildUsage.d.ts +48 -0
- package/dist/usage/rebuildUsage.js +104 -0
- package/dist/usage/runUsageConsumer.d.ts +22 -0
- package/dist/usage/runUsageConsumer.js +78 -0
- package/dist/usage/snapshotStorage.d.ts +14 -0
- package/dist/usage/snapshotStorage.js +95 -0
- package/dist/{voice/integrations/getTtsConfig.d.ts → usage/types.d.ts} +17 -6
- package/dist/utils/createCheckNumberPreconditions.js +4 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/voice/stt/Deepgram.d.ts +4 -57
- package/dist/voice/stt/Deepgram.js +15 -286
- package/dist/voice/stt/Google.d.ts +4 -15
- package/dist/voice/stt/Google.js +7 -103
- package/dist/voice/stt/types.d.ts +2 -38
- package/dist/voice/stt/types.js +25 -3
- package/dist/voice/tts/Azure.d.ts +4 -34
- package/dist/voice/tts/Azure.js +25 -105
- package/dist/voice/tts/Deepgram.d.ts +4 -38
- package/dist/voice/tts/Deepgram.js +25 -82
- package/dist/voice/tts/ElevenLabs.d.ts +4 -18
- package/dist/voice/tts/ElevenLabs.js +6 -97
- package/dist/voice/tts/Google.d.ts +4 -38
- package/dist/voice/tts/Google.js +25 -91
- package/dist/webhooks/createWebhooksHandlers.d.ts +37 -0
- package/dist/webhooks/createWebhooksHandlers.js +217 -0
- package/dist/webhooks/index.d.ts +37 -0
- package/dist/webhooks/index.js +51 -0
- package/dist/webhooks/lostCalls.d.ts +49 -0
- package/dist/webhooks/lostCalls.js +147 -0
- package/dist/webhooks/nodeCallEvents.d.ts +73 -0
- package/dist/webhooks/nodeCallEvents.js +177 -0
- package/dist/webhooks/runWebhookFanout.d.ts +44 -0
- package/dist/webhooks/runWebhookFanout.js +202 -0
- package/package.json +21 -31
- package/dist/applications/utils/applicationWithEncodedStruct.d.ts +0 -3
- package/dist/applications/utils/applicationWithEncodedStruct.js +0 -50
- package/dist/applications/utils/convertToApplicationData.js +0 -37
- package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +0 -786
- package/dist/applications/validation/assistantWithoutApiKeySchema.js +0 -35
- package/dist/applications/validation/createValidationSchema.d.ts +0 -1474
- package/dist/applications/validation/createValidationSchema.js +0 -67
- package/dist/applications/validation/prepareForValidation.d.ts +0 -21
- package/dist/applications/validation/prepareForValidation.js +0 -35
- package/dist/applications/validation/speechValidators.d.ts +0 -47
- package/dist/applications/validation/speechValidators.js +0 -50
- package/dist/applications/validation/validOrThrow.d.ts +0 -21
- package/dist/applications/validation/validOrThrow.js +0 -15
- package/dist/calls/createFetchCalls.d.ts +0 -22
- package/dist/calls/createFetchCalls.js +0 -88
- package/dist/calls/createFetchSingleCall.d.ts +0 -22
- package/dist/calls/influxdb.d.ts +0 -2
- package/dist/calls/runCallManager.d.ts +0 -8
- package/dist/calls/runCallManager.js +0 -75
- package/dist/core/buildWelcomeDemoService.js +0 -97
- package/dist/core/upsertDefaultPeer.d.ts +0 -2
- package/dist/events/amdResultCache.d.ts +0 -23
- package/dist/events/amdResultCache.js +0 -35
- package/dist/events/createInfluxDbPub.d.ts +0 -13
- package/dist/events/createInfluxDbPub.js +0 -89
- package/dist/events/createPerCallCache.js +0 -46
- package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
- package/dist/events/mapCallDirectionToEnum.js +0 -37
- package/dist/events/nats.d.ts +0 -10
- package/dist/events/nats.js +0 -82
- package/dist/events/transformEvent.d.ts +0 -2
- package/dist/events/transformEvent.js +0 -87
- package/dist/events/types.d.ts +0 -26
- package/dist/utils/createHandleDialEventsWithNats.js +0 -24
- package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +0 -23
- package/dist/utils/createHandleDialEventsWithVoiceClient.js +0 -27
- package/dist/utils/getIntegrationsFromFile.d.ts +0 -2
- package/dist/utils/getIntegrationsFromFile.js +0 -49
- package/dist/utils/mapDialStatus.d.ts +0 -21
- package/dist/utils/mapDialStatus.js +0 -38
- package/dist/voice/VoiceDispatcher.d.ts +0 -21
- package/dist/voice/VoiceDispatcher.js +0 -122
- package/dist/voice/amd/mapAsteriskAmd.d.ts +0 -38
- package/dist/voice/amd/mapAsteriskAmd.js +0 -68
- package/dist/voice/client/AudioSocketHandler.d.ts +0 -38
- package/dist/voice/client/AudioSocketHandler.js +0 -70
- package/dist/voice/client/AuthorizationHandler.d.ts +0 -13
- package/dist/voice/client/AuthorizationHandler.js +0 -78
- package/dist/voice/client/ExternalMediaHandler.d.ts +0 -32
- package/dist/voice/client/ExternalMediaHandler.js +0 -59
- package/dist/voice/client/GrpcClientHandler.d.ts +0 -36
- package/dist/voice/client/SpeechHandler.d.ts +0 -60
- package/dist/voice/client/SpeechHandler.js +0 -120
- package/dist/voice/client/VoiceClientImpl.d.ts +0 -79
- package/dist/voice/client/VoiceClientImpl.js +0 -198
- package/dist/voice/connectToAri.d.ts +0 -2
- package/dist/voice/connectToAri.js +0 -81
- package/dist/voice/createCreateVoiceClient.d.ts +0 -9
- package/dist/voice/createCreateVoiceClient.js +0 -97
- package/dist/voice/errors/ChannelVarNotFoundError.d.ts +0 -23
- package/dist/voice/errors/ChannelVarNotFoundError.js +0 -10
- package/dist/voice/errors/MethodNotImplementedError.d.ts +0 -22
- package/dist/voice/errors/MethodNotImplementedError.js +0 -27
- package/dist/voice/filters/AudioFilterFactory.d.ts +0 -35
- package/dist/voice/filters/AudioFilterFactory.js +0 -94
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.d.ts +0 -64
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.js +0 -252
- package/dist/voice/filters/aiCoustics/types.d.ts +0 -45
- package/dist/voice/filters/aiCoustics/types.js +0 -29
- package/dist/voice/filters/createAudioFilterChain.d.ts +0 -9
- package/dist/voice/filters/createAudioFilterChain.js +0 -171
- package/dist/voice/filters/createAudioFilterSession.d.ts +0 -15
- package/dist/voice/filters/createAudioFilterSession.js +0 -114
- package/dist/voice/filters/pcm.d.ts +0 -21
- package/dist/voice/filters/pcm.js +0 -37
- package/dist/voice/filters/types.d.ts +0 -61
- package/dist/voice/filters/types.js +0 -26
- package/dist/voice/handlers/createAnswerHandler.d.ts +0 -23
- package/dist/voice/handlers/createAnswerHandler.js +0 -24
- package/dist/voice/handlers/createHangupHandler.d.ts +0 -23
- package/dist/voice/handlers/createHangupHandler.js +0 -28
- package/dist/voice/handlers/createMuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createMuteHandler.js +0 -27
- package/dist/voice/handlers/createPlayDtmfHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayDtmfHandler.js +0 -27
- package/dist/voice/handlers/createPlayHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayHandler.js +0 -33
- package/dist/voice/handlers/createPlaybackControlHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlaybackControlHandler.js +0 -62
- package/dist/voice/handlers/createRecordHandler.d.ts +0 -4
- package/dist/voice/handlers/createRecordHandler.js +0 -58
- package/dist/voice/handlers/createSayHandler.d.ts +0 -4
- package/dist/voice/handlers/createSayHandler.js +0 -31
- package/dist/voice/handlers/createSetAudioFiltersHandler.d.ts +0 -11
- package/dist/voice/handlers/createSetAudioFiltersHandler.js +0 -74
- package/dist/voice/handlers/createStopSayHandler.d.ts +0 -3
- package/dist/voice/handlers/createStopSayHandler.js +0 -34
- package/dist/voice/handlers/createStreamGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamGatherHandler.js +0 -74
- package/dist/voice/handlers/createStreamHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamHandler.js +0 -70
- package/dist/voice/handlers/createUnmuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createUnmuteHandler.js +0 -27
- package/dist/voice/handlers/dial/createDialHandler.d.ts +0 -23
- package/dist/voice/handlers/dial/createDialHandler.js +0 -78
- package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +0 -24
- package/dist/voice/handlers/dial/handleChannelLeftBridge.js +0 -29
- package/dist/voice/handlers/dial/handleStasisEnd.d.ts +0 -21
- package/dist/voice/handlers/dial/handleStasisEnd.js +0 -19
- package/dist/voice/handlers/dial/handleStasisStart.d.ts +0 -27
- package/dist/voice/handlers/dial/handleStasisStart.js +0 -52
- package/dist/voice/handlers/dial/recordChannel.d.ts +0 -22
- package/dist/voice/handlers/gather/createGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/gather/createGatherHandler.js +0 -86
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +0 -26
- package/dist/voice/handlers/gather/getTimeoutPromise.js +0 -18
- package/dist/voice/handlers/index.d.ts +0 -33
- package/dist/voice/handlers/index.js +0 -49
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.d.ts +0 -21
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.js +0 -25
- package/dist/voice/handlers/utils/awaitForRecordingFinished.d.ts +0 -5
- package/dist/voice/handlers/utils/awaitForRecordingFinished.js +0 -53
- package/dist/voice/handlers/utils/isDtmf.d.ts +0 -20
- package/dist/voice/handlers/utils/textChunksByClause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByClause.js +0 -41
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.js +0 -34
- package/dist/voice/handlers/utils/withErrorHandling.d.ts +0 -22
- package/dist/voice/handlers/utils/withErrorHandling.js +0 -38
- package/dist/voice/integrations/ApplicationNotFoundError.d.ts +0 -22
- package/dist/voice/integrations/ApplicationNotFoundError.js +0 -28
- package/dist/voice/integrations/createCreateContainer.d.ts +0 -4
- package/dist/voice/integrations/createCreateContainer.js +0 -76
- package/dist/voice/integrations/getSttConfig.js +0 -30
- package/dist/voice/integrations/index.js +0 -35
- package/dist/voice/integrations/types.d.ts +0 -29
- package/dist/voice/stt/AbstractSpeechToText.d.ts +0 -33
- package/dist/voice/stt/AbstractSpeechToText.js +0 -19
- package/dist/voice/stt/SpeechToTextFactory.d.ts +0 -9
- package/dist/voice/stt/SpeechToTextFactory.js +0 -43
- package/dist/voice/transcribeOnConnection.d.ts +0 -35
- package/dist/voice/transcribeOnConnection.js +0 -91
- package/dist/voice/tts/AbstractTextToSpeech.d.ts +0 -40
- package/dist/voice/tts/AbstractTextToSpeech.js +0 -50
- package/dist/voice/tts/TextToSpeechFactory.d.ts +0 -8
- package/dist/voice/tts/TextToSpeechFactory.js +0 -47
- package/dist/voice/tts/types.d.ts +0 -48
- package/dist/voice/tts/types.js +0 -2
- package/dist/voice/tts/utils/convertUlawToPCM16.js +0 -40
- package/dist/voice/tts/utils/createChunkedSynthesisStream.d.ts +0 -28
- package/dist/voice/tts/utils/createChunkedSynthesisStream.js +0 -78
- package/dist/voice/tts/utils/createErrorStream.d.ts +0 -21
- package/dist/voice/tts/utils/createErrorStream.js +0 -28
- package/dist/voice/tts/utils/index.d.ts +0 -23
- package/dist/voice/tts/utils/index.js +0 -39
- package/dist/voice/tts/utils/isSsml.d.ts +0 -20
- package/dist/voice/tts/utils/isSsml.js +0 -25
- package/dist/voice/tts/utils/streamToBuffer.d.ts +0 -20
- package/dist/voice/tts/utils/streamToBuffer.js +0 -60
- package/dist/voice/types/ari.d.ts +0 -43
- package/dist/voice/types/ari.js +0 -48
- package/dist/voice/types/index.d.ts +0 -20
- package/dist/voice/types/index.js +0 -36
- package/dist/voice/types/voice.d.ts +0 -67
- package/dist/voice/types/voice.js +0 -2
- package/dist/voice/utils/VoiceServiceClientConstructor.d.ts +0 -3
- package/dist/voice/utils/createExternalMediaConfig.d.ts +0 -12
- package/dist/voice/utils/createExternalMediaConfig.js +0 -37
- package/dist/voice/utils/createGetChannelVar.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVar.js +0 -27
- package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVarWithoutThrow.js +0 -26
- package/dist/voice/utils/index.d.ts +0 -22
- package/dist/voice/utils/index.js +0 -38
- /package/dist/{events → records}/types.js +0 -0
- /package/dist/{voice/integrations → usage}/types.js +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.listAll = listAll;
|
|
46
|
+
exports.createSnapshotSources = createSnapshotSources;
|
|
47
|
+
/**
|
|
48
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
49
|
+
* http://github.com/fonoster/fonoster
|
|
50
|
+
*
|
|
51
|
+
* This file is part of Fonoster
|
|
52
|
+
*
|
|
53
|
+
* Licensed under the MIT License (the "License");
|
|
54
|
+
* you may not use this file except in compliance with
|
|
55
|
+
* the License. You may obtain a copy of the License at
|
|
56
|
+
*
|
|
57
|
+
* https://opensource.org/licenses/MIT
|
|
58
|
+
*
|
|
59
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
60
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
61
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
62
|
+
* See the License for the specific language governing permissions and
|
|
63
|
+
* limitations under the License.
|
|
64
|
+
*/
|
|
65
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
66
|
+
/** Every item of a workspace from a gRPC list handler (the sipnet services filter by workspace). */
|
|
67
|
+
function listAll(handler, accessKeyId) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
if (!handler)
|
|
71
|
+
return [];
|
|
72
|
+
const items = [];
|
|
73
|
+
let pageToken;
|
|
74
|
+
for (let page = 0; page < 100; page++) {
|
|
75
|
+
const metadata = new grpc.Metadata();
|
|
76
|
+
metadata.set("accessKeyId", accessKeyId);
|
|
77
|
+
const res = yield new Promise((resolve, reject) => void handler({ metadata, request: { pageSize: 100, pageToken } }, (err, r) => (err ? reject(err) : resolve(r !== null && r !== void 0 ? r : {}))));
|
|
78
|
+
items.push(...((_a = res.items) !== null && _a !== void 0 ? _a : []));
|
|
79
|
+
if (!res.nextPageToken || res.nextPageToken === pageToken)
|
|
80
|
+
break;
|
|
81
|
+
pageToken = res.nextPageToken;
|
|
82
|
+
}
|
|
83
|
+
return items;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const iso = (d) => (d instanceof Date ? d.toISOString() : d);
|
|
87
|
+
/** An application row as the cell's AppBridge reads it (AppBridge's `appFromRow` columns). */
|
|
88
|
+
function appRow(row) {
|
|
89
|
+
const out = {};
|
|
90
|
+
for (const [k, v] of Object.entries(row)) {
|
|
91
|
+
if (k === "intelligence" || k === "textToSpeech" || k === "speechToText")
|
|
92
|
+
continue;
|
|
93
|
+
out[k] = iso(v);
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The production snapshot sources: Prisma for apps, agents, webhooks, the catalog and the
|
|
99
|
+
* recording policy; the Routr-backed gRPC handlers for numbers and Routr resources.
|
|
100
|
+
*/
|
|
101
|
+
function createSnapshotSources(deps) {
|
|
102
|
+
const { db, handlers } = deps;
|
|
103
|
+
return {
|
|
104
|
+
apps(accessKeyId) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const rows = yield db.application.findMany({
|
|
107
|
+
where: { accessKeyId },
|
|
108
|
+
include: { intelligence: true },
|
|
109
|
+
orderBy: { createdAt: "asc" }
|
|
110
|
+
});
|
|
111
|
+
const agents = rows
|
|
112
|
+
.filter((r) => r.intelligence)
|
|
113
|
+
.map((r) => {
|
|
114
|
+
const i = r.intelligence;
|
|
115
|
+
return {
|
|
116
|
+
appRef: String(r.ref),
|
|
117
|
+
productRef: i.productRef,
|
|
118
|
+
config: i.config
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
return { apps: rows.map(appRow), agents };
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
numbers: (accessKeyId) => listAll(handlers.listNumbers, accessKeyId),
|
|
125
|
+
routr(accessKeyId) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const [domains, agents, trunks, acls] = yield Promise.all([
|
|
128
|
+
listAll(handlers.listDomains, accessKeyId),
|
|
129
|
+
listAll(handlers.listAgents, accessKeyId),
|
|
130
|
+
listAll(handlers.listTrunks, accessKeyId),
|
|
131
|
+
listAll(handlers.listAcls, accessKeyId)
|
|
132
|
+
]);
|
|
133
|
+
return { domains, agents, trunks, acls };
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
catalog(ids, providers) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const [p, m, v] = yield Promise.all([
|
|
139
|
+
db.registryProvider.findMany({ where: { id: { in: providers } } }),
|
|
140
|
+
db.registryModel.findMany({ where: { id: { in: ids } } }),
|
|
141
|
+
db.registryVoice.findMany({
|
|
142
|
+
where: { id: { in: ids } },
|
|
143
|
+
include: { models: true }
|
|
144
|
+
})
|
|
145
|
+
]);
|
|
146
|
+
const plain = (kind) => (r) => {
|
|
147
|
+
const out = { kind };
|
|
148
|
+
for (const [k, val] of Object.entries(r))
|
|
149
|
+
if (k !== "createdAt" && k !== "updatedAt")
|
|
150
|
+
out[k] =
|
|
151
|
+
k === "models"
|
|
152
|
+
? val.map((x) => x.modelId)
|
|
153
|
+
: val;
|
|
154
|
+
return out;
|
|
155
|
+
};
|
|
156
|
+
return [
|
|
157
|
+
...p.map(plain("provider")),
|
|
158
|
+
...m.map(plain("model")),
|
|
159
|
+
...v.map(plain("voice"))
|
|
160
|
+
];
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
webhooks(accessKeyId) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
// Webhooks are delivered from the cell (PR-7), so it gets the endpoints' signing secrets
|
|
166
|
+
// (Fonoster-generated, not provider keys; RG-B6).
|
|
167
|
+
const rows = yield db.webhookEndpoint.findMany({
|
|
168
|
+
where: { accessKeyId }
|
|
169
|
+
});
|
|
170
|
+
return rows.map((r) => {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
return ({
|
|
173
|
+
ref: r.ref,
|
|
174
|
+
url: r.url,
|
|
175
|
+
events: r.events,
|
|
176
|
+
secret: r.secret,
|
|
177
|
+
previousSecret: (_a = r.previousSecret) !== null && _a !== void 0 ? _a : null,
|
|
178
|
+
previousUntil: iso((_b = r.previousUntil) !== null && _b !== void 0 ? _b : null)
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
recordingPolicy(accessKeyId) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
var _a;
|
|
186
|
+
const retention = yield db.callRecordRetention.findMany({ where: { accessKeyId } });
|
|
187
|
+
return Object.assign(Object.assign({}, ((_a = deps.callFeatures) !== null && _a !== void 0 ? _a : {})), { retention: retention.map((r) => ({ part: r.part, days: r.days })) });
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { RegionRow, RegionStatus } from "./types";
|
|
20
|
+
export declare const OFFLINE_AFTER_MS: number;
|
|
21
|
+
/** The oldest supported version: the previous minor release of `current` (PR-6). */
|
|
22
|
+
export declare function requiredVersion(current: string): string;
|
|
23
|
+
/** True when `version` is the current or the previous minor release, or newer. */
|
|
24
|
+
export declare function isSupportedVersion(version: string, current: string): boolean;
|
|
25
|
+
export type StatusView = {
|
|
26
|
+
status: RegionStatus;
|
|
27
|
+
reason?: string;
|
|
28
|
+
requiredVersion?: string;
|
|
29
|
+
};
|
|
30
|
+
/** The shown status of a region from its row and the heartbeat rules (contract §4). */
|
|
31
|
+
export declare function regionStatus(row: Pick<RegionRow, "state" | "lastHeartbeatAt" | "enrolledAt" | "version" | "components">, options: {
|
|
32
|
+
now: Date;
|
|
33
|
+
currentVersion: string;
|
|
34
|
+
offlineAfterMs?: number;
|
|
35
|
+
}): StatusView;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OFFLINE_AFTER_MS = void 0;
|
|
4
|
+
exports.requiredVersion = requiredVersion;
|
|
5
|
+
exports.isSupportedVersion = isSupportedVersion;
|
|
6
|
+
exports.regionStatus = regionStatus;
|
|
7
|
+
exports.OFFLINE_AFTER_MS = 2 * 60000;
|
|
8
|
+
const parse = (v) => {
|
|
9
|
+
const m = /^v?(\d+)\.(\d+)(?:\.(\d+))?/.exec(v.trim());
|
|
10
|
+
return m ? { major: Number(m[1]), minor: Number(m[2]) } : undefined;
|
|
11
|
+
};
|
|
12
|
+
/** The oldest supported version: the previous minor release of `current` (PR-6). */
|
|
13
|
+
function requiredVersion(current) {
|
|
14
|
+
const c = parse(current);
|
|
15
|
+
if (!c)
|
|
16
|
+
return current;
|
|
17
|
+
return c.minor > 0 ? `${c.major}.${c.minor - 1}.0` : `${c.major}.0.0`;
|
|
18
|
+
}
|
|
19
|
+
/** True when `version` is the current or the previous minor release, or newer. */
|
|
20
|
+
function isSupportedVersion(version, current) {
|
|
21
|
+
const v = parse(version);
|
|
22
|
+
const r = parse(requiredVersion(current));
|
|
23
|
+
if (!v || !r)
|
|
24
|
+
return false;
|
|
25
|
+
return v.major > r.major || (v.major === r.major && v.minor >= r.minor);
|
|
26
|
+
}
|
|
27
|
+
/** The shown status of a region from its row and the heartbeat rules (contract §4). */
|
|
28
|
+
function regionStatus(row, options) {
|
|
29
|
+
var _a, _b, _c, _d, _e;
|
|
30
|
+
if (row.state !== "enrolled")
|
|
31
|
+
return { status: "waiting" };
|
|
32
|
+
const offlineAfter = (_a = options.offlineAfterMs) !== null && _a !== void 0 ? _a : exports.OFFLINE_AFTER_MS;
|
|
33
|
+
const last = (_b = row.lastHeartbeatAt) !== null && _b !== void 0 ? _b : undefined;
|
|
34
|
+
if (!last) {
|
|
35
|
+
// Enrolled, first heartbeat not yet in: waiting for a grace period, then offline.
|
|
36
|
+
const since = (_d = (_c = row.enrolledAt) === null || _c === void 0 ? void 0 : _c.getTime()) !== null && _d !== void 0 ? _d : 0;
|
|
37
|
+
return options.now.getTime() - since > offlineAfter
|
|
38
|
+
? { status: "offline", reason: "no heartbeat since enrollment" }
|
|
39
|
+
: { status: "waiting" };
|
|
40
|
+
}
|
|
41
|
+
if (options.now.getTime() - last.getTime() > offlineAfter)
|
|
42
|
+
return { status: "offline", reason: "no heartbeat for 2 minutes" };
|
|
43
|
+
if (row.version && !isSupportedVersion(row.version, options.currentVersion)) {
|
|
44
|
+
const required = requiredVersion(options.currentVersion);
|
|
45
|
+
return {
|
|
46
|
+
status: "unsupported",
|
|
47
|
+
requiredVersion: required,
|
|
48
|
+
reason: `version ${row.version} is no longer supported; upgrade the region to ${required} or later (config sync is paused)`
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const c = ((_e = row.components) !== null && _e !== void 0 ? _e : {});
|
|
52
|
+
const down = [];
|
|
53
|
+
if (!c.roomrNodes)
|
|
54
|
+
down.push("Roomr nodes");
|
|
55
|
+
// `appbridges` is 1 when AppBridge passes its health check through its Service, 0 when not.
|
|
56
|
+
if (!c.appbridges)
|
|
57
|
+
down.push("AppBridge");
|
|
58
|
+
if (c.autopilot === false)
|
|
59
|
+
down.push("autopilot");
|
|
60
|
+
if (down.length)
|
|
61
|
+
return { status: "degraded", reason: `no healthy ${down.join(", ")}` };
|
|
62
|
+
return { status: "connected" };
|
|
63
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import type { RegionEndpoints } from "./endpoints";
|
|
20
|
+
/** Wire names of the private region contract (openspec/changes/archive/2026-10-17-add-private-regions/contract.md). */
|
|
21
|
+
export declare const REGION_AUDIENCE = "fonoster.region.v1";
|
|
22
|
+
export declare const PRIVATE_REGION = "private";
|
|
23
|
+
/** A private region ref: `rg_` + lowercase base32. */
|
|
24
|
+
export declare const REGION_REF: RegExp;
|
|
25
|
+
export declare const isPrivateRegionRef: (region?: string | null) => boolean;
|
|
26
|
+
export declare const subjects: (ref: string) => {
|
|
27
|
+
all: string;
|
|
28
|
+
heartbeat: string;
|
|
29
|
+
config: string;
|
|
30
|
+
configRequest: string;
|
|
31
|
+
secretsNeeded: string;
|
|
32
|
+
relay: string;
|
|
33
|
+
index: string;
|
|
34
|
+
usage: string;
|
|
35
|
+
revoked: string;
|
|
36
|
+
/** region → cp request/reply: a workspace's bring-your-own key (public regions, §6). */
|
|
37
|
+
secretsGet: string;
|
|
38
|
+
endpoints: string;
|
|
39
|
+
/** cp → cell: please publish `region.R.endpoints` again (RE-B2). */
|
|
40
|
+
endpointsRequest: string;
|
|
41
|
+
/** Reply subjects for requests that cross the link (RG-B4). */
|
|
42
|
+
inbox: string;
|
|
43
|
+
};
|
|
44
|
+
export type Components = {
|
|
45
|
+
roomrNodes: number;
|
|
46
|
+
appbridges: number;
|
|
47
|
+
autopilot: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type Heartbeat = {
|
|
50
|
+
type: "region.heartbeat";
|
|
51
|
+
regionRef: string;
|
|
52
|
+
version: string;
|
|
53
|
+
components: Components;
|
|
54
|
+
activeCalls: number;
|
|
55
|
+
secretsSet: string[];
|
|
56
|
+
configVersion: number;
|
|
57
|
+
/** See `endpointsHash()` (RE-B2); a change makes the control plane ask for the endpoints. */
|
|
58
|
+
endpointsHash?: string;
|
|
59
|
+
at: string;
|
|
60
|
+
};
|
|
61
|
+
export type RegionStatus = "waiting" | "connected" | "degraded" | "offline" | "unsupported";
|
|
62
|
+
export type RegionKind = "public" | "private";
|
|
63
|
+
/** A configured public region (`regions.public`, the fallback for `default`). */
|
|
64
|
+
export type PublicRegion = {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
default?: boolean;
|
|
68
|
+
/** Configured connection details (contract §3a). */
|
|
69
|
+
endpoints?: RegionEndpoints;
|
|
70
|
+
};
|
|
71
|
+
/** A Region row (Prisma). */
|
|
72
|
+
export type RegionRow = {
|
|
73
|
+
ref: string;
|
|
74
|
+
id: string;
|
|
75
|
+
kind: RegionKind | string;
|
|
76
|
+
ownerRef: string | null;
|
|
77
|
+
displayName: string;
|
|
78
|
+
sipDomain: string | null;
|
|
79
|
+
published: boolean;
|
|
80
|
+
/** Legacy (old model): the workspace a private region was created for. */
|
|
81
|
+
accessKeyId: string | null;
|
|
82
|
+
state: string;
|
|
83
|
+
cellPublicKey: string | null;
|
|
84
|
+
version: string | null;
|
|
85
|
+
components: unknown;
|
|
86
|
+
activeCalls: number;
|
|
87
|
+
secretsSet: string[];
|
|
88
|
+
reportedConfig: number;
|
|
89
|
+
configVersion: number;
|
|
90
|
+
configChangedAt?: Date | null;
|
|
91
|
+
lastHeartbeatAt: Date | null;
|
|
92
|
+
enrolledAt: Date | null;
|
|
93
|
+
endpoints?: unknown;
|
|
94
|
+
endpointsHash?: string | null;
|
|
95
|
+
endpointsAt?: Date | null;
|
|
96
|
+
deletedAt: Date | null;
|
|
97
|
+
createdAt: Date;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
};
|
|
100
|
+
/** What `Workspace.region` holds for a region: the id (public) or the ref (private). */
|
|
101
|
+
export declare const regionKey: (row: Pick<RegionRow, "kind" | "id" | "ref">) => string;
|
|
102
|
+
/** A workspace as the regions code sees it (from Identity). */
|
|
103
|
+
export type WorkspaceInfo = {
|
|
104
|
+
ref: string;
|
|
105
|
+
accessKeyId: string;
|
|
106
|
+
name: string;
|
|
107
|
+
ownerRef: string;
|
|
108
|
+
region: string;
|
|
109
|
+
};
|
|
110
|
+
/** Identity's workspaces, read by the regions code (Identity has its own database). */
|
|
111
|
+
export type WorkspaceDirectory = {
|
|
112
|
+
workspace(accessKeyId: string): Promise<WorkspaceInfo | undefined>;
|
|
113
|
+
/** Workspaces whose `region` is this key (a public id or a private ref). */
|
|
114
|
+
inRegion(regionKey: string): Promise<WorkspaceInfo[]>;
|
|
115
|
+
};
|
|
116
|
+
/** The Prisma client, narrowed to what the regions code uses (tests pass a real one). */
|
|
117
|
+
export type RegionsDb = any;
|
|
118
|
+
/** A failure with the HTTP status and contract code to answer with. */
|
|
119
|
+
export declare class RegionError extends Error {
|
|
120
|
+
readonly status: number;
|
|
121
|
+
readonly code: string;
|
|
122
|
+
constructor(status: number, code: string, message?: string);
|
|
123
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegionError = exports.regionKey = exports.subjects = exports.isPrivateRegionRef = exports.REGION_REF = exports.PRIVATE_REGION = exports.REGION_AUDIENCE = void 0;
|
|
4
|
+
/** Wire names of the private region contract (openspec/changes/archive/2026-10-17-add-private-regions/contract.md). */
|
|
5
|
+
exports.REGION_AUDIENCE = "fonoster.region.v1";
|
|
6
|
+
exports.PRIVATE_REGION = "private";
|
|
7
|
+
/** A private region ref: `rg_` + lowercase base32. */
|
|
8
|
+
exports.REGION_REF = /^rg_[a-z2-7]{8,32}$/;
|
|
9
|
+
const isPrivateRegionRef = (region) => !!region && region.startsWith("rg_");
|
|
10
|
+
exports.isPrivateRegionRef = isPrivateRegionRef;
|
|
11
|
+
const subjects = (ref) => ({
|
|
12
|
+
all: `region.${ref}.>`,
|
|
13
|
+
heartbeat: `region.${ref}.heartbeat`,
|
|
14
|
+
config: `region.${ref}.config`,
|
|
15
|
+
configRequest: `region.${ref}.config.request`,
|
|
16
|
+
secretsNeeded: `region.${ref}.secrets.needed`,
|
|
17
|
+
relay: `region.${ref}.relay`,
|
|
18
|
+
index: `region.${ref}.index`,
|
|
19
|
+
usage: `region.${ref}.usage`,
|
|
20
|
+
revoked: `region.${ref}.revoked`,
|
|
21
|
+
/** region → cp request/reply: a workspace's bring-your-own key (public regions, §6). */
|
|
22
|
+
secretsGet: `region.${ref}.secrets.get`,
|
|
23
|
+
endpoints: `region.${ref}.endpoints`,
|
|
24
|
+
/** cp → cell: please publish `region.R.endpoints` again (RE-B2). */
|
|
25
|
+
endpointsRequest: `region.${ref}.endpoints.request`,
|
|
26
|
+
/** Reply subjects for requests that cross the link (RG-B4). */
|
|
27
|
+
inbox: `region.${ref}._INBOX`
|
|
28
|
+
});
|
|
29
|
+
exports.subjects = subjects;
|
|
30
|
+
/** What `Workspace.region` holds for a region: the id (public) or the ref (private). */
|
|
31
|
+
const regionKey = (row) => row.kind === "public" ? row.id : row.ref;
|
|
32
|
+
exports.regionKey = regionKey;
|
|
33
|
+
/** A failure with the HTTP status and contract code to answer with. */
|
|
34
|
+
class RegionError extends Error {
|
|
35
|
+
constructor(status, code, message) {
|
|
36
|
+
super(message !== null && message !== void 0 ? message : code);
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.code = code;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.RegionError = RegionError;
|
|
@@ -16,12 +16,18 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
declare
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
import * as grpc from "@grpc/grpc-js";
|
|
20
|
+
/** Services whose writes change a private cell's config (PR-7). */
|
|
21
|
+
export declare const SYNCED_SERVICES: string[];
|
|
22
|
+
type Service = {
|
|
23
|
+
definition: {
|
|
24
|
+
serviceName: string;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
handlers: grpc.UntypedServiceImplementation;
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Wraps the write handlers of the synced services so a successful write marks the workspace's
|
|
30
|
+
* config changed (the config sync publishes a new version for private workspaces).
|
|
31
|
+
*/
|
|
32
|
+
export declare function withConfigChangeHook<T extends Service>(services: T[], onChange: (accessKeyId: string) => void): T[];
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SYNCED_SERVICES = void 0;
|
|
4
|
+
exports.withConfigChangeHook = withConfigChangeHook;
|
|
5
|
+
/** Services whose writes change a private cell's config (PR-7). */
|
|
6
|
+
exports.SYNCED_SERVICES = [
|
|
7
|
+
"Applications",
|
|
8
|
+
"Numbers",
|
|
9
|
+
"Domains",
|
|
10
|
+
"Agents",
|
|
11
|
+
"Trunks",
|
|
12
|
+
"Acls",
|
|
13
|
+
"Credentials",
|
|
14
|
+
"Webhooks"
|
|
15
|
+
];
|
|
16
|
+
const WRITE = /^(create|update|delete|rotate|regenerate|resend)/;
|
|
17
|
+
/**
|
|
18
|
+
* Wraps the write handlers of the synced services so a successful write marks the workspace's
|
|
19
|
+
* config changed (the config sync publishes a new version for private workspaces).
|
|
20
|
+
*/
|
|
21
|
+
function withConfigChangeHook(services, onChange) {
|
|
22
|
+
return services.map((service) => {
|
|
23
|
+
if (!exports.SYNCED_SERVICES.includes(service.definition.serviceName))
|
|
24
|
+
return service;
|
|
25
|
+
const handlers = {};
|
|
26
|
+
for (const [name, handler] of Object.entries(service.handlers)) {
|
|
27
|
+
if (!WRITE.test(name) || typeof handler !== "function") {
|
|
28
|
+
handlers[name] = handler;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const fn = handler;
|
|
32
|
+
handlers[name] = ((call, cb) => fn(call, (err, ...rest) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
cb(err, ...rest);
|
|
35
|
+
if (err)
|
|
36
|
+
return;
|
|
37
|
+
const id = (_b = (_a = call.metadata) === null || _a === void 0 ? void 0 : _a.get("accessKeyId")) === null || _b === void 0 ? void 0 : _b[0];
|
|
38
|
+
if (id)
|
|
39
|
+
onChange(String(id));
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return Object.assign(Object.assign({}, service), { handlers });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -3,10 +3,10 @@ declare function createGetFnUtil(prisma: Prisma): (ref: string) => Promise<{
|
|
|
3
3
|
extended: {
|
|
4
4
|
accessKeyId: string;
|
|
5
5
|
};
|
|
6
|
-
ref: string;
|
|
7
6
|
accessKeyId: string;
|
|
8
|
-
secret: string;
|
|
9
7
|
name: string;
|
|
8
|
+
secret: string;
|
|
9
|
+
ref: string;
|
|
10
10
|
createdAt: Date;
|
|
11
11
|
updatedAt: Date;
|
|
12
12
|
} & {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
/** Where the router is mounted; the cookie is scoped to this path (M4). */
|
|
3
|
+
export declare const SESSION_PATH = "/api/session";
|
|
4
|
+
/** The httpOnly cookie that holds the dashboard's refresh token. */
|
|
5
|
+
export declare const SESSION_COOKIE = "fonoster_session";
|
|
6
|
+
/** Required on every request, so a plain cross-site form or link can't use the cookie. */
|
|
7
|
+
export declare const CSRF_HEADER = "x-requested-with";
|
|
8
|
+
export type SessionTokens = {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
refreshToken: string;
|
|
11
|
+
idToken: string;
|
|
12
|
+
};
|
|
13
|
+
/** Identity's ExchangeRefreshToken and RevokeToken, called in-process. */
|
|
14
|
+
export type SessionIdentity = {
|
|
15
|
+
exchangeRefreshToken(refreshToken: string): Promise<SessionTokens>;
|
|
16
|
+
revokeToken(refreshToken: string): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
/** Rejection from Identity: a gRPC status code. */
|
|
19
|
+
export declare class SessionIdentityError extends Error {
|
|
20
|
+
readonly code: number;
|
|
21
|
+
constructor(code: number, message: string);
|
|
22
|
+
}
|
|
23
|
+
export type SessionRouterDeps = {
|
|
24
|
+
identity: SessionIdentity;
|
|
25
|
+
/**
|
|
26
|
+
* Mark the cookie Secure. True when the app URL is https (the default); a plain-http
|
|
27
|
+
* deployment can't use Secure cookies, browsers would drop them.
|
|
28
|
+
*/
|
|
29
|
+
secureCookie: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The dashboard's session (security review M4): the refresh token lives in an httpOnly,
|
|
33
|
+
* SameSite=Strict cookie scoped to /api/session, so page scripts (and any XSS) never read it;
|
|
34
|
+
* the dashboard keeps only the access and id tokens, in memory.
|
|
35
|
+
*
|
|
36
|
+
* POST /api/session {refreshToken}: adopts a token from a fresh sign-in. It is
|
|
37
|
+
* rotated at once, so the copy the page saw is already spent.
|
|
38
|
+
* POST /api/session/refresh rotates the cookie's token, returns new access and id tokens
|
|
39
|
+
* POST /api/session/logout revokes the cookie's token family and clears the cookie
|
|
40
|
+
*
|
|
41
|
+
* Every request needs the `X-Requested-With` header (CSRF, besides SameSite=Strict); without
|
|
42
|
+
* it the answer is 403. The responses carry {accessToken, idToken, expiresAt}, never the
|
|
43
|
+
* refresh token. Envoy serves this on the dashboard's origin (its existing /api route), so no
|
|
44
|
+
* CORS is involved. SDK and API clients are unaffected: they keep exchanging refresh tokens
|
|
45
|
+
* over gRPC.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createSessionRouter(deps: SessionRouterDeps): Router;
|
|
48
|
+
/** Binds the router to the in-process Identity service's gRPC handlers. */
|
|
49
|
+
export declare function identityFromHandlers(handlers: Record<string, unknown>): SessionIdentity;
|