@neurosity/sdk 6.2.1-next.2 → 6.2.2

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.
Files changed (305) hide show
  1. package/dist/browser/neurosity.iife.js +48717 -0
  2. package/dist/browser/neurosity.js +666 -0
  3. package/dist/browser/neurosity.js.map +1 -0
  4. package/dist/{Neurosity.d.ts → cjs/Neurosity.d.ts} +2 -116
  5. package/dist/cjs/Neurosity.js +1244 -0
  6. package/dist/{api → cjs/api}/bluetooth/BluetoothClient.d.ts +6 -6
  7. package/dist/cjs/api/bluetooth/BluetoothClient.js +310 -0
  8. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +33 -0
  9. package/dist/cjs/api/bluetooth/BluetoothTransport.js +2 -0
  10. package/dist/{api → cjs/api}/bluetooth/constants.d.ts +0 -0
  11. package/dist/cjs/api/bluetooth/constants.js +9 -0
  12. package/dist/{api → cjs/api}/bluetooth/index.d.ts +0 -0
  13. package/dist/cjs/api/bluetooth/index.js +21 -0
  14. package/dist/{api → cjs/api}/bluetooth/react-native/ReactNativeTransport.d.ts +4 -4
  15. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +411 -0
  16. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  17. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +11 -0
  18. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  19. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +10 -0
  20. package/dist/{api → cjs/api}/bluetooth/types/index.d.ts +2 -2
  21. package/dist/cjs/api/bluetooth/types/index.js +22 -0
  22. package/dist/{api → cjs/api}/bluetooth/utils/create6DigitPin.d.ts +0 -0
  23. package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +8 -0
  24. package/dist/{api → cjs/api}/bluetooth/utils/csvBufferToEpoch.d.ts +0 -0
  25. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +36 -0
  26. package/dist/{api → cjs/api}/bluetooth/utils/encoding.d.ts +0 -0
  27. package/dist/cjs/api/bluetooth/utils/encoding.js +22 -0
  28. package/dist/{api → cjs/api}/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -0
  29. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +23 -0
  30. package/dist/{api → cjs/api}/bluetooth/utils/stitch.d.ts +1 -1
  31. package/dist/cjs/api/bluetooth/utils/stitch.js +22 -0
  32. package/dist/{api → cjs/api}/bluetooth/web/WebBluetoothTransport.d.ts +1 -1
  33. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +430 -0
  34. package/dist/{api → cjs/api}/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -0
  35. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +8 -0
  36. package/dist/{api → cjs/api}/bluetooth/web/isWebBluetoothSupported.d.ts +0 -0
  37. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +11 -0
  38. package/dist/{api → cjs/api}/firebase/FirebaseApp.d.ts +0 -0
  39. package/dist/cjs/api/firebase/FirebaseApp.js +70 -0
  40. package/dist/{api → cjs/api}/firebase/FirebaseDevice.d.ts +1 -1
  41. package/dist/cjs/api/firebase/FirebaseDevice.js +146 -0
  42. package/dist/{api → cjs/api}/firebase/FirebaseUser.d.ts +0 -0
  43. package/dist/cjs/api/firebase/FirebaseUser.js +434 -0
  44. package/dist/{api → cjs/api}/firebase/config.d.ts +0 -0
  45. package/dist/cjs/api/firebase/config.js +11 -0
  46. package/dist/{api → cjs/api}/firebase/deviceStore.d.ts +0 -0
  47. package/dist/cjs/api/firebase/deviceStore.js +191 -0
  48. package/dist/{api → cjs/api}/firebase/index.d.ts +0 -0
  49. package/dist/cjs/api/firebase/index.js +19 -0
  50. package/dist/{api → cjs/api}/https/config.d.ts +0 -0
  51. package/dist/cjs/api/https/config.js +4 -0
  52. package/dist/{api → cjs/api}/https/createOAuthURL.d.ts +0 -0
  53. package/dist/cjs/api/https/createOAuthURL.js +18 -0
  54. package/dist/{api → cjs/api}/https/getOAuthToken.d.ts +0 -0
  55. package/dist/cjs/api/https/getOAuthToken.js +34 -0
  56. package/dist/{api → cjs/api}/https/utils.d.ts +0 -0
  57. package/dist/cjs/api/https/utils.js +13 -0
  58. package/dist/{api → cjs/api}/index.d.ts +0 -8
  59. package/dist/cjs/api/index.js +307 -0
  60. package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  61. package/dist/cjs/index.js +18 -0
  62. package/dist/{subscriptions → cjs/subscriptions}/SubscriptionManager.d.ts +0 -0
  63. package/dist/cjs/subscriptions/SubscriptionManager.js +27 -0
  64. package/dist/{timesync → cjs/timesync}/Timesync.d.ts +1 -1
  65. package/dist/cjs/timesync/Timesync.js +78 -0
  66. package/dist/{timesync → cjs/timesync}/index.d.ts +0 -0
  67. package/dist/cjs/timesync/index.js +17 -0
  68. package/dist/cjs/types/accelerometer.d.ts +10 -0
  69. package/dist/cjs/types/accelerometer.js +2 -0
  70. package/dist/cjs/types/actions.d.ts +16 -0
  71. package/dist/cjs/types/actions.js +2 -0
  72. package/dist/cjs/types/awareness.d.ts +1 -0
  73. package/dist/cjs/types/awareness.js +2 -0
  74. package/dist/cjs/types/brainwaves.d.ts +26 -0
  75. package/dist/cjs/types/brainwaves.js +2 -0
  76. package/dist/cjs/types/calm.d.ts +6 -0
  77. package/dist/cjs/types/calm.js +2 -0
  78. package/dist/cjs/types/client.d.ts +22 -0
  79. package/dist/cjs/types/client.js +2 -0
  80. package/dist/cjs/types/credentials.d.ts +12 -0
  81. package/dist/cjs/types/credentials.js +2 -0
  82. package/dist/cjs/types/deviceInfo.d.ts +18 -0
  83. package/dist/cjs/types/deviceInfo.js +2 -0
  84. package/dist/cjs/types/epoch.d.ts +12 -0
  85. package/dist/cjs/types/epoch.js +2 -0
  86. package/dist/cjs/types/experiment.d.ts +9 -0
  87. package/dist/cjs/types/experiment.js +2 -0
  88. package/dist/cjs/types/focus.d.ts +6 -0
  89. package/dist/cjs/types/focus.js +2 -0
  90. package/dist/cjs/types/hapticEffects.d.ts +125 -0
  91. package/dist/cjs/types/hapticEffects.js +2 -0
  92. package/dist/cjs/types/kinesis.d.ts +6 -0
  93. package/dist/cjs/types/kinesis.js +2 -0
  94. package/dist/cjs/types/marker.d.ts +7 -0
  95. package/dist/cjs/types/marker.js +2 -0
  96. package/dist/cjs/types/metrics.d.ts +21 -0
  97. package/dist/cjs/types/metrics.js +2 -0
  98. package/dist/cjs/types/oauth.d.ts +20 -0
  99. package/dist/cjs/types/oauth.js +2 -0
  100. package/dist/cjs/types/options.d.ts +51 -0
  101. package/dist/cjs/types/options.js +2 -0
  102. package/dist/cjs/types/sample.d.ts +15 -0
  103. package/dist/cjs/types/sample.js +2 -0
  104. package/dist/cjs/types/settings.d.ts +13 -0
  105. package/dist/cjs/types/settings.js +2 -0
  106. package/dist/cjs/types/signalQuality.d.ts +13 -0
  107. package/dist/cjs/types/signalQuality.js +2 -0
  108. package/dist/cjs/types/skill.d.ts +68 -0
  109. package/dist/cjs/types/skill.js +2 -0
  110. package/dist/{types → cjs/types}/status.d.ts +0 -0
  111. package/dist/cjs/types/status.js +22 -0
  112. package/dist/{types → cjs/types}/streaming.d.ts +0 -0
  113. package/dist/cjs/types/streaming.js +20 -0
  114. package/dist/cjs/types/subscriptions.d.ts +23 -0
  115. package/dist/cjs/types/subscriptions.js +2 -0
  116. package/dist/cjs/types/training.d.ts +19 -0
  117. package/dist/cjs/types/training.js +2 -0
  118. package/dist/cjs/types/user.d.ts +12 -0
  119. package/dist/cjs/types/user.js +2 -0
  120. package/dist/{utils → cjs/utils}/errors.d.ts +0 -0
  121. package/dist/cjs/utils/errors.js +17 -0
  122. package/dist/{utils → cjs/utils}/filterInternalKeys.d.ts +0 -0
  123. package/dist/cjs/utils/filterInternalKeys.js +21 -0
  124. package/dist/{utils → cjs/utils}/hapticEffects.d.ts +0 -0
  125. package/dist/cjs/utils/hapticEffects.js +130 -0
  126. package/dist/{utils → cjs/utils}/heartbeat.d.ts +0 -0
  127. package/dist/cjs/utils/heartbeat.js +41 -0
  128. package/dist/{utils → cjs/utils}/is-node.d.ts +0 -0
  129. package/dist/cjs/utils/is-node.js +9 -0
  130. package/dist/cjs/utils/metrics.d.ts +1 -0
  131. package/dist/cjs/utils/metrics.js +56 -0
  132. package/dist/{utils → cjs/utils}/oauth.d.ts +1 -1
  133. package/dist/cjs/utils/oauth.js +92 -0
  134. package/dist/cjs/utils/pick.d.ts +1 -0
  135. package/dist/cjs/utils/pick.js +5 -0
  136. package/dist/{utils → cjs/utils}/pipes.d.ts +0 -0
  137. package/dist/cjs/utils/pipes.js +71 -0
  138. package/dist/{utils → cjs/utils}/platform.d.ts +0 -0
  139. package/dist/cjs/utils/platform.js +47 -0
  140. package/dist/{utils → cjs/utils}/subscription.d.ts +0 -0
  141. package/dist/cjs/utils/subscription.js +55 -0
  142. package/dist/cjs/utils/transferDevice.d.ts +9 -0
  143. package/dist/cjs/utils/transferDevice.js +2 -0
  144. package/dist/{utils → cjs/utils}/whileOnline.d.ts +1 -1
  145. package/dist/cjs/utils/whileOnline.js +15 -0
  146. package/dist/electron/index.js +86 -0
  147. package/dist/electron/index.js.map +1 -0
  148. package/dist/esm/Neurosity.d.ts +619 -0
  149. package/dist/esm/Neurosity.js +1213 -0
  150. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +72 -0
  151. package/dist/esm/api/bluetooth/BluetoothClient.js +306 -0
  152. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +33 -0
  153. package/dist/esm/api/bluetooth/BluetoothTransport.js +1 -0
  154. package/dist/esm/api/bluetooth/constants.d.ts +4 -0
  155. package/dist/esm/api/bluetooth/constants.js +6 -0
  156. package/dist/esm/api/bluetooth/index.d.ts +5 -0
  157. package/dist/esm/api/bluetooth/index.js +5 -0
  158. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +70 -0
  159. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +407 -0
  160. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  161. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +8 -0
  162. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  163. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +9 -0
  164. package/dist/esm/api/bluetooth/types/index.d.ts +31 -0
  165. package/dist/esm/api/bluetooth/types/index.js +19 -0
  166. package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
  167. package/dist/esm/api/bluetooth/utils/create6DigitPin.js +4 -0
  168. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
  169. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +31 -0
  170. package/dist/esm/api/bluetooth/utils/encoding.d.ts +3 -0
  171. package/dist/esm/api/bluetooth/utils/encoding.js +17 -0
  172. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
  173. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +16 -0
  174. package/dist/esm/api/bluetooth/utils/stitch.d.ts +5 -0
  175. package/dist/esm/api/bluetooth/utils/stitch.js +18 -0
  176. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +54 -0
  177. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +426 -0
  178. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
  179. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +4 -0
  180. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
  181. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +7 -0
  182. package/dist/esm/api/firebase/FirebaseApp.d.ts +20 -0
  183. package/dist/esm/api/firebase/FirebaseApp.js +63 -0
  184. package/dist/esm/api/firebase/FirebaseDevice.d.ts +68 -0
  185. package/dist/esm/api/firebase/FirebaseDevice.js +139 -0
  186. package/dist/esm/api/firebase/FirebaseUser.d.ts +53 -0
  187. package/dist/esm/api/firebase/FirebaseUser.js +426 -0
  188. package/dist/esm/api/firebase/config.d.ts +8 -0
  189. package/dist/esm/api/firebase/config.js +8 -0
  190. package/dist/esm/api/firebase/deviceStore.d.ts +26 -0
  191. package/dist/esm/api/firebase/deviceStore.js +184 -0
  192. package/dist/esm/api/firebase/index.d.ts +3 -0
  193. package/dist/esm/api/firebase/index.js +3 -0
  194. package/dist/esm/api/https/config.d.ts +1 -0
  195. package/dist/esm/api/https/config.js +1 -0
  196. package/dist/esm/api/https/createOAuthURL.d.ts +3 -0
  197. package/dist/esm/api/https/createOAuthURL.js +11 -0
  198. package/dist/esm/api/https/getOAuthToken.d.ts +3 -0
  199. package/dist/esm/api/https/getOAuthToken.js +27 -0
  200. package/dist/esm/api/https/utils.d.ts +2 -0
  201. package/dist/esm/api/https/utils.js +9 -0
  202. package/dist/esm/api/index.d.ts +109 -0
  203. package/dist/esm/api/index.js +300 -0
  204. package/dist/esm/index.d.ts +2 -0
  205. package/dist/esm/index.js +2 -0
  206. package/dist/esm/neurosity.mjs +48705 -0
  207. package/dist/esm/subscriptions/SubscriptionManager.d.ts +11 -0
  208. package/dist/esm/subscriptions/SubscriptionManager.js +23 -0
  209. package/dist/esm/timesync/Timesync.d.ts +20 -0
  210. package/dist/esm/timesync/Timesync.js +71 -0
  211. package/dist/esm/timesync/index.d.ts +1 -0
  212. package/dist/esm/timesync/index.js +1 -0
  213. package/dist/esm/types/accelerometer.d.ts +10 -0
  214. package/dist/esm/types/accelerometer.js +1 -0
  215. package/dist/esm/types/actions.d.ts +16 -0
  216. package/dist/esm/types/actions.js +1 -0
  217. package/dist/esm/types/awareness.d.ts +1 -0
  218. package/dist/esm/types/awareness.js +1 -0
  219. package/dist/esm/types/brainwaves.d.ts +26 -0
  220. package/dist/esm/types/brainwaves.js +1 -0
  221. package/dist/esm/types/calm.d.ts +6 -0
  222. package/dist/esm/types/calm.js +1 -0
  223. package/dist/esm/types/client.d.ts +22 -0
  224. package/dist/esm/types/client.js +1 -0
  225. package/dist/esm/types/credentials.d.ts +12 -0
  226. package/dist/esm/types/credentials.js +1 -0
  227. package/dist/esm/types/deviceInfo.d.ts +18 -0
  228. package/dist/esm/types/deviceInfo.js +1 -0
  229. package/dist/esm/types/epoch.d.ts +12 -0
  230. package/dist/esm/types/epoch.js +1 -0
  231. package/dist/esm/types/experiment.d.ts +9 -0
  232. package/dist/esm/types/experiment.js +1 -0
  233. package/dist/esm/types/focus.d.ts +6 -0
  234. package/dist/esm/types/focus.js +1 -0
  235. package/dist/esm/types/hapticEffects.d.ts +125 -0
  236. package/dist/esm/types/hapticEffects.js +1 -0
  237. package/dist/esm/types/kinesis.d.ts +6 -0
  238. package/dist/esm/types/kinesis.js +1 -0
  239. package/dist/esm/types/marker.d.ts +7 -0
  240. package/dist/esm/types/marker.js +1 -0
  241. package/dist/esm/types/metrics.d.ts +21 -0
  242. package/dist/esm/types/metrics.js +1 -0
  243. package/dist/esm/types/oauth.d.ts +20 -0
  244. package/dist/esm/types/oauth.js +1 -0
  245. package/dist/esm/types/options.d.ts +51 -0
  246. package/dist/esm/types/options.js +1 -0
  247. package/dist/esm/types/sample.d.ts +15 -0
  248. package/dist/esm/types/sample.js +1 -0
  249. package/dist/esm/types/settings.d.ts +13 -0
  250. package/dist/esm/types/settings.js +1 -0
  251. package/dist/esm/types/signalQuality.d.ts +13 -0
  252. package/dist/esm/types/signalQuality.js +1 -0
  253. package/dist/esm/types/skill.d.ts +68 -0
  254. package/dist/esm/types/skill.js +1 -0
  255. package/dist/esm/types/status.d.ts +26 -0
  256. package/dist/esm/types/status.js +19 -0
  257. package/dist/esm/types/streaming.d.ts +15 -0
  258. package/dist/esm/types/streaming.js +17 -0
  259. package/dist/esm/types/subscriptions.d.ts +23 -0
  260. package/dist/esm/types/subscriptions.js +1 -0
  261. package/dist/esm/types/training.d.ts +19 -0
  262. package/dist/esm/types/training.js +1 -0
  263. package/dist/esm/types/user.d.ts +12 -0
  264. package/dist/esm/types/user.js +1 -0
  265. package/dist/esm/utils/errors.d.ts +5 -0
  266. package/dist/esm/utils/errors.js +11 -0
  267. package/dist/esm/utils/filterInternalKeys.d.ts +3 -0
  268. package/dist/esm/utils/filterInternalKeys.js +17 -0
  269. package/dist/esm/utils/hapticEffects.d.ts +123 -0
  270. package/dist/esm/utils/hapticEffects.js +125 -0
  271. package/dist/esm/utils/heartbeat.d.ts +4 -0
  272. package/dist/esm/utils/heartbeat.js +33 -0
  273. package/dist/esm/utils/is-node.d.ts +1 -0
  274. package/dist/esm/utils/is-node.js +5 -0
  275. package/dist/esm/utils/metrics.d.ts +1 -0
  276. package/dist/esm/utils/metrics.js +52 -0
  277. package/dist/esm/utils/oauth.d.ts +9 -0
  278. package/dist/esm/utils/oauth.js +64 -0
  279. package/dist/esm/utils/pick.d.ts +1 -0
  280. package/dist/esm/utils/pick.js +1 -0
  281. package/dist/esm/utils/pipes.d.ts +46 -0
  282. package/dist/esm/utils/pipes.js +65 -0
  283. package/dist/esm/utils/platform.d.ts +30 -0
  284. package/dist/esm/utils/platform.js +41 -0
  285. package/dist/esm/utils/subscription.d.ts +6 -0
  286. package/dist/esm/utils/subscription.js +24 -0
  287. package/dist/esm/utils/transferDevice.d.ts +9 -0
  288. package/dist/esm/utils/transferDevice.js +1 -0
  289. package/dist/esm/utils/whileOnline.d.ts +8 -0
  290. package/dist/esm/utils/whileOnline.js +11 -0
  291. package/dist/examples/auth.html +32 -0
  292. package/dist/examples/cloud.html +17 -0
  293. package/dist/examples/index.html +1 -0
  294. package/dist/examples/neurosity.iife.js +48717 -0
  295. package/dist/examples/neurosity.js +666 -0
  296. package/dist/examples/neurosity.mjs +48705 -0
  297. package/dist/examples/training.html +49 -0
  298. package/package.json +23 -18
  299. package/dist/index.cjs +0 -2
  300. package/dist/index.cjs.map +0 -1
  301. package/dist/index.m.js +0 -2
  302. package/dist/index.m.js.map +0 -1
  303. package/dist/index.umd.js +0 -2
  304. package/dist/index.umd.js.map +0 -1
  305. package/dist/utils/metrics.d.ts +0 -6
