@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,70 @@
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.FirebaseApp = exports.SERVER_TIMESTAMP = void 0;
7
+ const app_1 = __importDefault(require("firebase/app"));
8
+ require("firebase/database");
9
+ require("firebase/auth");
10
+ require("firebase/functions");
11
+ require("firebase/firestore");
12
+ const config_1 = require("./config");
13
+ exports.SERVER_TIMESTAMP = app_1.default.database.ServerValue.TIMESTAMP;
14
+ /**
15
+ * @hidden
16
+ */
17
+ class FirebaseApp {
18
+ constructor(options) {
19
+ this.app = this.getApp(options.deviceId);
20
+ this.standalone = this.app.name === options.deviceId;
21
+ if (options.emulator) {
22
+ this.connectEmulators(options);
23
+ }
24
+ }
25
+ getApp(deviceId) {
26
+ const moduleApps = app_1.default.apps;
27
+ const browserApps = typeof window !== "undefined" &&
28
+ "firebase" in window &&
29
+ "apps" in window.firebase
30
+ ? window["firebase"]["apps"]
31
+ : [];
32
+ const neurosityApp = [...moduleApps, ...browserApps].find((app) => app.name === "[DEFAULT]" &&
33
+ app.options.databaseURL === config_1.config.databaseURL);
34
+ if (neurosityApp) {
35
+ return neurosityApp;
36
+ }
37
+ if (deviceId) {
38
+ const neurosityAppName = deviceId;
39
+ const neurosityApp = moduleApps.find((app) => app.name === neurosityAppName);
40
+ return neurosityApp
41
+ ? neurosityApp
42
+ : app_1.default.initializeApp(config_1.config, neurosityAppName);
43
+ }
44
+ return app_1.default.initializeApp(config_1.config);
45
+ }
46
+ connectEmulators(options) {
47
+ const { emulatorHost, emulatorAuthPort, emulatorDatabasePort, emulatorFunctionsPort, emulatorFirestorePort, emulatorOptions } = options;
48
+ this.app.auth().useEmulator(`http://${emulatorHost}:${emulatorAuthPort}`);
49
+ this.app
50
+ .database()
51
+ .useEmulator(emulatorHost, emulatorDatabasePort, emulatorOptions);
52
+ this.app.functions().useEmulator(emulatorHost, emulatorFunctionsPort);
53
+ this.app
54
+ .firestore()
55
+ .useEmulator(emulatorHost, emulatorFirestorePort, emulatorOptions);
56
+ }
57
+ goOnline() {
58
+ this.app.database().goOnline();
59
+ }
60
+ goOffline() {
61
+ this.app.database().goOffline();
62
+ }
63
+ disconnect() {
64
+ if (this.standalone) {
65
+ return this.app.delete();
66
+ }
67
+ return Promise.resolve();
68
+ }
69
+ }
70
+ exports.FirebaseApp = FirebaseApp;
@@ -1,7 +1,7 @@
1
1
  import firebase from "firebase/app";
2
2
  import { FirebaseApp } from "./FirebaseApp";
3
3
  import { SDKDependencies } from "../../types/options";
