@dronedeploy/rocos-js-sdk 3.0.1-alpha.8 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +59 -29
- package/cjs/IRocosSDK.d.ts +4 -3
- package/cjs/RocosSDK.d.ts +19 -7
- package/cjs/RocosSDK.js +31 -10
- package/cjs/api/streams/caller/CallerStream.js +5 -2
- package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
- package/cjs/api/streams/command/CommandStream.js +5 -2
- package/cjs/api/streams/command/CommandStreamNode.js +2 -1
- package/cjs/api/streams/control/ControlStream.js +5 -2
- package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
- package/cjs/api/streams/control/ControlStreamNode.js +2 -1
- package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
- package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
- package/cjs/api/streams/search/SearchStream.js +5 -2
- package/cjs/api/streams/search/SearchStreamNode.js +2 -1
- package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
- package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
- package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
- package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
- package/cjs/constants/api.d.ts +31 -15
- package/cjs/constants/api.js +35 -18
- package/cjs/helpers/cleanObject.js +4 -1
- package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
- package/cjs/helpers/getUniqueConfigKey.js +7 -2
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +1 -0
- package/cjs/helpers/kscript/Context.d.ts +34 -0
- package/cjs/helpers/kscript/Context.js +52 -0
- package/cjs/helpers/kscript/index.d.ts +1 -0
- package/cjs/helpers/kscript/index.js +27 -0
- package/cjs/helpers/kscript/kscript.d.ts +6 -0
- package/cjs/helpers/kscript/kscript.js +115 -0
- package/cjs/helpers/kscript/nodes/Identifier.d.ts +12 -0
- package/cjs/helpers/kscript/nodes/Identifier.js +20 -0
- package/cjs/helpers/kscript/nodes/Literal.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/Literal.js +22 -0
- package/cjs/helpers/kscript/nodes/Node.d.ts +9 -0
- package/cjs/helpers/kscript/nodes/Node.js +15 -0
- package/cjs/helpers/kscript/nodes/Program.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/Program.js +24 -0
- package/cjs/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
- package/cjs/helpers/kscript/nodes/TemplateLiteral.js +35 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.js +31 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +40 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.js +104 -0
- package/cjs/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
- package/cjs/helpers/kscript/nodes/expressions/CallExpression.js +38 -0
- package/cjs/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
- package/cjs/helpers/kscript/nodes/expressions/ChainExpression.js +25 -0
- package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
- package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.js +30 -0
- package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
- package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.js +18 -0
- package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
- package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.js +47 -0
- package/cjs/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
- package/cjs/helpers/kscript/nodes/expressions/MemberExpression.js +98 -0
- package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.js +59 -0
- package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
- package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.js +44 -0
- package/cjs/helpers/kscript/nodes/expressions/index.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/expressions/index.js +28 -0
- package/cjs/helpers/kscript/nodes/index.d.ts +4 -0
- package/cjs/helpers/kscript/nodes/index.js +10 -0
- package/cjs/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
- package/cjs/helpers/kscript/nodes/nodeTypes.js +29 -0
- package/cjs/helpers/kscript/utils.d.ts +4 -0
- package/cjs/helpers/kscript/utils.js +15 -0
- package/cjs/helpers/websandbox/connection.d.ts +2 -1
- package/cjs/helpers/websandbox/connection.js +6 -5
- package/cjs/helpers/websandbox/frame/frame.js +4 -1
- package/cjs/helpers/websandbox/frame/frame.source.js +1 -1
- package/cjs/helpers/websandbox/frame/worker/manager.d.ts +8 -4
- package/cjs/helpers/websandbox/frame/worker/manager.js +32 -14
- package/cjs/helpers/websandbox/frame/worker/worker.source.js +1 -1
- package/cjs/helpers/websandbox/sandbox.d.ts +1 -1
- package/cjs/helpers/websandbox/sandbox.js +7 -7
- package/cjs/models/IConnectedCallsign.d.ts +10 -0
- package/cjs/models/IConnectedCallsign.js +8 -0
- package/cjs/models/RocosError.d.ts +3 -0
- package/cjs/models/RocosError.js +3 -0
- package/cjs/models/ServiceEnum.d.ts +20 -17
- package/cjs/models/ServiceEnum.js +20 -17
- package/cjs/models/TelemetryStatus.d.ts +12 -0
- package/cjs/models/TelemetryStatus.js +17 -0
- package/cjs/models/Token.d.ts +2 -2
- package/cjs/models/Token.js +5 -5
- package/cjs/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
- package/cjs/models/asset-storage/SyncIntegrations.d.ts +1 -1
- package/cjs/models/device-credentials/DeviceCredentials.d.ts +61 -0
- package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
- package/cjs/models/graph/Position.d.ts +6 -0
- package/cjs/models/graph/Position.js +2 -0
- package/cjs/models/graph/Quaternion.d.ts +6 -0
- package/cjs/models/graph/Quaternion.js +2 -0
- package/cjs/models/graph/Vector3.d.ts +5 -0
- package/cjs/models/graph/Vector3.js +2 -0
- package/cjs/models/graph/index.d.ts +3 -0
- package/cjs/models/graph/index.js +19 -0
- package/cjs/models/index.d.ts +9 -2
- package/cjs/models/index.js +9 -2
- package/cjs/models/integrations/Location.d.ts +24 -0
- package/cjs/models/integrations/Location.js +2 -0
- package/cjs/models/integrations/PaginatedResults.d.ts +4 -0
- package/cjs/models/integrations/PaginatedResults.js +2 -0
- package/cjs/models/maps/Panorama.d.ts +12 -21
- package/cjs/models/projects/ExternalProject.d.ts +10 -0
- package/cjs/models/projects/ExternalProject.js +2 -0
- package/cjs/models/projects/NewProjectRequest.d.ts +8 -0
- package/cjs/models/projects/NewProjectRequest.js +2 -0
- package/cjs/models/target/Target.d.ts +30 -0
- package/cjs/models/target/Target.js +15 -0
- package/cjs/node/RocosSDKNode.d.ts +1 -5
- package/cjs/node/RocosSDKNode.js +9 -9
- package/cjs/services/AssetStorageService.d.ts +19 -19
- package/cjs/services/AssetStorageService.js +20 -9
- package/cjs/services/AuthService.d.ts +12 -1
- package/cjs/services/AuthService.js +25 -1
- package/cjs/services/BaseServiceAbstract.d.ts +1 -1
- package/cjs/services/BaseServiceAbstract.js +2 -2
- package/cjs/services/DeviceCredentialsService.d.ts +15 -0
- package/cjs/services/DeviceCredentialsService.js +56 -0
- package/cjs/services/EnvironmentService.d.ts +28 -0
- package/cjs/services/EnvironmentService.js +48 -0
- package/cjs/services/EvaluatorService.js +1 -1
- package/cjs/services/IntegrationService.d.ts +7 -1
- package/cjs/services/IntegrationService.js +8 -0
- package/cjs/services/MapService.d.ts +18 -8
- package/cjs/services/MapService.js +37 -19
- package/cjs/services/ProfileService.d.ts +24 -0
- package/cjs/services/ProfileService.js +34 -0
- package/cjs/services/ProjectService.d.ts +7 -2
- package/cjs/services/ProjectService.js +7 -3
- package/cjs/services/RTPWebRTCService.d.ts +6 -1
- package/cjs/services/RTPWebRTCService.js +10 -2
- package/cjs/services/RobotService.d.ts +3 -1
- package/cjs/services/RobotService.js +6 -0
- package/cjs/services/SpotProvisioningService.d.ts +1 -1
- package/cjs/services/SpotProvisioningServiceNode.d.ts +1 -1
- package/cjs/services/TargetService.d.ts +16 -0
- package/cjs/services/TargetService.js +58 -0
- package/cjs/services/TelemetryService.d.ts +10 -1
- package/cjs/services/TelemetryService.js +27 -5
- package/cjs/services/WorkflowService.d.ts +18 -8
- package/cjs/services/WorkflowService.js +37 -11
- package/cjs/services/index.d.ts +11 -9
- package/cjs/services/index.js +11 -9
- package/cjs/store/RocosStore.d.ts +1 -2
- package/esm/IRocosSDK.d.ts +4 -3
- package/esm/RocosSDK.d.ts +19 -7
- package/esm/RocosSDK.js +32 -11
- package/esm/api/streams/caller/CallerStream.js +5 -2
- package/esm/api/streams/caller/CallerStreamNode.js +2 -1
- package/esm/api/streams/command/CommandStream.js +5 -2
- package/esm/api/streams/command/CommandStreamNode.js +2 -1
- package/esm/api/streams/control/ControlStream.js +5 -2
- package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
- package/esm/api/streams/control/ControlStreamNode.js +2 -1
- package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
- package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
- package/esm/api/streams/search/SearchStream.js +5 -2
- package/esm/api/streams/search/SearchStreamNode.js +2 -1
- package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
- package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
- package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
- package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
- package/esm/constants/api.d.ts +31 -15
- package/esm/constants/api.js +31 -15
- package/esm/helpers/cleanObject.js +4 -1
- package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
- package/esm/helpers/getUniqueConfigKey.js +7 -2
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/kscript/Context.d.ts +34 -0
- package/esm/helpers/kscript/Context.js +49 -0
- package/esm/helpers/kscript/index.d.ts +1 -0
- package/esm/helpers/kscript/index.js +1 -0
- package/esm/helpers/kscript/kscript.d.ts +6 -0
- package/esm/helpers/kscript/kscript.js +107 -0
- package/esm/helpers/kscript/nodes/Identifier.d.ts +12 -0
- package/esm/helpers/kscript/nodes/Identifier.js +14 -0
- package/esm/helpers/kscript/nodes/Literal.d.ts +11 -0
- package/esm/helpers/kscript/nodes/Literal.js +16 -0
- package/esm/helpers/kscript/nodes/Node.d.ts +9 -0
- package/esm/helpers/kscript/nodes/Node.js +12 -0
- package/esm/helpers/kscript/nodes/Program.d.ts +11 -0
- package/esm/helpers/kscript/nodes/Program.js +18 -0
- package/esm/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
- package/esm/helpers/kscript/nodes/TemplateLiteral.js +29 -0
- package/esm/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
- package/esm/helpers/kscript/nodes/expressions/ArrayExpression.js +25 -0
- package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
- package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +34 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.js +98 -0
- package/esm/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
- package/esm/helpers/kscript/nodes/expressions/CallExpression.js +32 -0
- package/esm/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
- package/esm/helpers/kscript/nodes/expressions/ChainExpression.js +19 -0
- package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
- package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.js +24 -0
- package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
- package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.js +12 -0
- package/esm/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
- package/esm/helpers/kscript/nodes/expressions/LogicalExpression.js +41 -0
- package/esm/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
- package/esm/helpers/kscript/nodes/expressions/MemberExpression.js +92 -0
- package/esm/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
- package/esm/helpers/kscript/nodes/expressions/ObjectExpression.js +53 -0
- package/esm/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
- package/esm/helpers/kscript/nodes/expressions/UnaryExpression.js +38 -0
- package/esm/helpers/kscript/nodes/expressions/index.d.ts +11 -0
- package/esm/helpers/kscript/nodes/expressions/index.js +11 -0
- package/esm/helpers/kscript/nodes/index.d.ts +4 -0
- package/esm/helpers/kscript/nodes/index.js +3 -0
- package/esm/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
- package/esm/helpers/kscript/nodes/nodeTypes.js +24 -0
- package/esm/helpers/kscript/utils.d.ts +4 -0
- package/esm/helpers/kscript/utils.js +11 -0
- package/esm/helpers/websandbox/connection.d.ts +2 -1
- package/esm/helpers/websandbox/connection.js +6 -5
- package/esm/helpers/websandbox/frame/frame.js +4 -1
- package/esm/helpers/websandbox/frame/frame.source.js +1 -1
- package/esm/helpers/websandbox/frame/worker/manager.d.ts +8 -4
- package/esm/helpers/websandbox/frame/worker/manager.js +32 -14
- package/esm/helpers/websandbox/frame/worker/worker.source.js +1 -1
- package/esm/helpers/websandbox/sandbox.d.ts +1 -1
- package/esm/helpers/websandbox/sandbox.js +7 -7
- package/esm/models/IConnectedCallsign.d.ts +10 -0
- package/esm/models/IConnectedCallsign.js +5 -0
- package/esm/models/RocosError.d.ts +3 -0
- package/esm/models/RocosError.js +3 -0
- package/esm/models/ServiceEnum.d.ts +20 -17
- package/esm/models/ServiceEnum.js +20 -17
- package/esm/models/TelemetryStatus.d.ts +12 -0
- package/esm/models/TelemetryStatus.js +14 -0
- package/esm/models/Token.d.ts +2 -2
- package/esm/models/Token.js +5 -5
- package/esm/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
- package/esm/models/asset-storage/SyncIntegrations.d.ts +1 -1
- package/esm/models/device-credentials/DeviceCredentials.d.ts +61 -0
- package/esm/models/graph/Position.d.ts +6 -0
- package/esm/models/graph/Quaternion.d.ts +6 -0
- package/esm/models/graph/Vector3.d.ts +5 -0
- package/esm/models/graph/index.d.ts +3 -0
- package/esm/models/graph/index.js +3 -0
- package/esm/models/index.d.ts +9 -2
- package/esm/models/index.js +9 -2
- package/esm/models/integrations/Location.d.ts +24 -0
- package/esm/models/integrations/PaginatedResults.d.ts +4 -0
- package/esm/models/maps/Panorama.d.ts +12 -21
- package/esm/models/projects/ExternalProject.d.ts +10 -0
- package/esm/models/projects/NewProjectRequest.d.ts +8 -0
- package/esm/models/target/Target.d.ts +30 -0
- package/esm/models/target/Target.js +9 -0
- package/esm/node/RocosSDKNode.d.ts +1 -5
- package/esm/node/RocosSDKNode.js +10 -10
- package/esm/services/AssetStorageService.d.ts +19 -19
- package/esm/services/AssetStorageService.js +20 -9
- package/esm/services/AuthService.d.ts +12 -1
- package/esm/services/AuthService.js +25 -1
- package/esm/services/BaseServiceAbstract.d.ts +1 -1
- package/esm/services/BaseServiceAbstract.js +3 -3
- package/esm/services/DeviceCredentialsService.d.ts +15 -0
- package/esm/services/DeviceCredentialsService.js +52 -0
- package/esm/services/EnvironmentService.d.ts +28 -0
- package/esm/services/EnvironmentService.js +44 -0
- package/esm/services/EvaluatorService.js +1 -1
- package/esm/services/IntegrationService.d.ts +7 -1
- package/esm/services/IntegrationService.js +10 -2
- package/esm/services/MapService.d.ts +18 -8
- package/esm/services/MapService.js +38 -20
- package/esm/services/ProfileService.d.ts +24 -0
- package/esm/services/ProfileService.js +35 -1
- package/esm/services/ProjectService.d.ts +7 -2
- package/esm/services/ProjectService.js +9 -5
- package/esm/services/RTPWebRTCService.d.ts +6 -1
- package/esm/services/RTPWebRTCService.js +10 -2
- package/esm/services/RobotService.d.ts +3 -1
- package/esm/services/RobotService.js +8 -2
- package/esm/services/SpotProvisioningService.d.ts +1 -1
- package/esm/services/SpotProvisioningServiceNode.d.ts +1 -1
- package/esm/services/TargetService.d.ts +16 -0
- package/esm/services/TargetService.js +54 -0
- package/esm/services/TelemetryService.d.ts +10 -1
- package/esm/services/TelemetryService.js +28 -6
- package/esm/services/WorkflowService.d.ts +18 -8
- package/esm/services/WorkflowService.js +38 -12
- package/esm/services/index.d.ts +11 -9
- package/esm/services/index.js +11 -9
- package/esm/store/RocosStore.d.ts +1 -2
- package/package.json +2 -2
- package/cjs/helpers/cleanObject.spec.js +0 -55
- package/cjs/helpers/flattenObject.spec.js +0 -31
- package/cjs/helpers/flattenOneOf.spec.js +0 -159
- package/cjs/helpers/formatServiceUrl.spec.js +0 -18
- package/cjs/helpers/getSha256Hex.spec.js +0 -19
- package/cjs/helpers/getSha256HexNode.spec.js +0 -10
- package/cjs/helpers/getURLSearchParams.spec.js +0 -21
- package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
- package/cjs/helpers/splitRobotTopic.spec.js +0 -53
- package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
- package/cjs/helpers/standardDeviation.spec.js +0 -13
- package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
- package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
- package/cjs/models/CallsignStatus.d.ts +0 -6
- package/cjs/models/CallsignStatus.js +0 -10
- package/cjs/models/ExternalProject.d.ts +0 -6
- package/cjs/models/ExternalProject.js +0 -6
- package/cjs/models/Token.spec.d.ts +0 -1
- package/cjs/models/Token.spec.js +0 -110
- package/cjs/services/AuthService.spec.d.ts +0 -1
- package/cjs/services/AuthService.spec.js +0 -165
- package/cjs/services/CallerService.spec.d.ts +0 -1
- package/cjs/services/CallerService.spec.js +0 -229
- package/cjs/services/FunctionService.d.ts +0 -68
- package/cjs/services/FunctionService.js +0 -103
- package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
- package/cjs/services/PlatformTimeService.spec.js +0 -182
- package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
- package/cjs/services/RTPWebRTCService.spec.js +0 -171
- package/cjs/services/TelemetryService.spec.d.ts +0 -1
- package/cjs/services/TelemetryService.spec.js +0 -39
- package/esm/helpers/cleanObject.spec.d.ts +0 -1
- package/esm/helpers/cleanObject.spec.js +0 -53
- package/esm/helpers/flattenObject.spec.d.ts +0 -1
- package/esm/helpers/flattenObject.spec.js +0 -29
- package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
- package/esm/helpers/flattenOneOf.spec.js +0 -157
- package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
- package/esm/helpers/formatServiceUrl.spec.js +0 -16
- package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
- package/esm/helpers/getSha256Hex.spec.js +0 -14
- package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
- package/esm/helpers/getSha256HexNode.spec.js +0 -8
- package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
- package/esm/helpers/getURLSearchParams.spec.js +0 -19
- package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
- package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
- package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
- package/esm/helpers/splitRobotTopic.spec.js +0 -51
- package/esm/helpers/standardDeviation.spec.d.ts +0 -1
- package/esm/helpers/standardDeviation.spec.js +0 -11
- package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
- package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
- package/esm/models/CallsignStatus.d.ts +0 -6
- package/esm/models/CallsignStatus.js +0 -7
- package/esm/models/ExternalProject.d.ts +0 -6
- package/esm/models/ExternalProject.js +0 -2
- package/esm/models/Token.spec.d.ts +0 -1
- package/esm/models/Token.spec.js +0 -108
- package/esm/models/asset-storage/AssetModelItem.js +0 -1
- package/esm/services/AuthService.spec.d.ts +0 -1
- package/esm/services/AuthService.spec.js +0 -163
- package/esm/services/CallerService.spec.d.ts +0 -1
- package/esm/services/CallerService.spec.js +0 -227
- package/esm/services/FunctionService.d.ts +0 -68
- package/esm/services/FunctionService.js +0 -99
- package/esm/services/PlatformTimeService.spec.d.ts +0 -1
- package/esm/services/PlatformTimeService.spec.js +0 -180
- package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
- package/esm/services/RTPWebRTCService.spec.js +0 -169
- package/esm/services/TelemetryService.spec.d.ts +0 -1
- package/esm/services/TelemetryService.spec.js +0 -37
- /package/cjs/models/asset-storage/{AssetModelItem.js → AssetItem.js} +0 -0
- /package/{cjs/helpers/cleanObject.spec.d.ts → esm/models/asset-storage/AssetItem.js} +0 -0
- /package/{cjs/helpers/flattenObject.spec.d.ts → esm/models/device-credentials/DeviceCredentials.js} +0 -0
- /package/{cjs/helpers/flattenOneOf.spec.d.ts → esm/models/graph/Position.js} +0 -0
- /package/{cjs/helpers/formatServiceUrl.spec.d.ts → esm/models/graph/Quaternion.js} +0 -0
- /package/{cjs/helpers/getSha256Hex.spec.d.ts → esm/models/graph/Vector3.js} +0 -0
- /package/{cjs/helpers/getSha256HexNode.spec.d.ts → esm/models/integrations/Location.js} +0 -0
- /package/{cjs/helpers/getURLSearchParams.spec.d.ts → esm/models/integrations/PaginatedResults.js} +0 -0
- /package/{cjs/helpers/nanosecondToMillisecond.spec.d.ts → esm/models/projects/ExternalProject.js} +0 -0
- /package/{cjs/helpers/splitRobotTopic.spec.d.ts → esm/models/projects/NewProjectRequest.js} +0 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
class ArrayExpressionNode extends Node_1.default {
|
9
|
+
constructor(node, context) {
|
10
|
+
super(node, context, 'ArrayExpression');
|
11
|
+
}
|
12
|
+
run() {
|
13
|
+
const array = [];
|
14
|
+
for (const element of this.node.elements) {
|
15
|
+
if (element === null) {
|
16
|
+
// null implies an empty slot in the array (e.g. [1, , 3])
|
17
|
+
// an actual null value would be a literal node.
|
18
|
+
array.push(null);
|
19
|
+
delete array[array.length - 1];
|
20
|
+
}
|
21
|
+
else if (element.type === 'SpreadElement') {
|
22
|
+
array.push(...(0, utils_1.construct)(element.argument, this.context).run());
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
array.push((0, utils_1.construct)(element, this.context).run());
|
26
|
+
}
|
27
|
+
}
|
28
|
+
return array;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
exports.default = ArrayExpressionNode;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { AnyNode, ArrowFunctionExpression } from 'acorn';
|
2
|
+
import type Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/** Represents an arrow function expression.
|
5
|
+
*
|
6
|
+
* e.g. `(a, b) => a + b`
|
7
|
+
*
|
8
|
+
* In the sandbox this is the only way to define a function.
|
9
|
+
*/
|
10
|
+
export default class ArrowFunctionExpressionNode extends Node<ArrowFunctionExpression> {
|
11
|
+
private readonly params;
|
12
|
+
constructor(node: AnyNode, context: Context);
|
13
|
+
run(): unknown;
|
14
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
/** Represents an arrow function expression.
|
9
|
+
*
|
10
|
+
* e.g. `(a, b) => a + b`
|
11
|
+
*
|
12
|
+
* In the sandbox this is the only way to define a function.
|
13
|
+
*/
|
14
|
+
class ArrowFunctionExpressionNode extends Node_1.default {
|
15
|
+
constructor(node, context) {
|
16
|
+
super(node, context, 'ArrowFunctionExpression');
|
17
|
+
if (this.node.params.some((param) => param.type !== 'Identifier')) {
|
18
|
+
throw new Error('only identifiers are supported as parameters');
|
19
|
+
}
|
20
|
+
this.params = this.node.params;
|
21
|
+
}
|
22
|
+
run() {
|
23
|
+
if (!this.context.isFunctionCallAllowed)
|
24
|
+
throw new Error('functions are not allowed');
|
25
|
+
if (!this.node.expression)
|
26
|
+
throw new Error('functions must be an expression');
|
27
|
+
if (this.node.async)
|
28
|
+
throw new Error('async functions are not supported');
|
29
|
+
return (...args) => {
|
30
|
+
const scope = new Map();
|
31
|
+
for (const param of this.params) {
|
32
|
+
const index = this.params.indexOf(param);
|
33
|
+
scope.set(param.name, args?.[index]);
|
34
|
+
}
|
35
|
+
const newContext = this.context.newChildContext(scope);
|
36
|
+
return (0, utils_1.construct)(this.node.body, newContext).run();
|
37
|
+
};
|
38
|
+
}
|
39
|
+
}
|
40
|
+
exports.default = ArrowFunctionExpressionNode;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { AnyNode, BinaryExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/** A binary expression is an expression that consists of two operands and an operator
|
5
|
+
*
|
6
|
+
* e.g. `1 + 2`, `a === b`, `c < d`
|
7
|
+
*/
|
8
|
+
export default class BinaryExpressionNode extends Node<BinaryExpression> {
|
9
|
+
constructor(node: AnyNode, context: Context);
|
10
|
+
run(): unknown;
|
11
|
+
private operate;
|
12
|
+
private arithmetic;
|
13
|
+
private comparison;
|
14
|
+
private equality;
|
15
|
+
private checkIn;
|
16
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
/** A binary expression is an expression that consists of two operands and an operator
|
9
|
+
*
|
10
|
+
* e.g. `1 + 2`, `a === b`, `c < d`
|
11
|
+
*/
|
12
|
+
class BinaryExpressionNode extends Node_1.default {
|
13
|
+
constructor(node, context) {
|
14
|
+
super(node, context, 'BinaryExpression');
|
15
|
+
}
|
16
|
+
run() {
|
17
|
+
const left = (0, utils_1.construct)(this.node.left, this.context).run();
|
18
|
+
const right = (0, utils_1.construct)(this.node.right, this.context).run();
|
19
|
+
return this.operate(left, right);
|
20
|
+
}
|
21
|
+
operate(left, right) {
|
22
|
+
switch (this.node.operator) {
|
23
|
+
case '==':
|
24
|
+
case '!=':
|
25
|
+
case '===':
|
26
|
+
case '!==':
|
27
|
+
return this.equality(this.node.operator, left, right);
|
28
|
+
case '<':
|
29
|
+
case '<=':
|
30
|
+
case '>':
|
31
|
+
case '>=':
|
32
|
+
return this.comparison(this.node.operator, left, right);
|
33
|
+
case 'in':
|
34
|
+
return this.checkIn(left, right);
|
35
|
+
case '**':
|
36
|
+
case '+':
|
37
|
+
case '-':
|
38
|
+
case '*':
|
39
|
+
case '/':
|
40
|
+
case '%':
|
41
|
+
return this.arithmetic(this.node.operator, left, right);
|
42
|
+
default:
|
43
|
+
throw new Error(`Unsupported operator: ${this.node.operator}`);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
arithmetic(operator, left, right) {
|
47
|
+
if (operator === '+' && (typeof left === 'string' || typeof right === 'string')) {
|
48
|
+
return `${left}${right}`;
|
49
|
+
}
|
50
|
+
if (typeof left !== 'number' || typeof right !== 'number') {
|
51
|
+
throw new Error('Arithmetic operators are only supported for numbers');
|
52
|
+
}
|
53
|
+
switch (operator) {
|
54
|
+
case '+':
|
55
|
+
return left + right;
|
56
|
+
case '-':
|
57
|
+
return left - right;
|
58
|
+
case '*':
|
59
|
+
return left * right;
|
60
|
+
case '/':
|
61
|
+
return left / right;
|
62
|
+
case '%':
|
63
|
+
return left % right;
|
64
|
+
case '**':
|
65
|
+
return left ** right;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
comparison(operator, left, right) {
|
69
|
+
if (typeof left !== 'number' || typeof right !== 'number') {
|
70
|
+
throw new Error('Comparison operators are only supported for numbers');
|
71
|
+
}
|
72
|
+
switch (operator) {
|
73
|
+
case '<':
|
74
|
+
return left < right;
|
75
|
+
case '<=':
|
76
|
+
return left <= right;
|
77
|
+
case '>':
|
78
|
+
return left > right;
|
79
|
+
case '>=':
|
80
|
+
return left >= right;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
equality(operator, left, right) {
|
84
|
+
switch (operator) {
|
85
|
+
case '==':
|
86
|
+
// eslint-disable-next-line eqeqeq
|
87
|
+
return left == right;
|
88
|
+
case '!=':
|
89
|
+
// eslint-disable-next-line eqeqeq
|
90
|
+
return left != right;
|
91
|
+
case '===':
|
92
|
+
return left === right;
|
93
|
+
case '!==':
|
94
|
+
return left !== right;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
checkIn(left, right) {
|
98
|
+
if (!Array.isArray(right)) {
|
99
|
+
throw new Error('The "in" operator is only supported for arrays');
|
100
|
+
}
|
101
|
+
return right.includes(left);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
exports.default = BinaryExpressionNode;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { AnyNode, CallExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class CallExpressionNode extends Node<CallExpression> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
run(): unknown;
|
7
|
+
private spreadArgs;
|
8
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
class CallExpressionNode extends Node_1.default {
|
9
|
+
constructor(node, context) {
|
10
|
+
super(node, context, 'CallExpression');
|
11
|
+
}
|
12
|
+
run() {
|
13
|
+
if (!this.context.isFunctionCallAllowed)
|
14
|
+
throw new Error('Function calls are not allowed');
|
15
|
+
const callee = (0, utils_1.construct)(this.node.callee, this.context).run();
|
16
|
+
let thisArg = {};
|
17
|
+
if (this.node.callee.type === 'MemberExpression') {
|
18
|
+
thisArg = (0, utils_1.construct)(this.node.callee.object, this.context).run();
|
19
|
+
}
|
20
|
+
if (typeof callee !== 'function') {
|
21
|
+
throw new Error('callee is not a function');
|
22
|
+
}
|
23
|
+
const args = this.spreadArgs(this.node.arguments);
|
24
|
+
return callee.call(thisArg, ...args);
|
25
|
+
}
|
26
|
+
spreadArgs(args) {
|
27
|
+
return args.reduce((acc, arg) => {
|
28
|
+
if (arg.type === 'SpreadElement') {
|
29
|
+
acc.push(...(0, utils_1.construct)(arg.argument, this.context).run());
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
acc.push((0, utils_1.construct)(arg, this.context).run());
|
33
|
+
}
|
34
|
+
return acc;
|
35
|
+
}, []);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
exports.default = CallExpressionNode;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { AnyNode, ChainExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/**
|
5
|
+
* A ChainExpression node is created when the chain operator is used.
|
6
|
+
*
|
7
|
+
* e.g. `a?.b?.c`
|
8
|
+
*
|
9
|
+
* This node does not need to do anything special, as the chain operator is handled by the MemberExpressionNode.
|
10
|
+
*
|
11
|
+
* @see MemberExpressionNode
|
12
|
+
*/
|
13
|
+
export default class ExpressionStatementNode extends Node<ChainExpression> {
|
14
|
+
constructor(node: AnyNode, context: Context);
|
15
|
+
run(): unknown;
|
16
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
/**
|
9
|
+
* A ChainExpression node is created when the chain operator is used.
|
10
|
+
*
|
11
|
+
* e.g. `a?.b?.c`
|
12
|
+
*
|
13
|
+
* This node does not need to do anything special, as the chain operator is handled by the MemberExpressionNode.
|
14
|
+
*
|
15
|
+
* @see MemberExpressionNode
|
16
|
+
*/
|
17
|
+
class ExpressionStatementNode extends Node_1.default {
|
18
|
+
constructor(node, context) {
|
19
|
+
super(node, context, 'ChainExpression');
|
20
|
+
}
|
21
|
+
run() {
|
22
|
+
return (0, utils_1.construct)(this.node.expression, this.context).run();
|
23
|
+
}
|
24
|
+
}
|
25
|
+
exports.default = ExpressionStatementNode;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { AnyNode, ConditionalExpression, IfStatement } from 'acorn';
|
2
|
+
import type Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/** Represents a ternary conditional expression (a ? b : c) or an if statement (if (a) b else c).
|
5
|
+
*
|
6
|
+
* If a (test) is truthy, b (consequent) is returned. Otherwise, c (alternate) is returned.
|
7
|
+
*
|
8
|
+
* Since the if statement and the conditional expression are so similar, they are both handled by this node,
|
9
|
+
* even though they are separate in the AST.
|
10
|
+
*/
|
11
|
+
export default class ConditionalExpressionNode extends Node<IfStatement | ConditionalExpression> {
|
12
|
+
constructor(node: AnyNode, context: Context);
|
13
|
+
run(): unknown;
|
14
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
/** Represents a ternary conditional expression (a ? b : c) or an if statement (if (a) b else c).
|
9
|
+
*
|
10
|
+
* If a (test) is truthy, b (consequent) is returned. Otherwise, c (alternate) is returned.
|
11
|
+
*
|
12
|
+
* Since the if statement and the conditional expression are so similar, they are both handled by this node,
|
13
|
+
* even though they are separate in the AST.
|
14
|
+
*/
|
15
|
+
class ConditionalExpressionNode extends Node_1.default {
|
16
|
+
constructor(node, context) {
|
17
|
+
super(node, context, ['ConditionalExpression', 'IfStatement']);
|
18
|
+
}
|
19
|
+
run() {
|
20
|
+
const test = (0, utils_1.construct)(this.node.test, this.context).run();
|
21
|
+
if (test) {
|
22
|
+
return (0, utils_1.construct)(this.node.consequent, this.context).run();
|
23
|
+
}
|
24
|
+
if (this.node.alternate === null || this.node.alternate === undefined) {
|
25
|
+
return undefined;
|
26
|
+
}
|
27
|
+
return (0, utils_1.construct)(this.node.alternate, this.context).run();
|
28
|
+
}
|
29
|
+
}
|
30
|
+
exports.default = ConditionalExpressionNode;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { AnyNode, ExpressionStatement } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class ExpressionStatementNode extends Node<ExpressionStatement> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
run(): unknown;
|
7
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
class ExpressionStatementNode extends Node_1.default {
|
9
|
+
constructor(node, context) {
|
10
|
+
super(node, context, 'ExpressionStatement');
|
11
|
+
}
|
12
|
+
run() {
|
13
|
+
if (this.node.directive)
|
14
|
+
throw new Error('Directives are not supported');
|
15
|
+
return (0, utils_1.construct)(this.node.expression, this.context).run();
|
16
|
+
}
|
17
|
+
}
|
18
|
+
exports.default = ExpressionStatementNode;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { AnyNode, LogicalExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class BinaryExpressionNode extends Node<LogicalExpression> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
run(): unknown;
|
7
|
+
/** Try and skip evaluating the right operand */
|
8
|
+
private shortCircuit;
|
9
|
+
private operate;
|
10
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
class BinaryExpressionNode extends Node_1.default {
|
9
|
+
constructor(node, context) {
|
10
|
+
super(node, context, 'LogicalExpression');
|
11
|
+
}
|
12
|
+
run() {
|
13
|
+
const left = (0, utils_1.construct)(this.node.left, this.context).run();
|
14
|
+
const shortCircuit = this.shortCircuit(left);
|
15
|
+
if (shortCircuit !== null) {
|
16
|
+
return shortCircuit;
|
17
|
+
}
|
18
|
+
const right = (0, utils_1.construct)(this.node.right, this.context).run();
|
19
|
+
return this.operate(left, right);
|
20
|
+
}
|
21
|
+
/** Try and skip evaluating the right operand */
|
22
|
+
shortCircuit(left) {
|
23
|
+
if (this.node.operator === '&&' && !left) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
if (this.node.operator === '||' && left) {
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
if (this.node.operator === '??' && left !== null && left !== undefined) {
|
30
|
+
return left;
|
31
|
+
}
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
operate(left, right) {
|
35
|
+
switch (this.node.operator) {
|
36
|
+
case '||':
|
37
|
+
return left || right;
|
38
|
+
case '&&':
|
39
|
+
return left && right;
|
40
|
+
case '??':
|
41
|
+
return left ?? right;
|
42
|
+
default:
|
43
|
+
throw new Error(`Unsupported operator: ${this.node.operator}`);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
exports.default = BinaryExpressionNode;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { AnyNode, MemberExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/**
|
5
|
+
* A member expression is an expression that accesses a property of an object.
|
6
|
+
*
|
7
|
+
* Examples of member expressions are:
|
8
|
+
* - `a.b`
|
9
|
+
* - `a['b']`
|
10
|
+
* - `a[0]`
|
11
|
+
* - `a?.b`
|
12
|
+
* - `a?.['b']`
|
13
|
+
* - `a?.[0]`
|
14
|
+
*
|
15
|
+
* A member access in the sandbox is considered secure if the following conditions are met:
|
16
|
+
* - The property is not named 'constructor'
|
17
|
+
* - Either:
|
18
|
+
* * The property is owned by the object and is *not* on the whitelist.
|
19
|
+
* * The prototype is whitelisted and the property list is null or contains the property.
|
20
|
+
*
|
21
|
+
* @see Context.isPrototypeAllowed
|
22
|
+
*/
|
23
|
+
export default class MemberExpressionNode extends Node<MemberExpression> {
|
24
|
+
constructor(node: AnyNode, context: Context);
|
25
|
+
run(): unknown;
|
26
|
+
/** Returns the name of the property being accessed.
|
27
|
+
*
|
28
|
+
* Handles both computed and non-computed properties.
|
29
|
+
*/
|
30
|
+
private getPropertyIdentifier;
|
31
|
+
/** Checks if the property can be accessed on the object.
|
32
|
+
*
|
33
|
+
* @throws {Error} If the property is not allowed to be accessed.
|
34
|
+
*/
|
35
|
+
private checkPropertyAccess;
|
36
|
+
/** Searches the prototype chain of the object for the prototype that defines the property. */
|
37
|
+
private getPropertyPrototype;
|
38
|
+
/**
|
39
|
+
* Returns true if the property exists on the object.
|
40
|
+
*
|
41
|
+
* i.e. the property is defined somewhere on the prototype chain.
|
42
|
+
*/
|
43
|
+
private propertyExists;
|
44
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
/**
|
9
|
+
* A member expression is an expression that accesses a property of an object.
|
10
|
+
*
|
11
|
+
* Examples of member expressions are:
|
12
|
+
* - `a.b`
|
13
|
+
* - `a['b']`
|
14
|
+
* - `a[0]`
|
15
|
+
* - `a?.b`
|
16
|
+
* - `a?.['b']`
|
17
|
+
* - `a?.[0]`
|
18
|
+
*
|
19
|
+
* A member access in the sandbox is considered secure if the following conditions are met:
|
20
|
+
* - The property is not named 'constructor'
|
21
|
+
* - Either:
|
22
|
+
* * The property is owned by the object and is *not* on the whitelist.
|
23
|
+
* * The prototype is whitelisted and the property list is null or contains the property.
|
24
|
+
*
|
25
|
+
* @see Context.isPrototypeAllowed
|
26
|
+
*/
|
27
|
+
class MemberExpressionNode extends Node_1.default {
|
28
|
+
constructor(node, context) {
|
29
|
+
super(node, context, 'MemberExpression');
|
30
|
+
}
|
31
|
+
run() {
|
32
|
+
const object = (0, utils_1.construct)(this.node.object, this.context).run();
|
33
|
+
if (object === null || object === undefined) {
|
34
|
+
if (this.node.optional)
|
35
|
+
return undefined;
|
36
|
+
throw new Error(`Cannot read property of ${object}`);
|
37
|
+
}
|
38
|
+
const propertyIdentifier = this.getPropertyIdentifier();
|
39
|
+
if (!this.propertyExists(object, propertyIdentifier)) {
|
40
|
+
return undefined;
|
41
|
+
}
|
42
|
+
this.checkPropertyAccess(object, propertyIdentifier);
|
43
|
+
return object[propertyIdentifier];
|
44
|
+
}
|
45
|
+
/** Returns the name of the property being accessed.
|
46
|
+
*
|
47
|
+
* Handles both computed and non-computed properties.
|
48
|
+
*/
|
49
|
+
getPropertyIdentifier() {
|
50
|
+
if (this.node.computed) {
|
51
|
+
const name = (0, utils_1.construct)(this.node.property, this.context).run();
|
52
|
+
if (typeof name !== 'string' && typeof name !== 'number') {
|
53
|
+
throw new Error('Only string or number computed properties are supported');
|
54
|
+
}
|
55
|
+
return name;
|
56
|
+
}
|
57
|
+
if (this.node.property.type !== 'Identifier') {
|
58
|
+
throw new Error('Only identifiers are supported for non-computed member expression properties');
|
59
|
+
}
|
60
|
+
return this.node.property.name;
|
61
|
+
}
|
62
|
+
/** Checks if the property can be accessed on the object.
|
63
|
+
*
|
64
|
+
* @throws {Error} If the property is not allowed to be accessed.
|
65
|
+
*/
|
66
|
+
checkPropertyAccess(object, propertyIdentifier) {
|
67
|
+
if (typeof propertyIdentifier === 'number')
|
68
|
+
return;
|
69
|
+
if (propertyIdentifier === 'constructor') {
|
70
|
+
throw new Error('Cannot access constructor property');
|
71
|
+
}
|
72
|
+
const definingProto = this.getPropertyPrototype(object, propertyIdentifier);
|
73
|
+
const ownProperty = Object.prototype.hasOwnProperty.call(object, propertyIdentifier);
|
74
|
+
if (!this.context.isPrototypeAllowed(definingProto, propertyIdentifier, ownProperty)) {
|
75
|
+
throw new Error(`SecurityError: Access to property '${propertyIdentifier}' is not allowed`);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
/** Searches the prototype chain of the object for the prototype that defines the property. */
|
79
|
+
getPropertyPrototype(object, propertyIdentifier) {
|
80
|
+
let proto = object;
|
81
|
+
while (proto !== null) {
|
82
|
+
if (Object.prototype.hasOwnProperty.call(proto, propertyIdentifier)) {
|
83
|
+
return proto;
|
84
|
+
}
|
85
|
+
proto = Object.getPrototypeOf(proto);
|
86
|
+
}
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
/**
|
90
|
+
* Returns true if the property exists on the object.
|
91
|
+
*
|
92
|
+
* i.e. the property is defined somewhere on the prototype chain.
|
93
|
+
*/
|
94
|
+
propertyExists(object, propertyIdentifier) {
|
95
|
+
return this.getPropertyPrototype(object, propertyIdentifier) !== null;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
exports.default = MemberExpressionNode;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { AnyNode, ObjectExpression } from 'acorn';
|
2
|
+
import type Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class ObjectExpressionNode extends Node<ObjectExpression> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
run(): unknown;
|
7
|
+
private addProperty;
|
8
|
+
private spreadProperty;
|
9
|
+
private getKey;
|
10
|
+
private getStaticKey;
|
11
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Node_1 = __importDefault(require("../Node"));
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
class ObjectExpressionNode extends Node_1.default {
|
9
|
+
constructor(node, context) {
|
10
|
+
super(node, context, 'ObjectExpression');
|
11
|
+
}
|
12
|
+
run() {
|
13
|
+
const object = {};
|
14
|
+
for (const property of this.node.properties) {
|
15
|
+
if (property.type === 'SpreadElement') {
|
16
|
+
this.spreadProperty(property, object);
|
17
|
+
continue;
|
18
|
+
}
|
19
|
+
this.addProperty(property, object);
|
20
|
+
}
|
21
|
+
return object;
|
22
|
+
}
|
23
|
+
addProperty(property, object) {
|
24
|
+
if (property.kind !== 'init')
|
25
|
+
throw new Error('Only init properties are supported');
|
26
|
+
const key = this.getKey(property);
|
27
|
+
object[key] = (0, utils_1.construct)(property.value, this.context).run();
|
28
|
+
}
|
29
|
+
spreadProperty(property, object) {
|
30
|
+
const value = (0, utils_1.construct)(property.argument, this.context).run();
|
31
|
+
if (!(typeof value === 'object' && value !== null)) {
|
32
|
+
throw new Error('Spread argument must be an object');
|
33
|
+
}
|
34
|
+
Object.assign(object, value);
|
35
|
+
}
|
36
|
+
getKey(property) {
|
37
|
+
let key;
|
38
|
+
if (property.computed) {
|
39
|
+
key = (0, utils_1.construct)(property.key, this.context).run();
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
key = this.getStaticKey(property.key);
|
43
|
+
}
|
44
|
+
if (key === null || key === undefined)
|
45
|
+
throw new Error('Key cannot be null or undefined');
|
46
|
+
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'symbol') {
|
47
|
+
throw new Error(`Unsupported key type: ${typeof key}`);
|
48
|
+
}
|
49
|
+
return key;
|
50
|
+
}
|
51
|
+
getStaticKey(key) {
|
52
|
+
if (key.type === 'Identifier')
|
53
|
+
return key.name;
|
54
|
+
if (key.type === 'Literal')
|
55
|
+
return key.value;
|
56
|
+
throw new Error('Only identifier and literal keys are supported');
|
57
|
+
}
|
58
|
+
}
|
59
|
+
exports.default = ObjectExpressionNode;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { AnyNode, UnaryExpression } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
/** A unary expression is an expression that consists of a single operand and an operator
|
5
|
+
*
|
6
|
+
* e.g. `+1`, `-2`, `!true`, `typeof x`
|
7
|
+
*/
|
8
|
+
export default class UnaryExpressionNode extends Node<UnaryExpression> {
|
9
|
+
constructor(node: AnyNode, context: Context);
|
10
|
+
run(): unknown;
|
11
|
+
private arithmetic;
|
12
|
+
}
|