@neurosity/sdk 6.0.0-next.11

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 (312) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/dist/browser/neurosity.iife.js +48736 -0
  4. package/dist/browser/neurosity.js +672 -0
  5. package/dist/browser/neurosity.js.map +1 -0
  6. package/dist/cjs/Notion.d.ts +619 -0
  7. package/dist/cjs/Notion.js +1291 -0
  8. package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +59 -0
  9. package/dist/cjs/api/bluetooth/BluetoothClient.js +287 -0
  10. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +32 -0
  11. package/dist/cjs/api/bluetooth/BluetoothTransport.js +2 -0
  12. package/dist/cjs/api/bluetooth/constants.d.ts +4 -0
  13. package/dist/cjs/api/bluetooth/constants.js +9 -0
  14. package/dist/cjs/api/bluetooth/index.d.ts +4 -0
  15. package/dist/cjs/api/bluetooth/index.js +20 -0
  16. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
  17. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +386 -0
  18. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  19. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +11 -0
  20. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  21. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +10 -0
  22. package/dist/cjs/api/bluetooth/types/index.d.ts +31 -0
  23. package/dist/cjs/api/bluetooth/types/index.js +22 -0
  24. package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
  25. package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +8 -0
  26. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
  27. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +36 -0
  28. package/dist/cjs/api/bluetooth/utils/encoding.d.ts +3 -0
  29. package/dist/cjs/api/bluetooth/utils/encoding.js +22 -0
  30. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
  31. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +23 -0
  32. package/dist/cjs/api/bluetooth/utils/stitch.d.ts +5 -0
  33. package/dist/cjs/api/bluetooth/utils/stitch.js +22 -0
  34. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
  35. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +412 -0
  36. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
  37. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +8 -0
  38. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
  39. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +11 -0
  40. package/dist/cjs/api/firebase/FirebaseApp.d.ts +20 -0
  41. package/dist/cjs/api/firebase/FirebaseApp.js +70 -0
  42. package/dist/cjs/api/firebase/FirebaseDevice.d.ts +68 -0
  43. package/dist/cjs/api/firebase/FirebaseDevice.js +146 -0
  44. package/dist/cjs/api/firebase/FirebaseUser.d.ts +53 -0
  45. package/dist/cjs/api/firebase/FirebaseUser.js +434 -0
  46. package/dist/cjs/api/firebase/config.d.ts +8 -0
  47. package/dist/cjs/api/firebase/config.js +11 -0
  48. package/dist/cjs/api/firebase/deviceStore.d.ts +26 -0
  49. package/dist/cjs/api/firebase/deviceStore.js +191 -0
  50. package/dist/cjs/api/firebase/index.d.ts +3 -0
  51. package/dist/cjs/api/firebase/index.js +19 -0
  52. package/dist/cjs/api/https/config.d.ts +1 -0
  53. package/dist/cjs/api/https/config.js +4 -0
  54. package/dist/cjs/api/https/createOAuthURL.d.ts +3 -0
  55. package/dist/cjs/api/https/createOAuthURL.js +18 -0
  56. package/dist/cjs/api/https/getOAuthToken.d.ts +3 -0
  57. package/dist/cjs/api/https/getOAuthToken.js +34 -0
  58. package/dist/cjs/api/https/utils.d.ts +2 -0
  59. package/dist/cjs/api/https/utils.js +13 -0
  60. package/dist/cjs/api/index.d.ts +108 -0
  61. package/dist/cjs/api/index.js +306 -0
  62. package/dist/cjs/index.d.ts +3 -0
  63. package/dist/cjs/index.js +19 -0
  64. package/dist/cjs/skills/NotionOnDevice.d.ts +7 -0
  65. package/dist/cjs/skills/NotionOnDevice.js +25 -0
  66. package/dist/cjs/skills/createSkill.d.ts +7 -0
  67. package/dist/cjs/skills/createSkill.js +40 -0
  68. package/dist/cjs/skills/index.d.ts +2 -0
  69. package/dist/cjs/skills/index.js +18 -0
  70. package/dist/cjs/subscriptions/SubscriptionManager.d.ts +11 -0
  71. package/dist/cjs/subscriptions/SubscriptionManager.js +27 -0
  72. package/dist/cjs/timesync/Timesync.d.ts +20 -0
  73. package/dist/cjs/timesync/Timesync.js +78 -0
  74. package/dist/cjs/timesync/index.d.ts +1 -0
  75. package/dist/cjs/timesync/index.js +17 -0
  76. package/dist/cjs/types/accelerometer.d.ts +10 -0
  77. package/dist/cjs/types/accelerometer.js +2 -0
  78. package/dist/cjs/types/actions.d.ts +16 -0
  79. package/dist/cjs/types/actions.js +2 -0
  80. package/dist/cjs/types/awareness.d.ts +1 -0
  81. package/dist/cjs/types/awareness.js +2 -0
  82. package/dist/cjs/types/brainwaves.d.ts +26 -0
  83. package/dist/cjs/types/brainwaves.js +2 -0
  84. package/dist/cjs/types/calm.d.ts +6 -0
  85. package/dist/cjs/types/calm.js +2 -0
  86. package/dist/cjs/types/client.d.ts +22 -0
  87. package/dist/cjs/types/client.js +2 -0
  88. package/dist/cjs/types/credentials.d.ts +12 -0
  89. package/dist/cjs/types/credentials.js +2 -0
  90. package/dist/cjs/types/deviceInfo.d.ts +18 -0
  91. package/dist/cjs/types/deviceInfo.js +2 -0
  92. package/dist/cjs/types/epoch.d.ts +12 -0
  93. package/dist/cjs/types/epoch.js +2 -0
  94. package/dist/cjs/types/experiment.d.ts +9 -0
  95. package/dist/cjs/types/experiment.js +2 -0
  96. package/dist/cjs/types/focus.d.ts +6 -0
  97. package/dist/cjs/types/focus.js +2 -0
  98. package/dist/cjs/types/hapticEffects.d.ts +125 -0
  99. package/dist/cjs/types/hapticEffects.js +2 -0
  100. package/dist/cjs/types/kinesis.d.ts +6 -0
  101. package/dist/cjs/types/kinesis.js +2 -0
  102. package/dist/cjs/types/marker.d.ts +7 -0
  103. package/dist/cjs/types/marker.js +2 -0
  104. package/dist/cjs/types/metrics.d.ts +21 -0
  105. package/dist/cjs/types/metrics.js +2 -0
  106. package/dist/cjs/types/oauth.d.ts +20 -0
  107. package/dist/cjs/types/oauth.js +2 -0
  108. package/dist/cjs/types/options.d.ts +51 -0
  109. package/dist/cjs/types/options.js +2 -0
  110. package/dist/cjs/types/sample.d.ts +15 -0
  111. package/dist/cjs/types/sample.js +2 -0
  112. package/dist/cjs/types/settings.d.ts +13 -0
  113. package/dist/cjs/types/settings.js +2 -0
  114. package/dist/cjs/types/signalQuality.d.ts +13 -0
  115. package/dist/cjs/types/signalQuality.js +2 -0
  116. package/dist/cjs/types/skill.d.ts +68 -0
  117. package/dist/cjs/types/skill.js +2 -0
  118. package/dist/cjs/types/status.d.ts +26 -0
  119. package/dist/cjs/types/status.js +22 -0
  120. package/dist/cjs/types/streaming.d.ts +15 -0
  121. package/dist/cjs/types/streaming.js +20 -0
  122. package/dist/cjs/types/subscriptions.d.ts +23 -0
  123. package/dist/cjs/types/subscriptions.js +2 -0
  124. package/dist/cjs/types/training.d.ts +19 -0
  125. package/dist/cjs/types/training.js +2 -0
  126. package/dist/cjs/types/user.d.ts +12 -0
  127. package/dist/cjs/types/user.js +2 -0
  128. package/dist/cjs/utils/errors.d.ts +5 -0
  129. package/dist/cjs/utils/errors.js +17 -0
  130. package/dist/cjs/utils/filterInternalKeys.d.ts +3 -0
  131. package/dist/cjs/utils/filterInternalKeys.js +21 -0
  132. package/dist/cjs/utils/hapticEffects.d.ts +123 -0
  133. package/dist/cjs/utils/hapticEffects.js +130 -0
  134. package/dist/cjs/utils/heartbeat.d.ts +4 -0
  135. package/dist/cjs/utils/heartbeat.js +34 -0
  136. package/dist/cjs/utils/is-node.d.ts +1 -0
  137. package/dist/cjs/utils/is-node.js +9 -0
  138. package/dist/cjs/utils/metrics.d.ts +1 -0
  139. package/dist/cjs/utils/metrics.js +56 -0
  140. package/dist/cjs/utils/oauth.d.ts +9 -0
  141. package/dist/cjs/utils/oauth.js +92 -0
  142. package/dist/cjs/utils/pick.d.ts +1 -0
  143. package/dist/cjs/utils/pick.js +5 -0
  144. package/dist/cjs/utils/pipes.d.ts +46 -0
  145. package/dist/cjs/utils/pipes.js +71 -0
  146. package/dist/cjs/utils/platform.d.ts +30 -0
  147. package/dist/cjs/utils/platform.js +47 -0
  148. package/dist/cjs/utils/subscription.d.ts +6 -0
  149. package/dist/cjs/utils/subscription.js +55 -0
  150. package/dist/cjs/utils/transferDevice.d.ts +9 -0
  151. package/dist/cjs/utils/transferDevice.js +2 -0
  152. package/dist/cjs/utils/whileOnline.d.ts +8 -0
  153. package/dist/cjs/utils/whileOnline.js +15 -0
  154. package/dist/electron/index.js +92 -0
  155. package/dist/electron/index.js.map +1 -0
  156. package/dist/esm/Notion.d.ts +619 -0
  157. package/dist/esm/Notion.js +1260 -0
  158. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +59 -0
  159. package/dist/esm/api/bluetooth/BluetoothClient.js +283 -0
  160. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +32 -0
  161. package/dist/esm/api/bluetooth/BluetoothTransport.js +1 -0
  162. package/dist/esm/api/bluetooth/constants.d.ts +4 -0
  163. package/dist/esm/api/bluetooth/constants.js +6 -0
  164. package/dist/esm/api/bluetooth/index.d.ts +4 -0
  165. package/dist/esm/api/bluetooth/index.js +4 -0
  166. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
  167. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +382 -0
  168. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  169. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +8 -0
  170. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  171. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +9 -0
  172. package/dist/esm/api/bluetooth/types/index.d.ts +31 -0
  173. package/dist/esm/api/bluetooth/types/index.js +19 -0
  174. package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
  175. package/dist/esm/api/bluetooth/utils/create6DigitPin.js +4 -0
  176. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
  177. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +31 -0
  178. package/dist/esm/api/bluetooth/utils/encoding.d.ts +3 -0
  179. package/dist/esm/api/bluetooth/utils/encoding.js +17 -0
  180. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
  181. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +16 -0
  182. package/dist/esm/api/bluetooth/utils/stitch.d.ts +5 -0
  183. package/dist/esm/api/bluetooth/utils/stitch.js +18 -0
  184. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
  185. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +408 -0
  186. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
  187. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +4 -0
  188. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
  189. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +7 -0
  190. package/dist/esm/api/firebase/FirebaseApp.d.ts +20 -0
  191. package/dist/esm/api/firebase/FirebaseApp.js +63 -0
  192. package/dist/esm/api/firebase/FirebaseDevice.d.ts +68 -0
  193. package/dist/esm/api/firebase/FirebaseDevice.js +139 -0
  194. package/dist/esm/api/firebase/FirebaseUser.d.ts +53 -0
  195. package/dist/esm/api/firebase/FirebaseUser.js +426 -0
  196. package/dist/esm/api/firebase/config.d.ts +8 -0
  197. package/dist/esm/api/firebase/config.js +8 -0
  198. package/dist/esm/api/firebase/deviceStore.d.ts +26 -0
  199. package/dist/esm/api/firebase/deviceStore.js +184 -0
  200. package/dist/esm/api/firebase/index.d.ts +3 -0
  201. package/dist/esm/api/firebase/index.js +3 -0
  202. package/dist/esm/api/https/config.d.ts +1 -0
  203. package/dist/esm/api/https/config.js +1 -0
  204. package/dist/esm/api/https/createOAuthURL.d.ts +3 -0
  205. package/dist/esm/api/https/createOAuthURL.js +11 -0
  206. package/dist/esm/api/https/getOAuthToken.d.ts +3 -0
  207. package/dist/esm/api/https/getOAuthToken.js +27 -0
  208. package/dist/esm/api/https/utils.d.ts +2 -0
  209. package/dist/esm/api/https/utils.js +9 -0
  210. package/dist/esm/api/index.d.ts +108 -0
  211. package/dist/esm/api/index.js +299 -0
  212. package/dist/esm/index.d.ts +3 -0
  213. package/dist/esm/index.js +3 -0
  214. package/dist/esm/neurosity.mjs +48722 -0
  215. package/dist/esm/skills/NotionOnDevice.d.ts +7 -0
  216. package/dist/esm/skills/NotionOnDevice.js +21 -0
  217. package/dist/esm/skills/createSkill.d.ts +7 -0
  218. package/dist/esm/skills/createSkill.js +36 -0
  219. package/dist/esm/skills/index.d.ts +2 -0
  220. package/dist/esm/skills/index.js +2 -0
  221. package/dist/esm/subscriptions/SubscriptionManager.d.ts +11 -0
  222. package/dist/esm/subscriptions/SubscriptionManager.js +23 -0
  223. package/dist/esm/timesync/Timesync.d.ts +20 -0
  224. package/dist/esm/timesync/Timesync.js +71 -0
  225. package/dist/esm/timesync/index.d.ts +1 -0
  226. package/dist/esm/timesync/index.js +1 -0
  227. package/dist/esm/types/accelerometer.d.ts +10 -0
  228. package/dist/esm/types/accelerometer.js +1 -0
  229. package/dist/esm/types/actions.d.ts +16 -0
  230. package/dist/esm/types/actions.js +1 -0
  231. package/dist/esm/types/awareness.d.ts +1 -0
  232. package/dist/esm/types/awareness.js +1 -0
  233. package/dist/esm/types/brainwaves.d.ts +26 -0
  234. package/dist/esm/types/brainwaves.js +1 -0
  235. package/dist/esm/types/calm.d.ts +6 -0
  236. package/dist/esm/types/calm.js +1 -0
  237. package/dist/esm/types/client.d.ts +22 -0
  238. package/dist/esm/types/client.js +1 -0
  239. package/dist/esm/types/credentials.d.ts +12 -0
  240. package/dist/esm/types/credentials.js +1 -0
  241. package/dist/esm/types/deviceInfo.d.ts +18 -0
  242. package/dist/esm/types/deviceInfo.js +1 -0
  243. package/dist/esm/types/epoch.d.ts +12 -0
  244. package/dist/esm/types/epoch.js +1 -0
  245. package/dist/esm/types/experiment.d.ts +9 -0
  246. package/dist/esm/types/experiment.js +1 -0
  247. package/dist/esm/types/focus.d.ts +6 -0
  248. package/dist/esm/types/focus.js +1 -0
  249. package/dist/esm/types/hapticEffects.d.ts +125 -0
  250. package/dist/esm/types/hapticEffects.js +1 -0
  251. package/dist/esm/types/kinesis.d.ts +6 -0
  252. package/dist/esm/types/kinesis.js +1 -0
  253. package/dist/esm/types/marker.d.ts +7 -0
  254. package/dist/esm/types/marker.js +1 -0
  255. package/dist/esm/types/metrics.d.ts +21 -0
  256. package/dist/esm/types/metrics.js +1 -0
  257. package/dist/esm/types/oauth.d.ts +20 -0
  258. package/dist/esm/types/oauth.js +1 -0
  259. package/dist/esm/types/options.d.ts +51 -0
  260. package/dist/esm/types/options.js +1 -0
  261. package/dist/esm/types/sample.d.ts +15 -0
  262. package/dist/esm/types/sample.js +1 -0
  263. package/dist/esm/types/settings.d.ts +13 -0
  264. package/dist/esm/types/settings.js +1 -0
  265. package/dist/esm/types/signalQuality.d.ts +13 -0
  266. package/dist/esm/types/signalQuality.js +1 -0
  267. package/dist/esm/types/skill.d.ts +68 -0
  268. package/dist/esm/types/skill.js +1 -0
  269. package/dist/esm/types/status.d.ts +26 -0
  270. package/dist/esm/types/status.js +19 -0
  271. package/dist/esm/types/streaming.d.ts +15 -0
  272. package/dist/esm/types/streaming.js +17 -0
  273. package/dist/esm/types/subscriptions.d.ts +23 -0
  274. package/dist/esm/types/subscriptions.js +1 -0
  275. package/dist/esm/types/training.d.ts +19 -0
  276. package/dist/esm/types/training.js +1 -0
  277. package/dist/esm/types/user.d.ts +12 -0
  278. package/dist/esm/types/user.js +1 -0
  279. package/dist/esm/utils/errors.d.ts +5 -0
  280. package/dist/esm/utils/errors.js +11 -0
  281. package/dist/esm/utils/filterInternalKeys.d.ts +3 -0
  282. package/dist/esm/utils/filterInternalKeys.js +17 -0
  283. package/dist/esm/utils/hapticEffects.d.ts +123 -0
  284. package/dist/esm/utils/hapticEffects.js +125 -0
  285. package/dist/esm/utils/heartbeat.d.ts +4 -0
  286. package/dist/esm/utils/heartbeat.js +29 -0
  287. package/dist/esm/utils/is-node.d.ts +1 -0
  288. package/dist/esm/utils/is-node.js +5 -0
  289. package/dist/esm/utils/metrics.d.ts +1 -0
  290. package/dist/esm/utils/metrics.js +52 -0
  291. package/dist/esm/utils/oauth.d.ts +9 -0
  292. package/dist/esm/utils/oauth.js +64 -0
  293. package/dist/esm/utils/pick.d.ts +1 -0
  294. package/dist/esm/utils/pick.js +1 -0
  295. package/dist/esm/utils/pipes.d.ts +46 -0
  296. package/dist/esm/utils/pipes.js +65 -0
  297. package/dist/esm/utils/platform.d.ts +30 -0
  298. package/dist/esm/utils/platform.js +41 -0
  299. package/dist/esm/utils/subscription.d.ts +6 -0
  300. package/dist/esm/utils/subscription.js +24 -0
  301. package/dist/esm/utils/transferDevice.d.ts +9 -0
  302. package/dist/esm/utils/transferDevice.js +1 -0
  303. package/dist/esm/utils/whileOnline.d.ts +8 -0
  304. package/dist/esm/utils/whileOnline.js +11 -0
  305. package/dist/examples/auth.html +32 -0
  306. package/dist/examples/cloud.html +17 -0
  307. package/dist/examples/index.html +1 -0
  308. package/dist/examples/neurosity.iife.js +48736 -0
  309. package/dist/examples/neurosity.js +672 -0
  310. package/dist/examples/neurosity.mjs +48722 -0
  311. package/dist/examples/training.html +49 -0
  312. package/package.json +78 -0
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./FirebaseApp"), exports);
18
+ __exportStar(require("./FirebaseUser"), exports);
19
+ __exportStar(require("./FirebaseDevice"), exports);
@@ -0,0 +1 @@
1
+ export declare const prodFunctionsBaseUrl = "https://us-central1-neurosity-device.cloudfunctions.net";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prodFunctionsBaseUrl = void 0;
4
+ exports.prodFunctionsBaseUrl = "https://us-central1-neurosity-device.cloudfunctions.net";
@@ -0,0 +1,3 @@
1
+ import { SDKOptions } from "../../types/options";
2
+ import { OAuthConfig } from "../../types/oauth";
3
+ export declare function createOAuthURL(config: OAuthConfig, sdkOptions: SDKOptions): Promise<string>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createOAuthURL = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const utils_1 = require("./utils");
9
+ function createOAuthURL(config, sdkOptions) {
10
+ const { clientId, clientSecret, responseType, redirectUri, scope, state } = config;
11
+ const baseUrl = (0, utils_1.getFunctionsBaseURL)(sdkOptions);
12
+ return axios_1.default
13
+ .get(`${baseUrl}/authorize/entry`, {
14
+ params: Object.assign(Object.assign({ client_id: clientId }, (clientSecret ? { client_secret: clientSecret } : {})), { response_type: responseType, redirect_uri: redirectUri, scope: scope.join(","), state: state, redirect: "false" })
15
+ })
16
+ .then((response) => `${baseUrl}${response.data.url}`);
17
+ }
18
+ exports.createOAuthURL = createOAuthURL;
@@ -0,0 +1,3 @@
1
+ import { SDKOptions } from "../../types/options";
2
+ import { OAuthQuery, OAuthQueryResult } from "../../types/oauth";
3
+ export declare function getOAuthToken(query: OAuthQuery, sdkOptions: SDKOptions): Promise<OAuthQueryResult>;
@@ -0,0 +1,34 @@
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.getOAuthToken = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const utils_1 = require("./utils");
18
+ function getOAuthToken(query, sdkOptions) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const baseUrl = (0, utils_1.getFunctionsBaseURL)(sdkOptions);
21
+ // Get refresh token
22
+ const refreshResponse = yield axios_1.default.post(`${baseUrl}/getOAuthRefreshToken`, query);
23
+ const refreshToken = refreshResponse.data;
24
+ return axios_1.default
25
+ .post(`${baseUrl}/token`, {
26
+ grant_type: "refresh_token",
27
+ refresh_token: refreshToken.data,
28
+ client_id: query.clientId,
29
+ client_secret: query.clientSecret
30
+ })
31
+ .then((response) => JSON.parse(response.data)["access_token"]);
32
+ });
33
+ }
34
+ exports.getOAuthToken = getOAuthToken;
@@ -0,0 +1,2 @@
1
+ import { SDKOptions } from "../../types/options";
2
+ export declare function getFunctionsBaseURL(sdkOptions: SDKOptions): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFunctionsBaseURL = void 0;
4
+ const config_1 = require("./config");
5
+ function getFunctionsBaseURL(sdkOptions) {
6
+ if (!sdkOptions.emulator) {
7
+ return config_1.prodFunctionsBaseUrl;
8
+ }
9
+ const { emulatorHost, emulatorFunctionsPort } = sdkOptions;
10
+ const emulatorFunctionsBaseUrl = `http://${emulatorHost}:${emulatorFunctionsPort}/neurosity-device/us-central1`;
11
+ return emulatorFunctionsBaseUrl;
12
+ }
13
+ exports.getFunctionsBaseURL = getFunctionsBaseURL;
@@ -0,0 +1,108 @@
1
+ import { Observable } from "rxjs";
2
+ import { FirebaseApp, FirebaseUser, FirebaseDevice } from "./firebase";
3
+ import { Timesync } from "../timesync";
4
+ import { SubscriptionManager } from "../subscriptions/SubscriptionManager";
5
+ import { Client } from "../types/client";
6
+ import { Action, Actions } from "../types/actions";
7
+ import { Metrics } from "../types/metrics";
8
+ import { SDKOptions } from "../types/options";
9
+ import { SkillsClient } from "../types/skill";
10
+ import { Credentials, CustomToken } from "../types/credentials";
11
+ import { EmailAndPassword } from "../types/credentials";
12
+ import { ChangeSettings } from "../types/settings";
13
+ import { DeviceStatus } from "../types/status";
14
+ import { DeviceInfo, DeviceSelector } from "../types/deviceInfo";
15
+ import { UserClaims } from "../types/user";
16
+ import { OAuthRemoveResponse } from "../types/oauth";
17
+ import { Experiment } from "../types/experiment";
18
+ import { TransferDeviceOptions } from "../utils/transferDevice";
19
+ export { credentialWithLink, createUser, SERVER_TIMESTAMP } from "./firebase";
20
+ /**
21
+ * @hidden
22
+ */
23
+ export declare class CloudClient implements Client {
24
+ user: any;
25
+ userClaims: any;
26
+ protected options: SDKOptions;
27
+ protected firebaseApp: FirebaseApp;
28
+ protected firebaseUser: FirebaseUser;
29
+ protected firebaseDevice: FirebaseDevice;
30
+ protected timesync: Timesync;
31
+ protected subscriptionManager: SubscriptionManager;
32
+ constructor(options: SDKOptions);
33
+ onDeviceChange(): Observable<DeviceInfo>;
34
+ private setAutoSelectedDevice;
35
+ get actions(): Actions;
36
+ dispatchAction(action: Action): Promise<any>;
37
+ disconnect(): Promise<any>;
38
+ getInfo(): Promise<any>;
39
+ login(credentials: Credentials): Promise<any>;
40
+ logout(): Promise<any>;
41
+ onAuthStateChanged(): Observable<{
42
+ selectedDevice: DeviceInfo;
43
+ delete(): Promise<void>;
44
+ emailVerified: boolean;
45
+ getIdTokenResult(forceRefresh?: boolean): Promise<import("@firebase/auth-types").IdTokenResult>;
46
+ getIdToken(forceRefresh?: boolean): Promise<string>;
47
+ isAnonymous: boolean;
48
+ linkAndRetrieveDataWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
49
+ linkWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
50
+ linkWithPhoneNumber(phoneNumber: string, applicationVerifier: import("@firebase/auth-types").ApplicationVerifier): Promise<import("@firebase/auth-types").ConfirmationResult>;
51
+ linkWithPopup(provider: import("@firebase/auth-types").AuthProvider): Promise<import("@firebase/auth-types").UserCredential>;
52
+ linkWithRedirect(provider: import("@firebase/auth-types").AuthProvider): Promise<void>;
53
+ metadata: import("@firebase/auth-types").UserMetadata;
54
+ multiFactor: import("@firebase/auth-types").MultiFactorUser;
55
+ phoneNumber: string;
56
+ providerData: import("@firebase/auth-types").UserInfo[];
57
+ reauthenticateAndRetrieveDataWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
58
+ reauthenticateWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
59
+ reauthenticateWithPhoneNumber(phoneNumber: string, applicationVerifier: import("@firebase/auth-types").ApplicationVerifier): Promise<import("@firebase/auth-types").ConfirmationResult>;
60
+ reauthenticateWithPopup(provider: import("@firebase/auth-types").AuthProvider): Promise<import("@firebase/auth-types").UserCredential>;
61
+ reauthenticateWithRedirect(provider: import("@firebase/auth-types").AuthProvider): Promise<void>;
62
+ refreshToken: string;
63
+ reload(): Promise<void>;
64
+ sendEmailVerification(actionCodeSettings?: import("@firebase/auth-types").ActionCodeSettings): Promise<void>;
65
+ tenantId: string;
66
+ toJSON(): Object;
67
+ unlink(providerId: string): Promise<import("@firebase/auth-types").User>;
68
+ updateEmail(newEmail: string): Promise<void>;
69
+ updatePassword(newPassword: string): Promise<void>;
70
+ updatePhoneNumber(phoneCredential: import("@firebase/auth-types").AuthCredential): Promise<void>;
71
+ updateProfile(profile: {
72
+ displayName?: string;
73
+ photoURL?: string;
74
+ }): Promise<void>;
75
+ verifyBeforeUpdateEmail(newEmail: string, actionCodeSettings?: import("@firebase/auth-types").ActionCodeSettings): Promise<void>;
76
+ displayName: string;
77
+ email: string;
78
+ photoURL: string;
79
+ providerId: string;
80
+ uid: string;
81
+ }>;
82
+ getDevices(): Promise<DeviceInfo[]>;
83
+ addDevice(deviceId: string): Promise<void>;
84
+ removeDevice(deviceId: string): Promise<void>;
85
+ transferDevice(options: TransferDeviceOptions): Promise<void>;
86
+ onUserDevicesChange(): Observable<DeviceInfo[]>;
87
+ onUserClaimsChange(): Observable<UserClaims>;
88
+ didSelectDevice(): Promise<boolean>;
89
+ selectDevice(deviceSelector: DeviceSelector): Promise<DeviceInfo>;
90
+ getSelectedDevice(): Promise<DeviceInfo | null>;
91
+ status(): Observable<DeviceStatus>;
92
+ observeNamespace(namespace: string): Observable<any>;
93
+ onceNamespace(namespace: string): Promise<any>;
94
+ get metrics(): Metrics;
95
+ createAccount(credentials: EmailAndPassword): Promise<any>;
96
+ deleteAccount(): Promise<void>;
97
+ createBluetoothToken(): Promise<string>;
98
+ createCustomToken(): Promise<CustomToken>;
99
+ removeOAuthAccess(): Promise<OAuthRemoveResponse>;
100
+ onUserExperiments(): Observable<Experiment[]>;
101
+ deleteUserExperiment(experimentId: string): Promise<void>;
102
+ get skills(): SkillsClient;
103
+ get timestamp(): number;
104
+ getTimesyncOffset(): number;
105
+ changeSettings(settings: ChangeSettings): Promise<void>;
106
+ goOffline(): void;
107
+ goOnline(): void;
108
+ }
@@ -0,0 +1,306 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudClient = exports.SERVER_TIMESTAMP = exports.createUser = exports.credentialWithLink = void 0;
13
+ const rxjs_1 = require("rxjs");
14
+ const rxjs_2 = require("rxjs");
15
+ const operators_1 = require("rxjs/operators");
16
+ const firebase_1 = require("./firebase");
17
+ const timesync_1 = require("../timesync");
18
+ const SubscriptionManager_1 = require("../subscriptions/SubscriptionManager");
19
+ const heartbeat_1 = require("../utils/heartbeat");
20
+ const filterInternalKeys_1 = require("../utils/filterInternalKeys");
21
+ var firebase_2 = require("./firebase");
22
+ Object.defineProperty(exports, "credentialWithLink", { enumerable: true, get: function () { return firebase_2.credentialWithLink; } });
23
+ Object.defineProperty(exports, "createUser", { enumerable: true, get: function () { return firebase_2.createUser; } });
24
+ Object.defineProperty(exports, "SERVER_TIMESTAMP", { enumerable: true, get: function () { return firebase_2.SERVER_TIMESTAMP; } });
25
+ /**
26
+ * @hidden
27
+ */
28
+ class CloudClient {
29
+ constructor(options) {
30
+ /**
31
+ * @internal
32
+ */
33
+ this._selectedDevice = new rxjs_1.ReplaySubject(1);
34
+ this.options = options;
35
+ this.subscriptionManager = new SubscriptionManager_1.SubscriptionManager();
36
+ this.firebaseApp = new firebase_1.FirebaseApp(options);
37
+ this.firebaseUser = new firebase_1.FirebaseUser(this.firebaseApp);
38
+ this._selectedDevice.next(undefined);
39
+ this.firebaseUser.onAuthStateChanged().subscribe((user) => {
40
+ this.user = user;
41
+ });
42
+ this.firebaseUser.onUserClaimsChange().subscribe((userClaims) => {
43
+ this.userClaims = userClaims;
44
+ });
45
+ this.onDeviceChange().subscribe((device) => {
46
+ if (this.firebaseDevice) {
47
+ this.firebaseDevice.disconnect();
48
+ }
49
+ if (!device) {
50
+ return;
51
+ }
52
+ this.firebaseDevice = new firebase_1.FirebaseDevice({
53
+ deviceId: device.deviceId,
54
+ firebaseApp: this.firebaseApp,
55
+ dependencies: {
56
+ subscriptionManager: this.subscriptionManager
57
+ }
58
+ });
59
+ if (this.options.timesync) {
60
+ this.timesync = new timesync_1.Timesync({
61
+ status$: this.status(),
62
+ getTimesync: this.firebaseDevice.getTimesync.bind(this.firebaseDevice)
63
+ });
64
+ }
65
+ });
66
+ }
67
+ onDeviceChange() {
68
+ return this._selectedDevice
69
+ .asObservable()
70
+ .pipe((0, operators_1.filter)((value) => value !== undefined));
71
+ }
72
+ // Automatically select device when user logs in
73
+ setAutoSelectedDevice() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ // Select based on `deviceId` passed
76
+ if (this.options.deviceId) {
77
+ return yield this.selectDevice((devices) => {
78
+ return devices.find((device) => device.deviceId === this.options.deviceId);
79
+ });
80
+ }
81
+ // Auto select first-claimed device
82
+ if (!this.options.deviceId && this.options.autoSelectDevice) {
83
+ return yield this.selectDevice((devices) => {
84
+ // Auto select first device
85
+ return devices[0];
86
+ });
87
+ }
88
+ return null;
89
+ });
90
+ }
91
+ get actions() {
92
+ return {
93
+ dispatch: (action) => {
94
+ return this.firebaseDevice.dispatchAction(action);
95
+ }
96
+ };
97
+ }
98
+ dispatchAction(action) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ return yield this.firebaseDevice.dispatchAction(action);
101
+ });
102
+ }
103
+ disconnect() {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ return this.firebaseApp.disconnect();
106
+ });
107
+ }
108
+ getInfo() {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ return yield this.firebaseDevice.getInfo();
111
+ });
112
+ }
113
+ login(credentials) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ if (this.user) {
116
+ return Promise.reject(`Already logged in.`);
117
+ }
118
+ const auth = yield this.firebaseUser.login(credentials);
119
+ const selectedDevice = yield this.setAutoSelectedDevice();
120
+ return Object.assign(Object.assign({}, auth), { selectedDevice });
121
+ });
122
+ }
123
+ logout() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ if (this.firebaseDevice) {
126
+ this.firebaseDevice.disconnect();
127
+ }
128
+ return yield this.firebaseUser.logout();
129
+ });
130
+ }
131
+ onAuthStateChanged() {
132
+ return this.firebaseUser.onAuthStateChanged().pipe((0, operators_1.switchMap)((user) => __awaiter(this, void 0, void 0, function* () {
133
+ if (!user) {
134
+ return null;
135
+ }
136
+ const selectedDevice = this.didSelectDevice()
137
+ ? yield this.getSelectedDevice()
138
+ : yield this.setAutoSelectedDevice();
139
+ return Object.assign(Object.assign({}, user), { selectedDevice });
140
+ })));
141
+ }
142
+ getDevices() {
143
+ return this.firebaseUser.getDevices();
144
+ }
145
+ addDevice(deviceId) {
146
+ return this.firebaseUser.addDevice(deviceId);
147
+ }
148
+ removeDevice(deviceId) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ const [hasError, errorMessage] = yield this.firebaseUser
151
+ .removeDevice(deviceId)
152
+ .then(() => [false])
153
+ .catch((error) => [true, error]);
154
+ if (hasError) {
155
+ return Promise.reject(errorMessage);
156
+ }
157
+ const selectedDevice = yield this.getSelectedDevice();
158
+ if ((selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceId) === deviceId) {
159
+ this._selectedDevice.next(null);
160
+ }
161
+ });
162
+ }
163
+ transferDevice(options) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ const [hasError, error] = yield this.firebaseUser
166
+ .transferDevice(options)
167
+ .then(() => [false])
168
+ .catch((error) => [true, error]);
169
+ if (hasError) {
170
+ return Promise.reject(error);
171
+ }
172
+ const selectedDevice = yield this.getSelectedDevice();
173
+ if ((selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceId) === options.deviceId) {
174
+ this._selectedDevice.next(null);
175
+ }
176
+ });
177
+ }
178
+ onUserDevicesChange() {
179
+ return this.firebaseUser.onUserDevicesChange();
180
+ }
181
+ onUserClaimsChange() {
182
+ return this.firebaseUser.onUserClaimsChange();
183
+ }
184
+ didSelectDevice() {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ const selectedDevice = yield this.getSelectedDevice();
187
+ return !!selectedDevice;
188
+ });
189
+ }
190
+ selectDevice(deviceSelector) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ const devices = yield this.getDevices();
193
+ if (!devices) {
194
+ return Promise.reject(`Did not find any devices for this user. Make sure your device is claimed by your Neurosity account.`);
195
+ }
196
+ const deviceTupleSelector = (devices) => devices.find((device) => {
197
+ if (!Array.isArray(deviceSelector)) {
198
+ return false;
199
+ }
200
+ const [deviceKey, deviceValue] = deviceSelector;
201
+ return (JSON.stringify(device === null || device === void 0 ? void 0 : device[deviceKey]) === JSON.stringify(deviceValue));
202
+ });
203
+ const device = typeof deviceSelector === "function"
204
+ ? deviceSelector(devices)
205
+ : deviceTupleSelector(devices);
206
+ if (!device) {
207
+ return Promise.reject(`A device was not provided. Try returning a device from the devicesList provided in the callback.`);
208
+ }
209
+ const hasPermission = yield this.firebaseUser.hasDevicePermission(device.deviceId);
210
+ if (!hasPermission) {
211
+ return Promise.reject(`Rejected device access due to permissions.`);
212
+ }
213
+ this._selectedDevice.next(device);
214
+ return device;
215
+ });
216
+ }
217
+ getSelectedDevice() {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ return yield (0, rxjs_2.firstValueFrom)(this._selectedDevice);
220
+ });
221
+ }
222
+ status() {
223
+ return this.observeNamespace("status").pipe((0, heartbeat_1.offlineIfLostHeartbeat)(), (0, filterInternalKeys_1.filterInternalKeys)());
224
+ }
225
+ observeNamespace(namespace) {
226
+ const namespaceValues$ = (0, rxjs_2.fromEventPattern)((handler) => this.firebaseDevice.onNamespace(namespace, handler), (handler) => this.firebaseDevice.offNamespace(namespace, handler));
227
+ return this.onDeviceChange().pipe((0, operators_1.switchMap)((selectedDevice) => {
228
+ return selectedDevice ? namespaceValues$ : rxjs_1.EMPTY;
229
+ }));
230
+ }
231
+ onceNamespace(namespace) {
232
+ return __awaiter(this, void 0, void 0, function* () {
233
+ return yield this.firebaseDevice.onceNamespace(namespace);
234
+ });
235
+ }
236
+ get metrics() {
237
+ return {
238
+ next: (metricName, metricValue) => {
239
+ this.firebaseDevice.nextMetric(metricName, metricValue);
240
+ },
241
+ on: (subscription, callback) => {
242
+ return this.firebaseDevice.onMetric(subscription, callback);
243
+ },
244
+ subscribe: (subscription) => {
245
+ const subscriptionCreated = this.firebaseDevice.subscribeToMetric(subscription);
246
+ this.subscriptionManager.add(subscriptionCreated);
247
+ return subscriptionCreated;
248
+ },
249
+ unsubscribe: (subscription, listener) => {
250
+ this.subscriptionManager.remove(subscription);
251
+ this.firebaseDevice.unsubscribeFromMetric(subscription);
252
+ this.firebaseDevice.removeMetricListener(subscription, listener);
253
+ }
254
+ };
255
+ }
256
+ createAccount(credentials) {
257
+ return this.firebaseUser.createAccount(credentials);
258
+ }
259
+ deleteAccount() {
260
+ return this.firebaseUser.deleteAccount();
261
+ }
262
+ createBluetoothToken() {
263
+ return this.firebaseDevice.createBluetoothToken();
264
+ }
265
+ createCustomToken() {
266
+ return this.firebaseUser.createCustomToken();
267
+ }
268
+ removeOAuthAccess() {
269
+ return this.firebaseUser.removeOAuthAccess();
270
+ }
271
+ onUserExperiments() {
272
+ return this.firebaseUser.onUserExperiments();
273
+ }
274
+ deleteUserExperiment(experimentId) {
275
+ return this.firebaseUser.deleteUserExperiment(experimentId);
276
+ }
277
+ get skills() {
278
+ return {
279
+ get: (bundleId) => __awaiter(this, void 0, void 0, function* () {
280
+ return this.firebaseDevice.getSkill(bundleId);
281
+ })
282
+ };
283
+ }
284
+ get timestamp() {
285
+ return this.options.timesync ? this.timesync.timestamp : Date.now();
286
+ }
287
+ getTimesyncOffset() {
288
+ return this.timesync.offset;
289
+ }
290
+ changeSettings(settings) {
291
+ return this.firebaseDevice.changeSettings(settings);
292
+ }
293
+ goOffline() {
294
+ this.firebaseApp.goOffline();
295
+ }
296
+ goOnline() {
297
+ this.firebaseApp.goOnline();
298
+ }
299
+ /**
300
+ * @internal
301
+ */
302
+ __getApp() {
303
+ return this.firebaseApp.app;
304
+ }
305
+ }
306
+ exports.CloudClient = CloudClient;
@@ -0,0 +1,3 @@
1
+ export * from "./Notion";
2
+ export * from "./api/bluetooth";
3
+ export * from "./skills";
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Notion"), exports);
18
+ __exportStar(require("./api/bluetooth"), exports);
19
+ __exportStar(require("./skills"), exports);
@@ -0,0 +1,7 @@
1
+ import { Neurosity } from "../Notion";
2
+ import { SDKOptions } from "../types/options";
3
+ import { Skill } from "../types/skill";
4
+ export declare type NotionOnDevice = Omit<Neurosity, "skill">;
5
+ export interface OnDeviceOptions extends SDKOptions {
6
+ skill: Skill;
7
+ }
@@ -0,0 +1,25 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createNotionOnDevice = void 0;
13
+ const Notion_1 = require("../Notion");
14
+ /**
15
+ * @internal
16
+ */
17
+ function createNotionOnDevice(options) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const neurosity = new Notion_1.Neurosity(options);
20
+ const skill = Object.assign(Object.assign({}, (yield neurosity.skill(options.skill.bundleId))), { props: "props" in options.skill ? options.skill.props : {} });
21
+ delete neurosity.skill;
22
+ return [neurosity, skill];
23
+ });
24
+ }
25
+ exports.createNotionOnDevice = createNotionOnDevice;
@@ -0,0 +1,7 @@
1
+ import { OnDeviceOptions, NotionOnDevice } from "./NotionOnDevice";
2
+ import { SkillInstance, SkillSubscription } from "../types/skill";
3
+ declare type SkillApp = (neurosity: NotionOnDevice, skill: SkillInstance) => () => Promise<void>;
4
+ export declare function createSkill(app: SkillApp): {
5
+ subscribe: (options: OnDeviceOptions) => Promise<SkillSubscription>;
6
+ };
7
+ export {};
@@ -0,0 +1,40 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createSkill = void 0;
13
+ const NotionOnDevice_1 = require("./NotionOnDevice");
14
+ function createSkill(app) {
15
+ return {
16
+ subscribe: (options) => __awaiter(this, void 0, void 0, function* () {
17
+ const [neurosity, skill] = yield (0, NotionOnDevice_1.createNotionOnDevice)(Object.assign({}, options));
18
+ const teardown = app(neurosity, skill);
19
+ return {
20
+ unsubscribe: () => __awaiter(this, void 0, void 0, function* () {
21
+ yield neurosity.disconnect();
22
+ if (teardown && "then" in teardown) {
23
+ const cleanUp = yield teardown;
24
+ if (typeof cleanUp === "function") {
25
+ cleanUp();
26
+ }
27
+ }
28
+ if (typeof teardown === "function" && "then" in teardown()) {
29
+ return yield teardown();
30
+ }
31
+ if (typeof teardown === "function") {
32
+ return teardown();
33
+ }
34
+ return teardown;
35
+ })
36
+ };
37
+ })
38
+ };
39
+ }
40
+ exports.createSkill = createSkill;
@@ -0,0 +1,2 @@
1
+ export * from "./createSkill";
2
+ export * from "./NotionOnDevice";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./createSkill"), exports);
18
+ __exportStar(require("./NotionOnDevice"), exports);