@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.
Files changed (378) hide show
  1. package/README.md +59 -29
  2. package/cjs/IRocosSDK.d.ts +4 -3
  3. package/cjs/RocosSDK.d.ts +19 -7
  4. package/cjs/RocosSDK.js +31 -10
  5. package/cjs/api/streams/caller/CallerStream.js +5 -2
  6. package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
  7. package/cjs/api/streams/command/CommandStream.js +5 -2
  8. package/cjs/api/streams/command/CommandStreamNode.js +2 -1
  9. package/cjs/api/streams/control/ControlStream.js +5 -2
  10. package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  11. package/cjs/api/streams/control/ControlStreamNode.js +2 -1
  12. package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  13. package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  14. package/cjs/api/streams/search/SearchStream.js +5 -2
  15. package/cjs/api/streams/search/SearchStreamNode.js +2 -1
  16. package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
  17. package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  18. package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  19. package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  20. package/cjs/constants/api.d.ts +31 -15
  21. package/cjs/constants/api.js +35 -18
  22. package/cjs/helpers/cleanObject.js +4 -1
  23. package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
  24. package/cjs/helpers/getUniqueConfigKey.js +7 -2
  25. package/cjs/helpers/index.d.ts +1 -0
  26. package/cjs/helpers/index.js +1 -0
  27. package/cjs/helpers/kscript/Context.d.ts +34 -0
  28. package/cjs/helpers/kscript/Context.js +52 -0
  29. package/cjs/helpers/kscript/index.d.ts +1 -0
  30. package/cjs/helpers/kscript/index.js +27 -0
  31. package/cjs/helpers/kscript/kscript.d.ts +6 -0
  32. package/cjs/helpers/kscript/kscript.js +115 -0
  33. package/cjs/helpers/kscript/nodes/Identifier.d.ts +12 -0
  34. package/cjs/helpers/kscript/nodes/Identifier.js +20 -0
  35. package/cjs/helpers/kscript/nodes/Literal.d.ts +11 -0
  36. package/cjs/helpers/kscript/nodes/Literal.js +22 -0
  37. package/cjs/helpers/kscript/nodes/Node.d.ts +9 -0
  38. package/cjs/helpers/kscript/nodes/Node.js +15 -0
  39. package/cjs/helpers/kscript/nodes/Program.d.ts +11 -0
  40. package/cjs/helpers/kscript/nodes/Program.js +24 -0
  41. package/cjs/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
  42. package/cjs/helpers/kscript/nodes/TemplateLiteral.js +35 -0
  43. package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
  44. package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.js +31 -0
  45. package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
  46. package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +40 -0
  47. package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
  48. package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.js +104 -0
  49. package/cjs/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
  50. package/cjs/helpers/kscript/nodes/expressions/CallExpression.js +38 -0
  51. package/cjs/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
  52. package/cjs/helpers/kscript/nodes/expressions/ChainExpression.js +25 -0
  53. package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
  54. package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.js +30 -0
  55. package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
  56. package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.js +18 -0
  57. package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
  58. package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.js +47 -0
  59. package/cjs/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
  60. package/cjs/helpers/kscript/nodes/expressions/MemberExpression.js +98 -0
  61. package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
  62. package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.js +59 -0
  63. package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
  64. package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.js +44 -0
  65. package/cjs/helpers/kscript/nodes/expressions/index.d.ts +11 -0
  66. package/cjs/helpers/kscript/nodes/expressions/index.js +28 -0
  67. package/cjs/helpers/kscript/nodes/index.d.ts +4 -0
  68. package/cjs/helpers/kscript/nodes/index.js +10 -0
  69. package/cjs/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
  70. package/cjs/helpers/kscript/nodes/nodeTypes.js +29 -0
  71. package/cjs/helpers/kscript/utils.d.ts +4 -0
  72. package/cjs/helpers/kscript/utils.js +15 -0
  73. package/cjs/helpers/websandbox/connection.d.ts +2 -1
  74. package/cjs/helpers/websandbox/connection.js +6 -5
  75. package/cjs/helpers/websandbox/frame/frame.js +4 -1
  76. package/cjs/helpers/websandbox/frame/frame.source.js +1 -1
  77. package/cjs/helpers/websandbox/frame/worker/manager.d.ts +8 -4
  78. package/cjs/helpers/websandbox/frame/worker/manager.js +32 -14
  79. package/cjs/helpers/websandbox/frame/worker/worker.source.js +1 -1
  80. package/cjs/helpers/websandbox/sandbox.d.ts +1 -1
  81. package/cjs/helpers/websandbox/sandbox.js +7 -7
  82. package/cjs/models/IConnectedCallsign.d.ts +10 -0
  83. package/cjs/models/IConnectedCallsign.js +8 -0
  84. package/cjs/models/RocosError.d.ts +3 -0
  85. package/cjs/models/RocosError.js +3 -0
  86. package/cjs/models/ServiceEnum.d.ts +20 -17
  87. package/cjs/models/ServiceEnum.js +20 -17
  88. package/cjs/models/TelemetryStatus.d.ts +12 -0
  89. package/cjs/models/TelemetryStatus.js +17 -0
  90. package/cjs/models/Token.d.ts +2 -2
  91. package/cjs/models/Token.js +5 -5
  92. package/cjs/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
  93. package/cjs/models/asset-storage/SyncIntegrations.d.ts +1 -1
  94. package/cjs/models/device-credentials/DeviceCredentials.d.ts +61 -0
  95. package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
  96. package/cjs/models/graph/Position.d.ts +6 -0
  97. package/cjs/models/graph/Position.js +2 -0
  98. package/cjs/models/graph/Quaternion.d.ts +6 -0
  99. package/cjs/models/graph/Quaternion.js +2 -0
  100. package/cjs/models/graph/Vector3.d.ts +5 -0
  101. package/cjs/models/graph/Vector3.js +2 -0
  102. package/cjs/models/graph/index.d.ts +3 -0
  103. package/cjs/models/graph/index.js +19 -0
  104. package/cjs/models/index.d.ts +9 -2
  105. package/cjs/models/index.js +9 -2
  106. package/cjs/models/integrations/Location.d.ts +24 -0
  107. package/cjs/models/integrations/Location.js +2 -0
  108. package/cjs/models/integrations/PaginatedResults.d.ts +4 -0
  109. package/cjs/models/integrations/PaginatedResults.js +2 -0
  110. package/cjs/models/maps/Panorama.d.ts +12 -21
  111. package/cjs/models/projects/ExternalProject.d.ts +10 -0
  112. package/cjs/models/projects/ExternalProject.js +2 -0
  113. package/cjs/models/projects/NewProjectRequest.d.ts +8 -0
  114. package/cjs/models/projects/NewProjectRequest.js +2 -0
  115. package/cjs/models/target/Target.d.ts +30 -0
  116. package/cjs/models/target/Target.js +15 -0
  117. package/cjs/node/RocosSDKNode.d.ts +1 -5
  118. package/cjs/node/RocosSDKNode.js +9 -9
  119. package/cjs/services/AssetStorageService.d.ts +19 -19
  120. package/cjs/services/AssetStorageService.js +20 -9
  121. package/cjs/services/AuthService.d.ts +12 -1
  122. package/cjs/services/AuthService.js +25 -1
  123. package/cjs/services/BaseServiceAbstract.d.ts +1 -1
  124. package/cjs/services/BaseServiceAbstract.js +2 -2
  125. package/cjs/services/DeviceCredentialsService.d.ts +15 -0
  126. package/cjs/services/DeviceCredentialsService.js +56 -0
  127. package/cjs/services/EnvironmentService.d.ts +28 -0
  128. package/cjs/services/EnvironmentService.js +48 -0
  129. package/cjs/services/EvaluatorService.js +1 -1
  130. package/cjs/services/IntegrationService.d.ts +7 -1
  131. package/cjs/services/IntegrationService.js +8 -0
  132. package/cjs/services/MapService.d.ts +18 -8
  133. package/cjs/services/MapService.js +37 -19
  134. package/cjs/services/ProfileService.d.ts +24 -0
  135. package/cjs/services/ProfileService.js +34 -0
  136. package/cjs/services/ProjectService.d.ts +7 -2
  137. package/cjs/services/ProjectService.js +7 -3
  138. package/cjs/services/RTPWebRTCService.d.ts +6 -1
  139. package/cjs/services/RTPWebRTCService.js +10 -2
  140. package/cjs/services/RobotService.d.ts +3 -1
  141. package/cjs/services/RobotService.js +6 -0
  142. package/cjs/services/SpotProvisioningService.d.ts +1 -1
  143. package/cjs/services/SpotProvisioningServiceNode.d.ts +1 -1
  144. package/cjs/services/TargetService.d.ts +16 -0
  145. package/cjs/services/TargetService.js +58 -0
  146. package/cjs/services/TelemetryService.d.ts +10 -1
  147. package/cjs/services/TelemetryService.js +27 -5
  148. package/cjs/services/WorkflowService.d.ts +18 -8
  149. package/cjs/services/WorkflowService.js +37 -11
  150. package/cjs/services/index.d.ts +11 -9
  151. package/cjs/services/index.js +11 -9
  152. package/cjs/store/RocosStore.d.ts +1 -2
  153. package/esm/IRocosSDK.d.ts +4 -3
  154. package/esm/RocosSDK.d.ts +19 -7
  155. package/esm/RocosSDK.js +32 -11
  156. package/esm/api/streams/caller/CallerStream.js +5 -2
  157. package/esm/api/streams/caller/CallerStreamNode.js +2 -1
  158. package/esm/api/streams/command/CommandStream.js +5 -2
  159. package/esm/api/streams/command/CommandStreamNode.js +2 -1
  160. package/esm/api/streams/control/ControlStream.js +5 -2
  161. package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  162. package/esm/api/streams/control/ControlStreamNode.js +2 -1
  163. package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  164. package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  165. package/esm/api/streams/search/SearchStream.js +5 -2
  166. package/esm/api/streams/search/SearchStreamNode.js +2 -1
  167. package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
  168. package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  169. package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  170. package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  171. package/esm/constants/api.d.ts +31 -15
  172. package/esm/constants/api.js +31 -15
  173. package/esm/helpers/cleanObject.js +4 -1
  174. package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
  175. package/esm/helpers/getUniqueConfigKey.js +7 -2
  176. package/esm/helpers/index.d.ts +1 -0
  177. package/esm/helpers/index.js +1 -0
  178. package/esm/helpers/kscript/Context.d.ts +34 -0
  179. package/esm/helpers/kscript/Context.js +49 -0
  180. package/esm/helpers/kscript/index.d.ts +1 -0
  181. package/esm/helpers/kscript/index.js +1 -0
  182. package/esm/helpers/kscript/kscript.d.ts +6 -0
  183. package/esm/helpers/kscript/kscript.js +107 -0
  184. package/esm/helpers/kscript/nodes/Identifier.d.ts +12 -0
  185. package/esm/helpers/kscript/nodes/Identifier.js +14 -0
  186. package/esm/helpers/kscript/nodes/Literal.d.ts +11 -0
  187. package/esm/helpers/kscript/nodes/Literal.js +16 -0
  188. package/esm/helpers/kscript/nodes/Node.d.ts +9 -0
  189. package/esm/helpers/kscript/nodes/Node.js +12 -0
  190. package/esm/helpers/kscript/nodes/Program.d.ts +11 -0
  191. package/esm/helpers/kscript/nodes/Program.js +18 -0
  192. package/esm/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
  193. package/esm/helpers/kscript/nodes/TemplateLiteral.js +29 -0
  194. package/esm/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
  195. package/esm/helpers/kscript/nodes/expressions/ArrayExpression.js +25 -0
  196. package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
  197. package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +34 -0
  198. package/esm/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
  199. package/esm/helpers/kscript/nodes/expressions/BinaryExpression.js +98 -0
  200. package/esm/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
  201. package/esm/helpers/kscript/nodes/expressions/CallExpression.js +32 -0
  202. package/esm/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
  203. package/esm/helpers/kscript/nodes/expressions/ChainExpression.js +19 -0
  204. package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
  205. package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.js +24 -0
  206. package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
  207. package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.js +12 -0
  208. package/esm/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
  209. package/esm/helpers/kscript/nodes/expressions/LogicalExpression.js +41 -0
  210. package/esm/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
  211. package/esm/helpers/kscript/nodes/expressions/MemberExpression.js +92 -0
  212. package/esm/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
  213. package/esm/helpers/kscript/nodes/expressions/ObjectExpression.js +53 -0
  214. package/esm/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
  215. package/esm/helpers/kscript/nodes/expressions/UnaryExpression.js +38 -0
  216. package/esm/helpers/kscript/nodes/expressions/index.d.ts +11 -0
  217. package/esm/helpers/kscript/nodes/expressions/index.js +11 -0
  218. package/esm/helpers/kscript/nodes/index.d.ts +4 -0
  219. package/esm/helpers/kscript/nodes/index.js +3 -0
  220. package/esm/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
  221. package/esm/helpers/kscript/nodes/nodeTypes.js +24 -0
  222. package/esm/helpers/kscript/utils.d.ts +4 -0
  223. package/esm/helpers/kscript/utils.js +11 -0
  224. package/esm/helpers/websandbox/connection.d.ts +2 -1
  225. package/esm/helpers/websandbox/connection.js +6 -5
  226. package/esm/helpers/websandbox/frame/frame.js +4 -1
  227. package/esm/helpers/websandbox/frame/frame.source.js +1 -1
  228. package/esm/helpers/websandbox/frame/worker/manager.d.ts +8 -4
  229. package/esm/helpers/websandbox/frame/worker/manager.js +32 -14
  230. package/esm/helpers/websandbox/frame/worker/worker.source.js +1 -1
  231. package/esm/helpers/websandbox/sandbox.d.ts +1 -1
  232. package/esm/helpers/websandbox/sandbox.js +7 -7
  233. package/esm/models/IConnectedCallsign.d.ts +10 -0
  234. package/esm/models/IConnectedCallsign.js +5 -0
  235. package/esm/models/RocosError.d.ts +3 -0
  236. package/esm/models/RocosError.js +3 -0
  237. package/esm/models/ServiceEnum.d.ts +20 -17
  238. package/esm/models/ServiceEnum.js +20 -17
  239. package/esm/models/TelemetryStatus.d.ts +12 -0
  240. package/esm/models/TelemetryStatus.js +14 -0
  241. package/esm/models/Token.d.ts +2 -2
  242. package/esm/models/Token.js +5 -5
  243. package/esm/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
  244. package/esm/models/asset-storage/SyncIntegrations.d.ts +1 -1
  245. package/esm/models/device-credentials/DeviceCredentials.d.ts +61 -0
  246. package/esm/models/graph/Position.d.ts +6 -0
  247. package/esm/models/graph/Quaternion.d.ts +6 -0
  248. package/esm/models/graph/Vector3.d.ts +5 -0
  249. package/esm/models/graph/index.d.ts +3 -0
  250. package/esm/models/graph/index.js +3 -0
  251. package/esm/models/index.d.ts +9 -2
  252. package/esm/models/index.js +9 -2
  253. package/esm/models/integrations/Location.d.ts +24 -0
  254. package/esm/models/integrations/PaginatedResults.d.ts +4 -0
  255. package/esm/models/maps/Panorama.d.ts +12 -21
  256. package/esm/models/projects/ExternalProject.d.ts +10 -0
  257. package/esm/models/projects/NewProjectRequest.d.ts +8 -0
  258. package/esm/models/target/Target.d.ts +30 -0
  259. package/esm/models/target/Target.js +9 -0
  260. package/esm/node/RocosSDKNode.d.ts +1 -5
  261. package/esm/node/RocosSDKNode.js +10 -10
  262. package/esm/services/AssetStorageService.d.ts +19 -19
  263. package/esm/services/AssetStorageService.js +20 -9
  264. package/esm/services/AuthService.d.ts +12 -1
  265. package/esm/services/AuthService.js +25 -1
  266. package/esm/services/BaseServiceAbstract.d.ts +1 -1
  267. package/esm/services/BaseServiceAbstract.js +3 -3
  268. package/esm/services/DeviceCredentialsService.d.ts +15 -0
  269. package/esm/services/DeviceCredentialsService.js +52 -0
  270. package/esm/services/EnvironmentService.d.ts +28 -0
  271. package/esm/services/EnvironmentService.js +44 -0
  272. package/esm/services/EvaluatorService.js +1 -1
  273. package/esm/services/IntegrationService.d.ts +7 -1
  274. package/esm/services/IntegrationService.js +10 -2
  275. package/esm/services/MapService.d.ts +18 -8
  276. package/esm/services/MapService.js +38 -20
  277. package/esm/services/ProfileService.d.ts +24 -0
  278. package/esm/services/ProfileService.js +35 -1
  279. package/esm/services/ProjectService.d.ts +7 -2
  280. package/esm/services/ProjectService.js +9 -5
  281. package/esm/services/RTPWebRTCService.d.ts +6 -1
  282. package/esm/services/RTPWebRTCService.js +10 -2
  283. package/esm/services/RobotService.d.ts +3 -1
  284. package/esm/services/RobotService.js +8 -2
  285. package/esm/services/SpotProvisioningService.d.ts +1 -1
  286. package/esm/services/SpotProvisioningServiceNode.d.ts +1 -1
  287. package/esm/services/TargetService.d.ts +16 -0
  288. package/esm/services/TargetService.js +54 -0
  289. package/esm/services/TelemetryService.d.ts +10 -1
  290. package/esm/services/TelemetryService.js +28 -6
  291. package/esm/services/WorkflowService.d.ts +18 -8
  292. package/esm/services/WorkflowService.js +38 -12
  293. package/esm/services/index.d.ts +11 -9
  294. package/esm/services/index.js +11 -9
  295. package/esm/store/RocosStore.d.ts +1 -2
  296. package/package.json +2 -2
  297. package/cjs/helpers/cleanObject.spec.js +0 -55
  298. package/cjs/helpers/flattenObject.spec.js +0 -31
  299. package/cjs/helpers/flattenOneOf.spec.js +0 -159
  300. package/cjs/helpers/formatServiceUrl.spec.js +0 -18
  301. package/cjs/helpers/getSha256Hex.spec.js +0 -19
  302. package/cjs/helpers/getSha256HexNode.spec.js +0 -10
  303. package/cjs/helpers/getURLSearchParams.spec.js +0 -21
  304. package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
  305. package/cjs/helpers/splitRobotTopic.spec.js +0 -53
  306. package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
  307. package/cjs/helpers/standardDeviation.spec.js +0 -13
  308. package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  309. package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
  310. package/cjs/models/CallsignStatus.d.ts +0 -6
  311. package/cjs/models/CallsignStatus.js +0 -10
  312. package/cjs/models/ExternalProject.d.ts +0 -6
  313. package/cjs/models/ExternalProject.js +0 -6
  314. package/cjs/models/Token.spec.d.ts +0 -1
  315. package/cjs/models/Token.spec.js +0 -110
  316. package/cjs/services/AuthService.spec.d.ts +0 -1
  317. package/cjs/services/AuthService.spec.js +0 -165
  318. package/cjs/services/CallerService.spec.d.ts +0 -1
  319. package/cjs/services/CallerService.spec.js +0 -229
  320. package/cjs/services/FunctionService.d.ts +0 -68
  321. package/cjs/services/FunctionService.js +0 -103
  322. package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
  323. package/cjs/services/PlatformTimeService.spec.js +0 -182
  324. package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
  325. package/cjs/services/RTPWebRTCService.spec.js +0 -171
  326. package/cjs/services/TelemetryService.spec.d.ts +0 -1
  327. package/cjs/services/TelemetryService.spec.js +0 -39
  328. package/esm/helpers/cleanObject.spec.d.ts +0 -1
  329. package/esm/helpers/cleanObject.spec.js +0 -53
  330. package/esm/helpers/flattenObject.spec.d.ts +0 -1
  331. package/esm/helpers/flattenObject.spec.js +0 -29
  332. package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
  333. package/esm/helpers/flattenOneOf.spec.js +0 -157
  334. package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
  335. package/esm/helpers/formatServiceUrl.spec.js +0 -16
  336. package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
  337. package/esm/helpers/getSha256Hex.spec.js +0 -14
  338. package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
  339. package/esm/helpers/getSha256HexNode.spec.js +0 -8
  340. package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
  341. package/esm/helpers/getURLSearchParams.spec.js +0 -19
  342. package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  343. package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
  344. package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
  345. package/esm/helpers/splitRobotTopic.spec.js +0 -51
  346. package/esm/helpers/standardDeviation.spec.d.ts +0 -1
  347. package/esm/helpers/standardDeviation.spec.js +0 -11
  348. package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  349. package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
  350. package/esm/models/CallsignStatus.d.ts +0 -6
  351. package/esm/models/CallsignStatus.js +0 -7
  352. package/esm/models/ExternalProject.d.ts +0 -6
  353. package/esm/models/ExternalProject.js +0 -2
  354. package/esm/models/Token.spec.d.ts +0 -1
  355. package/esm/models/Token.spec.js +0 -108
  356. package/esm/models/asset-storage/AssetModelItem.js +0 -1
  357. package/esm/services/AuthService.spec.d.ts +0 -1
  358. package/esm/services/AuthService.spec.js +0 -163
  359. package/esm/services/CallerService.spec.d.ts +0 -1
  360. package/esm/services/CallerService.spec.js +0 -227
  361. package/esm/services/FunctionService.d.ts +0 -68
  362. package/esm/services/FunctionService.js +0 -99
  363. package/esm/services/PlatformTimeService.spec.d.ts +0 -1
  364. package/esm/services/PlatformTimeService.spec.js +0 -180
  365. package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
  366. package/esm/services/RTPWebRTCService.spec.js +0 -169
  367. package/esm/services/TelemetryService.spec.d.ts +0 -1
  368. package/esm/services/TelemetryService.spec.js +0 -37
  369. /package/cjs/models/asset-storage/{AssetModelItem.js → AssetItem.js} +0 -0
  370. /package/{cjs/helpers/cleanObject.spec.d.ts → esm/models/asset-storage/AssetItem.js} +0 -0
  371. /package/{cjs/helpers/flattenObject.spec.d.ts → esm/models/device-credentials/DeviceCredentials.js} +0 -0
  372. /package/{cjs/helpers/flattenOneOf.spec.d.ts → esm/models/graph/Position.js} +0 -0
  373. /package/{cjs/helpers/formatServiceUrl.spec.d.ts → esm/models/graph/Quaternion.js} +0 -0
  374. /package/{cjs/helpers/getSha256Hex.spec.d.ts → esm/models/graph/Vector3.js} +0 -0
  375. /package/{cjs/helpers/getSha256HexNode.spec.d.ts → esm/models/integrations/Location.js} +0 -0
  376. /package/{cjs/helpers/getURLSearchParams.spec.d.ts → esm/models/integrations/PaginatedResults.js} +0 -0
  377. /package/{cjs/helpers/nanosecondToMillisecond.spec.d.ts → esm/models/projects/ExternalProject.js} +0 -0
  378. /package/{cjs/helpers/splitRobotTopic.spec.d.ts → esm/models/projects/NewProjectRequest.js} +0 -0
