@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.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/browser/neurosity.iife.js +48736 -0
- package/dist/browser/neurosity.js +672 -0
- package/dist/browser/neurosity.js.map +1 -0
- package/dist/cjs/Notion.d.ts +619 -0
- package/dist/cjs/Notion.js +1291 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +59 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.js +287 -0
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +32 -0
- package/dist/cjs/api/bluetooth/BluetoothTransport.js +2 -0
- package/dist/cjs/api/bluetooth/constants.d.ts +4 -0
- package/dist/cjs/api/bluetooth/constants.js +9 -0
- package/dist/cjs/api/bluetooth/index.d.ts +4 -0
- package/dist/cjs/api/bluetooth/index.js +20 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +386 -0
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +11 -0
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +10 -0
- package/dist/cjs/api/bluetooth/types/index.d.ts +31 -0
- package/dist/cjs/api/bluetooth/types/index.js +22 -0
- package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
- package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +8 -0
- package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
- package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +36 -0
- package/dist/cjs/api/bluetooth/utils/encoding.d.ts +3 -0
- package/dist/cjs/api/bluetooth/utils/encoding.js +22 -0
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +23 -0
- package/dist/cjs/api/bluetooth/utils/stitch.d.ts +5 -0
- package/dist/cjs/api/bluetooth/utils/stitch.js +22 -0
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +412 -0
- package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
- package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +8 -0
- package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
- package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +11 -0
- package/dist/cjs/api/firebase/FirebaseApp.d.ts +20 -0
- package/dist/cjs/api/firebase/FirebaseApp.js +70 -0
- package/dist/cjs/api/firebase/FirebaseDevice.d.ts +68 -0
- package/dist/cjs/api/firebase/FirebaseDevice.js +146 -0
- package/dist/cjs/api/firebase/FirebaseUser.d.ts +53 -0
- package/dist/cjs/api/firebase/FirebaseUser.js +434 -0
- package/dist/cjs/api/firebase/config.d.ts +8 -0
- package/dist/cjs/api/firebase/config.js +11 -0
- package/dist/cjs/api/firebase/deviceStore.d.ts +26 -0
- package/dist/cjs/api/firebase/deviceStore.js +191 -0
- package/dist/cjs/api/firebase/index.d.ts +3 -0
- package/dist/cjs/api/firebase/index.js +19 -0
- package/dist/cjs/api/https/config.d.ts +1 -0
- package/dist/cjs/api/https/config.js +4 -0
- package/dist/cjs/api/https/createOAuthURL.d.ts +3 -0
- package/dist/cjs/api/https/createOAuthURL.js +18 -0
- package/dist/cjs/api/https/getOAuthToken.d.ts +3 -0
- package/dist/cjs/api/https/getOAuthToken.js +34 -0
- package/dist/cjs/api/https/utils.d.ts +2 -0
- package/dist/cjs/api/https/utils.js +13 -0
- package/dist/cjs/api/index.d.ts +108 -0
- package/dist/cjs/api/index.js +306 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/skills/NotionOnDevice.d.ts +7 -0
- package/dist/cjs/skills/NotionOnDevice.js +25 -0
- package/dist/cjs/skills/createSkill.d.ts +7 -0
- package/dist/cjs/skills/createSkill.js +40 -0
- package/dist/cjs/skills/index.d.ts +2 -0
- package/dist/cjs/skills/index.js +18 -0
- package/dist/cjs/subscriptions/SubscriptionManager.d.ts +11 -0
- package/dist/cjs/subscriptions/SubscriptionManager.js +27 -0
- package/dist/cjs/timesync/Timesync.d.ts +20 -0
- package/dist/cjs/timesync/Timesync.js +78 -0
- package/dist/cjs/timesync/index.d.ts +1 -0
- package/dist/cjs/timesync/index.js +17 -0
- package/dist/cjs/types/accelerometer.d.ts +10 -0
- package/dist/cjs/types/accelerometer.js +2 -0
- package/dist/cjs/types/actions.d.ts +16 -0
- package/dist/cjs/types/actions.js +2 -0
- package/dist/cjs/types/awareness.d.ts +1 -0
- package/dist/cjs/types/awareness.js +2 -0
- package/dist/cjs/types/brainwaves.d.ts +26 -0
- package/dist/cjs/types/brainwaves.js +2 -0
- package/dist/cjs/types/calm.d.ts +6 -0
- package/dist/cjs/types/calm.js +2 -0
- package/dist/cjs/types/client.d.ts +22 -0
- package/dist/cjs/types/client.js +2 -0
- package/dist/cjs/types/credentials.d.ts +12 -0
- package/dist/cjs/types/credentials.js +2 -0
- package/dist/cjs/types/deviceInfo.d.ts +18 -0
- package/dist/cjs/types/deviceInfo.js +2 -0
- package/dist/cjs/types/epoch.d.ts +12 -0
- package/dist/cjs/types/epoch.js +2 -0
- package/dist/cjs/types/experiment.d.ts +9 -0
- package/dist/cjs/types/experiment.js +2 -0
- package/dist/cjs/types/focus.d.ts +6 -0
- package/dist/cjs/types/focus.js +2 -0
- package/dist/cjs/types/hapticEffects.d.ts +125 -0
- package/dist/cjs/types/hapticEffects.js +2 -0
- package/dist/cjs/types/kinesis.d.ts +6 -0
- package/dist/cjs/types/kinesis.js +2 -0
- package/dist/cjs/types/marker.d.ts +7 -0
- package/dist/cjs/types/marker.js +2 -0
- package/dist/cjs/types/metrics.d.ts +21 -0
- package/dist/cjs/types/metrics.js +2 -0
- package/dist/cjs/types/oauth.d.ts +20 -0
- package/dist/cjs/types/oauth.js +2 -0
- package/dist/cjs/types/options.d.ts +51 -0
- package/dist/cjs/types/options.js +2 -0
- package/dist/cjs/types/sample.d.ts +15 -0
- package/dist/cjs/types/sample.js +2 -0
- package/dist/cjs/types/settings.d.ts +13 -0
- package/dist/cjs/types/settings.js +2 -0
- package/dist/cjs/types/signalQuality.d.ts +13 -0
- package/dist/cjs/types/signalQuality.js +2 -0
- package/dist/cjs/types/skill.d.ts +68 -0
- package/dist/cjs/types/skill.js +2 -0
- package/dist/cjs/types/status.d.ts +26 -0
- package/dist/cjs/types/status.js +22 -0
- package/dist/cjs/types/streaming.d.ts +15 -0
- package/dist/cjs/types/streaming.js +20 -0
- package/dist/cjs/types/subscriptions.d.ts +23 -0
- package/dist/cjs/types/subscriptions.js +2 -0
- package/dist/cjs/types/training.d.ts +19 -0
- package/dist/cjs/types/training.js +2 -0
- package/dist/cjs/types/user.d.ts +12 -0
- package/dist/cjs/types/user.js +2 -0
- package/dist/cjs/utils/errors.d.ts +5 -0
- package/dist/cjs/utils/errors.js +17 -0
- package/dist/cjs/utils/filterInternalKeys.d.ts +3 -0
- package/dist/cjs/utils/filterInternalKeys.js +21 -0
- package/dist/cjs/utils/hapticEffects.d.ts +123 -0
- package/dist/cjs/utils/hapticEffects.js +130 -0
- package/dist/cjs/utils/heartbeat.d.ts +4 -0
- package/dist/cjs/utils/heartbeat.js +34 -0
- package/dist/cjs/utils/is-node.d.ts +1 -0
- package/dist/cjs/utils/is-node.js +9 -0
- package/dist/cjs/utils/metrics.d.ts +1 -0
- package/dist/cjs/utils/metrics.js +56 -0
- package/dist/cjs/utils/oauth.d.ts +9 -0
- package/dist/cjs/utils/oauth.js +92 -0
- package/dist/cjs/utils/pick.d.ts +1 -0
- package/dist/cjs/utils/pick.js +5 -0
- package/dist/cjs/utils/pipes.d.ts +46 -0
- package/dist/cjs/utils/pipes.js +71 -0
- package/dist/cjs/utils/platform.d.ts +30 -0
- package/dist/cjs/utils/platform.js +47 -0
- package/dist/cjs/utils/subscription.d.ts +6 -0
- package/dist/cjs/utils/subscription.js +55 -0
- package/dist/cjs/utils/transferDevice.d.ts +9 -0
- package/dist/cjs/utils/transferDevice.js +2 -0
- package/dist/cjs/utils/whileOnline.d.ts +8 -0
- package/dist/cjs/utils/whileOnline.js +15 -0
- package/dist/electron/index.js +92 -0
- package/dist/electron/index.js.map +1 -0
- package/dist/esm/Notion.d.ts +619 -0
- package/dist/esm/Notion.js +1260 -0
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +59 -0
- package/dist/esm/api/bluetooth/BluetoothClient.js +283 -0
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +32 -0
- package/dist/esm/api/bluetooth/BluetoothTransport.js +1 -0
- package/dist/esm/api/bluetooth/constants.d.ts +4 -0
- package/dist/esm/api/bluetooth/constants.js +6 -0
- package/dist/esm/api/bluetooth/index.d.ts +4 -0
- package/dist/esm/api/bluetooth/index.js +4 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +382 -0
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +8 -0
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +9 -0
- package/dist/esm/api/bluetooth/types/index.d.ts +31 -0
- package/dist/esm/api/bluetooth/types/index.js +19 -0
- package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
- package/dist/esm/api/bluetooth/utils/create6DigitPin.js +4 -0
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +31 -0
- package/dist/esm/api/bluetooth/utils/encoding.d.ts +3 -0
- package/dist/esm/api/bluetooth/utils/encoding.js +17 -0
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +16 -0
- package/dist/esm/api/bluetooth/utils/stitch.d.ts +5 -0
- package/dist/esm/api/bluetooth/utils/stitch.js +18 -0
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +408 -0
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +4 -0
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +7 -0
- package/dist/esm/api/firebase/FirebaseApp.d.ts +20 -0
- package/dist/esm/api/firebase/FirebaseApp.js +63 -0
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +68 -0
- package/dist/esm/api/firebase/FirebaseDevice.js +139 -0
- package/dist/esm/api/firebase/FirebaseUser.d.ts +53 -0
- package/dist/esm/api/firebase/FirebaseUser.js +426 -0
- package/dist/esm/api/firebase/config.d.ts +8 -0
- package/dist/esm/api/firebase/config.js +8 -0
- package/dist/esm/api/firebase/deviceStore.d.ts +26 -0
- package/dist/esm/api/firebase/deviceStore.js +184 -0
- package/dist/esm/api/firebase/index.d.ts +3 -0
- package/dist/esm/api/firebase/index.js +3 -0
- package/dist/esm/api/https/config.d.ts +1 -0
- package/dist/esm/api/https/config.js +1 -0
- package/dist/esm/api/https/createOAuthURL.d.ts +3 -0
- package/dist/esm/api/https/createOAuthURL.js +11 -0
- package/dist/esm/api/https/getOAuthToken.d.ts +3 -0
- package/dist/esm/api/https/getOAuthToken.js +27 -0
- package/dist/esm/api/https/utils.d.ts +2 -0
- package/dist/esm/api/https/utils.js +9 -0
- package/dist/esm/api/index.d.ts +108 -0
- package/dist/esm/api/index.js +299 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/neurosity.mjs +48722 -0
- package/dist/esm/skills/NotionOnDevice.d.ts +7 -0
- package/dist/esm/skills/NotionOnDevice.js +21 -0
- package/dist/esm/skills/createSkill.d.ts +7 -0
- package/dist/esm/skills/createSkill.js +36 -0
- package/dist/esm/skills/index.d.ts +2 -0
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/subscriptions/SubscriptionManager.d.ts +11 -0
- package/dist/esm/subscriptions/SubscriptionManager.js +23 -0
- package/dist/esm/timesync/Timesync.d.ts +20 -0
- package/dist/esm/timesync/Timesync.js +71 -0
- package/dist/esm/timesync/index.d.ts +1 -0
- package/dist/esm/timesync/index.js +1 -0
- package/dist/esm/types/accelerometer.d.ts +10 -0
- package/dist/esm/types/accelerometer.js +1 -0
- package/dist/esm/types/actions.d.ts +16 -0
- package/dist/esm/types/actions.js +1 -0
- package/dist/esm/types/awareness.d.ts +1 -0
- package/dist/esm/types/awareness.js +1 -0
- package/dist/esm/types/brainwaves.d.ts +26 -0
- package/dist/esm/types/brainwaves.js +1 -0
- package/dist/esm/types/calm.d.ts +6 -0
- package/dist/esm/types/calm.js +1 -0
- package/dist/esm/types/client.d.ts +22 -0
- package/dist/esm/types/client.js +1 -0
- package/dist/esm/types/credentials.d.ts +12 -0
- package/dist/esm/types/credentials.js +1 -0
- package/dist/esm/types/deviceInfo.d.ts +18 -0
- package/dist/esm/types/deviceInfo.js +1 -0
- package/dist/esm/types/epoch.d.ts +12 -0
- package/dist/esm/types/epoch.js +1 -0
- package/dist/esm/types/experiment.d.ts +9 -0
- package/dist/esm/types/experiment.js +1 -0
- package/dist/esm/types/focus.d.ts +6 -0
- package/dist/esm/types/focus.js +1 -0
- package/dist/esm/types/hapticEffects.d.ts +125 -0
- package/dist/esm/types/hapticEffects.js +1 -0
- package/dist/esm/types/kinesis.d.ts +6 -0
- package/dist/esm/types/kinesis.js +1 -0
- package/dist/esm/types/marker.d.ts +7 -0
- package/dist/esm/types/marker.js +1 -0
- package/dist/esm/types/metrics.d.ts +21 -0
- package/dist/esm/types/metrics.js +1 -0
- package/dist/esm/types/oauth.d.ts +20 -0
- package/dist/esm/types/oauth.js +1 -0
- package/dist/esm/types/options.d.ts +51 -0
- package/dist/esm/types/options.js +1 -0
- package/dist/esm/types/sample.d.ts +15 -0
- package/dist/esm/types/sample.js +1 -0
- package/dist/esm/types/settings.d.ts +13 -0
- package/dist/esm/types/settings.js +1 -0
- package/dist/esm/types/signalQuality.d.ts +13 -0
- package/dist/esm/types/signalQuality.js +1 -0
- package/dist/esm/types/skill.d.ts +68 -0
- package/dist/esm/types/skill.js +1 -0
- package/dist/esm/types/status.d.ts +26 -0
- package/dist/esm/types/status.js +19 -0
- package/dist/esm/types/streaming.d.ts +15 -0
- package/dist/esm/types/streaming.js +17 -0
- package/dist/esm/types/subscriptions.d.ts +23 -0
- package/dist/esm/types/subscriptions.js +1 -0
- package/dist/esm/types/training.d.ts +19 -0
- package/dist/esm/types/training.js +1 -0
- package/dist/esm/types/user.d.ts +12 -0
- package/dist/esm/types/user.js +1 -0
- package/dist/esm/utils/errors.d.ts +5 -0
- package/dist/esm/utils/errors.js +11 -0
- package/dist/esm/utils/filterInternalKeys.d.ts +3 -0
- package/dist/esm/utils/filterInternalKeys.js +17 -0
- package/dist/esm/utils/hapticEffects.d.ts +123 -0
- package/dist/esm/utils/hapticEffects.js +125 -0
- package/dist/esm/utils/heartbeat.d.ts +4 -0
- package/dist/esm/utils/heartbeat.js +29 -0
- package/dist/esm/utils/is-node.d.ts +1 -0
- package/dist/esm/utils/is-node.js +5 -0
- package/dist/esm/utils/metrics.d.ts +1 -0
- package/dist/esm/utils/metrics.js +52 -0
- package/dist/esm/utils/oauth.d.ts +9 -0
- package/dist/esm/utils/oauth.js +64 -0
- package/dist/esm/utils/pick.d.ts +1 -0
- package/dist/esm/utils/pick.js +1 -0
- package/dist/esm/utils/pipes.d.ts +46 -0
- package/dist/esm/utils/pipes.js +65 -0
- package/dist/esm/utils/platform.d.ts +30 -0
- package/dist/esm/utils/platform.js +41 -0
- package/dist/esm/utils/subscription.d.ts +6 -0
- package/dist/esm/utils/subscription.js +24 -0
- package/dist/esm/utils/transferDevice.d.ts +9 -0
- package/dist/esm/utils/transferDevice.js +1 -0
- package/dist/esm/utils/whileOnline.d.ts +8 -0
- package/dist/esm/utils/whileOnline.js +11 -0
- package/dist/examples/auth.html +32 -0
- package/dist/examples/cloud.html +17 -0
- package/dist/examples/index.html +1 -0
- package/dist/examples/neurosity.iife.js +48736 -0
- package/dist/examples/neurosity.js +672 -0
- package/dist/examples/neurosity.mjs +48722 -0
- package/dist/examples/training.html +49 -0
- package/package.json +78 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import firebase from "firebase/app";
|
|
2
|
+
import "firebase/database";
|
|
3
|
+
import "firebase/auth";
|
|
4
|
+
import "firebase/functions";
|
|
5
|
+
import "firebase/firestore";
|
|
6
|
+
import { config } from "./config";
|
|
7
|
+
export const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export class FirebaseApp {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.app = this.getApp(options.deviceId);
|
|
14
|
+
this.standalone = this.app.name === options.deviceId;
|
|
15
|
+
if (options.emulator) {
|
|
16
|
+
this.connectEmulators(options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
getApp(deviceId) {
|
|
20
|
+
const moduleApps = firebase.apps;
|
|
21
|
+
const browserApps = typeof window !== "undefined" &&
|
|
22
|
+
"firebase" in window &&
|
|
23
|
+
"apps" in window.firebase
|
|
24
|
+
? window["firebase"]["apps"]
|
|
25
|
+
: [];
|
|
26
|
+
const neurosityApp = [...moduleApps, ...browserApps].find((app) => app.name === "[DEFAULT]" &&
|
|
27
|
+
app.options.databaseURL === config.databaseURL);
|
|
28
|
+
if (neurosityApp) {
|
|
29
|
+
return neurosityApp;
|
|
30
|
+
}
|
|
31
|
+
if (deviceId) {
|
|
32
|
+
const neurosityAppName = deviceId;
|
|
33
|
+
const neurosityApp = moduleApps.find((app) => app.name === neurosityAppName);
|
|
34
|
+
return neurosityApp
|
|
35
|
+
? neurosityApp
|
|
36
|
+
: firebase.initializeApp(config, neurosityAppName);
|
|
37
|
+
}
|
|
38
|
+
return firebase.initializeApp(config);
|
|
39
|
+
}
|
|
40
|
+
connectEmulators(options) {
|
|
41
|
+
const { emulatorHost, emulatorAuthPort, emulatorDatabasePort, emulatorFunctionsPort, emulatorFirestorePort, emulatorOptions } = options;
|
|
42
|
+
this.app.auth().useEmulator(`http://${emulatorHost}:${emulatorAuthPort}`);
|
|
43
|
+
this.app
|
|
44
|
+
.database()
|
|
45
|
+
.useEmulator(emulatorHost, emulatorDatabasePort, emulatorOptions);
|
|
46
|
+
this.app.functions().useEmulator(emulatorHost, emulatorFunctionsPort);
|
|
47
|
+
this.app
|
|
48
|
+
.firestore()
|
|
49
|
+
.useEmulator(emulatorHost, emulatorFirestorePort, emulatorOptions);
|
|
50
|
+
}
|
|
51
|
+
goOnline() {
|
|
52
|
+
this.app.database().goOnline();
|
|
53
|
+
}
|
|
54
|
+
goOffline() {
|
|
55
|
+
this.app.database().goOffline();
|
|
56
|
+
}
|
|
57
|
+
disconnect() {
|
|
58
|
+
if (this.standalone) {
|
|
59
|
+
return this.app.delete();
|
|
60
|
+
}
|
|
61
|
+
return Promise.resolve();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import firebase from "firebase/app";
|
|
2
|
+
import { FirebaseApp } from "./FirebaseApp";
|
|
3
|
+
import { SDKDependencies } from "../../types/options";
|
|
4
|
+
declare type FirebaseDeviceOptions = {
|
|
5
|
+
deviceId: string;
|
|
6
|
+
firebaseApp: FirebaseApp;
|
|
7
|
+
dependencies: SDKDependencies;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export declare class FirebaseDevice {
|
|
13
|
+
static serverType: string;
|
|
14
|
+
protected app: firebase.app.App;
|
|
15
|
+
protected deviceStore: any;
|
|
16
|
+
deviceId: string;
|
|
17
|
+
constructor({ deviceId, firebaseApp, dependencies }: FirebaseDeviceOptions);
|
|
18
|
+
get timestamp(): any;
|
|
19
|
+
dispatchAction(action: any): Promise<any>;
|
|
20
|
+
getInfo(): Promise<any>;
|
|
21
|
+
onNamespace(namespace: string, callback: Function): Function;
|
|
22
|
+
onceNamespace(namespace: string): Promise<any>;
|
|
23
|
+
offNamespace(namespace: string, listener: Function): void;
|
|
24
|
+
getTimesync(): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Pushes metric for each subscriptions in path:
|
|
27
|
+
* /devices/:deviceId/metrics/:metricName
|
|
28
|
+
*/
|
|
29
|
+
nextMetric(metricName: string, metricValue: {
|
|
30
|
+
[label: string]: any;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Listens for metrics in path:
|
|
34
|
+
* /devices/:deviceId/metrics/:metricName
|
|
35
|
+
*/
|
|
36
|
+
onMetric(subscription: any, callback: any): Function;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new and unique subscription in path:
|
|
39
|
+
* /devices/:deviceId/subscriptions/:subscriptionId
|
|
40
|
+
* E.g. /devices/device1/subscriptions/subscription3
|
|
41
|
+
*
|
|
42
|
+
* @param subscription
|
|
43
|
+
* @returns subscriptionId
|
|
44
|
+
*/
|
|
45
|
+
subscribeToMetric(subscription: any): any;
|
|
46
|
+
/**
|
|
47
|
+
* Removes subscription in path:
|
|
48
|
+
* /devices/:deviceId/subscriptions/:subscriptionId
|
|
49
|
+
*
|
|
50
|
+
* @param subscription
|
|
51
|
+
*/
|
|
52
|
+
unsubscribeFromMetric(subscription: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Removes metric listener
|
|
55
|
+
* /devices/:deviceId/metric
|
|
56
|
+
* or
|
|
57
|
+
* /devices/:deviceId/metric/label
|
|
58
|
+
*
|
|
59
|
+
* @param subscription
|
|
60
|
+
* @param listener
|
|
61
|
+
*/
|
|
62
|
+
removeMetricListener(subscription: any, listener: Function): void;
|
|
63
|
+
changeSettings(settings: any): Promise<void>;
|
|
64
|
+
getSkill(bundleId: any): Promise<any>;
|
|
65
|
+
createBluetoothToken(): Promise<string>;
|
|
66
|
+
disconnect(): void;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 firebase from "firebase/app";
|
|
11
|
+
import { createDeviceStore } from "./deviceStore";
|
|
12
|
+
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export class FirebaseDevice {
|
|
17
|
+
constructor({ deviceId, firebaseApp, dependencies }) {
|
|
18
|
+
if (!deviceId) {
|
|
19
|
+
throw new Error(`No Device ID provided.`);
|
|
20
|
+
}
|
|
21
|
+
this.deviceId = deviceId;
|
|
22
|
+
this.app = firebaseApp.app;
|
|
23
|
+
this.deviceStore = createDeviceStore(this.app, deviceId, dependencies.subscriptionManager);
|
|
24
|
+
}
|
|
25
|
+
get timestamp() {
|
|
26
|
+
return SERVER_TIMESTAMP;
|
|
27
|
+
}
|
|
28
|
+
dispatchAction(action) {
|
|
29
|
+
return this.deviceStore.dispatchAction(action);
|
|
30
|
+
}
|
|
31
|
+
getInfo() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return yield this.deviceStore.once("info");
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
onNamespace(namespace, callback) {
|
|
37
|
+
return this.deviceStore.onNamespace(namespace, callback);
|
|
38
|
+
}
|
|
39
|
+
onceNamespace(namespace) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return yield this.deviceStore.once(namespace);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
offNamespace(namespace, listener) {
|
|
45
|
+
this.deviceStore.offNamespace(namespace, listener);
|
|
46
|
+
}
|
|
47
|
+
getTimesync() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const response = yield this.dispatchAction({
|
|
50
|
+
command: "timesync",
|
|
51
|
+
action: "get",
|
|
52
|
+
responseRequired: true,
|
|
53
|
+
responseTimeout: 250
|
|
54
|
+
});
|
|
55
|
+
return response.timestamp;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pushes metric for each subscriptions in path:
|
|
60
|
+
* /devices/:deviceId/metrics/:metricName
|
|
61
|
+
*/
|
|
62
|
+
nextMetric(metricName, metricValue) {
|
|
63
|
+
this.deviceStore.nextMetric(metricName, metricValue);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Listens for metrics in path:
|
|
67
|
+
* /devices/:deviceId/metrics/:metricName
|
|
68
|
+
*/
|
|
69
|
+
onMetric(subscription, callback) {
|
|
70
|
+
return this.deviceStore.onMetric(subscription, callback);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new and unique subscription in path:
|
|
74
|
+
* /devices/:deviceId/subscriptions/:subscriptionId
|
|
75
|
+
* E.g. /devices/device1/subscriptions/subscription3
|
|
76
|
+
*
|
|
77
|
+
* @param subscription
|
|
78
|
+
* @returns subscriptionId
|
|
79
|
+
*/
|
|
80
|
+
subscribeToMetric(subscription) {
|
|
81
|
+
const subscriptionId = this.deviceStore.subscribeToMetric(Object.assign(Object.assign({}, subscription), { serverType: FirebaseDevice.serverType // @deprecated
|
|
82
|
+
}));
|
|
83
|
+
return subscriptionId;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Removes subscription in path:
|
|
87
|
+
* /devices/:deviceId/subscriptions/:subscriptionId
|
|
88
|
+
*
|
|
89
|
+
* @param subscription
|
|
90
|
+
*/
|
|
91
|
+
unsubscribeFromMetric(subscription) {
|
|
92
|
+
this.deviceStore.unsubscribeFromMetric(subscription);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes metric listener
|
|
96
|
+
* /devices/:deviceId/metric
|
|
97
|
+
* or
|
|
98
|
+
* /devices/:deviceId/metric/label
|
|
99
|
+
*
|
|
100
|
+
* @param subscription
|
|
101
|
+
* @param listener
|
|
102
|
+
*/
|
|
103
|
+
removeMetricListener(subscription, listener) {
|
|
104
|
+
this.deviceStore.removeMetricListener(subscription, listener);
|
|
105
|
+
}
|
|
106
|
+
changeSettings(settings) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return this.deviceStore.update("settings", settings);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
getSkill(bundleId) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
return yield this.deviceStore.lastOfChildValue("skills", "bundleId", bundleId);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
createBluetoothToken() {
|
|
117
|
+
var _a;
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const [error, token] = yield this.app
|
|
120
|
+
.functions()
|
|
121
|
+
.httpsCallable("createBluetoothToken")({
|
|
122
|
+
deviceId: this.deviceId
|
|
123
|
+
})
|
|
124
|
+
.then(({ data }) => [null, data === null || data === void 0 ? void 0 : data.token])
|
|
125
|
+
.catch((error) => [error, null]);
|
|
126
|
+
if (error) {
|
|
127
|
+
return Promise.reject((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error);
|
|
128
|
+
}
|
|
129
|
+
if (!token) {
|
|
130
|
+
return Promise.reject(`Failed to create Bluetooth token.`);
|
|
131
|
+
}
|
|
132
|
+
return token;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
disconnect() {
|
|
136
|
+
this.deviceStore.disconnect();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
FirebaseDevice.serverType = "firebase";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import firebase from "firebase/app";
|
|
3
|
+
import { User } from "@firebase/auth-types";
|
|
4
|
+
import { FirebaseApp } from "./FirebaseApp";
|
|
5
|
+
import { Credentials, EmailAndPassword, CustomToken } from "../../types/credentials";
|
|
6
|
+
import { UserClaims } from "../../types/user";
|
|
7
|
+
import { DeviceInfo } from "../../types/deviceInfo";
|
|
8
|
+
import { OAuthRemoveResponse } from "../../types/oauth";
|
|
9
|
+
import { Experiment } from "../../types/experiment";
|
|
10
|
+
import { TransferDeviceOptions } from "../../utils/transferDevice";
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export declare const credentialWithLink: Function;
|
|
15
|
+
/**
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
export declare function createUser(...args: any[]): any;
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export declare class FirebaseUser {
|
|
23
|
+
app: firebase.app.App;
|
|
24
|
+
user: User | null;
|
|
25
|
+
constructor(firebaseApp: FirebaseApp);
|
|
26
|
+
auth(): firebase.auth.Auth;
|
|
27
|
+
createAccount(credentials: EmailAndPassword): Promise<any>;
|
|
28
|
+
deleteAccount(): Promise<void>;
|
|
29
|
+
onAuthStateChanged(): Observable<User | null>;
|
|
30
|
+
onLogin(): Observable<User>;
|
|
31
|
+
login(credentials: Credentials): Promise<firebase.auth.UserCredential>;
|
|
32
|
+
logout(): Promise<void>;
|
|
33
|
+
createCustomToken(): Promise<CustomToken>;
|
|
34
|
+
removeOAuthAccess(): Promise<OAuthRemoveResponse>;
|
|
35
|
+
getDevices(): Promise<DeviceInfo[]>;
|
|
36
|
+
addDevice(deviceId: string): Promise<void>;
|
|
37
|
+
removeDevice(deviceId: string): Promise<void>;
|
|
38
|
+
transferDevice(options: TransferDeviceOptions): Promise<void>;
|
|
39
|
+
isDeviceIdValid(deviceId: string): Promise<boolean>;
|
|
40
|
+
onUserDevicesChange(): Observable<DeviceInfo[]>;
|
|
41
|
+
onUserClaimsChange(): Observable<UserClaims>;
|
|
42
|
+
getIdToken(forceRefresh?: boolean): Promise<void>;
|
|
43
|
+
getClaims(): Promise<UserClaims>;
|
|
44
|
+
private userDevicesToDeviceInfoList;
|
|
45
|
+
hasDevicePermission(deviceId: string): Promise<boolean>;
|
|
46
|
+
private getDeviceClaimedByPath;
|
|
47
|
+
private getUserClaimedDevicePath;
|
|
48
|
+
private getUserDevicesPath;
|
|
49
|
+
private getUserClaimsUpdatedOnPath;
|
|
50
|
+
private getDeviceInfoPath;
|
|
51
|
+
onUserExperiments(): Observable<Experiment[]>;
|
|
52
|
+
deleteUserExperiment(experimentId: string): Promise<void>;
|
|
53
|
+
}
|