@@ -0,0 +1,68 @@
1
+ import { Observable } from "rxjs";
2
+ /**
3
+ * @hidden
4
+ */
5
+ declare type SkillProps = {
6
+ [key: string]: string | number | boolean;
7
+ };
8
+ /**
9
+ * @hidden
10
+ */
11
+ export interface Skill {
12
+ id: string;
13
+ bundleId: string;
14
+ spec: string;
15
+ name: string;
16
+ description: string;
17
+ props?: SkillProps;
18
+ organization?: string;
19
+ metrics: string[];
20
+ userId: string;
21
+ timestamp: number;
22
+ status: string;
23
+ thumbnail: string;
24
+ }
25
+ /**
26
+ * @hidden
27
+ */
28
+ export interface DeviceSkill {
29
+ id: string;
30
+ bundleId: string;
31
+ installedDate: number;
32
+ manifest: {
33
+ [key: string]: any;
34
+ };
35
+ status: string;
36
+ }
37
+ /**
38
+ * @hidden
39
+ */
40
+ declare type SkillMetric = {
41
+ [key: string]: any;
42
+ };
43
+ /**
44
+ * @hidden
45
+ */
46
+ interface SkillMetricNext {
47
+ next(value: SkillMetric): void;
48
+ }
49
+ /**
50
+ * @hidden
51
+ */
52
+ export interface SkillInstance {
53
+ props?: SkillProps;
54
+ metric(metric: string): Observable<SkillMetric> | SkillMetricNext;
55
+ }
56
+ /**
57
+ * @hidden
58
+ */
59
+ export interface SkillSubscription {
60
+ unsubscribe(): void;
61
+ }
62
+ /**
63
+ * @hidden
64
+ */
65
+ export interface SkillsClient {
66
+ get: (id: string) => Promise<DeviceSkill>;
67
+ }
68
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SLEEP_MODE_REASON = exports.STATUS = void 0;
4
+ /**
5
+ * @hidden
6
+ */
7
+ var STATUS;
8
+ (function (STATUS) {
9
+ STATUS["ONLINE"] = "online";
10
+ STATUS["OFFLINE"] = "offline";
11
+ STATUS["UPDATING"] = "updating";
12
+ STATUS["BOOTING"] = "booting";
13
+ STATUS["SHUTTING_OFF"] = "shuttingOff";
14
+ })(STATUS = exports.STATUS || (exports.STATUS = {}));
15
+ /**
16
+ * @hidden
17
+ */
18
+ var SLEEP_MODE_REASON;
19
+ (function (SLEEP_MODE_REASON) {
20
+ SLEEP_MODE_REASON["UPDATING"] = "updating";
21
+ SLEEP_MODE_REASON["CHARGING"] = "charging";
22
+ })(SLEEP_MODE_REASON = exports.SLEEP_MODE_REASON || (exports.SLEEP_MODE_REASON = {}));
File without changes
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STREAMING_MODE = exports.STREAMING_TYPE = void 0;
4
+ /**
5
+ * @hidden
6
+ */
7
+ var STREAMING_TYPE;
8
+ (function (STREAMING_TYPE) {
9
+ STREAMING_TYPE["WIFI"] = "wifi";
10
+ STREAMING_TYPE["BLUETOOTH"] = "bluetooth";
11
+ })(STREAMING_TYPE = exports.STREAMING_TYPE || (exports.STREAMING_TYPE = {}));
12
+ /**
13
+ * @hidden
14
+ */
15
+ var STREAMING_MODE;
16
+ (function (STREAMING_MODE) {
17
+ STREAMING_MODE["WIFI_ONLY"] = "wifi-only";
18
+ STREAMING_MODE["WIFI_WITH_BLUETOOTH_FALLBACK"] = "wifi-with-bluetooth-fallback";
19
+ STREAMING_MODE["BLUETOOTH_WITH_WIFI_FALLBACK"] = "bluetooth-with-wifi-fallback";
20
+ })(STREAMING_MODE = exports.STREAMING_MODE || (exports.STREAMING_MODE = {}));
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export interface PendingSubscription {
5
+ metric: string;
6
+ labels: string[];
7
+ atomic: boolean;
8
+ serverType?: string;
9
+ }
10
+ /**
11
+ * @hidden
12
+ */
13
+ export interface Subscription extends PendingSubscription {
14
+ id: string;
15
+ clientId: string;
16
+ serverType: string;
17
+ }
18
+ /**
19
+ * @hidden
20
+ */
21
+ export interface Subscriptions {
22
+ [id: string]: Subscription;
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export interface TrainingRecording {
5
+ experimentId: string;
6
+ metric: string;
7
+ label: string;
8
+ fit?: boolean;
9
+ baseline?: boolean;
10
+ timestamp?: number;
11
+ }
12
+ /**
13
+ * @hidden
14
+ */
15
+ export interface Training {
16
+ record(training: TrainingRecording): void;
17
+ stop(training: TrainingRecording): void;
18
+ stopAll(): void;
19
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export declare type UserDevice = {
2
+ claimedOn: number;
3
+ };
4
+ export declare type UserDevices = {
5
+ [deviceId: string]: UserDevice;
6
+ };
7
+ /**
8
+ * @hidden
9
+ */
10
+ export declare type UserClaims = {
11
+ [claimName: string]: boolean | string;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exceededMaxItems = exports.locationNotFound = exports.metricNotSupportedByModel = exports.mustSelectDevice = exports.prefix = void 0;
4
+ exports.prefix = "Neurosity SDK: ";
5
+ exports.mustSelectDevice = new Error(`${exports.prefix}A device must be selected. Make sure to call "neurosity.selectDevice()"`);
6
+ const metricNotSupportedByModel = (metric, modelVersion) => {
7
+ return new Error(`${exports.prefix}${metric} not supported on model version ${modelVersion}. See docs.neurosity.co for more info.`);
8
+ };
9
+ exports.metricNotSupportedByModel = metricNotSupportedByModel;
10
+ const locationNotFound = (location, modelVersion) => {
11
+ return new Error(`${exports.prefix}${location} location not supported on model version ${modelVersion}. Check spelling or see docs.neurosity.co for more info.`);
12
+ };
13
+ exports.locationNotFound = locationNotFound;
14
+ const exceededMaxItems = (maxItems) => {
15
+ return new Error(`${exports.prefix}Maximum items in array is ${maxItems}`);
16
+ };
17
+ exports.exceededMaxItems = exceededMaxItems;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterInternalKeys = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ function filterInternalKeys() {
7
+ return (0, rxjs_1.pipe)((0, operators_1.map)((status) => {
8
+ if (!status) {
9
+ return status;
10
+ }
11
+ // remove internal properties that start with "__"
12
+ const filteredStatus = Object.entries(status).reduce((acc, [key, value]) => {
13
+ if (!key.startsWith("__")) {
14
+ acc[key] = value;
15
+ }
16
+ return acc;
17
+ }, {});
18
+ return filteredStatus;
19
+ }));
20
+ }
21
+ exports.filterInternalKeys = filterInternalKeys;
File without changes
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buzz4_40 = exports.buzz3_60 = exports.buzz2_80 = exports.buzz1_100 = exports.longDoubleSharpTick3_60 = exports.longDoubleSharpTick2_80 = exports.longDoubleSharpTick1_100 = exports.longDoubleSharpClickMedium3_60 = exports.longDoubleSharpClickMedium2_80 = exports.longDoubleSharpClickMedium1_100 = exports.longDoubleSharpClickStrong4_30 = exports.longDoubleSharpClickStrong3_60 = exports.longDoubleSharpClickStrong2_80 = exports.longDoubleSharpClickStrong1_100 = exports.shortDoubleSharpTick3_60 = exports.shortDoubleSharpTick2_80 = exports.shortDoubleSharpTick1_100 = exports.shortDoubleClickMedium3_60 = exports.shortDoubleClickMedium2_80 = exports.shortDoubleClickMedium1_100 = exports.shortDoubleClickStrong4_30 = exports.shortDoubleClickStrong3_60 = exports.shortDoubleClickStrong2_80 = exports.shortDoubleClickStrong1_100 = exports.sharpTick3_60 = exports.sharpTick2_80 = exports.sharpTick1_100 = exports.mediumClick3_60 = exports.mediumClick2_80 = exports.mediumClick1_100 = exports.strongClick4_30 = exports.strongClick3_60 = exports.strongClick2_80 = exports.strongClick1_100 = exports.alert1000ms = exports.alert750ms = exports.strongBuzz100 = exports.softFuzz60 = exports.tripleClick100 = exports.doubleClick60 = exports.doubleClick100 = exports.softBump30 = exports.softBump60 = exports.softBump100 = exports.sharpClick30 = exports.sharpClick60 = exports.sharpClick100 = exports.strongClick30 = exports.strongClick60 = exports.strongClick100 = void 0;
4
+ exports.transitionRampDownLongSharp1_50_to_0 = exports.transitionRampDownShortSmooth2_50_to_0 = exports.transitionRampDownShortSmooth1_50_to_0 = exports.transitionRampDownMediumSmooth2_50_to_0 = exports.transitionRampDownMediumSmooth1_50_to_0 = exports.transitionRampDownLongSmooth2_50_to_0 = exports.transitionRampDownLongSmooth1_50_to_0 = exports.transitionRampUpShortSharp2_0_to_100 = exports.transitionRampUpShortSharp1_0_to_100 = exports.transitionRampUpMediumSharp2_0_to_100 = exports.transitionRampUpMediumSharp1_0_to_100 = exports.transitionRampUpLongSharp2_0_to_100 = exports.transitionRampUpLongSharp1_0_to_100 = exports.transitionRampUpShortSmooth2_0_to_100 = exports.transitionRampUpShortSmooth1_0_to_100 = exports.transitionRampUpMediumSmooth2_0_to_100 = exports.transitionRampUpMediumSmooth1_0_to_100 = exports.transitionRampUpLongSmooth2_0_to_100 = exports.transitionRampUpLongSmooth1_0_to_100 = exports.transitionRampDownShortSharp2_100_to_0 = exports.transitionRampDownShortSharp1_100_to_0 = exports.transitionRampDownLongMedium2_100_to_0 = exports.transitionRampDownLongMedium1_100_to_0 = exports.transitionRampDownLongSharp2_100_to_0 = exports.transitionRampDownLongSharp1_100_to_0 = exports.transitionRampDownShortSmooth2_100_to_0 = exports.transitionRampDownShortSmooth1_100_to_0 = exports.transitionRampDownMediumSmooth2_100_to_0 = exports.transitionRampDownMediumSmooth1_100_to_0 = exports.transitionRampDownLongSmooth2_100_to_0 = exports.transitionRampDownLongSmooth1_100_to_0 = exports.transistionHum6_10 = exports.transistionHum5_20 = exports.transistionHum4_40 = exports.transistionHum3_60 = exports.transistionHum2_80 = exports.transistionHum1_100 = exports.transistionClick6_10 = exports.transistionClick5_20 = exports.transistionClick4_40 = exports.transistionClick3_60 = exports.transistionClick2_80 = exports.transistionClick1_100 = exports.pulsingSharp2_60 = exports.pulsingSharp1_100 = exports.pulsingMedium2_60 = exports.pulsingMedium1_100 = exports.pulsingStong2_60 = exports.pulsingStong1_100 = exports.buzz5_20 = void 0;
5
+ exports.smoothHum5_10 = exports.smoothHum4_20 = exports.smoothHum3_30 = exports.smoothHum2_40 = exports.smoothHum1_50 = exports.longBuzzForProgrammaticStopping_100 = exports.transitionRampUpShortSharp2_0_to_50 = exports.transitionRampUpShortSharp1_0_to_50 = exports.transitionRampUpMediumSharp2_0_to_50 = exports.transitionRampUpMediumSharp1_0_to_50 = exports.transitionRampUpLongSharp2_0_to_50 = exports.transitionRampUpLongSharp1_0_to_50 = exports.transitionRampUpShortSmooth2_0_to_50 = exports.transitionRampUpShortSmooth1_0_to_50 = exports.transitionRampUpMediumSmooth2_0_to_50 = exports.transitionRampUpMediumSmooth1_0_to_50 = exports.transitionRampUpLongSmooth2_0_to_50 = exports.transitionRampUpLongSmooth1_0_to_50 = exports.transitionRampDownShortSharp2_50_to_0 = exports.transitionRampDownShortSharp1_50_to_0 = exports.transitionRampDownMediumSharp2_50_to_0 = exports.transitionRampDownMediumSharp1_50_to_0 = exports.transitionRampDownLongSharp2_50_to_0 = void 0;
6
+ // All 127ish codes here:
7
+ /// https://cdn-learn.adafruit.com/downloads/pdf/adafruit-drv2605-haptic-controller-breakout.pdf
8
+ exports.strongClick100 = "strongClick100";
9
+ exports.strongClick60 = "strongClick60";
10
+ exports.strongClick30 = "strongClick30";
11
+ exports.sharpClick100 = "sharpClick100";
12
+ exports.sharpClick60 = "sharpClick60";
13
+ exports.sharpClick30 = "sharpClick30";
14
+ exports.softBump100 = "softBump100";
15
+ exports.softBump60 = "softBump60";
16
+ exports.softBump30 = "softBump30";
17
+ exports.doubleClick100 = "doubleClick100";
18
+ exports.doubleClick60 = "doubleClick60";
19
+ exports.tripleClick100 = "tripleClick100";
20
+ exports.softFuzz60 = "softFuzz60";
21
+ exports.strongBuzz100 = "strongBuzz100";
22
+ exports.alert750ms = "alert750ms";
23
+ exports.alert1000ms = "alert1000ms";
24
+ exports.strongClick1_100 = "strongClick1_100";
25
+ exports.strongClick2_80 = "strongClick2_80";
26
+ exports.strongClick3_60 = "strongClick3_60";
27
+ exports.strongClick4_30 = "strongClick4_30";
28
+ exports.mediumClick1_100 = "mediumClick1_100";
29
+ exports.mediumClick2_80 = "mediumClick2_80";
30
+ exports.mediumClick3_60 = "mediumClick3_60";
31
+ exports.sharpTick1_100 = "sharpTick1_100";
32
+ exports.sharpTick2_80 = "sharpTick2_80";
33
+ exports.sharpTick3_60 = "sharpTick3_60";
34
+ exports.shortDoubleClickStrong1_100 = "shortDoubleClickStrong1_100";
35
+ exports.shortDoubleClickStrong2_80 = "shortDoubleClickStrong2_80";
36
+ exports.shortDoubleClickStrong3_60 = "shortDoubleClickStrong3_60";
37
+ exports.shortDoubleClickStrong4_30 = "shortDoubleClickStrong4_30";
38
+ exports.shortDoubleClickMedium1_100 = "shortDoubleClickMedium1_100";
39
+ exports.shortDoubleClickMedium2_80 = "shortDoubleClickMedium2_80";
40
+ exports.shortDoubleClickMedium3_60 = "shortDoubleClickMedium3_60";
41
+ exports.shortDoubleSharpTick1_100 = "shortDoubleSharpTick1_100";
42
+ exports.shortDoubleSharpTick2_80 = "shortDoubleSharpTick2_80";
43
+ exports.shortDoubleSharpTick3_60 = "shortDoubleSharpTick3_60";
44
+ exports.longDoubleSharpClickStrong1_100 = "longDoubleSharpClickStrong1_100";
45
+ exports.longDoubleSharpClickStrong2_80 = "longDoubleSharpClickStrong2_80";
46
+ exports.longDoubleSharpClickStrong3_60 = "longDoubleSharpClickStrong3_60";
47
+ exports.longDoubleSharpClickStrong4_30 = "longDoubleSharpClickStrong4_30";
48
+ exports.longDoubleSharpClickMedium1_100 = "longDoubleSharpClickMedium1_100";
49
+ exports.longDoubleSharpClickMedium2_80 = "longDoubleSharpClickMedium2_80";
50
+ exports.longDoubleSharpClickMedium3_60 = "longDoubleSharpClickMedium3_60";
51
+ exports.longDoubleSharpTick1_100 = "longDoubleSharpTick1_100";
52
+ exports.longDoubleSharpTick2_80 = "longDoubleSharpTick2_80";
53
+ exports.longDoubleSharpTick3_60 = "longDoubleSharpTick3_60";
54
+ exports.buzz1_100 = "buzz1_100";
55
+ exports.buzz2_80 = "buzz2_80";
56
+ exports.buzz3_60 = "buzz3_60";
57
+ exports.buzz4_40 = "buzz4_40";
58
+ exports.buzz5_20 = "buzz5_20";
59
+ exports.pulsingStong1_100 = "pulsingStong1_100";
60
+ exports.pulsingStong2_60 = "pulsingStong2_60";
61
+ exports.pulsingMedium1_100 = "pulsingMedium1_100";
62
+ exports.pulsingMedium2_60 = "pulsingMedium2_60";
63
+ exports.pulsingSharp1_100 = "pulsingSharp1_100";
64
+ exports.pulsingSharp2_60 = "pulsingSharp2_60";
65
+ exports.transistionClick1_100 = "transistionClick1_100";
66
+ exports.transistionClick2_80 = "transistionClick2_80";
67
+ exports.transistionClick3_60 = "transistionClick3_60";
68
+ exports.transistionClick4_40 = "transistionClick4_40";
69
+ exports.transistionClick5_20 = "transistionClick5_20";
70
+ exports.transistionClick6_10 = "transistionClick6_10";
71
+ exports.transistionHum1_100 = "transistionHum1_100";
72
+ exports.transistionHum2_80 = "transistionHum2_80";
73
+ exports.transistionHum3_60 = "transistionHum3_60";
74
+ exports.transistionHum4_40 = "transistionHum4_40";
75
+ exports.transistionHum5_20 = "transistionHum5_20";
76
+ exports.transistionHum6_10 = "transistionHum6_10";
77
+ exports.transitionRampDownLongSmooth1_100_to_0 = "transitionRampDownLongSmooth1_100_to_0";
78
+ exports.transitionRampDownLongSmooth2_100_to_0 = "transitionRampDownLongSmooth2_100_to_0";
79
+ exports.transitionRampDownMediumSmooth1_100_to_0 = "transitionRampDownMediumSmooth1_100_to_0";
80
+ exports.transitionRampDownMediumSmooth2_100_to_0 = "transitionRampDownMediumSmooth2_100_to_0";
81
+ exports.transitionRampDownShortSmooth1_100_to_0 = "transitionRampDownShortSmooth1_100_to_0";
82
+ exports.transitionRampDownShortSmooth2_100_to_0 = "transitionRampDownShortSmooth2_100_to_0";
83
+ exports.transitionRampDownLongSharp1_100_to_0 = "transitionRampDownLongSharp1_100_to_0";
84
+ exports.transitionRampDownLongSharp2_100_to_0 = "transitionRampDownLongSharp2_100_to_0";
85
+ exports.transitionRampDownLongMedium1_100_to_0 = "transitionRampDownLongMedium1_100_to_0";
86
+ exports.transitionRampDownLongMedium2_100_to_0 = "transitionRampDownLongMedium2_100_to_0";
87
+ exports.transitionRampDownShortSharp1_100_to_0 = "transitionRampDownShortSharp1_100_to_0";
88
+ exports.transitionRampDownShortSharp2_100_to_0 = "transitionRampDownShortSharp2_100_to_0";
89
+ exports.transitionRampUpLongSmooth1_0_to_100 = "transitionRampUpLongSmooth1_0_to_100";
90
+ exports.transitionRampUpLongSmooth2_0_to_100 = "transitionRampUpLongSmooth2_0_to_100";
91
+ exports.transitionRampUpMediumSmooth1_0_to_100 = "transitionRampUpMediumSmooth1_0_to_100";
92
+ exports.transitionRampUpMediumSmooth2_0_to_100 = "transitionRampUpMediumSmooth2_0_to_100";
93
+ exports.transitionRampUpShortSmooth1_0_to_100 = "transitionRampUpShortSmooth1_0_to_100";
94
+ exports.transitionRampUpShortSmooth2_0_to_100 = "transitionRampUpShortSmooth2_0_to_100";
95
+ exports.transitionRampUpLongSharp1_0_to_100 = "transitionRampUpLongSharp1_0_to_100";
96
+ exports.transitionRampUpLongSharp2_0_to_100 = "transitionRampUpLongSharp2_0_to_100";
97
+ exports.transitionRampUpMediumSharp1_0_to_100 = "transitionRampUpMediumSharp1_0_to_100";
98
+ exports.transitionRampUpMediumSharp2_0_to_100 = "transitionRampUpMediumSharp2_0_to_100";
99
+ exports.transitionRampUpShortSharp1_0_to_100 = "transitionRampUpShortSharp1_0_to_100";
100
+ exports.transitionRampUpShortSharp2_0_to_100 = "transitionRampUpShortSharp2_0_to_100";
101
+ exports.transitionRampDownLongSmooth1_50_to_0 = "transitionRampDownLongSmooth1_50_to_0";
102
+ exports.transitionRampDownLongSmooth2_50_to_0 = "transitionRampDownLongSmooth2_50_to_0";
103
+ exports.transitionRampDownMediumSmooth1_50_to_0 = "transitionRampDownMediumSmooth1_50_to_0";
104
+ exports.transitionRampDownMediumSmooth2_50_to_0 = "transitionRampDownMediumSmooth2_50_to_0";
105
+ exports.transitionRampDownShortSmooth1_50_to_0 = "transitionRampDownShortSmooth1_50_to_0";
106
+ exports.transitionRampDownShortSmooth2_50_to_0 = "transitionRampDownShortSmooth2_50_to_0";
107
+ exports.transitionRampDownLongSharp1_50_to_0 = "transitionRampDownLongSharp1_50_to_0";
108
+ exports.transitionRampDownLongSharp2_50_to_0 = "transitionRampDownLongSharp2_50_to_0";
109
+ exports.transitionRampDownMediumSharp1_50_to_0 = "transitionRampDownMediumSharp1_50_to_0";
110
+ exports.transitionRampDownMediumSharp2_50_to_0 = "transitionRampDownMediumSharp2_50_to_0";
111
+ exports.transitionRampDownShortSharp1_50_to_0 = "transitionRampDownShortSharp1_50_to_0";
112
+ exports.transitionRampDownShortSharp2_50_to_0 = "transitionRampDownShortSharp2_50_to_0";
113
+ exports.transitionRampUpLongSmooth1_0_to_50 = "transitionRampUpLongSmooth1_0_to_50";
114
+ exports.transitionRampUpLongSmooth2_0_to_50 = "transitionRampUpLongSmooth2_0_to_50";
115
+ exports.transitionRampUpMediumSmooth1_0_to_50 = "transitionRampUpMediumSmooth1_0_to_50";
116
+ exports.transitionRampUpMediumSmooth2_0_to_50 = "transitionRampUpMediumSmooth2_0_to_50";
117
+ exports.transitionRampUpShortSmooth1_0_to_50 = "transitionRampUpShortSmooth1_0_to_50";
118
+ exports.transitionRampUpShortSmooth2_0_to_50 = "transitionRampUpShortSmooth2_0_to_50";
119
+ exports.transitionRampUpLongSharp1_0_to_50 = "transitionRampUpLongSharp1_0_to_50";
120
+ exports.transitionRampUpLongSharp2_0_to_50 = "transitionRampUpLongSharp2_0_to_50";
121
+ exports.transitionRampUpMediumSharp1_0_to_50 = "transitionRampUpMediumSharp1_0_to_50";
122
+ exports.transitionRampUpMediumSharp2_0_to_50 = "transitionRampUpMediumSharp2_0_to_50";
123
+ exports.transitionRampUpShortSharp1_0_to_50 = "transitionRampUpShortSharp1_0_to_50";
124
+ exports.transitionRampUpShortSharp2_0_to_50 = "transitionRampUpShortSharp2_0_to_50";
125
+ exports.longBuzzForProgrammaticStopping_100 = "longBuzzForProgrammaticStopping_100";
126
+ exports.smoothHum1_50 = "smoothHum1_50";
127
+ exports.smoothHum2_40 = "smoothHum2_40";
128
+ exports.smoothHum3_30 = "smoothHum3_30";
129
+ exports.smoothHum4_20 = "smoothHum4_20";
130
+ exports.smoothHum5_10 = "smoothHum5_10";
File without changes
@@ -0,0 +1,41 @@
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
+ exports.deviceHasLostHeartbeat = exports.heartbeatAwareStatus = void 0;
7
+ const rxjs_1 = require("rxjs");
8
+ const operators_1 = require("rxjs/operators");
9
+ const operators_2 = require("rxjs/operators");
10
+ const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
11
+ const status_1 = require("../types/status");
12
+ const HEARTBEAT_UPDATE_INTERVAL = 30000; // 30 seconds - set by the OS
13
+ const LOST_HEARTBEAT_AFTER = HEARTBEAT_UPDATE_INTERVAL * 2.5; // 75 seconds
14
+ function heartbeatAwareStatus(status$) {
15
+ const lastLocalHeartbeat$ = status$.pipe((0, operators_1.map)(({ lastHeartbeat }) => lastHeartbeat), (0, operators_2.distinctUntilChanged)(), (0, operators_1.map)(() => Date.now()));
16
+ const lostHeartbeat$ = lastLocalHeartbeat$.pipe((0, operators_1.switchMap)(() => (0, rxjs_1.timer)(LOST_HEARTBEAT_AFTER)), (0, operators_1.map)(() => null), (0, operators_1.startWith)(null));
17
+ return (0, rxjs_1.combineLatest)({
18
+ status: status$,
19
+ lostHeartbeat: lostHeartbeat$ // @important - do not remove, adeed for state synchronization, value not used
20
+ }).pipe((0, operators_2.withLatestFrom)(lastLocalHeartbeat$), (0, operators_1.map)(([{ status }, lastLocalHeartbeat]) => {
21
+ if (!lastLocalHeartbeat) {
22
+ return status;
23
+ }
24
+ const lostHeartbeat = deviceHasLostHeartbeat(status, lastLocalHeartbeat);
25
+ return lostHeartbeat
26
+ ? Object.assign(Object.assign({}, status), { state: status_1.STATUS.OFFLINE }) : status;
27
+ }), (0, operators_2.distinctUntilChanged)((a, b) => (0, fast_deep_equal_1.default)(a, b)));
28
+ }
29
+ exports.heartbeatAwareStatus = heartbeatAwareStatus;
30
+ function deviceHasLostHeartbeat(status, lastLocalHeartbeat) {
31
+ if (!("lastHeartbeat" in status)) {
32
+ return false;
33
+ }
34
+ // We are converting the heartbeat to the local time because the previous
35
+ // implementation that used the server timestamp had bug where SDK clients
36
+ // running on hardware with drifted/out-of-sync clocks (cough cough Android)
37
+ // would override the state to offline when the heartbeat was active.
38
+ const lostHeartbeat = Date.now() - lastLocalHeartbeat > LOST_HEARTBEAT_AFTER;
39
+ return lostHeartbeat;
40
+ }
41
+ exports.deviceHasLostHeartbeat = deviceHasLostHeartbeat;
File without changes
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNode = void 0;
4
+ function isNode() {
5
+ return (typeof process !== "undefined" &&
6
+ process.versions != null &&
7
+ process.versions.node != null);
8
+ }
9
+ exports.isNode = isNode;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCloudMetric = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const whileOnline_1 = require("./whileOnline");
7
+ const subscription_1 = require("./subscription");
8
+ /**
9
+ * @internal
10
+ */
11
+ function getCloudMetric(dependencies, subscription) {
12
+ const { options, cloudClient, onDeviceChange, status } = dependencies;
13
+ const { metric, labels, atomic } = subscription;
14
+ const metricError = (0, subscription_1.validate)(metric, labels, options);
15
+ if (metricError) {
16
+ return (0, rxjs_1.throwError)(() => metricError);
17
+ }
18
+ const metric$ = new rxjs_1.Observable((observer) => {
19
+ const subscriptions = atomic
20
+ ? [
21
+ cloudClient.metrics.subscribe({
22
+ metric: metric,
23
+ labels: labels,
24
+ atomic: atomic
25
+ })
26
+ ]
27
+ : labels.map((label) => {
28
+ return cloudClient.metrics.subscribe({
29
+ metric: metric,
30
+ labels: [label],
31
+ atomic: atomic
32
+ });
33
+ });
34
+ const subscriptionWithListeners = subscriptions.map((subscription) => ({
35
+ subscription,
36
+ listener: cloudClient.metrics.on(subscription, (...data) => {
37
+ observer.next(...data);
38
+ })
39
+ }));
40
+ return () => {
41
+ subscriptionWithListeners.forEach(({ subscription, listener }) => {
42
+ cloudClient.metrics.unsubscribe(subscription, listener);
43
+ });
44
+ };
45
+ });
46
+ return onDeviceChange().pipe((0, operators_1.switchMap)((device) => {
47
+ if (!device) {
48
+ return rxjs_1.EMPTY;
49
+ }
50
+ return metric$.pipe((0, whileOnline_1.whileOnline)({
51
+ status$: status(),
52
+ allowWhileOnSleepMode: false
53
+ }));
54
+ }));
55
+ }
56
+ exports.getCloudMetric = getCloudMetric;
@@ -1,5 +1,5 @@
1
1
  import { Action } from "../types/actions";
2
- type OAuthClaims = {
2
+ declare type OAuthClaims = {
3
3
  oauth?: true;
4
4
  authId?: string;
5
5
  scopes?: string;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.validateOAuthScopeForFunctionName = exports.validateOAuthScopeForAction = void 0;
27
+ const errors = __importStar(require("../utils/errors"));
28
+ const scopeRequiredByAction = {
29
+ "marker/add": "write:brainwave-markers",
30
+ "brainwaves/record": "write:brainwaves",
31
+ "haptics/queue": "write:haptics",
32
+ "training/record": "write:kinesis",
33
+ "training/stop": "write:kinesis",
34
+ "training/stopAll": "write:kinesis",
35
+ "wifi/reset": "write:wifi-settings"
36
+ };
37
+ const scopeRequiredByFunctionName = {
38
+ //metrics
39
+ accelerometer: "read:accelerometer",
40
+ brainwaves: "read:brainwaves",
41
+ calm: "read:calm",
42
+ focus: "read:focus",
43
+ kinesis: "read:kinesis",
44
+ predictions: "read:kinesis",
45
+ signalQuality: "read:signal-quality",
46
+ // end of metrics
47
+ // device info
48
+ getInfo: "read:devices-info",
49
+ getSelectedDevice: "read:devices-info",
50
+ selectDevice: "read:devices-info",
51
+ onDeviceChange: "read:devices-info",
52
+ onUserDevicesChange: "read:devices-info",
53
+ // end device info
54
+ settings: "read:devices-settings",
55
+ changeSettings: "write:devices-settings",
56
+ status: "read:devices-status",
57
+ addDevice: "write:devices-add",
58
+ removeDevice: "write:devices-remove",
59
+ transferDevice: "write:devices-remove"
60
+ };
61
+ function validateOAuthScopeForAction(userClaims, action) {
62
+ const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
63
+ if (!oauth) {
64
+ return [false, null];
65
+ }
66
+ const scopes = scopesString.split(",");
67
+ const { command, action: actionName } = action;
68
+ const requiredScope = scopeRequiredByAction[`${command}/${actionName}`];
69
+ const hasRequireScopes = scopes.includes(requiredScope);
70
+ if (hasRequireScopes) {
71
+ return [false, null];
72
+ }
73
+ return [true, getScopeError(requiredScope)];
74
+ }
75
+ exports.validateOAuthScopeForAction = validateOAuthScopeForAction;
76
+ function validateOAuthScopeForFunctionName(userClaims, functionName) {
77
+ const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
78
+ if (!oauth) {
79
+ return [false, null];
80
+ }
81
+ const scopes = scopesString.split(",");
82
+ const requiredScope = scopeRequiredByFunctionName[functionName];
83
+ const hasRequireScopes = scopes.includes(requiredScope);
84
+ if (hasRequireScopes) {
85
+ return [false, null];
86
+ }
87
+ return [true, getScopeError(requiredScope)];
88
+ }
89
+ exports.validateOAuthScopeForFunctionName = validateOAuthScopeForFunctionName;
90
+ function getScopeError(...requiredScopes) {
91
+ return new Error(`${errors.prefix}You are trying to access data with an OAuth token without access to the following scopes: ${requiredScopes.join(", ")}.`);
92
+ }
@@ -0,0 +1 @@
1
+ export declare const pick: (object: any, props: any) => any;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pick = void 0;
4
+ const pick = (object, props) => props.reduce((acc, prop) => (Object.assign(Object.assign({}, acc), (object.hasOwnProperty(prop) ? { [prop]: object[prop] } : {}))), {});
5
+ exports.pick = pick;
File without changes