@@ -1,157 +0,0 @@
1
- import { flattenOneOf, hasOneOfField } from './flattenOneOf';
2
- describe('flattenOneOf', () => {
3
- describe('hasOneOfField', () => {
4
- it('should return false for non-object', () => {
5
- expect(hasOneOfField(null)).toBe(false);
6
- expect(hasOneOfField(undefined)).toBe(false);
7
- expect(hasOneOfField(1)).toBe(false);
8
- expect(hasOneOfField('')).toBe(false);
9
- expect(hasOneOfField(true)).toBe(false);
10
- });
11
- it('should return false for null content', () => {
12
- expect(hasOneOfField({ content: null })).toBe(false);
13
- });
14
- it('should return false for non-object content', () => {
15
- expect(hasOneOfField({ content: 1 })).toBe(false);
16
- expect(hasOneOfField({ content: '' })).toBe(false);
17
- expect(hasOneOfField({ content: true })).toBe(false);
18
- });
19
- it('should return false for non-string oneofKind', () => {
20
- expect(hasOneOfField({ content: { oneofKind: 1 } })).toBe(false);
21
- expect(hasOneOfField({ content: { oneofKind: null } })).toBe(false);
22
- expect(hasOneOfField({ content: { oneofKind: true } })).toBe(false);
23
- expect(hasOneOfField({ content: { oneofKind: {} } })).toBe(false);
24
- });
25
- it('should return true for valid oneOfField', () => {
26
- expect(hasOneOfField({ content: { oneofKind: 'test' } })).toBe(true);
27
- });
28
- });
29
- describe('flattenOneOf', () => {
30
- it('should flatten a simple oneof type', () => {
31
- const a = {
32
- a: 'a',
33
- content: {
34
- oneofKind: 'b',
35
- b: true,
36
- },
37
- };
38
- expect(flattenOneOf(a)).toEqual({
39
- a: 'a',
40
- b: true,
41
- });
42
- });
43
- it('should flatten a nested oneof type, one level only', () => {
44
- const a = {
45
- b: {
46
- content: {
47
- oneofKind: 'c',
48
- c: true,
49
- },
50
- },
51
- content: {
52
- oneofKind: 'd',
53
- d: {
54
- content: {
55
- oneofKind: 'e',
56
- e: 5,
57
- },
58
- },
59
- },
60
- };
61
- expect(flattenOneOf(a)).toEqual({
62
- b: {
63
- content: {
64
- oneofKind: 'c',
65
- c: true,
66
- },
67
- },
68
- d: {
69
- content: {
70
- oneofKind: 'e',
71
- e: 5,
72
- },
73
- },
74
- });
75
- });
76
- it('should flatten to undefined if the referenced property does not exist', () => {
77
- const a = {
78
- content: {
79
- oneofKind: 'b',
80
- c: true,
81
- },
82
- };
83
- expect(flattenOneOf(a)).toEqual({
84
- b: undefined,
85
- });
86
- });
87
- it('should return the original object if it does not have a oneof field', () => {
88
- const a = {
89
- a: 'a',
90
- b: 'b',
91
- };
92
- expect(flattenOneOf(a)).toEqual(a);
93
- });
94
- });
95
- describe('flattenOneOf - deep', () => {
96
- it('should flatten a simple oneof type', () => {
97
- const a = {
98
- a: 'a',
99
- content: {
100
- oneofKind: 'b',
101
- b: {
102
- d: 4,
103
- },
104
- },
105
- };
106
- expect(flattenOneOf(a, true)).toEqual({
107
- a: 'a',
108
- b: { d: 4 },
109
- });
110
- });
111
- it('should flatten a nested oneof type, all levels', () => {
112
- const a = {
113
- b: {
114
- content: {
115
- oneofKind: 'c',
116
- c: true,
117
- },
118
- },
119
- content: {
120
- oneofKind: 'd',
121
- d: {
122
- content: {
123
- oneofKind: 'e',
124
- e: 5,
125
- },
126
- },
127
- },
128
- };
129
- expect(flattenOneOf(a, true)).toEqual({
130
- b: {
131
- c: true,
132
- },
133
- d: {
134
- e: 5,
135
- },
136
- });
137
- });
138
- it('should flatten to undefined if the referenced property does not exist', () => {
139
- const a = {
140
- content: {
141
- oneofKind: 'b',
142
- c: true,
143
- },
144
- };
145
- expect(flattenOneOf(a, true)).toEqual({
146
- b: undefined,
147
- });
148
- });
149
- it('should return the original object if it does not have a oneof field', () => {
150
- const a = {
151
- a: 'a',
152
- b: 'b',
153
- };
154
- expect(flattenOneOf(a, true)).toEqual(a);
155
- });
156
- });
157
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import { formatServiceUrl } from './formatServiceUrl';
2
- describe('formatServiceUrl', () => {
3
- const url = 'https://{url}/admin/users/{test}/invitations';
4
- it('should format url', () => {
5
- let newUrl = formatServiceUrl(url, { url: 'test.com', test: 'me' });
6
- expect(newUrl).toEqual('https://test.com/admin/users/me/invitations');
7
- newUrl = formatServiceUrl(url, { url: 'test2.com', test: 'me2' });
8
- expect(newUrl).toEqual('https://test2.com/admin/users/me2/invitations');
9
- });
10
- it('should format insecure url', () => {
11
- let newUrl = formatServiceUrl(url, { url: 'test.com', test: 'me' }, true);
12
- expect(newUrl).toEqual('http://test.com/admin/users/me/invitations');
13
- newUrl = formatServiceUrl(url, { url: 'test2.com', test: 'me2' }, true);
14
- expect(newUrl).toEqual('http://test2.com/admin/users/me2/invitations');
15
- });
16
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import crypto from 'crypto';
2
- import { getSha256Hex } from './getSha256Hex';
3
- Object.defineProperty(globalThis, 'crypto', {
4
- value: {
5
- subtle: crypto.webcrypto.subtle,
6
- },
7
- });
8
- describe('getSha256Hex', () => {
9
- it('should return the correct SHA-256 hash', async () => {
10
- const buffer = new TextEncoder().encode('Hello, World!');
11
- const hash = await getSha256Hex(buffer);
12
- expect(hash).toBe('dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f');
13
- });
14
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { getSha256HexNode } from './getSha256HexNode';
2
- describe('getSha256HexNode', () => {
3
- it('should return the correct SHA-256 hash', async () => {
4
- const buffer = new TextEncoder().encode('Hello, World!');
5
- const hash = await getSha256HexNode(buffer);
6
- expect(hash).toBe('dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f');
7
- });
8
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { getURLSearchParams } from './getURLSearchParams';
2
- describe('getURLSearchParams', () => {
3
- it('Should return the original param if URLSearchParams', () => {
4
- const param = new URLSearchParams();
5
- const searchParam = getURLSearchParams(param);
6
- expect(searchParam).toBe(param);
7
- });
8
- it('Should a new URLSearchParams ', () => {
9
- const param = {
10
- foo: 'bar',
11
- bar: true,
12
- foobar: 123,
13
- };
14
- const searchParam = getURLSearchParams(param);
15
- expect(searchParam.get('foo')).toBe('bar');
16
- expect(searchParam.get('bar')).toBe('true');
17
- expect(searchParam.get('foobar')).toBe('123');
18
- });
19
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- import { nanosecondToMillisecond } from './nanosecondToMillisecond';
2
- describe('nanosecondToMillisecond', () => {
3
- it.each `
4
- input | expected
5
- ${'0.0001'} | ${0.0000000001}
6
- ${'1'} | ${0.000001}
7
- ${'1000000'} | ${1}
8
- ${'10000000'} | ${10}
9
- ${'-100000006'} | ${-100.000006}
10
- ${'1000000000000000000'} | ${1000000000000}
11
- ${'1234567891011100001'} | ${1234567891011.100001}
12
- ${'1234567891011100000'} | ${1234567891011.1}
13
- ${0.0001} | ${0.0000000001}
14
- ${1} | ${0.000001}
15
- ${1000000} | ${1}
16
- ${1000000000000001} | ${1000000000.000001}
17
- `('should convert $input to $expected', ({ input, expected }) => {
18
- expect(nanosecondToMillisecond(input)).toBe(expected);
19
- });
20
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import { splitRobotTopic } from './splitRobotTopic';
2
- describe('splitRobotTopic', () => {
3
- it('should split a path with a single topic', () => {
4
- expect(splitRobotTopic('/component/topic')).toEqual({
5
- component: 'component',
6
- topic: 'topic',
7
- });
8
- });
9
- it('should split a path with multiple topics', () => {
10
- expect(splitRobotTopic('/component/topic/with/multiple/topics')).toEqual({
11
- component: 'component',
12
- topic: 'topic/with/multiple/topics',
13
- });
14
- });
15
- it('should split a path with no topics', () => {
16
- expect(splitRobotTopic('/component')).toEqual({
17
- component: 'component',
18
- topic: '',
19
- });
20
- });
21
- it('should split a path with no forward slash', () => {
22
- expect(splitRobotTopic('component/topic')).toEqual({
23
- component: 'component',
24
- topic: 'topic',
25
- });
26
- });
27
- it('should split a path with no forward slash and no topics', () => {
28
- expect(splitRobotTopic('component')).toEqual({
29
- component: 'component',
30
- topic: '',
31
- });
32
- });
33
- it('should split a path with no forward slash and multiple topics', () => {
34
- expect(splitRobotTopic('component/topic/with/multiple/topics')).toEqual({
35
- component: 'component',
36
- topic: 'topic/with/multiple/topics',
37
- });
38
- });
39
- it('should handle a path with multiple forward slashes', () => {
40
- expect(splitRobotTopic('///component/topic/with/multiple/topics')).toEqual({
41
- component: 'component',
42
- topic: 'topic/with/multiple/topics',
43
- });
44
- });
45
- it('should handle a path with multiple forward slashes and no topics', () => {
46
- expect(splitRobotTopic('///component')).toEqual({
47
- component: 'component',
48
- topic: '',
49
- });
50
- });
51
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { standardDeviation } from './standardDeviation';
2
- describe('standardDeviation', () => {
3
- it('should calculate standard deviation correctly', () => {
4
- let numbers = [10, 12, 23, 23, 16, 23, 21, 16];
5
- let stdDev = standardDeviation(numbers);
6
- expect(Math.abs(stdDev - 4.8989794855664)).toBeLessThan(0.000001);
7
- numbers = [100, 12, 23, 23, 116, 23, 21, 162];
8
- stdDev = standardDeviation(numbers);
9
- expect(Math.abs(stdDev - 53.702886328394)).toBeLessThan(0.000001);
10
- });
11
- });
@@ -1,4 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- export {};
@@ -1,127 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import WorkerManager from './manager';
5
- const WorkerMocks = {
6
- postMessage: jest.fn(),
7
- terminate: jest.fn(),
8
- addEventListener: jest.fn(),
9
- removeEventListener: jest.fn(),
10
- onerror: jest.fn(),
11
- onmessage: jest.fn(),
12
- onmessageerror: jest.fn(),
13
- dispatchEvent: jest.fn(),
14
- clearAllMocks() {
15
- this.postMessage.mockClear();
16
- this.terminate.mockClear();
17
- this.addEventListener.mockClear();
18
- this.removeEventListener.mockClear();
19
- this.onerror.mockClear();
20
- this.onmessage.mockClear();
21
- this.onmessageerror.mockClear();
22
- this.dispatchEvent.mockClear();
23
- },
24
- };
25
- class MockWorkerClass {
26
- constructor() {
27
- this.postMessage = WorkerMocks.postMessage;
28
- this.terminate = WorkerMocks.terminate;
29
- this.addEventListener = WorkerMocks.addEventListener;
30
- this.removeEventListener = WorkerMocks.removeEventListener;
31
- this.onerror = WorkerMocks.onerror;
32
- this.onmessage = WorkerMocks.onmessage;
33
- this.onmessageerror = WorkerMocks.onmessageerror;
34
- this.dispatchEvent = WorkerMocks.dispatchEvent;
35
- }
36
- }
37
- Object.defineProperty(window, 'Worker', {
38
- value: MockWorkerClass,
39
- writable: true,
40
- });
41
- Object.defineProperty(window, 'URL', {
42
- value: {
43
- createObjectURL: jest.fn(),
44
- },
45
- });
46
- // add mock to AbortSignal.timeout
47
- Object.defineProperty(AbortSignal, 'timeout', {
48
- value: jest.fn().mockImplementation((timeout) => {
49
- return new AbortController().signal;
50
- }),
51
- });
52
- const task = {
53
- id: 'test',
54
- code: '1',
55
- timeout: 1000,
56
- };
57
- const response = {
58
- data: {
59
- id: 'test',
60
- success: true,
61
- result: 'test',
62
- },
63
- };
64
- describe('WorkerManager', () => {
65
- beforeEach(() => {
66
- WorkerMocks.clearAllMocks();
67
- });
68
- it('should send a task to the worker', async () => {
69
- const listeners = [];
70
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
71
- listeners.push(listener);
72
- });
73
- WorkerMocks.postMessage.mockImplementation((msg) => {
74
- listeners.forEach((listener) => {
75
- listener(response);
76
- });
77
- });
78
- const manager = new WorkerManager();
79
- const result = await manager.execute(task);
80
- expect(result).toEqual('test');
81
- });
82
- it('should handle listener for a single task', async () => {
83
- const listeners = [];
84
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
85
- listeners.push(listener);
86
- });
87
- WorkerMocks.removeEventListener.mockImplementation((_, listener) => {
88
- const index = listeners.indexOf(listener);
89
- listeners.splice(index, 1);
90
- });
91
- const manager = new WorkerManager();
92
- expect(listeners.length).toEqual(0);
93
- const result = manager.execute(task);
94
- expect(listeners.length).toEqual(1);
95
- listeners[0](response);
96
- await result;
97
- expect(listeners.length).toEqual(0);
98
- });
99
- it('should handle listener for multiple simultaneous task', async () => {
100
- const listeners = [];
101
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
102
- listeners.push(listener);
103
- });
104
- WorkerMocks.removeEventListener.mockImplementation((_, listener) => {
105
- const index = listeners.indexOf(listener);
106
- listeners.splice(index, 1);
107
- });
108
- const manager = new WorkerManager();
109
- expect(listeners.length).toEqual(0);
110
- const result1 = manager.execute(task);
111
- const result2 = manager.execute(task);
112
- expect(listeners.length).toEqual(2);
113
- const result3 = manager.execute(task);
114
- expect(listeners.length).toEqual(3);
115
- const [listener1, listener2, listener3] = listeners;
116
- listener1(response);
117
- await result1;
118
- expect(listeners.length).toEqual(2);
119
- listener3(response);
120
- await result3;
121
- expect(listeners.length).toEqual(1);
122
- listener2(response);
123
- await result2;
124
- expect(listeners.length).toEqual(0);
125
- expect(WorkerMocks.removeEventListener).toHaveBeenCalledTimes(3);
126
- });
127
- });
@@ -1,6 +0,0 @@
1
- export declare enum CallsignStatus {
2
- UNKNOWN = "unknown",
3
- ONLINE = "online",
4
- OFFLINE = "offline",
5
- ERROR = "error"
6
- }
@@ -1,7 +0,0 @@
1
- export var CallsignStatus;
2
- (function (CallsignStatus) {
3
- CallsignStatus["UNKNOWN"] = "unknown";
4
- CallsignStatus["ONLINE"] = "online";
5
- CallsignStatus["OFFLINE"] = "offline";
6
- CallsignStatus["ERROR"] = "error";
7
- })(CallsignStatus || (CallsignStatus = {}));
@@ -1,6 +0,0 @@
1
- export declare class ExternalProject {
2
- id?: string;
3
- name?: string;
4
- createdAt?: number;
5
- isLinked?: boolean;
6
- }
@@ -1,2 +0,0 @@
1
- export class ExternalProject {
2
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,108 +0,0 @@
1
- import { Token } from './Token';
2
- const generateToken = (config) => {
3
- const defaultPayload = {
4
- iat: 1234567890,
5
- exp: 9876543210,
6
- iss: 'myissuer',
7
- aud: 'myaudience',
8
- sub: 'mysubject',
9
- };
10
- const encodedHeader = Buffer.from(JSON.stringify(config?.header ?? { alg: 'HS256', typ: 'JWT' })).toString('base64');
11
- const encodedPayload = Buffer.from(JSON.stringify(config?.payload ?? defaultPayload)).toString('base64');
12
- if (config?.signature === null) {
13
- return `${encodedHeader}.${encodedPayload}`;
14
- }
15
- return `${encodedHeader}.${encodedPayload}.${config?.signature ?? 'signature'}`;
16
- };
17
- describe('Token', () => {
18
- describe('constructor', () => {
19
- it('can get information from a valid token', () => {
20
- const token = new Token(generateToken());
21
- expect(token.issuedAt).toEqual(new Date(1234567890000));
22
- expect(token.expires).toEqual(new Date(9876543210000));
23
- expect(token.issuer).toEqual('myissuer');
24
- expect(token.audience).toEqual('myaudience');
25
- expect(token.subject).toEqual('mysubject');
26
- });
27
- it('should throw an error for a non-jwt', () => {
28
- // completely invalid string
29
- expect(() => new Token('not a jwt')).toThrowError('Invalid token');
30
- // invalid header
31
- expect(() => {
32
- new Token(generateToken({
33
- header: {
34
- alg: 'HS256',
35
- typ: 'Not-a-JWT',
36
- },
37
- }));
38
- }).toThrowError('Invalid token');
39
- // too many parts
40
- expect(() => {
41
- new Token('a.b.c.d');
42
- }).toThrowError('Invalid token');
43
- });
44
- it('should allow a token with no signature', () => {
45
- const token = new Token(generateToken({ signature: null }));
46
- expect(token.issuedAt).toEqual(new Date(1234567890000));
47
- expect(token.expires).toEqual(new Date(9876543210000));
48
- expect(token.issuer).toEqual('myissuer');
49
- expect(token.audience).toEqual('myaudience');
50
- expect(token.subject).toEqual('mysubject');
51
- });
52
- });
53
- describe('isExpired', () => {
54
- const baseDate = new Date(2021, 0, 1, 0, 0, 0, 0);
55
- beforeEach(() => {
56
- jest.useFakeTimers();
57
- jest.setSystemTime(baseDate);
58
- });
59
- afterEach(() => {
60
- jest.useRealTimers();
61
- });
62
- const expiredDate = (baseDate.getTime() - 1000 * 60 * 5) / 1000; // 5 minutes ago
63
- const notExpiredDate = (baseDate.getTime() + 1000 * 60 * 60 * 24) / 1000; // 1 day from now
64
- it('should return true if the token is expired', () => {
65
- const token = new Token(generateToken({ payload: { exp: expiredDate } }));
66
- expect(token.isExpired()).toEqual(true);
67
- });
68
- it('should return false if the token is not expired', () => {
69
- const token = new Token(generateToken({ payload: { exp: notExpiredDate } }));
70
- expect(token.isExpired()).toEqual(false);
71
- });
72
- });
73
- describe('isExpiredIn', () => {
74
- const baseDate = new Date(2021, 0, 1, 0, 0, 0, 0);
75
- beforeEach(() => {
76
- jest.useFakeTimers();
77
- jest.setSystemTime(baseDate);
78
- });
79
- afterEach(() => {
80
- jest.useRealTimers();
81
- });
82
- const expiredDate = (baseDate.getTime() - 1000 * 60 * 5) / 1000; // 5 minutes ago
83
- const expiredIn5MinsDate = (baseDate.getTime() + 1000 * 60 * 5) / 1000; // 5 minutes from now
84
- const expiredIn25MinsDate = (baseDate.getTime() + 1000 * 60 * 25) / 1000; // 25 minutes from now
85
- const expiredIn2HoursDate = (baseDate.getTime() + 1000 * 60 * 60 * 2) / 1000; // 2 hours from now
86
- it('should return true if the token is expired in the given time', () => {
87
- const token = new Token(generateToken({ payload: { exp: expiredIn5MinsDate } }));
88
- expect(token.isExpiredIn(5, 'minutes')).toEqual(true);
89
- expect(token.isExpiredIn(25, 'minutes')).toEqual(true);
90
- expect(token.isExpiredIn(2, 'hours')).toEqual(true);
91
- const token2 = new Token(generateToken({ payload: { exp: expiredIn25MinsDate } }));
92
- expect(token2.isExpiredIn(25, 'minutes')).toEqual(true);
93
- expect(token2.isExpiredIn(2, 'hours')).toEqual(true);
94
- const token3 = new Token(generateToken({ payload: { exp: expiredDate } }));
95
- expect(token3.isExpiredIn(5, 'minutes')).toEqual(true);
96
- expect(token3.isExpiredIn(25, 'minutes')).toEqual(true);
97
- expect(token3.isExpiredIn(2, 'hours')).toEqual(true);
98
- });
99
- it('should return false if the token is not expired in the given time', () => {
100
- const token = new Token(generateToken({ payload: { exp: expiredIn5MinsDate } }));
101
- expect(token.isExpiredIn(4, 'minutes')).toEqual(false);
102
- const token2 = new Token(generateToken({ payload: { exp: expiredIn25MinsDate } }));
103
- expect(token2.isExpiredIn(24, 'minutes')).toEqual(false);
104
- const token3 = new Token(generateToken({ payload: { exp: expiredIn2HoursDate } }));
105
- expect(token3.isExpiredIn(1, 'hours')).toEqual(false);
106
- });
107
- });
108
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};