doover-js 0.11.0 → 0.13.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/README.md +106 -0
- package/dist/apis/_args.js +5 -5
- package/dist/apis/agents-api.d.ts +4 -4
- package/dist/apis/agents-api.js +2 -2
- package/dist/apis/aggregates-api.d.ts +4 -4
- package/dist/apis/aggregates-api.js +5 -5
- package/dist/apis/alarms-api.d.ts +2 -2
- package/dist/apis/alarms-api.js +3 -3
- package/dist/apis/channels-api.d.ts +3 -3
- package/dist/apis/channels-api.js +6 -6
- package/dist/apis/connections-api.d.ts +2 -2
- package/dist/apis/connections-api.js +6 -6
- package/dist/apis/messages-api.d.ts +4 -4
- package/dist/apis/messages-api.js +11 -11
- package/dist/apis/notifications-api.d.ts +2 -2
- package/dist/apis/notifications-api.js +4 -4
- package/dist/apis/organisations-api.d.ts +2 -2
- package/dist/apis/permissions-api.d.ts +2 -2
- package/dist/apis/permissions-api.js +3 -3
- package/dist/apis/processors-api.d.ts +2 -2
- package/dist/apis/turn-api.d.ts +2 -2
- package/dist/apis/users-api.d.ts +2 -2
- package/dist/auth/auth-store.d.ts +1 -1
- package/dist/auth/build-auth.d.ts +3 -3
- package/dist/auth/build-auth.js +8 -8
- package/dist/auth/cookie-auth.d.ts +1 -1
- package/dist/auth/cookie-auth.js +2 -2
- package/dist/auth/doover-auth.d.ts +2 -2
- package/dist/auth/doover-token-auth.d.ts +3 -3
- package/dist/auth/doover-token-auth.js +13 -13
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.js +15 -0
- package/dist/client/data-client.d.ts +17 -14
- package/dist/client/doover-client.d.ts +9 -7
- package/dist/client/doover-client.js +44 -42
- package/dist/client/errors.d.ts +2 -2
- package/dist/client/errors.js +4 -4
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +12 -0
- package/dist/client/local-agent-client.d.ts +3 -3
- package/dist/client/local-agent-client.js +19 -19
- package/dist/client/multiplex-client.d.ts +5 -5
- package/dist/client/multiplex-client.js +25 -25
- package/dist/client/multiplex-gateway.d.ts +3 -3
- package/dist/client/multiplex-merge.d.ts +1 -1
- package/dist/client/network-status.d.ts +17 -0
- package/dist/client/network-status.js +70 -0
- package/dist/client/offline-cache.d.ts +9 -4
- package/dist/client/offline-cache.js +34 -22
- package/dist/client/provenance.d.ts +1 -1
- package/dist/client/request-options.d.ts +1 -1
- package/dist/client/singleton.d.ts +2 -2
- package/dist/client/singleton.js +2 -2
- package/dist/client/status-tracker.d.ts +1 -1
- package/dist/esm/apis/_args.d.ts +16 -0
- package/dist/esm/apis/_args.js +27 -0
- package/dist/esm/apis/agents-api.d.ts +196 -0
- package/dist/esm/apis/agents-api.js +327 -0
- package/dist/esm/apis/aggregates-api.d.ts +67 -0
- package/dist/esm/apis/aggregates-api.js +64 -0
- package/dist/esm/apis/alarms-api.d.ts +48 -0
- package/dist/esm/apis/alarms-api.js +75 -0
- package/dist/esm/apis/channels-api.d.ts +83 -0
- package/dist/esm/apis/channels-api.js +65 -0
- package/dist/esm/apis/connections-api.d.ts +45 -0
- package/dist/esm/apis/connections-api.js +44 -0
- package/dist/esm/apis/messages-api.d.ts +128 -0
- package/dist/esm/apis/messages-api.js +179 -0
- package/dist/esm/apis/notifications-api.d.ts +94 -0
- package/dist/esm/apis/notifications-api.js +153 -0
- package/dist/esm/apis/organisations-api.d.ts +26 -0
- package/dist/esm/apis/organisations-api.js +41 -0
- package/dist/esm/apis/permissions-api.d.ts +17 -0
- package/dist/esm/apis/permissions-api.js +23 -0
- package/dist/esm/apis/processors-api.d.ts +56 -0
- package/dist/esm/apis/processors-api.js +97 -0
- package/dist/esm/apis/turn-api.d.ts +7 -0
- package/dist/esm/apis/turn-api.js +8 -0
- package/dist/esm/apis/users-api.d.ts +8 -0
- package/dist/esm/apis/users-api.js +9 -0
- package/dist/esm/auth/auth-profile.d.ts +45 -0
- package/dist/esm/auth/auth-profile.js +68 -0
- package/dist/esm/auth/auth-store.d.ts +14 -0
- package/dist/esm/auth/build-auth.d.ts +38 -0
- package/dist/esm/auth/build-auth.js +92 -0
- package/dist/esm/auth/cookie-auth.d.ts +91 -0
- package/dist/esm/auth/cookie-auth.js +196 -0
- package/dist/esm/auth/doover-auth.d.ts +52 -0
- package/dist/esm/auth/doover-auth.js +28 -0
- package/dist/esm/auth/doover-token-auth.d.ts +39 -0
- package/dist/esm/auth/doover-token-auth.js +217 -0
- package/dist/esm/auth/errors.d.ts +3 -0
- package/dist/esm/auth/errors.js +6 -0
- package/dist/esm/auth/index.d.ts +10 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/jwt.d.ts +6 -0
- package/dist/esm/auth/jwt.js +26 -0
- package/dist/esm/client/capabilities.d.ts +10 -0
- package/dist/esm/client/capabilities.js +42 -0
- package/dist/esm/client/data-client.d.ts +107 -0
- package/dist/esm/client/doover-client.d.ts +48 -0
- package/dist/esm/client/doover-client.js +96 -0
- package/dist/esm/client/errors.d.ts +32 -0
- package/dist/esm/client/errors.js +64 -0
- package/dist/esm/client/index.d.ts +6 -0
- package/dist/esm/client/index.js +3 -0
- package/dist/esm/client/local-agent-client.d.ts +65 -0
- package/dist/esm/client/local-agent-client.js +225 -0
- package/dist/esm/client/multiplex-client.d.ts +165 -0
- package/dist/esm/client/multiplex-client.js +842 -0
- package/dist/esm/client/multiplex-gateway.d.ts +49 -0
- package/dist/esm/client/multiplex-gateway.js +110 -0
- package/dist/esm/client/multiplex-merge.d.ts +12 -0
- package/dist/esm/client/multiplex-merge.js +38 -0
- package/dist/esm/client/network-status.d.ts +17 -0
- package/dist/esm/client/network-status.js +66 -0
- package/dist/esm/client/offline-cache.d.ts +167 -0
- package/dist/esm/client/offline-cache.js +769 -0
- package/dist/esm/client/provenance.d.ts +60 -0
- package/dist/esm/client/provenance.js +108 -0
- package/dist/esm/client/request-options.d.ts +23 -0
- package/dist/esm/client/request-options.js +23 -0
- package/dist/esm/client/singleton.d.ts +26 -0
- package/dist/esm/client/singleton.js +54 -0
- package/dist/esm/client/stats.d.ts +79 -0
- package/dist/esm/client/stats.js +155 -0
- package/dist/esm/client/status-tracker.d.ts +24 -0
- package/dist/esm/client/status-tracker.js +86 -0
- package/dist/esm/gateway/gateway-client.d.ts +86 -0
- package/dist/esm/gateway/gateway-client.js +463 -0
- package/dist/esm/gateway/index.d.ts +3 -0
- package/dist/esm/gateway/index.js +1 -0
- package/dist/esm/gateway/types.d.ts +142 -0
- package/dist/esm/http/errors.d.ts +19 -0
- package/dist/esm/http/errors.js +22 -0
- package/dist/esm/http/index.d.ts +3 -0
- package/dist/esm/http/index.js +2 -0
- package/dist/esm/http/rest-client.d.ts +64 -0
- package/dist/esm/http/rest-client.js +181 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/node/config-manager.d.ts +34 -0
- package/dist/esm/node/config-manager.js +140 -0
- package/dist/esm/node/index.d.ts +1 -0
- package/dist/esm/node/index.js +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react/context.d.ts +23 -0
- package/dist/esm/react/context.js +28 -0
- package/dist/esm/react/index.d.ts +38 -0
- package/dist/esm/react/index.js +21 -0
- package/dist/esm/react/messageRangeStore.d.ts +93 -0
- package/dist/esm/react/messageRangeStore.js +140 -0
- package/dist/esm/react/sharedQueryClient.d.ts +21 -0
- package/dist/esm/react/sharedQueryClient.js +35 -0
- package/dist/esm/react/useAgentChannel.d.ts +8 -0
- package/dist/esm/react/useAgentChannel.js +9 -0
- package/dist/esm/react/useAgentConnections.d.ts +8 -0
- package/dist/esm/react/useAgentConnections.js +20 -0
- package/dist/esm/react/useAgentTokenState.d.ts +70 -0
- package/dist/esm/react/useAgentTokenState.js +127 -0
- package/dist/esm/react/useChannelAggregate.d.ts +64 -0
- package/dist/esm/react/useChannelAggregate.js +77 -0
- package/dist/esm/react/useChannelMessage.d.ts +45 -0
- package/dist/esm/react/useChannelMessage.js +79 -0
- package/dist/esm/react/useChannelMessages.d.ts +83 -0
- package/dist/esm/react/useChannelMessages.js +214 -0
- package/dist/esm/react/useChannelSubscription.d.ts +27 -0
- package/dist/esm/react/useChannelSubscription.js +30 -0
- package/dist/esm/react/useClientStatus.d.ts +10 -0
- package/dist/esm/react/useClientStatus.js +19 -0
- package/dist/esm/react/useConnectionState.d.ts +26 -0
- package/dist/esm/react/useConnectionState.js +45 -0
- package/dist/esm/react/useDeviceMap.d.ts +109 -0
- package/dist/esm/react/useDeviceMap.js +59 -0
- package/dist/esm/react/useInvocationLogs.d.ts +23 -0
- package/dist/esm/react/useInvocationLogs.js +37 -0
- package/dist/esm/react/useMultiAgentAggregates.d.ts +38 -0
- package/dist/esm/react/useMultiAgentAggregates.js +104 -0
- package/dist/esm/react/useMultiAgentChannelMessages.d.ts +79 -0
- package/dist/esm/react/useMultiAgentChannelMessages.js +169 -0
- package/dist/esm/react/useOfflineStatus.d.ts +8 -0
- package/dist/esm/react/useOfflineStatus.js +37 -0
- package/dist/esm/react/useSendMessage.d.ts +16 -0
- package/dist/esm/react/useSendMessage.js +26 -0
- package/dist/esm/react/useSendRpc.d.ts +68 -0
- package/dist/esm/react/useSendRpc.js +164 -0
- package/dist/esm/react/useTurnCredentials.d.ts +12 -0
- package/dist/esm/react/useTurnCredentials.js +22 -0
- package/dist/esm/react/useUpdateAggregate.d.ts +27 -0
- package/dist/esm/react/useUpdateAggregate.js +39 -0
- package/dist/esm/react/useUpdateMessage.d.ts +38 -0
- package/dist/esm/react/useUpdateMessage.js +36 -0
- package/dist/esm/refine/index.d.ts +72 -0
- package/dist/esm/refine/index.js +215 -0
- package/dist/esm/rpc/errors.d.ts +10 -0
- package/dist/esm/rpc/errors.js +19 -0
- package/dist/esm/rpc/index.d.ts +3 -0
- package/dist/esm/rpc/index.js +2 -0
- package/dist/esm/rpc/rpc-dispatcher.d.ts +41 -0
- package/dist/esm/rpc/rpc-dispatcher.js +141 -0
- package/dist/esm/types/audit.d.ts +53 -0
- package/dist/esm/types/audit.js +11 -0
- package/dist/esm/types/batch.d.ts +85 -0
- package/dist/esm/types/batch.js +42 -0
- package/dist/esm/types/common.d.ts +250 -0
- package/dist/esm/types/connection.d.ts +72 -0
- package/dist/esm/types/connection.js +7 -0
- package/dist/esm/types/index.d.ts +9 -0
- package/dist/esm/types/openapi.d.ts +195 -0
- package/dist/esm/types/provenance.d.ts +45 -0
- package/dist/esm/types/viewer.d.ts +122 -0
- package/dist/esm/utils/snowflake.d.ts +21 -0
- package/dist/esm/utils/snowflake.js +33 -0
- package/dist/esm/viewer/doover-data-provider.d.ts +90 -0
- package/dist/esm/viewer/doover-data-provider.js +189 -0
- package/dist/esm/viewer/path-parsing.d.ts +5 -0
- package/dist/esm/viewer/path-parsing.js +35 -0
- package/dist/gateway/gateway-client.d.ts +5 -5
- package/dist/gateway/gateway-client.js +5 -5
- package/dist/gateway/index.d.ts +3 -0
- package/dist/gateway/index.js +5 -0
- package/dist/gateway/types.d.ts +1 -1
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.js +9 -0
- package/dist/http/rest-client.d.ts +5 -3
- package/dist/http/rest-client.js +2 -2
- package/dist/index.d.ts +64 -62
- package/dist/index.js +92 -89
- package/dist/node/config-manager.d.ts +2 -2
- package/dist/node/config-manager.js +5 -5
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +2 -2
- package/dist/react/context.d.ts +1 -1
- package/dist/react/index.d.ts +38 -38
- package/dist/react/index.js +59 -59
- package/dist/react/messageRangeStore.d.ts +1 -1
- package/dist/react/useAgentChannel.d.ts +3 -3
- package/dist/react/useAgentChannel.js +2 -2
- package/dist/react/useAgentConnections.d.ts +1 -1
- package/dist/react/useAgentConnections.js +2 -2
- package/dist/react/useAgentTokenState.d.ts +3 -3
- package/dist/react/useAgentTokenState.js +8 -8
- package/dist/react/useChannelAggregate.d.ts +3 -3
- package/dist/react/useChannelAggregate.js +8 -8
- package/dist/react/useChannelMessage.d.ts +2 -2
- package/dist/react/useChannelMessage.js +4 -4
- package/dist/react/useChannelMessages.d.ts +3 -3
- package/dist/react/useChannelMessages.js +10 -10
- package/dist/react/useChannelSubscription.d.ts +2 -2
- package/dist/react/useChannelSubscription.js +2 -2
- package/dist/react/useClientStatus.d.ts +1 -1
- package/dist/react/useClientStatus.js +2 -2
- package/dist/react/useConnectionState.js +2 -2
- package/dist/react/useDeviceMap.js +2 -2
- package/dist/react/useInvocationLogs.d.ts +1 -1
- package/dist/react/useInvocationLogs.js +2 -2
- package/dist/react/useMultiAgentAggregates.d.ts +1 -1
- package/dist/react/useMultiAgentAggregates.js +5 -5
- package/dist/react/useMultiAgentChannelMessages.d.ts +1 -1
- package/dist/react/useMultiAgentChannelMessages.js +2 -2
- package/dist/react/useOfflineStatus.d.ts +2 -2
- package/dist/react/useOfflineStatus.js +31 -17
- package/dist/react/useSendMessage.d.ts +2 -2
- package/dist/react/useSendMessage.js +2 -2
- package/dist/react/useSendRpc.d.ts +2 -2
- package/dist/react/useSendRpc.js +2 -2
- package/dist/react/useTurnCredentials.d.ts +2 -2
- package/dist/react/useTurnCredentials.js +2 -2
- package/dist/react/useUpdateAggregate.d.ts +3 -3
- package/dist/react/useUpdateAggregate.js +4 -4
- package/dist/react/useUpdateMessage.d.ts +2 -2
- package/dist/react/useUpdateMessage.js +2 -2
- package/dist/refine/index.d.ts +1 -1
- package/dist/rpc/errors.d.ts +1 -1
- package/dist/rpc/index.d.ts +3 -0
- package/dist/rpc/index.js +7 -0
- package/dist/rpc/rpc-dispatcher.d.ts +4 -4
- package/dist/rpc/rpc-dispatcher.js +2 -2
- package/dist/types/common.d.ts +1 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +2 -0
- package/dist/types/openapi.d.ts +1 -1
- package/dist/types/viewer.d.ts +2 -2
- package/dist/viewer/doover-data-provider.d.ts +10 -10
- package/dist/viewer/doover-data-provider.js +25 -25
- package/dist/viewer/path-parsing.d.ts +1 -1
- package/package.json +795 -8
- package/dist/test/api-args.test.js +0 -48
- package/dist/test/api-overloads.test.d.ts +0 -9
- package/dist/test/api-overloads.test.js +0 -330
- package/dist/test/apis.test.js +0 -408
- package/dist/test/auth.test.js +0 -708
- package/dist/test/batch-apis.test.js +0 -183
- package/dist/test/capabilities.test.js +0 -27
- package/dist/test/config-manager.test.js +0 -160
- package/dist/test/data-client-errors.test.js +0 -24
- package/dist/test/data-client-shape.test.js +0 -28
- package/dist/test/doover-client-dataclient.test.d.ts +0 -1
- package/dist/test/doover-client-dataclient.test.js +0 -58
- package/dist/test/doover-client-provenance.test.d.ts +0 -1
- package/dist/test/doover-client-provenance.test.js +0 -32
- package/dist/test/doover-client.test.d.ts +0 -1
- package/dist/test/doover-client.test.js +0 -42
- package/dist/test/doover-data-provider.test.d.ts +0 -1
- package/dist/test/doover-data-provider.test.js +0 -657
- package/dist/test/exports.test.d.ts +0 -1
- package/dist/test/exports.test.js +0 -80
- package/dist/test/gateway-client.test.d.ts +0 -1
- package/dist/test/gateway-client.test.js +0 -474
- package/dist/test/gateway-provenance.test.d.ts +0 -1
- package/dist/test/gateway-provenance.test.js +0 -29
- package/dist/test/gateway-subscriptions.test.d.ts +0 -1
- package/dist/test/gateway-subscriptions.test.js +0 -95
- package/dist/test/helpers.d.ts +0 -32
- package/dist/test/helpers.js +0 -115
- package/dist/test/local-agent-client.test.d.ts +0 -1
- package/dist/test/local-agent-client.test.js +0 -202
- package/dist/test/message-range-store.test.d.ts +0 -1
- package/dist/test/message-range-store.test.js +0 -183
- package/dist/test/multiplex-capabilities.test.d.ts +0 -1
- package/dist/test/multiplex-capabilities.test.js +0 -37
- package/dist/test/multiplex-conflicts.test.d.ts +0 -1
- package/dist/test/multiplex-conflicts.test.js +0 -35
- package/dist/test/multiplex-gateway.test.d.ts +0 -1
- package/dist/test/multiplex-gateway.test.js +0 -103
- package/dist/test/multiplex-merge.test.d.ts +0 -1
- package/dist/test/multiplex-merge.test.js +0 -19
- package/dist/test/multiplex-noncore.test.d.ts +0 -1
- package/dist/test/multiplex-noncore.test.js +0 -82
- package/dist/test/multiplex-passthrough.test.d.ts +0 -1
- package/dist/test/multiplex-passthrough.test.js +0 -35
- package/dist/test/multiplex-reads.test.d.ts +0 -1
- package/dist/test/multiplex-reads.test.js +0 -87
- package/dist/test/multiplex-registry.test.d.ts +0 -1
- package/dist/test/multiplex-registry.test.js +0 -81
- package/dist/test/multiplex-routing.test.d.ts +0 -1
- package/dist/test/multiplex-routing.test.js +0 -45
- package/dist/test/multiplex-status.test.d.ts +0 -1
- package/dist/test/multiplex-status.test.js +0 -63
- package/dist/test/multiplex-writes.test.d.ts +0 -1
- package/dist/test/multiplex-writes.test.js +0 -93
- package/dist/test/offline-cache.test.d.ts +0 -1
- package/dist/test/offline-cache.test.js +0 -289
- package/dist/test/provenance-regression.test.d.ts +0 -1
- package/dist/test/provenance-regression.test.js +0 -45
- package/dist/test/provenance-stamper.test.d.ts +0 -1
- package/dist/test/provenance-stamper.test.js +0 -41
- package/dist/test/provenance-type.test.d.ts +0 -1
- package/dist/test/provenance-type.test.js +0 -15
- package/dist/test/react-channel-messages-forward.test.d.ts +0 -1
- package/dist/test/react-channel-messages-forward.test.js +0 -139
- package/dist/test/react-channel-messages-range.test.d.ts +0 -1
- package/dist/test/react-channel-messages-range.test.js +0 -109
- package/dist/test/react-client-status.test.d.ts +0 -1
- package/dist/test/react-client-status.test.js +0 -35
- package/dist/test/react-dataclient.test.d.ts +0 -1
- package/dist/test/react-dataclient.test.js +0 -28
- package/dist/test/react-exports.test.d.ts +0 -1
- package/dist/test/react-exports.test.js +0 -46
- package/dist/test/react-multiagent-messages.test.d.ts +0 -1
- package/dist/test/react-multiagent-messages.test.js +0 -113
- package/dist/test/react-sources-option.test.d.ts +0 -1
- package/dist/test/react-sources-option.test.js +0 -41
- package/dist/test/react.test.d.ts +0 -1
- package/dist/test/react.test.js +0 -482
- package/dist/test/refine.test.d.ts +0 -1
- package/dist/test/refine.test.js +0 -71
- package/dist/test/rest-client.test.d.ts +0 -1
- package/dist/test/rest-client.test.js +0 -197
- package/dist/test/rpc-dispatcher.test.d.ts +0 -1
- package/dist/test/rpc-dispatcher.test.js +0 -251
- package/dist/test/singleton.test.d.ts +0 -1
- package/dist/test/singleton.test.js +0 -62
- package/dist/test/stats-rpc.test.d.ts +0 -1
- package/dist/test/stats-rpc.test.js +0 -69
- package/dist/test/status-tracker.test.d.ts +0 -1
- package/dist/test/status-tracker.test.js +0 -85
- package/dist/test/users-api.test.d.ts +0 -1
- package/dist/test/users-api.test.js +0 -19
- package/dist/test/utils.test.d.ts +0 -1
- package/dist/test/utils.test.js +0 -64
- /package/dist/{test/api-args.test.d.ts → esm/auth/auth-store.js} +0 -0
- /package/dist/{test/apis.test.d.ts → esm/client/data-client.js} +0 -0
- /package/dist/{test/auth.test.d.ts → esm/gateway/types.js} +0 -0
- /package/dist/{test/batch-apis.test.d.ts → esm/types/common.js} +0 -0
- /package/dist/{test/capabilities.test.d.ts → esm/types/index.js} +0 -0
- /package/dist/{test/config-manager.test.d.ts → esm/types/openapi.js} +0 -0
- /package/dist/{test/data-client-errors.test.d.ts → esm/types/provenance.js} +0 -0
- /package/dist/{test/data-client-shape.test.d.ts → esm/types/viewer.js} +0 -0
package/dist/auth/build-auth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildAuth = buildAuth;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const cookie_auth_js_1 = require("./cookie-auth.js");
|
|
5
|
+
const doover_token_auth_js_1 = require("./doover-token-auth.js");
|
|
6
|
+
const errors_js_1 = require("./errors.js");
|
|
7
7
|
const TOKEN_FIELDS = [
|
|
8
8
|
"token",
|
|
9
9
|
"tokenExpires",
|
|
@@ -43,7 +43,7 @@ function buildAuth(options) {
|
|
|
43
43
|
// Validate mutual exclusivity.
|
|
44
44
|
const hasRaw = TOKEN_FIELDS.some((k) => options[k] !== undefined);
|
|
45
45
|
if (hasRaw || options.profile !== undefined || options.configManager !== undefined) {
|
|
46
|
-
throw new
|
|
46
|
+
throw new errors_js_1.DooverAuthError("Cannot combine 'auth' with raw auth config fields (token, profile, configManager, etc.)");
|
|
47
47
|
}
|
|
48
48
|
return options.auth;
|
|
49
49
|
}
|
|
@@ -51,12 +51,12 @@ function buildAuth(options) {
|
|
|
51
51
|
let resolvedProfile = null;
|
|
52
52
|
if (typeof options.profile === "string") {
|
|
53
53
|
if (!options.configManager) {
|
|
54
|
-
throw new
|
|
54
|
+
throw new errors_js_1.DooverAuthError("A 'configManager' (AuthProfileStore) is required when 'profile' is a string. " +
|
|
55
55
|
"Use the doover-js/node subpath to import ConfigManager, or provide an AuthProfile directly.");
|
|
56
56
|
}
|
|
57
57
|
resolvedProfile = options.configManager.get(options.profile) ?? null;
|
|
58
58
|
if (!resolvedProfile) {
|
|
59
|
-
throw new
|
|
59
|
+
throw new errors_js_1.DooverAuthError(`Profile '${options.profile}' not found in the config manager`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
else if (options.profile instanceof Object && "profile" in options.profile) {
|
|
@@ -69,7 +69,7 @@ function buildAuth(options) {
|
|
|
69
69
|
if (!hasTokenInput && !profileHasToken) {
|
|
70
70
|
// No token data at all — fall back to cookie auth, which can still renew
|
|
71
71
|
// the session when the app has told us where its auth server lives.
|
|
72
|
-
const auth = new
|
|
72
|
+
const auth = new cookie_auth_js_1.CookieAuth({
|
|
73
73
|
authServerUrl: options.authServerUrl ?? resolvedProfile?.authServerUrl ?? null,
|
|
74
74
|
fetchImpl: options.fetchImpl,
|
|
75
75
|
});
|
|
@@ -79,7 +79,7 @@ function buildAuth(options) {
|
|
|
79
79
|
return auth;
|
|
80
80
|
}
|
|
81
81
|
// Build DooverTokenAuth with explicit fields overriding profile values.
|
|
82
|
-
const auth = new
|
|
82
|
+
const auth = new doover_token_auth_js_1.DooverTokenAuth({
|
|
83
83
|
token: options.token ?? undefined,
|
|
84
84
|
tokenExpires: options.tokenExpires ?? undefined,
|
|
85
85
|
refreshToken: options.refreshToken ?? undefined,
|
package/dist/auth/cookie-auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CookieAuth = void 0;
|
|
4
|
-
const
|
|
4
|
+
const doover_auth_js_1 = require("./doover-auth.js");
|
|
5
5
|
/** Default FusionAuth hosted-backend refresh endpoint. */
|
|
6
6
|
const DEFAULT_REFRESH_PATH = "/app/refresh/";
|
|
7
7
|
/** Default name of the cookie holding the access token's expiry (Unix seconds). */
|
|
@@ -33,7 +33,7 @@ const ATTEMPT_TTL_MS = 5000;
|
|
|
33
33
|
* reconnects, since `GatewayClient` awaits it before opening a socket), and
|
|
34
34
|
* `handleUnauthorized` lets `RestClient` replay a 401 once after a renewal.
|
|
35
35
|
*/
|
|
36
|
-
class CookieAuth extends
|
|
36
|
+
class CookieAuth extends doover_auth_js_1.DooverAuth {
|
|
37
37
|
constructor(options = {}) {
|
|
38
38
|
super();
|
|
39
39
|
this.refreshInFlight = null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AuthProfile } from "./auth-profile";
|
|
2
|
-
import type { AuthProfileStore } from "./auth-store";
|
|
1
|
+
import type { AuthProfile } from "./auth-profile.js";
|
|
2
|
+
import type { AuthProfileStore } from "./auth-store.js";
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class shared by cookie and token auth strategies.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DooverAuth } from "./doover-auth";
|
|
2
|
-
import type { AuthProfile } from "./auth-profile";
|
|
3
|
-
import type { AuthProfileStore } from "./auth-store";
|
|
1
|
+
import { DooverAuth } from "./doover-auth.js";
|
|
2
|
+
import type { AuthProfile } from "./auth-profile.js";
|
|
3
|
+
import type { AuthProfileStore } from "./auth-store.js";
|
|
4
4
|
export declare class DooverTokenAuth extends DooverAuth {
|
|
5
5
|
private token;
|
|
6
6
|
private tokenExpires;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DooverTokenAuth = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const doover_auth_js_1 = require("./doover-auth.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
const jwt_js_1 = require("./jwt.js");
|
|
7
7
|
/** Buffer in milliseconds before expiry at which we trigger a refresh (30 s). */
|
|
8
8
|
const REFRESH_BUFFER_MS = 30000;
|
|
9
|
-
class DooverTokenAuth extends
|
|
9
|
+
class DooverTokenAuth extends doover_auth_js_1.DooverAuth {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
super();
|
|
12
12
|
this.refreshInFlight = null;
|
|
@@ -63,7 +63,7 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
63
63
|
}
|
|
64
64
|
async ensureReady() {
|
|
65
65
|
if (this.authInvalid) {
|
|
66
|
-
throw new
|
|
66
|
+
throw new errors_js_1.DooverAuthError("Authentication is invalid; sign in again");
|
|
67
67
|
}
|
|
68
68
|
if (!this.needsRefresh()) {
|
|
69
69
|
return;
|
|
@@ -106,7 +106,7 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
106
106
|
this.tokenExpires = new Date(profile.tokenExpires);
|
|
107
107
|
}
|
|
108
108
|
if (!this.tokenExpires && this.token) {
|
|
109
|
-
this.tokenExpires = (0,
|
|
109
|
+
this.tokenExpires = (0, jwt_js_1.decodeTokenExpiry)(this.token);
|
|
110
110
|
}
|
|
111
111
|
if (!this.refreshToken && profile.refreshToken) {
|
|
112
112
|
this.refreshToken = profile.refreshToken;
|
|
@@ -138,7 +138,7 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
138
138
|
!this.refreshToken ||
|
|
139
139
|
!this.authServerClientId) {
|
|
140
140
|
this.markAuthInvalid();
|
|
141
|
-
throw new
|
|
141
|
+
throw new errors_js_1.DooverAuthError("Cannot refresh token: missing authServerUrl, refreshToken, or authServerClientId");
|
|
142
142
|
}
|
|
143
143
|
const url = new URL(`${this.authServerUrl}/oauth2/token`);
|
|
144
144
|
url.searchParams.set("grant_type", "refresh_token");
|
|
@@ -154,25 +154,25 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
catch (err) {
|
|
157
|
-
throw new
|
|
157
|
+
throw new errors_js_1.DooverAuthError(`Token refresh request failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
158
158
|
}
|
|
159
159
|
if (!response.ok) {
|
|
160
160
|
if (response.status >= 400 && response.status < 500) {
|
|
161
161
|
this.markAuthInvalid();
|
|
162
162
|
}
|
|
163
|
-
throw new
|
|
163
|
+
throw new errors_js_1.DooverAuthError(`Token refresh failed with status ${response.status}`);
|
|
164
164
|
}
|
|
165
165
|
const body = (await response.json());
|
|
166
166
|
if (!body.access_token) {
|
|
167
167
|
this.markAuthInvalid();
|
|
168
|
-
throw new
|
|
168
|
+
throw new errors_js_1.DooverAuthError("Token refresh response did not contain an access_token");
|
|
169
169
|
}
|
|
170
170
|
this.authInvalid = false;
|
|
171
171
|
this.token = body.access_token;
|
|
172
172
|
this.tokenExpires =
|
|
173
173
|
typeof body.expires_in === "number"
|
|
174
174
|
? new Date(Date.now() + body.expires_in * 1000)
|
|
175
|
-
: (0,
|
|
175
|
+
: (0, jwt_js_1.decodeTokenExpiry)(body.access_token);
|
|
176
176
|
if (body.refresh_token) {
|
|
177
177
|
this.refreshToken = body.refresh_token;
|
|
178
178
|
}
|
|
@@ -194,7 +194,7 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
194
194
|
this.configManager.write();
|
|
195
195
|
}
|
|
196
196
|
catch (err) {
|
|
197
|
-
throw new
|
|
197
|
+
throw new errors_js_1.DooverAuthError(`Failed to persist refreshed token: ${err instanceof Error ? err.message : String(err)}`);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -213,7 +213,7 @@ class DooverTokenAuth extends doover_auth_1.DooverAuth {
|
|
|
213
213
|
return new Date(explicit);
|
|
214
214
|
}
|
|
215
215
|
if (token) {
|
|
216
|
-
return (0,
|
|
216
|
+
return (0, jwt_js_1.decodeTokenExpiry)(token);
|
|
217
217
|
}
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { DooverAuth } from "./doover-auth.js";
|
|
2
|
+
export { CookieAuth } from "./cookie-auth.js";
|
|
3
|
+
export type { CookieAuthOptions } from "./cookie-auth.js";
|
|
4
|
+
export { DooverTokenAuth } from "./doover-token-auth.js";
|
|
5
|
+
export { AuthProfile } from "./auth-profile.js";
|
|
6
|
+
export type { AuthProfileData } from "./auth-profile.js";
|
|
7
|
+
export type { AuthProfileStore } from "./auth-store.js";
|
|
8
|
+
export { DooverAuthError } from "./errors.js";
|
|
9
|
+
export { buildAuth } from "./build-auth.js";
|
|
10
|
+
export type { AuthConfig } from "./build-auth.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAuth = exports.DooverAuthError = exports.AuthProfile = exports.DooverTokenAuth = exports.CookieAuth = exports.DooverAuth = void 0;
|
|
4
|
+
var doover_auth_js_1 = require("./doover-auth.js");
|
|
5
|
+
Object.defineProperty(exports, "DooverAuth", { enumerable: true, get: function () { return doover_auth_js_1.DooverAuth; } });
|
|
6
|
+
var cookie_auth_js_1 = require("./cookie-auth.js");
|
|
7
|
+
Object.defineProperty(exports, "CookieAuth", { enumerable: true, get: function () { return cookie_auth_js_1.CookieAuth; } });
|
|
8
|
+
var doover_token_auth_js_1 = require("./doover-token-auth.js");
|
|
9
|
+
Object.defineProperty(exports, "DooverTokenAuth", { enumerable: true, get: function () { return doover_token_auth_js_1.DooverTokenAuth; } });
|
|
10
|
+
var auth_profile_js_1 = require("./auth-profile.js");
|
|
11
|
+
Object.defineProperty(exports, "AuthProfile", { enumerable: true, get: function () { return auth_profile_js_1.AuthProfile; } });
|
|
12
|
+
var errors_js_1 = require("./errors.js");
|
|
13
|
+
Object.defineProperty(exports, "DooverAuthError", { enumerable: true, get: function () { return errors_js_1.DooverAuthError; } });
|
|
14
|
+
var build_auth_js_1 = require("./build-auth.js");
|
|
15
|
+
Object.defineProperty(exports, "buildAuth", { enumerable: true, get: function () { return build_auth_js_1.buildAuth; } });
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
1
|
+
import type { NetworkStatusSource } from "./network-status.js";
|
|
2
|
+
import type { AgentsApi } from "../apis/agents-api.js";
|
|
3
|
+
import type { AggregatesApi } from "../apis/aggregates-api.js";
|
|
4
|
+
import type { AlarmsApi } from "../apis/alarms-api.js";
|
|
5
|
+
import type { ChannelsApi } from "../apis/channels-api.js";
|
|
6
|
+
import type { ConnectionsApi } from "../apis/connections-api.js";
|
|
7
|
+
import type { MessagesApi } from "../apis/messages-api.js";
|
|
8
|
+
import type { NotificationsApi } from "../apis/notifications-api.js";
|
|
9
|
+
import type { PermissionsApi } from "../apis/permissions-api.js";
|
|
10
|
+
import type { ProcessorsApi } from "../apis/processors-api.js";
|
|
11
|
+
import type { TurnApi } from "../apis/turn-api.js";
|
|
12
|
+
import type { UsersApi } from "../apis/users-api.js";
|
|
13
|
+
import type { GatewayClient } from "../gateway/gateway-client.js";
|
|
14
|
+
import type { RpcDispatcher } from "../rpc/rpc-dispatcher.js";
|
|
15
|
+
import type { Capability } from "./capabilities.js";
|
|
15
16
|
/**
|
|
16
17
|
* Public structural shape of each concrete subclient — `Pick<Class, keyof Class>`
|
|
17
18
|
* yields just the public members as a plain object type (no nominal/private-member
|
|
@@ -76,6 +77,8 @@ export interface DataClientStatus {
|
|
|
76
77
|
* later; the invariant is that `DooverClient` always satisfies it.
|
|
77
78
|
*/
|
|
78
79
|
export interface DataClient {
|
|
80
|
+
/** Optional platform source; React hooks otherwise use browser network status. */
|
|
81
|
+
readonly networkStatus?: NetworkStatusSource;
|
|
79
82
|
readonly agents: AgentsApiLike;
|
|
80
83
|
readonly channels: ChannelsApiLike;
|
|
81
84
|
readonly messages: MessagesApiLike;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
import { type NetworkStatusSource } from "./network-status.js";
|
|
2
|
+
import { OrganisationsApi } from "../apis/organisations-api.js";
|
|
3
|
+
import type { DooverAuth } from "../auth/doover-auth.js";
|
|
4
|
+
import { RestClient, type DooverClientConfig } from "../http/rest-client.js";
|
|
5
|
+
import { DooverDataProvider } from "../viewer/doover-data-provider.js";
|
|
6
|
+
import { type Capability } from "./capabilities.js";
|
|
7
|
+
import type { AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, AgentScope, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client.js";
|
|
8
|
+
import { DooverStatsCollector, type DooverStatsSnapshot } from "./stats.js";
|
|
8
9
|
export declare class DooverClient implements DataClient {
|
|
10
|
+
readonly networkStatus: NetworkStatusSource;
|
|
9
11
|
readonly auth: DooverAuth;
|
|
10
12
|
readonly rest: RestClient;
|
|
11
13
|
readonly viewer: DooverDataProvider;
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DooverClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
4
|
+
const network_status_js_1 = require("./network-status.js");
|
|
5
|
+
const agents_api_js_1 = require("../apis/agents-api.js");
|
|
6
|
+
const aggregates_api_js_1 = require("../apis/aggregates-api.js");
|
|
7
|
+
const alarms_api_js_1 = require("../apis/alarms-api.js");
|
|
8
|
+
const channels_api_js_1 = require("../apis/channels-api.js");
|
|
9
|
+
const connections_api_js_1 = require("../apis/connections-api.js");
|
|
10
|
+
const messages_api_js_1 = require("../apis/messages-api.js");
|
|
11
|
+
const notifications_api_js_1 = require("../apis/notifications-api.js");
|
|
12
|
+
const organisations_api_js_1 = require("../apis/organisations-api.js");
|
|
13
|
+
const permissions_api_js_1 = require("../apis/permissions-api.js");
|
|
14
|
+
const processors_api_js_1 = require("../apis/processors-api.js");
|
|
15
|
+
const turn_api_js_1 = require("../apis/turn-api.js");
|
|
16
|
+
const users_api_js_1 = require("../apis/users-api.js");
|
|
17
|
+
const build_auth_js_1 = require("../auth/build-auth.js");
|
|
18
|
+
const gateway_client_js_1 = require("../gateway/gateway-client.js");
|
|
19
|
+
const rest_client_js_1 = require("../http/rest-client.js");
|
|
20
|
+
const rpc_dispatcher_js_1 = require("../rpc/rpc-dispatcher.js");
|
|
21
|
+
const doover_data_provider_js_1 = require("../viewer/doover-data-provider.js");
|
|
22
|
+
const capabilities_js_1 = require("./capabilities.js");
|
|
23
|
+
const provenance_js_1 = require("./provenance.js");
|
|
24
|
+
const status_tracker_js_1 = require("./status-tracker.js");
|
|
25
|
+
const stats_js_1 = require("./stats.js");
|
|
26
|
+
const ALL_CAPS_SET = new Set(capabilities_js_1.ALL_CAPABILITIES);
|
|
26
27
|
class DooverClient {
|
|
27
28
|
constructor(config) {
|
|
28
|
-
this.
|
|
29
|
+
this.networkStatus = config.networkStatus ?? network_status_js_1.browserNetworkStatus;
|
|
30
|
+
this.auth = (0, build_auth_js_1.buildAuth)({
|
|
29
31
|
auth: config.auth,
|
|
30
32
|
profile: config.profile,
|
|
31
33
|
configManager: config.configManager,
|
|
@@ -47,37 +49,37 @@ class DooverClient {
|
|
|
47
49
|
...(config.organisationId ? { organisationId: config.organisationId } : {}),
|
|
48
50
|
},
|
|
49
51
|
};
|
|
50
|
-
const stamper = new
|
|
51
|
-
this.rest = new
|
|
52
|
-
this.gatewayImpl = new
|
|
52
|
+
const stamper = new provenance_js_1.ProvenanceStamper(this.identity);
|
|
53
|
+
this.rest = new rest_client_js_1.RestClient(config, this.auth);
|
|
54
|
+
this.gatewayImpl = new gateway_client_js_1.GatewayClient(config, this.auth);
|
|
53
55
|
this.gatewayImpl.setProvenanceHook((value, ctx) => stamper.stampGatewayEvent(value, ctx));
|
|
54
56
|
this.gateway = this.gatewayImpl;
|
|
55
|
-
this.viewer = new
|
|
57
|
+
this.viewer = new doover_data_provider_js_1.DooverDataProvider({
|
|
56
58
|
rest: this.rest,
|
|
57
59
|
gateway: this.gatewayImpl,
|
|
58
60
|
controlApiUrl: config.controlApiUrl,
|
|
59
61
|
});
|
|
60
|
-
this.users = (0,
|
|
61
|
-
this.channels = (0,
|
|
62
|
-
this.messages = (0,
|
|
63
|
-
this.aggregates = (0,
|
|
64
|
-
this.alarms = (0,
|
|
65
|
-
this.connections = (0,
|
|
66
|
-
this.notifications = (0,
|
|
67
|
-
this.organisations = (0,
|
|
68
|
-
this.permissions = (0,
|
|
69
|
-
this.processors = (0,
|
|
70
|
-
this.turn = (0,
|
|
71
|
-
this.agents = (0,
|
|
62
|
+
this.users = (0, provenance_js_1.wrapSubclient)(new users_api_js_1.UsersApi(this.rest, config.controlApiUrl), "users", stamper);
|
|
63
|
+
this.channels = (0, provenance_js_1.wrapSubclient)(new channels_api_js_1.ChannelsApi(this.rest), "channels", stamper);
|
|
64
|
+
this.messages = (0, provenance_js_1.wrapSubclient)(new messages_api_js_1.MessagesApi(this.rest), "messages", stamper);
|
|
65
|
+
this.aggregates = (0, provenance_js_1.wrapSubclient)(new aggregates_api_js_1.AggregatesApi(this.rest), "aggregates", stamper);
|
|
66
|
+
this.alarms = (0, provenance_js_1.wrapSubclient)(new alarms_api_js_1.AlarmsApi(this.rest), "alarms", stamper);
|
|
67
|
+
this.connections = (0, provenance_js_1.wrapSubclient)(new connections_api_js_1.ConnectionsApi(this.rest), "connections", stamper);
|
|
68
|
+
this.notifications = (0, provenance_js_1.wrapSubclient)(new notifications_api_js_1.NotificationsApi(this.rest), "notifications", stamper);
|
|
69
|
+
this.organisations = (0, provenance_js_1.wrapSubclient)(new organisations_api_js_1.OrganisationsApi(this.rest, config.controlApiUrl), "organisations", stamper);
|
|
70
|
+
this.permissions = (0, provenance_js_1.wrapSubclient)(new permissions_api_js_1.PermissionsApi(this.rest), "permissions", stamper);
|
|
71
|
+
this.processors = (0, provenance_js_1.wrapSubclient)(new processors_api_js_1.ProcessorsApi(this.rest), "processors", stamper);
|
|
72
|
+
this.turn = (0, provenance_js_1.wrapSubclient)(new turn_api_js_1.TurnApi(this.rest), "turn", stamper);
|
|
73
|
+
this.agents = (0, provenance_js_1.wrapSubclient)(new agents_api_js_1.AgentsApi(this.rest, config.controlApiUrl), "agents", stamper);
|
|
72
74
|
// RpcDispatcher needs the concrete MessagesApi (it calls postMessage internally);
|
|
73
75
|
// give it an *unwrapped* one so stamping happens once at the public boundary.
|
|
74
|
-
this.rpcImpl = new
|
|
76
|
+
this.rpcImpl = new rpc_dispatcher_js_1.RpcDispatcher(this.gatewayImpl, new messages_api_js_1.MessagesApi(this.rest));
|
|
75
77
|
this.rpc = this.rpcImpl;
|
|
76
|
-
this.stats = new
|
|
78
|
+
this.stats = new stats_js_1.DooverStatsCollector();
|
|
77
79
|
this.rest.setStats(this.stats);
|
|
78
80
|
this.gatewayImpl.setStats(this.stats);
|
|
79
81
|
this.rpcImpl.setStats(this.stats);
|
|
80
|
-
this.statusTracker = new
|
|
82
|
+
this.statusTracker = new status_tracker_js_1.ClientStatusTracker(this.identity.id, this.gateway, () => this.getKnownAgentScope());
|
|
81
83
|
}
|
|
82
84
|
enableStats() { this.stats.setEnabled(true); }
|
|
83
85
|
disableStats() { this.stats.setEnabled(false); }
|
package/dist/client/errors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Capability } from "./capabilities";
|
|
2
|
-
import { DooverApiError } from "../http/errors";
|
|
1
|
+
import type { Capability } from "./capabilities.js";
|
|
2
|
+
import { DooverApiError } from "../http/errors.js";
|
|
3
3
|
/**
|
|
4
4
|
* Thrown when a `DataClient` method is called whose backing capability the
|
|
5
5
|
* client does not advertise. Extends `DooverApiError` so existing
|
package/dist/client/errors.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DooverOfflineError = exports.AmbiguousWriteError = exports.UnsupportedCapabilityError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_js_1 = require("../http/errors.js");
|
|
5
5
|
/**
|
|
6
6
|
* Thrown when a `DataClient` method is called whose backing capability the
|
|
7
7
|
* client does not advertise. Extends `DooverApiError` so existing
|
|
8
8
|
* `instanceof DooverApiError` error handling catches it; the HTTP-ish fields
|
|
9
9
|
* are placeholders since no request was made.
|
|
10
10
|
*/
|
|
11
|
-
class UnsupportedCapabilityError extends
|
|
11
|
+
class UnsupportedCapabilityError extends errors_js_1.DooverApiError {
|
|
12
12
|
constructor(capability, clientId) {
|
|
13
13
|
super({
|
|
14
14
|
status: 0,
|
|
@@ -30,7 +30,7 @@ exports.UnsupportedCapabilityError = UnsupportedCapabilityError;
|
|
|
30
30
|
* member — more than one enabled member owns the targeted agent and has the
|
|
31
31
|
* write capability, and the call was not `sources`-scoped to one of them.
|
|
32
32
|
*/
|
|
33
|
-
class AmbiguousWriteError extends
|
|
33
|
+
class AmbiguousWriteError extends errors_js_1.DooverApiError {
|
|
34
34
|
constructor(capability, candidateSourceIds) {
|
|
35
35
|
super({
|
|
36
36
|
status: 0,
|
|
@@ -52,7 +52,7 @@ exports.AmbiguousWriteError = AmbiguousWriteError;
|
|
|
52
52
|
* Thrown by offline-aware clients when a network-only operation is attempted
|
|
53
53
|
* while offline, or when an offline read has no usable cached value.
|
|
54
54
|
*/
|
|
55
|
-
class DooverOfflineError extends
|
|
55
|
+
class DooverOfflineError extends errors_js_1.DooverApiError {
|
|
56
56
|
constructor(operation, message, cacheKey) {
|
|
57
57
|
super({
|
|
58
58
|
status: 0,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DooverClient } from "./doover-client.js";
|
|
2
|
+
export { getDooverClient, peekDooverClient, resetDooverClient } from "./singleton.js";
|
|
3
|
+
export type { DooverClientConfig } from "../http/rest-client.js";
|
|
4
|
+
export type * from "./data-client.js";
|
|
5
|
+
export { browserNetworkStatus, createNetworkStatusStore } from "./network-status.js";
|
|
6
|
+
export type { NetworkStatusSource, NetworkStatusSnapshot } from "./network-status.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNetworkStatusStore = exports.browserNetworkStatus = exports.resetDooverClient = exports.peekDooverClient = exports.getDooverClient = exports.DooverClient = void 0;
|
|
4
|
+
var doover_client_js_1 = require("./doover-client.js");
|
|
5
|
+
Object.defineProperty(exports, "DooverClient", { enumerable: true, get: function () { return doover_client_js_1.DooverClient; } });
|
|
6
|
+
var singleton_js_1 = require("./singleton.js");
|
|
7
|
+
Object.defineProperty(exports, "getDooverClient", { enumerable: true, get: function () { return singleton_js_1.getDooverClient; } });
|
|
8
|
+
Object.defineProperty(exports, "peekDooverClient", { enumerable: true, get: function () { return singleton_js_1.peekDooverClient; } });
|
|
9
|
+
Object.defineProperty(exports, "resetDooverClient", { enumerable: true, get: function () { return singleton_js_1.resetDooverClient; } });
|
|
10
|
+
var network_status_js_1 = require("./network-status.js");
|
|
11
|
+
Object.defineProperty(exports, "browserNetworkStatus", { enumerable: true, get: function () { return network_status_js_1.browserNetworkStatus; } });
|
|
12
|
+
Object.defineProperty(exports, "createNetworkStatusStore", { enumerable: true, get: function () { return network_status_js_1.createNetworkStatusStore; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type DooverClientConfig } from "../http/rest-client";
|
|
2
|
-
import type { Capability } from "./capabilities";
|
|
3
|
-
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client";
|
|
1
|
+
import { type DooverClientConfig } from "../http/rest-client.js";
|
|
2
|
+
import type { Capability } from "./capabilities.js";
|
|
3
|
+
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client.js";
|
|
4
4
|
export interface LocalAgentClientConfig {
|
|
5
5
|
/** Base URL of the local agent's REST API, e.g. "http://192.168.0.7:49100". */
|
|
6
6
|
baseUrl: string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalAgentClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
4
|
+
const agents_api_js_1 = require("../apis/agents-api.js");
|
|
5
|
+
const aggregates_api_js_1 = require("../apis/aggregates-api.js");
|
|
6
|
+
const channels_api_js_1 = require("../apis/channels-api.js");
|
|
7
|
+
const messages_api_js_1 = require("../apis/messages-api.js");
|
|
8
|
+
const gateway_client_js_1 = require("../gateway/gateway-client.js");
|
|
9
|
+
const rest_client_js_1 = require("../http/rest-client.js");
|
|
10
|
+
const errors_js_1 = require("./errors.js");
|
|
11
|
+
const provenance_js_1 = require("./provenance.js");
|
|
12
|
+
const status_tracker_js_1 = require("./status-tracker.js");
|
|
13
13
|
const LOCAL_CAPABILITIES = [
|
|
14
14
|
"agents.list",
|
|
15
15
|
"channels.list",
|
|
@@ -49,7 +49,7 @@ class LocalAgentClient {
|
|
|
49
49
|
meta: { baseUrl: config.baseUrl },
|
|
50
50
|
};
|
|
51
51
|
this.capSet = new Set(LOCAL_CAPABILITIES);
|
|
52
|
-
const stamper = new
|
|
52
|
+
const stamper = new provenance_js_1.ProvenanceStamper(this.identity);
|
|
53
53
|
// RestClient / GatewayClient expect a DooverClientConfig — give them one
|
|
54
54
|
// with the local URLs, no auth, no org/sharing headers.
|
|
55
55
|
const restConfig = {
|
|
@@ -63,16 +63,16 @@ class LocalAgentClient {
|
|
|
63
63
|
webSocketFactory: config.webSocketFactory,
|
|
64
64
|
disableBrowserLifecycleHooks: config.disableBrowserLifecycleHooks,
|
|
65
65
|
};
|
|
66
|
-
this.rest = new
|
|
67
|
-
this.gatewayImpl = new
|
|
66
|
+
this.rest = new rest_client_js_1.RestClient(restConfig); // no auth arg
|
|
67
|
+
this.gatewayImpl = new gateway_client_js_1.GatewayClient(restConfig); // no auth arg
|
|
68
68
|
this.gatewayImpl.setProvenanceHook((value, ctx) => stamper.stampGatewayEvent(value, ctx));
|
|
69
69
|
this.gateway = this.gatewayImpl;
|
|
70
70
|
// Real subclients for advertised methods, gated so only allowed methods pass;
|
|
71
71
|
// all others throw UnsupportedCapabilityError.
|
|
72
|
-
const realAgents = (0,
|
|
73
|
-
const realChannels = (0,
|
|
74
|
-
const realMessages = (0,
|
|
75
|
-
const realAggregates = (0,
|
|
72
|
+
const realAgents = (0, provenance_js_1.wrapSubclient)(new agents_api_js_1.AgentsApi(this.rest, config.baseUrl), "agents", stamper);
|
|
73
|
+
const realChannels = (0, provenance_js_1.wrapSubclient)(new channels_api_js_1.ChannelsApi(this.rest), "channels", stamper);
|
|
74
|
+
const realMessages = (0, provenance_js_1.wrapSubclient)(new messages_api_js_1.MessagesApi(this.rest), "messages", stamper);
|
|
75
|
+
const realAggregates = (0, provenance_js_1.wrapSubclient)(new aggregates_api_js_1.AggregatesApi(this.rest), "aggregates", stamper);
|
|
76
76
|
this.agents = this.gatedSubclient("agents", realAgents, ["listAgents"]);
|
|
77
77
|
this.channels = this.gatedSubclient("channels", realChannels, ["listChannels", "getChannel"]);
|
|
78
78
|
this.aggregates = this.gatedSubclient("aggregates", realAggregates, ["getAggregate", "putAggregate", "patchAggregate"]);
|
|
@@ -86,7 +86,7 @@ class LocalAgentClient {
|
|
|
86
86
|
this.turn = this.unsupportedSubclient("turn");
|
|
87
87
|
this.users = this.unsupportedSubclient("users");
|
|
88
88
|
this.rpc = this.unsupportedSubclient("rpc");
|
|
89
|
-
this.statusTracker = new
|
|
89
|
+
this.statusTracker = new status_tracker_js_1.ClientStatusTracker(this.identity.id, this.gateway, () => this.getKnownAgentScope());
|
|
90
90
|
// Resolve the device id on (re)connect so routing is precise before the
|
|
91
91
|
// first agent-scoped request; invalidate the cache on each new session.
|
|
92
92
|
this.gatewayImpl.on("ready", () => {
|
|
@@ -154,7 +154,7 @@ class LocalAgentClient {
|
|
|
154
154
|
return Reflect.get(target, prop, receiver);
|
|
155
155
|
return () => {
|
|
156
156
|
const cap = METHOD_TO_CAPABILITY[`${name}.${prop}`] ?? guessCapability(name);
|
|
157
|
-
return Promise.reject(new
|
|
157
|
+
return Promise.reject(new errors_js_1.UnsupportedCapabilityError(cap, clientId));
|
|
158
158
|
};
|
|
159
159
|
},
|
|
160
160
|
});
|
|
@@ -172,7 +172,7 @@ class LocalAgentClient {
|
|
|
172
172
|
return undefined;
|
|
173
173
|
return () => {
|
|
174
174
|
const cap = METHOD_TO_CAPABILITY[`${name}.${prop}`] ?? guessCapability(name);
|
|
175
|
-
return Promise.reject(new
|
|
175
|
+
return Promise.reject(new errors_js_1.UnsupportedCapabilityError(cap, clientId));
|
|
176
176
|
};
|
|
177
177
|
},
|
|
178
178
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Capability } from "./capabilities";
|
|
2
|
-
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client";
|
|
3
|
-
export type { DataClient } from "./data-client";
|
|
4
|
-
export type { AgentScope } from "./data-client";
|
|
5
|
-
export type { DataClientStatus } from "./data-client";
|
|
1
|
+
import type { Capability } from "./capabilities.js";
|
|
2
|
+
import type { AgentScope, AgentsApiLike, AggregatesApiLike, AlarmsApiLike, ChannelsApiLike, ConnectionsApiLike, DataClient, DataClientStatus, GatewayClientLike, MessagesApiLike, NotificationsApiLike, PermissionsApiLike, ProcessorsApiLike, RpcDispatcherLike, TurnApiLike, UsersApiLike } from "./data-client.js";
|
|
3
|
+
export type { DataClient } from "./data-client.js";
|
|
4
|
+
export type { AgentScope } from "./data-client.js";
|
|
5
|
+
export type { DataClientStatus } from "./data-client.js";
|
|
6
6
|
export interface MultiplexConflict {
|
|
7
7
|
method: string;
|
|
8
8
|
agentId: string;
|