@neurosity/sdk 6.2.0 → 6.2.1-next.1

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 (299) hide show
  1. package/package.json +19 -23
  2. package/CHANGELOG.md +0 -25
  3. package/dist/browser/neurosity.iife.js +0 -48712
  4. package/dist/browser/neurosity.js +0 -666
  5. package/dist/browser/neurosity.js.map +0 -1
  6. package/dist/cjs/Neurosity.d.ts +0 -619
  7. package/dist/cjs/Neurosity.js +0 -1244
  8. package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +0 -72
  9. package/dist/cjs/api/bluetooth/BluetoothClient.js +0 -310
  10. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +0 -33
  11. package/dist/cjs/api/bluetooth/BluetoothTransport.js +0 -2
  12. package/dist/cjs/api/bluetooth/constants.d.ts +0 -4
  13. package/dist/cjs/api/bluetooth/constants.js +0 -9
  14. package/dist/cjs/api/bluetooth/index.d.ts +0 -4
  15. package/dist/cjs/api/bluetooth/index.js +0 -20
  16. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +0 -70
  17. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +0 -406
  18. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
  19. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +0 -11
  20. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
  21. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -10
  22. package/dist/cjs/api/bluetooth/types/index.d.ts +0 -31
  23. package/dist/cjs/api/bluetooth/types/index.js +0 -22
  24. package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +0 -1
  25. package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +0 -8
  26. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +0 -11
  27. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +0 -36
  28. package/dist/cjs/api/bluetooth/utils/encoding.d.ts +0 -3
  29. package/dist/cjs/api/bluetooth/utils/encoding.js +0 -22
  30. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -2
  31. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +0 -23
  32. package/dist/cjs/api/bluetooth/utils/stitch.d.ts +0 -5
  33. package/dist/cjs/api/bluetooth/utils/stitch.js +0 -22
  34. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +0 -54
  35. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +0 -430
  36. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -1
  37. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -8
  38. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +0 -1
  39. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +0 -11
  40. package/dist/cjs/api/firebase/FirebaseApp.d.ts +0 -20
  41. package/dist/cjs/api/firebase/FirebaseApp.js +0 -70
  42. package/dist/cjs/api/firebase/FirebaseDevice.d.ts +0 -68
  43. package/dist/cjs/api/firebase/FirebaseDevice.js +0 -146
  44. package/dist/cjs/api/firebase/FirebaseUser.d.ts +0 -53
  45. package/dist/cjs/api/firebase/FirebaseUser.js +0 -434
  46. package/dist/cjs/api/firebase/config.d.ts +0 -8
  47. package/dist/cjs/api/firebase/config.js +0 -11
  48. package/dist/cjs/api/firebase/deviceStore.d.ts +0 -26
  49. package/dist/cjs/api/firebase/deviceStore.js +0 -191
  50. package/dist/cjs/api/firebase/index.d.ts +0 -3
  51. package/dist/cjs/api/firebase/index.js +0 -19
  52. package/dist/cjs/api/https/config.d.ts +0 -1
  53. package/dist/cjs/api/https/config.js +0 -4
  54. package/dist/cjs/api/https/createOAuthURL.d.ts +0 -3
  55. package/dist/cjs/api/https/createOAuthURL.js +0 -18
  56. package/dist/cjs/api/https/getOAuthToken.d.ts +0 -3
  57. package/dist/cjs/api/https/getOAuthToken.js +0 -34
  58. package/dist/cjs/api/https/utils.d.ts +0 -2
  59. package/dist/cjs/api/https/utils.js +0 -13
  60. package/dist/cjs/api/index.d.ts +0 -109
  61. package/dist/cjs/api/index.js +0 -307
  62. package/dist/cjs/index.d.ts +0 -2
  63. package/dist/cjs/index.js +0 -18
  64. package/dist/cjs/subscriptions/SubscriptionManager.d.ts +0 -11
  65. package/dist/cjs/subscriptions/SubscriptionManager.js +0 -27
  66. package/dist/cjs/timesync/Timesync.d.ts +0 -20
  67. package/dist/cjs/timesync/Timesync.js +0 -78
  68. package/dist/cjs/timesync/index.d.ts +0 -1
  69. package/dist/cjs/timesync/index.js +0 -17
  70. package/dist/cjs/types/accelerometer.d.ts +0 -10
  71. package/dist/cjs/types/accelerometer.js +0 -2
  72. package/dist/cjs/types/actions.d.ts +0 -16
  73. package/dist/cjs/types/actions.js +0 -2
  74. package/dist/cjs/types/awareness.d.ts +0 -1
  75. package/dist/cjs/types/awareness.js +0 -2
  76. package/dist/cjs/types/brainwaves.d.ts +0 -26
  77. package/dist/cjs/types/brainwaves.js +0 -2
  78. package/dist/cjs/types/calm.d.ts +0 -6
  79. package/dist/cjs/types/calm.js +0 -2
  80. package/dist/cjs/types/client.d.ts +0 -22
  81. package/dist/cjs/types/client.js +0 -2
  82. package/dist/cjs/types/credentials.d.ts +0 -12
  83. package/dist/cjs/types/credentials.js +0 -2
  84. package/dist/cjs/types/deviceInfo.d.ts +0 -18
  85. package/dist/cjs/types/deviceInfo.js +0 -2
  86. package/dist/cjs/types/epoch.d.ts +0 -12
  87. package/dist/cjs/types/epoch.js +0 -2
  88. package/dist/cjs/types/experiment.d.ts +0 -9
  89. package/dist/cjs/types/experiment.js +0 -2
  90. package/dist/cjs/types/focus.d.ts +0 -6
  91. package/dist/cjs/types/focus.js +0 -2
  92. package/dist/cjs/types/hapticEffects.d.ts +0 -125
  93. package/dist/cjs/types/hapticEffects.js +0 -2
  94. package/dist/cjs/types/kinesis.d.ts +0 -6
  95. package/dist/cjs/types/kinesis.js +0 -2
  96. package/dist/cjs/types/marker.d.ts +0 -7
  97. package/dist/cjs/types/marker.js +0 -2
  98. package/dist/cjs/types/metrics.d.ts +0 -21
  99. package/dist/cjs/types/metrics.js +0 -2
  100. package/dist/cjs/types/oauth.d.ts +0 -20
  101. package/dist/cjs/types/oauth.js +0 -2
  102. package/dist/cjs/types/options.d.ts +0 -51
  103. package/dist/cjs/types/options.js +0 -2
  104. package/dist/cjs/types/sample.d.ts +0 -15
  105. package/dist/cjs/types/sample.js +0 -2
  106. package/dist/cjs/types/settings.d.ts +0 -13
  107. package/dist/cjs/types/settings.js +0 -2
  108. package/dist/cjs/types/signalQuality.d.ts +0 -13
  109. package/dist/cjs/types/signalQuality.js +0 -2
  110. package/dist/cjs/types/skill.d.ts +0 -68
  111. package/dist/cjs/types/skill.js +0 -2
  112. package/dist/cjs/types/status.d.ts +0 -26
  113. package/dist/cjs/types/status.js +0 -22
  114. package/dist/cjs/types/streaming.d.ts +0 -15
  115. package/dist/cjs/types/streaming.js +0 -20
  116. package/dist/cjs/types/subscriptions.d.ts +0 -23
  117. package/dist/cjs/types/subscriptions.js +0 -2
  118. package/dist/cjs/types/training.d.ts +0 -19
  119. package/dist/cjs/types/training.js +0 -2
  120. package/dist/cjs/types/user.d.ts +0 -12
  121. package/dist/cjs/types/user.js +0 -2
  122. package/dist/cjs/utils/errors.d.ts +0 -5
  123. package/dist/cjs/utils/errors.js +0 -17
  124. package/dist/cjs/utils/filterInternalKeys.d.ts +0 -3
  125. package/dist/cjs/utils/filterInternalKeys.js +0 -21
  126. package/dist/cjs/utils/hapticEffects.d.ts +0 -123
  127. package/dist/cjs/utils/hapticEffects.js +0 -130
  128. package/dist/cjs/utils/heartbeat.d.ts +0 -4
  129. package/dist/cjs/utils/heartbeat.js +0 -41
  130. package/dist/cjs/utils/is-node.d.ts +0 -1
  131. package/dist/cjs/utils/is-node.js +0 -9
  132. package/dist/cjs/utils/metrics.d.ts +0 -1
  133. package/dist/cjs/utils/metrics.js +0 -56
  134. package/dist/cjs/utils/oauth.d.ts +0 -9
  135. package/dist/cjs/utils/oauth.js +0 -92
  136. package/dist/cjs/utils/pick.d.ts +0 -1
  137. package/dist/cjs/utils/pick.js +0 -5
  138. package/dist/cjs/utils/pipes.d.ts +0 -46
  139. package/dist/cjs/utils/pipes.js +0 -71
  140. package/dist/cjs/utils/platform.d.ts +0 -30
  141. package/dist/cjs/utils/platform.js +0 -47
  142. package/dist/cjs/utils/subscription.d.ts +0 -6
  143. package/dist/cjs/utils/subscription.js +0 -55
  144. package/dist/cjs/utils/transferDevice.d.ts +0 -9
  145. package/dist/cjs/utils/transferDevice.js +0 -2
  146. package/dist/cjs/utils/whileOnline.d.ts +0 -8
  147. package/dist/cjs/utils/whileOnline.js +0 -15
  148. package/dist/electron/index.js +0 -86
  149. package/dist/electron/index.js.map +0 -1
  150. package/dist/esm/Neurosity.d.ts +0 -619
  151. package/dist/esm/Neurosity.js +0 -1213
  152. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +0 -72
  153. package/dist/esm/api/bluetooth/BluetoothClient.js +0 -306
  154. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +0 -33
  155. package/dist/esm/api/bluetooth/BluetoothTransport.js +0 -1
  156. package/dist/esm/api/bluetooth/constants.d.ts +0 -4
  157. package/dist/esm/api/bluetooth/constants.js +0 -6
  158. package/dist/esm/api/bluetooth/index.d.ts +0 -4
  159. package/dist/esm/api/bluetooth/index.js +0 -4
  160. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +0 -70
  161. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +0 -402
  162. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
  163. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +0 -8
  164. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
  165. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -9
  166. package/dist/esm/api/bluetooth/types/index.d.ts +0 -31
  167. package/dist/esm/api/bluetooth/types/index.js +0 -19
  168. package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +0 -1
  169. package/dist/esm/api/bluetooth/utils/create6DigitPin.js +0 -4
  170. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +0 -11
  171. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +0 -31
  172. package/dist/esm/api/bluetooth/utils/encoding.d.ts +0 -3
  173. package/dist/esm/api/bluetooth/utils/encoding.js +0 -17
  174. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -2
  175. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +0 -16
  176. package/dist/esm/api/bluetooth/utils/stitch.d.ts +0 -5
  177. package/dist/esm/api/bluetooth/utils/stitch.js +0 -18
  178. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +0 -54
  179. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +0 -426
  180. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -1
  181. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -4
  182. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +0 -1
  183. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +0 -7
  184. package/dist/esm/api/firebase/FirebaseApp.d.ts +0 -20
  185. package/dist/esm/api/firebase/FirebaseApp.js +0 -63
  186. package/dist/esm/api/firebase/FirebaseDevice.d.ts +0 -68
  187. package/dist/esm/api/firebase/FirebaseDevice.js +0 -139
  188. package/dist/esm/api/firebase/FirebaseUser.d.ts +0 -53
  189. package/dist/esm/api/firebase/FirebaseUser.js +0 -426
  190. package/dist/esm/api/firebase/config.d.ts +0 -8
  191. package/dist/esm/api/firebase/config.js +0 -8
  192. package/dist/esm/api/firebase/deviceStore.d.ts +0 -26
  193. package/dist/esm/api/firebase/deviceStore.js +0 -184
  194. package/dist/esm/api/firebase/index.d.ts +0 -3
  195. package/dist/esm/api/firebase/index.js +0 -3
  196. package/dist/esm/api/https/config.d.ts +0 -1
  197. package/dist/esm/api/https/config.js +0 -1
  198. package/dist/esm/api/https/createOAuthURL.d.ts +0 -3
  199. package/dist/esm/api/https/createOAuthURL.js +0 -11
  200. package/dist/esm/api/https/getOAuthToken.d.ts +0 -3
  201. package/dist/esm/api/https/getOAuthToken.js +0 -27
  202. package/dist/esm/api/https/utils.d.ts +0 -2
  203. package/dist/esm/api/https/utils.js +0 -9
  204. package/dist/esm/api/index.d.ts +0 -109
  205. package/dist/esm/api/index.js +0 -300
  206. package/dist/esm/index.d.ts +0 -2
  207. package/dist/esm/index.js +0 -2
  208. package/dist/esm/neurosity.mjs +0 -48700
  209. package/dist/esm/subscriptions/SubscriptionManager.d.ts +0 -11
  210. package/dist/esm/subscriptions/SubscriptionManager.js +0 -23
  211. package/dist/esm/timesync/Timesync.d.ts +0 -20
  212. package/dist/esm/timesync/Timesync.js +0 -71
  213. package/dist/esm/timesync/index.d.ts +0 -1
  214. package/dist/esm/timesync/index.js +0 -1
  215. package/dist/esm/types/accelerometer.d.ts +0 -10
  216. package/dist/esm/types/accelerometer.js +0 -1
  217. package/dist/esm/types/actions.d.ts +0 -16
  218. package/dist/esm/types/actions.js +0 -1
  219. package/dist/esm/types/awareness.d.ts +0 -1
  220. package/dist/esm/types/awareness.js +0 -1
  221. package/dist/esm/types/brainwaves.d.ts +0 -26
  222. package/dist/esm/types/brainwaves.js +0 -1
  223. package/dist/esm/types/calm.d.ts +0 -6
  224. package/dist/esm/types/calm.js +0 -1
  225. package/dist/esm/types/client.d.ts +0 -22
  226. package/dist/esm/types/client.js +0 -1
  227. package/dist/esm/types/credentials.d.ts +0 -12
  228. package/dist/esm/types/credentials.js +0 -1
  229. package/dist/esm/types/deviceInfo.d.ts +0 -18
  230. package/dist/esm/types/deviceInfo.js +0 -1
  231. package/dist/esm/types/epoch.d.ts +0 -12
  232. package/dist/esm/types/epoch.js +0 -1
  233. package/dist/esm/types/experiment.d.ts +0 -9
  234. package/dist/esm/types/experiment.js +0 -1
  235. package/dist/esm/types/focus.d.ts +0 -6
  236. package/dist/esm/types/focus.js +0 -1
  237. package/dist/esm/types/hapticEffects.d.ts +0 -125
  238. package/dist/esm/types/hapticEffects.js +0 -1
  239. package/dist/esm/types/kinesis.d.ts +0 -6
  240. package/dist/esm/types/kinesis.js +0 -1
  241. package/dist/esm/types/marker.d.ts +0 -7
  242. package/dist/esm/types/marker.js +0 -1
  243. package/dist/esm/types/metrics.d.ts +0 -21
  244. package/dist/esm/types/metrics.js +0 -1
  245. package/dist/esm/types/oauth.d.ts +0 -20
  246. package/dist/esm/types/oauth.js +0 -1
  247. package/dist/esm/types/options.d.ts +0 -51
  248. package/dist/esm/types/options.js +0 -1
  249. package/dist/esm/types/sample.d.ts +0 -15
  250. package/dist/esm/types/sample.js +0 -1
  251. package/dist/esm/types/settings.d.ts +0 -13
  252. package/dist/esm/types/settings.js +0 -1
  253. package/dist/esm/types/signalQuality.d.ts +0 -13
  254. package/dist/esm/types/signalQuality.js +0 -1
  255. package/dist/esm/types/skill.d.ts +0 -68
  256. package/dist/esm/types/skill.js +0 -1
  257. package/dist/esm/types/status.d.ts +0 -26
  258. package/dist/esm/types/status.js +0 -19
  259. package/dist/esm/types/streaming.d.ts +0 -15
  260. package/dist/esm/types/streaming.js +0 -17
  261. package/dist/esm/types/subscriptions.d.ts +0 -23
  262. package/dist/esm/types/subscriptions.js +0 -1
  263. package/dist/esm/types/training.d.ts +0 -19
  264. package/dist/esm/types/training.js +0 -1
  265. package/dist/esm/types/user.d.ts +0 -12
  266. package/dist/esm/types/user.js +0 -1
  267. package/dist/esm/utils/errors.d.ts +0 -5
  268. package/dist/esm/utils/errors.js +0 -11
  269. package/dist/esm/utils/filterInternalKeys.d.ts +0 -3
  270. package/dist/esm/utils/filterInternalKeys.js +0 -17
  271. package/dist/esm/utils/hapticEffects.d.ts +0 -123
  272. package/dist/esm/utils/hapticEffects.js +0 -125
  273. package/dist/esm/utils/heartbeat.d.ts +0 -4
  274. package/dist/esm/utils/heartbeat.js +0 -33
  275. package/dist/esm/utils/is-node.d.ts +0 -1
  276. package/dist/esm/utils/is-node.js +0 -5
  277. package/dist/esm/utils/metrics.d.ts +0 -1
  278. package/dist/esm/utils/metrics.js +0 -52
  279. package/dist/esm/utils/oauth.d.ts +0 -9
  280. package/dist/esm/utils/oauth.js +0 -64
  281. package/dist/esm/utils/pick.d.ts +0 -1
  282. package/dist/esm/utils/pick.js +0 -1
  283. package/dist/esm/utils/pipes.d.ts +0 -46
  284. package/dist/esm/utils/pipes.js +0 -65
  285. package/dist/esm/utils/platform.d.ts +0 -30
  286. package/dist/esm/utils/platform.js +0 -41
  287. package/dist/esm/utils/subscription.d.ts +0 -6
  288. package/dist/esm/utils/subscription.js +0 -24
  289. package/dist/esm/utils/transferDevice.d.ts +0 -9
  290. package/dist/esm/utils/transferDevice.js +0 -1
  291. package/dist/esm/utils/whileOnline.d.ts +0 -8
  292. package/dist/esm/utils/whileOnline.js +0 -11
  293. package/dist/examples/auth.html +0 -32
  294. package/dist/examples/cloud.html +0 -17
  295. package/dist/examples/index.html +0 -1
  296. package/dist/examples/neurosity.iife.js +0 -48712
  297. package/dist/examples/neurosity.js +0 -666
  298. package/dist/examples/neurosity.mjs +0 -48700
  299. package/dist/examples/training.html +0 -49