4
- type FirebaseDeviceOptions = {
4
+ declare type FirebaseDeviceOptions = {
5
5
  deviceId: string;
6
6
  firebaseApp: FirebaseApp;
7
7
  dependencies: SDKDependencies;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FirebaseDevice = void 0;
16
+ const app_1 = __importDefault(require("firebase/app"));
17
+ const deviceStore_1 = require("./deviceStore");
18
+ const SERVER_TIMESTAMP = app_1.default.database.ServerValue.TIMESTAMP;
19
+ /**
20
+ * @hidden
21
+ */
22
+ class FirebaseDevice {
23
+ constructor({ deviceId, firebaseApp, dependencies }) {
24
+ if (!deviceId) {
25
+ throw new Error(`No Device ID provided.`);
26
+ }
27
+ this.deviceId = deviceId;
28
+ this.app = firebaseApp.app;
29
+ this.deviceStore = (0, deviceStore_1.createDeviceStore)(this.app, deviceId, dependencies.subscriptionManager);
30
+ }
31
+ get timestamp() {
32
+ return SERVER_TIMESTAMP;
33
+ }
34
+ dispatchAction(action) {
35
+ return this.deviceStore.dispatchAction(action);
36
+ }
37
+ getInfo() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return yield this.deviceStore.once("info");
40
+ });
41
+ }
42
+ onNamespace(namespace, callback) {
43
+ return this.deviceStore.onNamespace(namespace, callback);
44
+ }
45
+ onceNamespace(namespace) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ return yield this.deviceStore.once(namespace);
48
+ });
49
+ }
50
+ offNamespace(namespace, listener) {
51
+ this.deviceStore.offNamespace(namespace, listener);
52
+ }
53
+ getTimesync() {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const response = yield this.dispatchAction({
56
+ command: "timesync",
57
+ action: "get",
58
+ responseRequired: true,
59
+ responseTimeout: 250
60
+ });
61
+ return response.timestamp;
62
+ });
63
+ }
64
+ /**
65
+ * Pushes metric for each subscriptions in path:
66
+ * /devices/:deviceId/metrics/:metricName
67
+ */
68
+ nextMetric(metricName, metricValue) {
69
+ this.deviceStore.nextMetric(metricName, metricValue);
70
+ }
71
+ /**
72
+ * Listens for metrics in path:
73
+ * /devices/:deviceId/metrics/:metricName
74
+ */
75
+ onMetric(subscription, callback) {
76
+ return this.deviceStore.onMetric(subscription, callback);
77
+ }
78
+ /**
79
+ * Creates a new and unique subscription in path:
80
+ * /devices/:deviceId/subscriptions/:subscriptionId
81
+ * E.g. /devices/device1/subscriptions/subscription3
82
+ *
83
+ * @param subscription
84
+ * @returns subscriptionId
85
+ */
86
+ subscribeToMetric(subscription) {
87
+ const subscriptionId = this.deviceStore.subscribeToMetric(Object.assign(Object.assign({}, subscription), { serverType: FirebaseDevice.serverType // @deprecated
88
+ }));
89
+ return subscriptionId;
90
+ }
91
+ /**
92
+ * Removes subscription in path:
93
+ * /devices/:deviceId/subscriptions/:subscriptionId
94
+ *
95
+ * @param subscription
96
+ */
97
+ unsubscribeFromMetric(subscription) {
98
+ this.deviceStore.unsubscribeFromMetric(subscription);
99
+ }
100
+ /**
101
+ * Removes metric listener
102
+ * /devices/:deviceId/metric
103
+ * or
104
+ * /devices/:deviceId/metric/label
105
+ *
106
+ * @param subscription
107
+ * @param listener
108
+ */
109
+ removeMetricListener(subscription, listener) {
110
+ this.deviceStore.removeMetricListener(subscription, listener);
111
+ }
112
+ changeSettings(settings) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ return this.deviceStore.update("settings", settings);
115
+ });
116
+ }
117
+ getSkill(bundleId) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ return yield this.deviceStore.lastOfChildValue("skills", "bundleId", bundleId);
120
+ });
121
+ }
122
+ createBluetoothToken() {
123
+ var _a;
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const [error, token] = yield this.app
126
+ .functions()
127
+ .httpsCallable("createBluetoothToken")({
128
+ deviceId: this.deviceId
129
+ })
130
+ .then(({ data }) => [null, data === null || data === void 0 ? void 0 : data.token])
131
+ .catch((error) => [error, null]);
132
+ if (error) {
133
+ return Promise.reject((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error);
134
+ }
135
+ if (!token) {
136
+ return Promise.reject(`Failed to create Bluetooth token.`);
137
+ }
138
+ return token;
139
+ });
140
+ }
141
+ disconnect() {
142
+ this.deviceStore.disconnect();
143
+ }
144
+ }
145
+ exports.FirebaseDevice = FirebaseDevice;
146
+ FirebaseDevice.serverType = "firebase";
File without changes
@@ -0,0 +1,434 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FirebaseUser = exports.createUser = exports.credentialWithLink = void 0;
16
+ const rxjs_1 = require("rxjs");
17
+ const operators_1 = require("rxjs/operators");
18
+ const app_1 = __importDefault(require("firebase/app"));
19
+ const SERVER_TIMESTAMP = app_1.default.database.ServerValue.TIMESTAMP;
20
+ /**
21
+ * @hidden
22
+ */
23
+ exports.credentialWithLink = app_1.default.auth.EmailAuthProvider.credentialWithLink;
24
+ /**
25
+ * @hidden
26
+ */
27
+ function createUser(...args) {
28
+ return new app_1.default.User(...args);
29
+ }
30
+ exports.createUser = createUser;
31
+ /**
32
+ * @hidden
33
+ */
34
+ class FirebaseUser {
35
+ constructor(firebaseApp) {
36
+ this.app = firebaseApp.app;
37
+ this.app.auth().onAuthStateChanged((user) => {
38
+ this.user = user;
39
+ });
40
+ }
41
+ auth() {
42
+ return this.app.auth();
43
+ }
44
+ createAccount(credentials) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const { email, password } = credentials;
47
+ const [error, user] = yield this.app
48
+ .auth()
49
+ .createUserWithEmailAndPassword(email, password)
50
+ .then((user) => [null, user])
51
+ .catch((error) => [error, null]);
52
+ if (error) {
53
+ return Promise.reject(error);
54
+ }
55
+ return user;
56
+ });
57
+ }
58
+ deleteAccount() {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const user = this.app.auth().currentUser;
61
+ if (!user) {
62
+ return Promise.reject(new Error(`You are trying to delete an account that is not authenticated. To delete an account, the account must have signed in recently.`));
63
+ }
64
+ const [devicesError, devices] = yield this.getDevices()
65
+ .then((response) => [null, response])
66
+ .catch((error) => [error, null]);
67
+ if (devicesError) {
68
+ return Promise.reject(devicesError);
69
+ }
70
+ if (devices.length) {
71
+ const removeDeviceError = yield Promise.all(devices.map((device) => this.removeDevice(device.deviceId)))
72
+ .then(() => null)
73
+ .catch((error) => error);
74
+ if (removeDeviceError) {
75
+ return Promise.reject(removeDeviceError);
76
+ }
77
+ }
78
+ return user.delete();
79
+ });
80
+ }
81
+ onAuthStateChanged() {
82
+ return new rxjs_1.Observable((subscriber) => {
83
+ try {
84
+ this.app.auth().onAuthStateChanged((user) => {
85
+ subscriber.next(user);
86
+ }, (error) => {
87
+ subscriber.error(error);
88
+ });
89
+ }
90
+ catch (error) {
91
+ subscriber.error(error);
92
+ }
93
+ });
94
+ }
95
+ onLogin() {
96
+ return new rxjs_1.Observable((subscriber) => {
97
+ const unsubscribe = this.app
98
+ .auth()
99
+ .onAuthStateChanged((user) => {
100
+ if (!!user) {
101
+ subscriber.next(user);
102
+ subscriber.complete();
103
+ }
104
+ });
105
+ return () => unsubscribe();
106
+ });
107
+ }
108
+ login(credentials) {
109
+ if ("customToken" in credentials) {
110
+ const { customToken } = credentials;
111
+ return this.app.auth().signInWithCustomToken(customToken);
112
+ }
113
+ if ("idToken" in credentials && "providerId" in credentials) {
114
+ const provider = new app_1.default.auth.OAuthProvider(credentials.providerId);
115
+ const oAuthCredential = provider.credential(credentials.idToken);
116
+ return this.app.auth().signInWithCredential(oAuthCredential);
117
+ }
118
+ if ("email" in credentials && "password" in credentials) {
119
+ const { email, password } = credentials;
120
+ return this.app
121
+ .auth()
122
+ .signInWithEmailAndPassword(email, password);
123
+ }
124
+ throw new Error(`Either {email,password}, {customToken}, or {idToken,providerId} is required`);
125
+ }
126
+ logout() {
127
+ return this.app.auth().signOut();
128
+ }
129
+ createCustomToken() {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const [error, customToken] = yield this.app
132
+ .functions()
133
+ .httpsCallable("createCustomToken")()
134
+ .then(({ data }) => [null, data])
135
+ .catch((error) => [error, null]);
136
+ if (error) {
137
+ return Promise.reject(error);
138
+ }
139
+ return customToken;
140
+ });
141
+ }
142
+ removeOAuthAccess() {
143
+ var _a;
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const userId = (_a = this.user) === null || _a === void 0 ? void 0 : _a.uid;
146
+ if (!userId) {
147
+ return Promise.reject(`OAuth access can only be removed while logged in via OAuth.`);
148
+ }
149
+ const [error, response] = yield this.app
150
+ .functions()
151
+ .httpsCallable("removeAccessOAuthApp")()
152
+ .then(({ data }) => [null, data])
153
+ .catch((error) => [error, null]);
154
+ if (error) {
155
+ return Promise.reject(error);
156
+ }
157
+ const logoutError = yield this.logout()
158
+ .then(() => false)
159
+ .catch((error) => error);
160
+ if (logoutError) {
161
+ return Promise.reject(logoutError);
162
+ }
163
+ return response;
164
+ });
165
+ }
166
+ getDevices() {
167
+ var _a;
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ const userId = (_a = this.user) === null || _a === void 0 ? void 0 : _a.uid;
170
+ if (!userId) {
171
+ return Promise.reject(`Please login.`);
172
+ }
173
+ const snapshot = yield this.app
174
+ .database()
175
+ .ref(this.getUserDevicesPath())
176
+ .once("value");
177
+ const userDevices = snapshot.val();
178
+ return this.userDevicesToDeviceInfoList(userDevices);
179
+ });
180
+ }
181
+ addDevice(deviceId) {
182
+ var _a;
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ const userId = (_a = this.user) === null || _a === void 0 ? void 0 : _a.uid;
185
+ if (!userId) {
186
+ return Promise.reject(`Please login.`);
187
+ }
188
+ const devices = yield this.getDevices().catch((error) => {
189
+ console.log(error);
190
+ });
191
+ const deviceAlreadyInAccount = devices &&
192
+ devices.length &&
193
+ devices.map(({ deviceId }) => deviceId).includes(deviceId);
194
+ if (deviceAlreadyInAccount) {
195
+ return Promise.reject(`The device is already added to this account.`);
196
+ }
197
+ const [isValid, invalidErrorMessage] = yield this.isDeviceIdValid(deviceId)
198
+ .then((isValid) => [isValid])
199
+ .catch((error) => [false, error]);
200
+ if (!isValid) {
201
+ return Promise.reject(invalidErrorMessage);
202
+ }
203
+ const claimedByPath = this.getDeviceClaimedByPath(deviceId);
204
+ const userDevicePath = this.getUserClaimedDevicePath(deviceId);
205
+ const [hasError, errorMessage] = yield this.app
206
+ .database()
207
+ .ref()
208
+ .update({
209
+ [claimedByPath]: userId,
210
+ [userDevicePath]: {
211
+ claimedOn: SERVER_TIMESTAMP
212
+ }
213
+ })
214
+ .then(() => [false])
215
+ .catch((error) => [true, error]);
216
+ if (hasError) {
217
+ return Promise.reject(errorMessage);
218
+ }
219
+ });
220
+ }
221
+ removeDevice(deviceId) {
222
+ var _a;
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ const userId = (_a = this.user) === null || _a === void 0 ? void 0 : _a.uid;
225
+ if (!userId) {
226
+ return Promise.reject(`Please login.`);
227
+ }
228
+ const claimedByPath = this.getDeviceClaimedByPath(deviceId);
229
+ const userDevicePath = this.getUserClaimedDevicePath(deviceId);
230
+ const claimedByRef = this.app.database().ref(claimedByPath);
231
+ const userDeviceRef = this.app.database().ref(userDevicePath);
232
+ const [hasError, errorMessage] = yield Promise.all([
233
+ claimedByRef.remove(),
234
+ userDeviceRef.remove()
235
+ ])
236
+ .then(() => [false])
237
+ .catch((error) => [true, error]);
238
+ if (hasError) {
239
+ return Promise.reject(errorMessage);
240
+ }
241
+ });
242
+ }
243
+ transferDevice(options) {
244
+ var _a;
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ const userId = (_a = this.user) === null || _a === void 0 ? void 0 : _a.uid;
247
+ if (!userId) {
248
+ return Promise.reject(new Error(`transferDevice: auth is required.`));
249
+ }
250
+ if (!("recipientsEmail" in options) &&
251
+ !("recipientsUserId" in options)) {
252
+ return Promise.reject(new Error(`transferDevice: either 'recipientsEmail' or 'recipientsUserId' key is required.`));
253
+ }
254
+ if (!(options === null || options === void 0 ? void 0 : options.deviceId)) {
255
+ return Promise.reject(new Error(`transferDevice: a deviceId is required.`));
256
+ }
257
+ const [error, response] = yield this.app
258
+ .functions()
259
+ .httpsCallable("transferDeviceOwnership")(options)
260
+ .then(({ data }) => [null, data])
261
+ .catch((error) => [error, null]);
262
+ if (error) {
263
+ return Promise.reject(error);
264
+ }
265
+ });
266
+ }
267
+ isDeviceIdValid(deviceId) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ // hex string of 32 characters
270
+ const hexRegEx = /[0-9A-Fa-f]{32}/g;
271
+ if (!deviceId ||
272
+ deviceId.length !== 32 ||
273
+ !hexRegEx.test(deviceId)) {
274
+ return Promise.reject("The device id is incorrectly formatted.");
275
+ }
276
+ const claimedByPath = this.getDeviceClaimedByPath(deviceId);
277
+ const claimedByRef = this.app.database().ref(claimedByPath);
278
+ const claimedBySnapshot = yield claimedByRef
279
+ .once("value")
280
+ .catch(() => null);
281
+ if (!claimedBySnapshot || claimedBySnapshot.exists()) {
282
+ return Promise.reject("The device has already been claimed.");
283
+ }
284
+ return true;
285
+ });
286
+ }
287
+ onUserDevicesChange() {
288
+ return this.onAuthStateChanged().pipe((0, operators_1.switchMap)((user) => {
289
+ if (!user) {
290
+ return rxjs_1.EMPTY;
291
+ }
292
+ const userDevicesPath = this.getUserDevicesPath();
293
+ const userDevicesRef = this.app.database().ref(userDevicesPath);
294
+ return (0, rxjs_1.fromEventPattern)((handler) => userDevicesRef.on("value", handler), (handler) => userDevicesRef.off("value", handler)).pipe((0, operators_1.map)(([snapshot]) => snapshot.val()), (0, operators_1.switchMap)((userDevices) => {
295
+ return (0, rxjs_1.from)(this.userDevicesToDeviceInfoList(userDevices));
296
+ }));
297
+ }));
298
+ }
299
+ onUserClaimsChange() {
300
+ return this.onAuthStateChanged().pipe((0, operators_1.switchMap)((user) => {
301
+ if (!user) {
302
+ return rxjs_1.EMPTY;
303
+ }
304
+ const claimsUpdatedOnPath = this.getUserClaimsUpdatedOnPath();
305
+ const claimsUpdatedOnRef = this.app
306
+ .database()
307
+ .ref(claimsUpdatedOnPath);
308
+ return (0, rxjs_1.fromEventPattern)((handler) => claimsUpdatedOnRef.on("value", handler), (handler) => claimsUpdatedOnRef.off("value", handler)).pipe((0, operators_1.map)(([snapshot]) => snapshot.val()), (0, operators_1.switchMap)(() => {
309
+ // Force refresh of auth id token
310
+ return (0, rxjs_1.from)(this.getIdToken(true)).pipe((0, operators_1.switchMap)(() => (0, rxjs_1.from)(this.getClaims())));
311
+ }));
312
+ }));
313
+ }
314
+ getIdToken(forceRefresh = false) {
315
+ var _a;
316
+ return __awaiter(this, void 0, void 0, function* () {
317
+ const user = (_a = this.app.auth()) === null || _a === void 0 ? void 0 : _a.currentUser;
318
+ if (!user) {
319
+ return Promise.reject(`getUserIdToken: unable to get currentUser`);
320
+ }
321
+ yield user.getIdToken(forceRefresh).catch((error) => {
322
+ console.error(error);
323
+ });
324
+ });
325
+ }
326
+ getClaims() {
327
+ var _a;
328
+ const user = (_a = this.app.auth()) === null || _a === void 0 ? void 0 : _a.currentUser;
329
+ if (!user) {
330
+ return Promise.reject(`getUserClaims: unable to get currentUser`);
331
+ }
332
+ return user
333
+ .getIdTokenResult()
334
+ .then((token) => token.claims)
335
+ .catch((error) => {
336
+ console.error(error);
337
+ return null;
338
+ });
339
+ }
340
+ userDevicesToDeviceInfoList(userDevices) {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ const devicesInfoSnapshots = Object.keys(userDevices !== null && userDevices !== void 0 ? userDevices : {}).map((deviceId) => this.app
343
+ .database()
344
+ .ref(this.getDeviceInfoPath(deviceId))
345
+ .once("value"));
346
+ const devicesList = yield Promise.all(devicesInfoSnapshots).then((snapshots) => snapshots.map((snapshot) => snapshot.val()));
347
+ const validDevices = devicesList.filter((device) => !!device);
348
+ validDevices.sort((a, b) => {
349
+ return (userDevices[a.deviceId].claimedOn -
350
+ userDevices[b.deviceId].claimedOn);
351
+ });
352
+ return validDevices;
353
+ });
354
+ }
355
+ hasDevicePermission(deviceId) {
356
+ return __awaiter(this, void 0, void 0, function* () {
357
+ const deviceInfoPath = this.getDeviceInfoPath(deviceId);
358
+ const hasPermission = yield this.app
359
+ .database()
360
+ .ref(deviceInfoPath)
361
+ .once("value")
362
+ .then(() => true)
363
+ .catch(() => false);
364
+ return hasPermission;
365
+ });
366
+ }
367
+ getDeviceClaimedByPath(deviceId) {
368
+ return `devices/${deviceId}/status/claimedBy`;
369
+ }
370
+ getUserClaimedDevicePath(deviceId) {
371
+ const userId = this.user.uid;
372
+ return `users/${userId}/devices/${deviceId}`;
373
+ }
374
+ getUserDevicesPath() {
375
+ const userId = this.user.uid;
376
+ return `users/${userId}/devices`;
377
+ }
378
+ getUserClaimsUpdatedOnPath() {
379
+ const userId = this.user.uid;
380
+ return `users/${userId}/claimsUpdatedOn`;
381
+ }
382
+ getDeviceInfoPath(deviceId) {
383
+ return `devices/${deviceId}/info`;
384
+ }
385
+ onUserExperiments() {
386
+ return this.onAuthStateChanged().pipe((0, operators_1.switchMap)((user) => {
387
+ if (!user) {
388
+ return rxjs_1.EMPTY;
389
+ }
390
+ const userId = this.user.uid;
391
+ const userExperimentsRef = this.app
392
+ .database()
393
+ .ref("experiments")
394
+ .orderByChild("userId")
395
+ .equalTo(userId)
396
+ .limitToFirst(100);
397
+ return (0, rxjs_1.fromEventPattern)((handler) => userExperimentsRef.on("value", handler), (handler) => userExperimentsRef.off("value", handler)).pipe((0, operators_1.map)(([snapshot]) => snapshot.val()),
398
+ // transform experiments map into sorted list
399
+ (0, operators_1.map)((experimentsMaps) => {
400
+ return Object.entries(experimentsMaps !== null && experimentsMaps !== void 0 ? experimentsMaps : {})
401
+ .map(([id, value]) => {
402
+ var _a;
403
+ return (Object.assign({ id: (_a = value === null || value === void 0 ? void 0 : value.id) !== null && _a !== void 0 ? _a : id }, value));
404
+ })
405
+ .sort((a, b) => new Date(b === null || b === void 0 ? void 0 : b.timestamp).getTime() -
406
+ new Date(a === null || a === void 0 ? void 0 : a.timestamp).getTime());
407
+ }));
408
+ }));
409
+ }
410
+ deleteUserExperiment(experimentId) {
411
+ return __awaiter(this, void 0, void 0, function* () {
412
+ if (!experimentId) {
413
+ return Promise.reject(`deleteUserExperiment: please provide an experiment id`);
414
+ }
415
+ const removeExperiment = (experimentId) => {
416
+ return this.app
417
+ .database()
418
+ .ref("experiments")
419
+ .child(experimentId)
420
+ .remove();
421
+ };
422
+ const removeRelations = (experimentId) => {
423
+ return this.app.functions().httpsCallable("removeRelations")({
424
+ experimentId
425
+ });
426
+ };
427
+ yield Promise.all([
428
+ removeExperiment(experimentId),
429
+ removeRelations(experimentId)
430
+ ]).catch(() => { });
431
+ });
432
+ }
433
+ }
434
+ exports.FirebaseUser = FirebaseUser;
File without changes
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ exports.config = {
5
+ apiKey: "AIzaSyB0TkZ83Fj0CIzn8AAmE-Osc92s3ER8hy8",
6
+ authDomain: "neurosity-device.firebaseapp.com",
7
+ databaseURL: "https://neurosity-device.firebaseio.com",
8
+ projectId: "neurosity-device",
9
+ storageBucket: "neurosity-device.appspot.com",
10
+ messagingSenderId: "212595049674"
11
+ };
File without changes