@@ -1,72 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { ReplaySubject } from "rxjs";
3
- import { WebBluetoothTransport } from "./web/WebBluetoothTransport";
4
- import { ReactNativeTransport } from "./react-native/ReactNativeTransport";
5
- import { DeviceInfo } from "../../types/deviceInfo";
6
- import { Action } from "../../types/actions";
7
- import { Epoch } from "../../types/epoch";
8
- import { BLUETOOTH_CONNECTION } from "./types";
9
- import { DeviceNicknameOrPeripheral } from "./BluetoothTransport";
10
- import { Peripheral } from "./react-native/types/BleManagerTypes";
11
- export declare type BluetoothTransport = WebBluetoothTransport | ReactNativeTransport;
12
- declare type IsAuthenticated = boolean;
13
- declare type ExpiresIn = number;
14
- declare type IsAuthenticatedResponse = [IsAuthenticated, ExpiresIn];
15
- declare type CreateBluetoothToken = () => Promise<string>;
16
- declare type Options = {
17
- transport: BluetoothTransport;
18
- selectedDevice$: Observable<DeviceInfo>;
19
- createBluetoothToken: CreateBluetoothToken;
20
- };
21
- export declare class BluetoothClient {
22
- transport: BluetoothTransport;
23
- deviceInfo: DeviceInfo;
24
- selectedDevice$: ReplaySubject<DeviceInfo>;
25
- isAuthenticated$: ReplaySubject<boolean>;
26
- _focus$: Observable<any>;
27
- _calm$: Observable<any>;
28
- _accelerometer$: Observable<any>;
29
- _brainwavesRaw$: Observable<any>;
30
- _brainwavesRawUnfiltered$: Observable<any>;
31
- _brainwavesPSD$: Observable<any>;
32
- _brainwavesPowerByBand$: Observable<any>;
33
- _signalQuality$: Observable<any>;
34
- _status$: Observable<any>;
35
- _settings$: Observable<any>;
36
- _wifiNearbyNetworks$: Observable<any>;
37
- _wifiConnections$: Observable<any>;
38
- constructor(options: Options);
39
- _autoAuthenticate(createBluetoothToken: CreateBluetoothToken): Observable<IsAuthenticatedResponse>;
40
- enableAutoConnect(autoConnect: boolean): void;
41
- _hasBluetoothSupport(): Promise<boolean>;
42
- authenticate(token: string): Promise<IsAuthenticatedResponse>;
43
- isAuthenticated(): Promise<IsAuthenticatedResponse>;
44
- scan(options?: any): Observable<Peripheral[]>;
45
- connect(deviceNicknameORPeripheral?: DeviceNicknameOrPeripheral): Promise<void>;
46
- disconnect(): Promise<void>;
47
- connection(): Observable<BLUETOOTH_CONNECTION>;
48
- logs(): Observable<string>;
49
- getDeviceId(): Promise<string>;
50
- _withAuthentication<T>(getter: () => Promise<T>): Promise<T>;
51
- _subscribeWhileAuthenticated(characteristicName: string): Observable<any>;
52
- focus(): Observable<any>;
53
- calm(): Observable<any>;
54
- accelerometer(): Observable<any>;
55
- brainwaves(label: string): Observable<Epoch | any>;
56
- signalQuality(): Observable<any>;
57
- addMarker(label: string): Promise<void>;
58
- getInfo(): Promise<DeviceInfo>;
59
- status(): Observable<any>;
60
- dispatchAction(action: Action): Promise<any>;
61
- settings(): Observable<any>;
62
- haptics(effects: any): Promise<any>;
63
- get wifi(): {
64
- nearbyNetworks: () => Observable<any>;
65
- connections: () => Observable<any>;
66
- connect: (ssid: string, password?: string) => Promise<any>;
67
- forgetConnection: (ssid: string) => Promise<any>;
68
- reset: () => Promise<any>;
69
- speedTest: () => Promise<any>;
70
- };
71
- }
72
- export {};
@@ -1,306 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { defer, firstValueFrom, timer } from "rxjs";
11
- import { ReplaySubject, EMPTY } from "rxjs";
12
- import { switchMap, share, tap } from "rxjs/operators";
13
- import { distinctUntilChanged } from "rxjs/operators";
14
- import { WebBluetoothTransport } from "./web/WebBluetoothTransport";
15
- import { ReactNativeTransport } from "./react-native/ReactNativeTransport";
16
- import { csvBufferToEpoch } from "./utils/csvBufferToEpoch";
17
- import { BLUETOOTH_CONNECTION } from "./types";
18
- import { osHasBluetoothSupport } from "./utils/osHasBluetoothSupport";
19
- export class BluetoothClient {
20
- constructor(options) {
21
- this.selectedDevice$ = new ReplaySubject(1);
22
- this.isAuthenticated$ = new ReplaySubject(1);
23
- const { transport, selectedDevice$, createBluetoothToken } = options !== null && options !== void 0 ? options : {};
24
- if (!transport) {
25
- throw new Error(`No bluetooth transport provided.`);
26
- }
27
- this.transport = transport;
28
- // Pass events to the internal selectedDevice$ if selectedDevice$ is passed via options
29
- if (selectedDevice$) {
30
- selectedDevice$.subscribe(this.selectedDevice$);
31
- }
32
- // Auto Connect
33
- this.transport._autoConnect(this.selectedDevice$).subscribe({
34
- error: (error) => {
35
- var _a;
36
- this.transport.addLog(`Auto connect: error -> ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
37
- }
38
- });
39
- // Auto authentication
40
- if (typeof createBluetoothToken === "function") {
41
- this.transport.addLog("Auto authentication enabled");
42
- this._autoAuthenticate(createBluetoothToken).subscribe();
43
- }
44
- else {
45
- this.transport.addLog("Auto authentication not enabled");
46
- }
47
- // Auto manage action notifications
48
- this.transport._autoToggleActionNotifications(this.selectedDevice$);
49
- // Multicast metrics (share)
50
- this._focus$ = this._subscribeWhileAuthenticated("focus");
51
- this._calm$ = this._subscribeWhileAuthenticated("calm");
52
- this._accelerometer$ = this._subscribeWhileAuthenticated("accelerometer");
53
- this._brainwavesRaw$ = this._subscribeWhileAuthenticated("raw");
54
- this._brainwavesRawUnfiltered$ =
55
- this._subscribeWhileAuthenticated("rawUnfiltered");
56
- this._brainwavesPSD$ = this._subscribeWhileAuthenticated("psd");
57
- this._brainwavesPowerByBand$ =
58
- this._subscribeWhileAuthenticated("powerByBand");
59
- this._signalQuality$ = this._subscribeWhileAuthenticated("signalQuality");
60
- this._status$ = this._subscribeWhileAuthenticated("status");
61
- this._settings$ = this._subscribeWhileAuthenticated("settings");
62
- this._wifiNearbyNetworks$ =
63
- this._subscribeWhileAuthenticated("wifiNearbyNetworks");
64
- this._wifiConnections$ =
65
- this._subscribeWhileAuthenticated("wifiConnections");
66
- }
67
- _autoAuthenticate(createBluetoothToken) {
68
- const REAUTHENTICATE_INTERVAL = 3600000; // 1 hour
69
- const reauthenticateInterval$ = timer(0, REAUTHENTICATE_INTERVAL).pipe(tap(() => {
70
- this.transport.addLog(`Auto authentication in progress...`);
71
- }));
72
- return this.selectedDevice$.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
73
- ? EMPTY
74
- : this.connection().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
75
- ? reauthenticateInterval$
76
- : EMPTY), switchMap(() => __awaiter(this, void 0, void 0, function* () { return yield this.isAuthenticated(); })), tap(([isAuthenticated]) => __awaiter(this, void 0, void 0, function* () {
77
- if (!isAuthenticated) {
78
- const token = yield createBluetoothToken();
79
- yield this.authenticate(token);
80
- }
81
- else {
82
- this.transport.addLog(`Already authenticated`);
83
- }
84
- })))));
85
- }
86
- enableAutoConnect(autoConnect) {
87
- this.transport.enableAutoConnect(autoConnect);
88
- }
89
- _hasBluetoothSupport() {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const selectedDevice = yield firstValueFrom(this.selectedDevice$);
92
- return osHasBluetoothSupport(selectedDevice);
93
- });
94
- }
95
- authenticate(token) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const hasBluetoothSupport = yield this._hasBluetoothSupport();
98
- if (!hasBluetoothSupport) {
99
- const errorMessage = `authenticate method: The OS version does not support Bluetooth.`;
100
- this.transport.addLog(errorMessage);
101
- return Promise.reject(errorMessage);
102
- }
103
- yield this.transport.writeCharacteristic("auth", token);
104
- const isAuthenticatedResponse = yield this.isAuthenticated();
105
- const [isAuthenticated] = isAuthenticatedResponse;
106
- this.transport.addLog(`Authentication ${isAuthenticated ? "succeeded" : "failed"}`);
107
- this.isAuthenticated$.next(isAuthenticated);
108
- return isAuthenticatedResponse;
109
- });
110
- }
111
- isAuthenticated() {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const [isAuthenticated, expiresIn] = yield this.transport.readCharacteristic("auth", true);
114
- this.isAuthenticated$.next(isAuthenticated);
115
- return [isAuthenticated, expiresIn];
116
- });
117
- }
118
- // Method for React Native only
119
- scan(options) {
120
- if (this.transport instanceof ReactNativeTransport) {
121
- return this.transport.scan(options);
122
- }
123
- if (this.transport instanceof WebBluetoothTransport) {
124
- throw new Error(`scan method is compatibly with the React Native transport only`);
125
- }
126
- throw new Error(`unknown transport`);
127
- }
128
- // Argument for React Native only
129
- connect(deviceNicknameORPeripheral) {
130
- if (this.transport instanceof ReactNativeTransport) {
131
- return this.transport.connect(deviceNicknameORPeripheral);
132
- }
133
- if (this.transport instanceof WebBluetoothTransport) {
134
- return deviceNicknameORPeripheral
135
- ? this.transport.connect(deviceNicknameORPeripheral)
136
- : this.transport.connect();
137
- }
138
- }
139
- disconnect() {
140
- return this.transport.disconnect();
141
- }
142
- connection() {
143
- return this.transport.connection();
144
- }
145
- logs() {
146
- return this.transport.logs$.asObservable();
147
- }
148
- getDeviceId() {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- // This is a public characteristic and does not require authentication
151
- return this.transport.readCharacteristic("deviceId");
152
- });
153
- }
154
- _withAuthentication(getter) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- // First check if the OS supports Bluetooth before checking if the device is authenticated
157
- const hasBluetoothSupport = yield this._hasBluetoothSupport();
158
- if (!hasBluetoothSupport) {
159
- const errorMessage = `The OS version does not support Bluetooth.`;
160
- this.transport.addLog(errorMessage);
161
- return Promise.reject(errorMessage);
162
- }
163
- const isAuthenticated = yield firstValueFrom(this.isAuthenticated$);
164
- if (!isAuthenticated) {
165
- const errorMessage = `Authentication required.`;
166
- this.transport.addLog(errorMessage);
167
- return Promise.reject(errorMessage);
168
- }
169
- return yield getter();
170
- });
171
- }
172
- _subscribeWhileAuthenticated(characteristicName) {
173
- return this.selectedDevice$.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
174
- ? EMPTY
175
- : this.isAuthenticated$.pipe(distinctUntilChanged(), switchMap((isAuthenticated) => isAuthenticated
176
- ? this.transport.subscribeToCharacteristic({
177
- characteristicName
178
- })
179
- : EMPTY))), share());
180
- }
181
- focus() {
182
- return this._focus$;
183
- }
184
- calm() {
185
- return this._calm$;
186
- }
187
- accelerometer() {
188
- return this._accelerometer$;
189
- }
190
- brainwaves(label) {
191
- switch (label) {
192
- default:
193
- case "raw":
194
- return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRaw$.pipe(csvBufferToEpoch(deviceInfo))));
195
- case "rawUnfiltered":
196
- return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRawUnfiltered$.pipe(csvBufferToEpoch(deviceInfo))));
197
- case "psd":
198
- return this._brainwavesPSD$;
199
- case "powerByBand":
200
- return this._brainwavesPowerByBand$;
201
- }
202
- }
203
- signalQuality() {
204
- return this._signalQuality$;
205
- }
206
- addMarker(label) {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- yield this.dispatchAction({
209
- action: "marker",
210
- command: "add",
211
- message: {
212
- timestamp: Date.now(),
213
- label
214
- }
215
- });
216
- });
217
- }
218
- getInfo() {
219
- return __awaiter(this, void 0, void 0, function* () {
220
- return yield this._withAuthentication(() => firstValueFrom(this.transport.subscribeToCharacteristic({
221
- characteristicName: "deviceInfo"
222
- })));
223
- });
224
- }
225
- status() {
226
- return this._status$;
227
- }
228
- dispatchAction(action) {
229
- return __awaiter(this, void 0, void 0, function* () {
230
- return yield this._withAuthentication(() => this.transport.dispatchAction({
231
- characteristicName: "actions",
232
- action
233
- }));
234
- });
235
- }
236
- settings() {
237
- return this._settings$;
238
- }
239
- haptics(effects) {
240
- const metric = "haptics";
241
- return this.dispatchAction({
242
- action: metric,
243
- command: "queue",
244
- responseRequired: true,
245
- responseTimeout: 4000,
246
- // @TODO: implement validation logic as per SDK
247
- message: { effects }
248
- });
249
- }
250
- get wifi() {
251
- return {
252
- nearbyNetworks: () => this._wifiNearbyNetworks$,
253
- connections: () => this._wifiConnections$,
254
- connect: (ssid, password) => {
255
- if (!ssid) {
256
- return Promise.reject(`Missing ssid`);
257
- }
258
- return this.dispatchAction({
259
- action: "wifi",
260
- command: "connect",
261
- responseRequired: true,
262
- responseTimeout: 1000 * 60 * 2,
263
- message: {
264
- ssid,
265
- password: password !== null && password !== void 0 ? password : null
266
- }
267
- });
268
- },
269
- forgetConnection: (ssid) => {
270
- if (!ssid) {
271
- return Promise.reject(`Missing ssid`);
272
- }
273
- return this.dispatchAction({
274
- action: "wifi",
275
- command: "forget-connection",
276
- responseRequired: true,
277
- responseTimeout: 1000 * 15,
278
- message: {
279
- ssid
280
- }
281
- });
282
- },
283
- reset: () => {
284
- return this.dispatchAction({
285
- action: "wifi",
286
- command: "reset",
287
- responseRequired: true,
288
- responseTimeout: 1000 * 30,
289
- message: {
290
- // without this, the action will resolve as soon as the
291
- // action is received by the OS
292
- respondOnSuccess: true
293
- }
294
- });
295
- },
296
- speedTest: () => {
297
- return this.dispatchAction({
298
- action: "wifi",
299
- command: "speed-test",
300
- responseRequired: true,
301
- responseTimeout: 1000 * 60 * 1 // 1 minute
302
- });
303
- }
304
- };
305
- }
306
- }
@@ -1,33 +0,0 @@
1
- import { Observable, Subject } from "rxjs";
2
- import { BLUETOOTH_CONNECTION, TRANSPORT_TYPE } from "./types";
3
- import { Action } from "../../types/actions";
4
- import { DeviceInfo } from "../../types/deviceInfo";
5
- import { Peripheral } from "./react-native/types/BleManagerTypes";
6
- export declare type DeviceNicknameOrPeripheral = string | Peripheral;
7
- /**
8
- * @hidden
9
- */
10
- export interface BluetoothTransport {
11
- type: TRANSPORT_TYPE;
12
- connect(deviceNicknameORPeripheral?: DeviceNicknameOrPeripheral): Promise<void>;
13
- _autoConnect(selectedDevice$: Observable<DeviceInfo>): Observable<void>;
14
- disconnect(): Promise<void>;
15
- connection(): Observable<BLUETOOTH_CONNECTION>;
16
- requestDevice?(): any;
17
- addLog: (log: string) => void;
18
- logs$: Subject<string>;
19
- enableAutoConnect?(value: boolean): void;
20
- scan?(options?: {
21
- seconds?: number;
22
- }): Observable<Peripheral[]>;
23
- subscribeToCharacteristic(args: {
24
- characteristicName: string;
25
- manageNotifications?: boolean;
26
- }): Observable<any>;
27
- readCharacteristic(characteristicName: string, parse?: boolean): Promise<any>;
28
- writeCharacteristic(characteristicName: string, data: string): Promise<void>;
29
- dispatchAction(args: {
30
- characteristicName: string;
31
- action: Action;
32
- }): Promise<any>;
33
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare const ANDROID_MAX_MTU: number;
2
- export declare const REACT_NATIVE_MAX_BYTE_SIZE: number;
3
- export declare const DEFAULT_ACTION_RESPONSE_TIMEOUT: number;
4
- export declare const CHARACTERISTIC_UUIDS_TO_NAMES: any;
@@ -1,6 +0,0 @@
1
- import { BLUETOOTH_CHARACTERISTICS } from "@neurosity/ipk";
2
- export const ANDROID_MAX_MTU = 512;
3
- export const REACT_NATIVE_MAX_BYTE_SIZE = 512; // the default is 20
4
- export const DEFAULT_ACTION_RESPONSE_TIMEOUT = 1000 * 60; // 1 minute
5
- // Reverse BLUETOOTH_CHARACTERISTICS key/values for easy lookup
6
- export const CHARACTERISTIC_UUIDS_TO_NAMES = Object.fromEntries(Object.entries(BLUETOOTH_CHARACTERISTICS).map((entries) => entries.reverse()));
@@ -1,4 +0,0 @@
1
- export * from "./BluetoothClient";
2
- export * from "./web/WebBluetoothTransport";
3
- export * from "./react-native/ReactNativeTransport";
4
- export * from "./utils/osHasBluetoothSupport";
@@ -1,4 +0,0 @@
1
- export * from "./BluetoothClient";
2
- export * from "./web/WebBluetoothTransport";
3
- export * from "./react-native/ReactNativeTransport";
4
- export * from "./utils/osHasBluetoothSupport";
@@ -1,70 +0,0 @@
1
- import { BehaviorSubject, ReplaySubject } from "rxjs";
2
- import { Observable } from "rxjs";
3
- import { BluetoothTransport } from "../BluetoothTransport";
4
- import { ActionOptions, SubscribeOptions } from "../types";
5
- import { TRANSPORT_TYPE, BLUETOOTH_CONNECTION } from "../types";
6
- import { BleManager } from "./types/BleManagerTypes";
7
- import { Peripheral } from "./types/BleManagerTypes";
8
- import { NativeEventEmitter } from "./types/ReactNativeTypes";
9
- import { PlatformOSType } from "./types/ReactNativeTypes";
10
- import { DeviceInfo } from "../../../types/deviceInfo";
11
- declare type Characteristic = {
12
- characteristicUUID: string;
13
- serviceUUID: string;
14
- peripheralId: string;
15
- };
16
- declare type CharacteristicsByName = {
17
- [name: string]: Characteristic;
18
- };
19
- declare type Options = {
20
- BleManager: BleManager;
21
- bleManagerEmitter: NativeEventEmitter;
22
- platform: PlatformOSType;
23
- autoConnect?: boolean;
24
- };
25
- declare type BleManagerEvents = {
26
- stopScan$: Observable<void>;
27
- discoverPeripheral$: Observable<Peripheral>;
28
- connectPeripheral$: Observable<void>;
29
- disconnectPeripheral$: Observable<void>;
30
- didUpdateValueForCharacteristic$: Observable<any>;
31
- didUpdateState$: Observable<any>;
32
- };
33
- export declare class ReactNativeTransport implements BluetoothTransport {
34
- type: TRANSPORT_TYPE;
35
- options: Options;
36
- BleManager: BleManager;
37
- bleManagerEmitter: NativeEventEmitter;
38
- platform: PlatformOSType;
39
- bleEvents: BleManagerEvents;
40
- device: Peripheral;
41
- characteristicsByName: CharacteristicsByName;
42
- connection$: BehaviorSubject<BLUETOOTH_CONNECTION>;
43
- pendingActions$: BehaviorSubject<any[]>;
44
- logs$: ReplaySubject<string>;
45
- onDisconnected$: Observable<void>;
46
- connectionStream$: Observable<BLUETOOTH_CONNECTION>;
47
- _isAutoConnectEnabled$: ReplaySubject<boolean>;
48
- constructor(options: Options);
49
- addLog(log: string): void;
50
- isConnected(): boolean;
51
- _autoConnect(selectedDevice$: Observable<DeviceInfo>): Observable<void>;
52
- enableAutoConnect(autoConnect: boolean): void;
53
- connection(): Observable<BLUETOOTH_CONNECTION>;
54
- _fromEvent(eventName: string): Observable<any>;
55
- scan(options?: {
56
- seconds?: number;
57
- once?: boolean;
58
- }): Observable<Peripheral[]>;
59
- connect(peripheral: Peripheral): Promise<void>;
60
- disconnect(): Promise<void>;
61
- getCharacteristicByName(characteristicName: string): Characteristic;
62
- subscribeToCharacteristic({ characteristicName, manageNotifications }: SubscribeOptions): Observable<any>;
63
- readCharacteristic(characteristicName: string, parse?: boolean): Promise<any>;
64
- writeCharacteristic(characteristicName: string, data: string): Promise<void>;
65
- _addPendingAction(actionId: number): void;
66
- _removePendingAction(actionId: number): void;
67
- _autoToggleActionNotifications(selectedDevice$: Observable<DeviceInfo>): Promise<void>;
68
- dispatchAction({ characteristicName, action }: ActionOptions): Promise<any>;
69
- }
70
- export {};