@neurosity/sdk 6.1.1 → 6.2.1-next.0
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/dist/{cjs/Neurosity.d.ts → Neurosity.d.ts} +116 -2
- package/dist/{cjs/api → api}/bluetooth/BluetoothClient.d.ts +6 -6
- package/dist/{cjs/api → api}/bluetooth/constants.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/index.d.ts +1 -0
- package/dist/{esm/api → api}/bluetooth/react-native/ReactNativeTransport.d.ts +5 -4
- package/dist/{cjs/api → api}/bluetooth/types/index.d.ts +2 -2
- package/dist/{cjs/api → api}/bluetooth/utils/create6DigitPin.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/utils/csvBufferToEpoch.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/utils/encoding.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/utils/stitch.d.ts +1 -1
- package/dist/{esm/api → api}/bluetooth/web/WebBluetoothTransport.d.ts +1 -1
- package/dist/{cjs/api → api}/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -0
- package/dist/{cjs/api → api}/bluetooth/web/isWebBluetoothSupported.d.ts +0 -0
- package/dist/{cjs/api → api}/firebase/FirebaseApp.d.ts +0 -0
- package/dist/{cjs/api → api}/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/{cjs/api → api}/firebase/FirebaseUser.d.ts +0 -0
- package/dist/{cjs/api → api}/firebase/config.d.ts +0 -0
- package/dist/{cjs/api → api}/firebase/deviceStore.d.ts +0 -0
- package/dist/{cjs/api → api}/firebase/index.d.ts +0 -0
- package/dist/{cjs/api → api}/https/config.d.ts +0 -0
- package/dist/{cjs/api → api}/https/createOAuthURL.d.ts +0 -0
- package/dist/{cjs/api → api}/https/getOAuthToken.d.ts +0 -0
- package/dist/{cjs/api → api}/https/utils.d.ts +0 -0
- package/dist/{esm/api → api}/index.d.ts +8 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- package/dist/index.m.js +2 -0
- package/dist/index.m.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/{cjs/subscriptions → subscriptions}/SubscriptionManager.d.ts +0 -0
- package/dist/{cjs/timesync → timesync}/Timesync.d.ts +1 -1
- package/dist/{cjs/timesync → timesync}/index.d.ts +0 -0
- package/dist/{cjs/types → types}/status.d.ts +0 -0
- package/dist/{cjs/types → types}/streaming.d.ts +0 -0
- package/dist/{cjs/utils → utils}/errors.d.ts +0 -0
- package/dist/{cjs/utils → utils}/filterInternalKeys.d.ts +0 -0
- package/dist/{cjs/utils → utils}/hapticEffects.d.ts +0 -0
- package/dist/{cjs/utils → utils}/heartbeat.d.ts +0 -0
- package/dist/{cjs/utils → utils}/is-node.d.ts +0 -0
- package/dist/utils/metrics.d.ts +6 -0
- package/dist/{cjs/utils → utils}/oauth.d.ts +1 -1
- package/dist/{cjs/utils → utils}/pipes.d.ts +0 -0
- package/dist/{cjs/utils → utils}/platform.d.ts +0 -0
- package/dist/{cjs/utils → utils}/subscription.d.ts +0 -0
- package/dist/{cjs/utils → utils}/whileOnline.d.ts +1 -1
- package/package.json +15 -23
- package/CHANGELOG.md +0 -25
- package/dist/browser/neurosity.iife.js +0 -48711
- package/dist/browser/neurosity.js +0 -666
- package/dist/browser/neurosity.js.map +0 -1
- package/dist/cjs/Neurosity.js +0 -1244
- package/dist/cjs/api/bluetooth/BluetoothClient.js +0 -310
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +0 -33
- package/dist/cjs/api/bluetooth/BluetoothTransport.js +0 -2
- package/dist/cjs/api/bluetooth/constants.js +0 -9
- package/dist/cjs/api/bluetooth/index.js +0 -20
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +0 -69
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +0 -405
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +0 -11
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -10
- package/dist/cjs/api/bluetooth/types/index.js +0 -22
- package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +0 -8
- package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +0 -36
- package/dist/cjs/api/bluetooth/utils/encoding.js +0 -22
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +0 -23
- package/dist/cjs/api/bluetooth/utils/stitch.js +0 -22
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +0 -54
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +0 -430
- package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -8
- package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +0 -11
- package/dist/cjs/api/firebase/FirebaseApp.js +0 -70
- package/dist/cjs/api/firebase/FirebaseDevice.js +0 -146
- package/dist/cjs/api/firebase/FirebaseUser.js +0 -434
- package/dist/cjs/api/firebase/config.js +0 -11
- package/dist/cjs/api/firebase/deviceStore.js +0 -191
- package/dist/cjs/api/firebase/index.js +0 -19
- package/dist/cjs/api/https/config.js +0 -4
- package/dist/cjs/api/https/createOAuthURL.js +0 -18
- package/dist/cjs/api/https/getOAuthToken.js +0 -34
- package/dist/cjs/api/https/utils.js +0 -13
- package/dist/cjs/api/index.d.ts +0 -109
- package/dist/cjs/api/index.js +0 -307
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/subscriptions/SubscriptionManager.js +0 -27
- package/dist/cjs/timesync/Timesync.js +0 -78
- package/dist/cjs/timesync/index.js +0 -17
- package/dist/cjs/types/accelerometer.d.ts +0 -10
- package/dist/cjs/types/accelerometer.js +0 -2
- package/dist/cjs/types/actions.d.ts +0 -16
- package/dist/cjs/types/actions.js +0 -2
- package/dist/cjs/types/awareness.d.ts +0 -1
- package/dist/cjs/types/awareness.js +0 -2
- package/dist/cjs/types/brainwaves.d.ts +0 -26
- package/dist/cjs/types/brainwaves.js +0 -2
- package/dist/cjs/types/calm.d.ts +0 -6
- package/dist/cjs/types/calm.js +0 -2
- package/dist/cjs/types/client.d.ts +0 -22
- package/dist/cjs/types/client.js +0 -2
- package/dist/cjs/types/credentials.d.ts +0 -12
- package/dist/cjs/types/credentials.js +0 -2
- package/dist/cjs/types/deviceInfo.d.ts +0 -18
- package/dist/cjs/types/deviceInfo.js +0 -2
- package/dist/cjs/types/epoch.d.ts +0 -12
- package/dist/cjs/types/epoch.js +0 -2
- package/dist/cjs/types/experiment.d.ts +0 -9
- package/dist/cjs/types/experiment.js +0 -2
- package/dist/cjs/types/focus.d.ts +0 -6
- package/dist/cjs/types/focus.js +0 -2
- package/dist/cjs/types/hapticEffects.d.ts +0 -125
- package/dist/cjs/types/hapticEffects.js +0 -2
- package/dist/cjs/types/kinesis.d.ts +0 -6
- package/dist/cjs/types/kinesis.js +0 -2
- package/dist/cjs/types/marker.d.ts +0 -7
- package/dist/cjs/types/marker.js +0 -2
- package/dist/cjs/types/metrics.d.ts +0 -21
- package/dist/cjs/types/metrics.js +0 -2
- package/dist/cjs/types/oauth.d.ts +0 -20
- package/dist/cjs/types/oauth.js +0 -2
- package/dist/cjs/types/options.d.ts +0 -51
- package/dist/cjs/types/options.js +0 -2
- package/dist/cjs/types/sample.d.ts +0 -15
- package/dist/cjs/types/sample.js +0 -2
- package/dist/cjs/types/settings.d.ts +0 -13
- package/dist/cjs/types/settings.js +0 -2
- package/dist/cjs/types/signalQuality.d.ts +0 -13
- package/dist/cjs/types/signalQuality.js +0 -2
- package/dist/cjs/types/skill.d.ts +0 -68
- package/dist/cjs/types/skill.js +0 -2
- package/dist/cjs/types/status.js +0 -22
- package/dist/cjs/types/streaming.js +0 -20
- package/dist/cjs/types/subscriptions.d.ts +0 -23
- package/dist/cjs/types/subscriptions.js +0 -2
- package/dist/cjs/types/training.d.ts +0 -19
- package/dist/cjs/types/training.js +0 -2
- package/dist/cjs/types/user.d.ts +0 -12
- package/dist/cjs/types/user.js +0 -2
- package/dist/cjs/utils/errors.js +0 -17
- package/dist/cjs/utils/filterInternalKeys.js +0 -21
- package/dist/cjs/utils/hapticEffects.js +0 -130
- package/dist/cjs/utils/heartbeat.js +0 -41
- package/dist/cjs/utils/is-node.js +0 -9
- package/dist/cjs/utils/metrics.d.ts +0 -1
- package/dist/cjs/utils/metrics.js +0 -56
- package/dist/cjs/utils/oauth.js +0 -92
- package/dist/cjs/utils/pick.d.ts +0 -1
- package/dist/cjs/utils/pick.js +0 -5
- package/dist/cjs/utils/pipes.js +0 -71
- package/dist/cjs/utils/platform.js +0 -47
- package/dist/cjs/utils/subscription.js +0 -55
- package/dist/cjs/utils/transferDevice.d.ts +0 -9
- package/dist/cjs/utils/transferDevice.js +0 -2
- package/dist/cjs/utils/whileOnline.js +0 -15
- package/dist/electron/index.js +0 -86
- package/dist/electron/index.js.map +0 -1
- package/dist/esm/Neurosity.d.ts +0 -619
- package/dist/esm/Neurosity.js +0 -1213
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +0 -72
- package/dist/esm/api/bluetooth/BluetoothClient.js +0 -306
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +0 -33
- package/dist/esm/api/bluetooth/BluetoothTransport.js +0 -1
- package/dist/esm/api/bluetooth/constants.d.ts +0 -4
- package/dist/esm/api/bluetooth/constants.js +0 -6
- package/dist/esm/api/bluetooth/index.d.ts +0 -4
- package/dist/esm/api/bluetooth/index.js +0 -4
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +0 -401
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +0 -8
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -9
- package/dist/esm/api/bluetooth/types/index.d.ts +0 -31
- package/dist/esm/api/bluetooth/types/index.js +0 -19
- package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +0 -1
- package/dist/esm/api/bluetooth/utils/create6DigitPin.js +0 -4
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +0 -11
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +0 -31
- package/dist/esm/api/bluetooth/utils/encoding.d.ts +0 -3
- package/dist/esm/api/bluetooth/utils/encoding.js +0 -17
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -2
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +0 -16
- package/dist/esm/api/bluetooth/utils/stitch.d.ts +0 -5
- package/dist/esm/api/bluetooth/utils/stitch.js +0 -18
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +0 -426
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -1
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -4
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +0 -1
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +0 -7
- package/dist/esm/api/firebase/FirebaseApp.d.ts +0 -20
- package/dist/esm/api/firebase/FirebaseApp.js +0 -63
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +0 -68
- package/dist/esm/api/firebase/FirebaseDevice.js +0 -139
- package/dist/esm/api/firebase/FirebaseUser.d.ts +0 -53
- package/dist/esm/api/firebase/FirebaseUser.js +0 -426
- package/dist/esm/api/firebase/config.d.ts +0 -8
- package/dist/esm/api/firebase/config.js +0 -8
- package/dist/esm/api/firebase/deviceStore.d.ts +0 -26
- package/dist/esm/api/firebase/deviceStore.js +0 -184
- package/dist/esm/api/firebase/index.d.ts +0 -3
- package/dist/esm/api/firebase/index.js +0 -3
- package/dist/esm/api/https/config.d.ts +0 -1
- package/dist/esm/api/https/config.js +0 -1
- package/dist/esm/api/https/createOAuthURL.d.ts +0 -3
- package/dist/esm/api/https/createOAuthURL.js +0 -11
- package/dist/esm/api/https/getOAuthToken.d.ts +0 -3
- package/dist/esm/api/https/getOAuthToken.js +0 -27
- package/dist/esm/api/https/utils.d.ts +0 -2
- package/dist/esm/api/https/utils.js +0 -9
- package/dist/esm/api/index.js +0 -300
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/neurosity.mjs +0 -48699
- package/dist/esm/subscriptions/SubscriptionManager.d.ts +0 -11
- package/dist/esm/subscriptions/SubscriptionManager.js +0 -23
- package/dist/esm/timesync/Timesync.d.ts +0 -20
- package/dist/esm/timesync/Timesync.js +0 -71
- package/dist/esm/timesync/index.d.ts +0 -1
- package/dist/esm/timesync/index.js +0 -1
- package/dist/esm/types/accelerometer.d.ts +0 -10
- package/dist/esm/types/accelerometer.js +0 -1
- package/dist/esm/types/actions.d.ts +0 -16
- package/dist/esm/types/actions.js +0 -1
- package/dist/esm/types/awareness.d.ts +0 -1
- package/dist/esm/types/awareness.js +0 -1
- package/dist/esm/types/brainwaves.d.ts +0 -26
- package/dist/esm/types/brainwaves.js +0 -1
- package/dist/esm/types/calm.d.ts +0 -6
- package/dist/esm/types/calm.js +0 -1
- package/dist/esm/types/client.d.ts +0 -22
- package/dist/esm/types/client.js +0 -1
- package/dist/esm/types/credentials.d.ts +0 -12
- package/dist/esm/types/credentials.js +0 -1
- package/dist/esm/types/deviceInfo.d.ts +0 -18
- package/dist/esm/types/deviceInfo.js +0 -1
- package/dist/esm/types/epoch.d.ts +0 -12
- package/dist/esm/types/epoch.js +0 -1
- package/dist/esm/types/experiment.d.ts +0 -9
- package/dist/esm/types/experiment.js +0 -1
- package/dist/esm/types/focus.d.ts +0 -6
- package/dist/esm/types/focus.js +0 -1
- package/dist/esm/types/hapticEffects.d.ts +0 -125
- package/dist/esm/types/hapticEffects.js +0 -1
- package/dist/esm/types/kinesis.d.ts +0 -6
- package/dist/esm/types/kinesis.js +0 -1
- package/dist/esm/types/marker.d.ts +0 -7
- package/dist/esm/types/marker.js +0 -1
- package/dist/esm/types/metrics.d.ts +0 -21
- package/dist/esm/types/metrics.js +0 -1
- package/dist/esm/types/oauth.d.ts +0 -20
- package/dist/esm/types/oauth.js +0 -1
- package/dist/esm/types/options.d.ts +0 -51
- package/dist/esm/types/options.js +0 -1
- package/dist/esm/types/sample.d.ts +0 -15
- package/dist/esm/types/sample.js +0 -1
- package/dist/esm/types/settings.d.ts +0 -13
- package/dist/esm/types/settings.js +0 -1
- package/dist/esm/types/signalQuality.d.ts +0 -13
- package/dist/esm/types/signalQuality.js +0 -1
- package/dist/esm/types/skill.d.ts +0 -68
- package/dist/esm/types/skill.js +0 -1
- package/dist/esm/types/status.d.ts +0 -26
- package/dist/esm/types/status.js +0 -19
- package/dist/esm/types/streaming.d.ts +0 -15
- package/dist/esm/types/streaming.js +0 -17
- package/dist/esm/types/subscriptions.d.ts +0 -23
- package/dist/esm/types/subscriptions.js +0 -1
- package/dist/esm/types/training.d.ts +0 -19
- package/dist/esm/types/training.js +0 -1
- package/dist/esm/types/user.d.ts +0 -12
- package/dist/esm/types/user.js +0 -1
- package/dist/esm/utils/errors.d.ts +0 -5
- package/dist/esm/utils/errors.js +0 -11
- package/dist/esm/utils/filterInternalKeys.d.ts +0 -3
- package/dist/esm/utils/filterInternalKeys.js +0 -17
- package/dist/esm/utils/hapticEffects.d.ts +0 -123
- package/dist/esm/utils/hapticEffects.js +0 -125
- package/dist/esm/utils/heartbeat.d.ts +0 -4
- package/dist/esm/utils/heartbeat.js +0 -33
- package/dist/esm/utils/is-node.d.ts +0 -1
- package/dist/esm/utils/is-node.js +0 -5
- package/dist/esm/utils/metrics.d.ts +0 -1
- package/dist/esm/utils/metrics.js +0 -52
- package/dist/esm/utils/oauth.d.ts +0 -9
- package/dist/esm/utils/oauth.js +0 -64
- package/dist/esm/utils/pick.d.ts +0 -1
- package/dist/esm/utils/pick.js +0 -1
- package/dist/esm/utils/pipes.d.ts +0 -46
- package/dist/esm/utils/pipes.js +0 -65
- package/dist/esm/utils/platform.d.ts +0 -30
- package/dist/esm/utils/platform.js +0 -41
- package/dist/esm/utils/subscription.d.ts +0 -6
- package/dist/esm/utils/subscription.js +0 -24
- package/dist/esm/utils/transferDevice.d.ts +0 -9
- package/dist/esm/utils/transferDevice.js +0 -1
- package/dist/esm/utils/whileOnline.d.ts +0 -8
- package/dist/esm/utils/whileOnline.js +0 -11
- package/dist/examples/auth.html +0 -32
- package/dist/examples/cloud.html +0 -17
- package/dist/examples/index.html +0 -1
- package/dist/examples/neurosity.iife.js +0 -48711
- package/dist/examples/neurosity.js +0 -666
- package/dist/examples/neurosity.mjs +0 -48699
- package/dist/examples/training.html +0 -49
package/dist/esm/utils/oauth.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as errors from "../utils/errors";
|
|
2
|
-
const scopeRequiredByAction = {
|
|
3
|
-
"marker/add": "write:brainwave-markers",
|
|
4
|
-
"brainwaves/record": "write:brainwaves",
|
|
5
|
-
"haptics/queue": "write:haptics",
|
|
6
|
-
"training/record": "write:kinesis",
|
|
7
|
-
"training/stop": "write:kinesis",
|
|
8
|
-
"training/stopAll": "write:kinesis",
|
|
9
|
-
"wifi/reset": "write:wifi-settings"
|
|
10
|
-
};
|
|
11
|
-
const scopeRequiredByFunctionName = {
|
|
12
|
-
//metrics
|
|
13
|
-
accelerometer: "read:accelerometer",
|
|
14
|
-
brainwaves: "read:brainwaves",
|
|
15
|
-
calm: "read:calm",
|
|
16
|
-
focus: "read:focus",
|
|
17
|
-
kinesis: "read:kinesis",
|
|
18
|
-
predictions: "read:kinesis",
|
|
19
|
-
signalQuality: "read:signal-quality",
|
|
20
|
-
// end of metrics
|
|
21
|
-
// device info
|
|
22
|
-
getInfo: "read:devices-info",
|
|
23
|
-
getSelectedDevice: "read:devices-info",
|
|
24
|
-
selectDevice: "read:devices-info",
|
|
25
|
-
onDeviceChange: "read:devices-info",
|
|
26
|
-
onUserDevicesChange: "read:devices-info",
|
|
27
|
-
// end device info
|
|
28
|
-
settings: "read:devices-settings",
|
|
29
|
-
changeSettings: "write:devices-settings",
|
|
30
|
-
status: "read:devices-status",
|
|
31
|
-
addDevice: "write:devices-add",
|
|
32
|
-
removeDevice: "write:devices-remove",
|
|
33
|
-
transferDevice: "write:devices-remove"
|
|
34
|
-
};
|
|
35
|
-
export function validateOAuthScopeForAction(userClaims, action) {
|
|
36
|
-
const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
|
|
37
|
-
if (!oauth) {
|
|
38
|
-
return [false, null];
|
|
39
|
-
}
|
|
40
|
-
const scopes = scopesString.split(",");
|
|
41
|
-
const { command, action: actionName } = action;
|
|
42
|
-
const requiredScope = scopeRequiredByAction[`${command}/${actionName}`];
|
|
43
|
-
const hasRequireScopes = scopes.includes(requiredScope);
|
|
44
|
-
if (hasRequireScopes) {
|
|
45
|
-
return [false, null];
|
|
46
|
-
}
|
|
47
|
-
return [true, getScopeError(requiredScope)];
|
|
48
|
-
}
|
|
49
|
-
export function validateOAuthScopeForFunctionName(userClaims, functionName) {
|
|
50
|
-
const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
|
|
51
|
-
if (!oauth) {
|
|
52
|
-
return [false, null];
|
|
53
|
-
}
|
|
54
|
-
const scopes = scopesString.split(",");
|
|
55
|
-
const requiredScope = scopeRequiredByFunctionName[functionName];
|
|
56
|
-
const hasRequireScopes = scopes.includes(requiredScope);
|
|
57
|
-
if (hasRequireScopes) {
|
|
58
|
-
return [false, null];
|
|
59
|
-
}
|
|
60
|
-
return [true, getScopeError(requiredScope)];
|
|
61
|
-
}
|
|
62
|
-
function getScopeError(...requiredScopes) {
|
|
63
|
-
return new Error(`${errors.prefix}You are trying to access data with an OAuth token without access to the following scopes: ${requiredScopes.join(", ")}.`);
|
|
64
|
-
}
|
package/dist/esm/utils/pick.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const pick: (object: any, props: any) => any;
|
package/dist/esm/utils/pick.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const pick = (object, props) => props.reduce((acc, prop) => (Object.assign(Object.assign({}, acc), (object.hasOwnProperty(prop) ? { [prop]: object[prop] } : {}))), {});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Annotates stream with user-defined metadata
|
|
3
|
-
* @method addInfo
|
|
4
|
-
* @example eeg$.pipe(addinfo({ samplingRate: 256, channelNames: ["Af7", "Fp1", "Fp2", "Af8"] })
|
|
5
|
-
* @param {Object} info Info to be added to the EEG stream. Relevant info may include: `samplingRate` and `channelNames`
|
|
6
|
-
* @returns {Observable<Sample|Epoch|PSD>}
|
|
7
|
-
*/
|
|
8
|
-
export declare const addInfo: (infoValue: any) => import("rxjs").UnaryFunction<import("rxjs").Observable<any>, import("rxjs").Observable<any>>;
|
|
9
|
-
/**
|
|
10
|
-
* Takes an array or RxJS buffer of EEG Samples and returns an Epoch.
|
|
11
|
-
* @method bufferToEpoch
|
|
12
|
-
* @example eeg$.pipe(bufferTime(1000), bufferToEpoch({ samplingRate: 256 }))
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} options - Data structure options
|
|
15
|
-
* @param {number} [options.samplingRate] Sampling rate
|
|
16
|
-
* @param {string} [options.dataProp='data'] Name of the key associated with eeg data
|
|
17
|
-
*
|
|
18
|
-
* @returns {Observable<Epoch>}
|
|
19
|
-
*/
|
|
20
|
-
export declare const bufferToEpoch: ({ samplingRate, dataProp }?: {
|
|
21
|
-
samplingRate?: number;
|
|
22
|
-
dataProp?: string;
|
|
23
|
-
}) => import("rxjs").UnaryFunction<import("rxjs").Observable<unknown>, import("rxjs").Observable<{
|
|
24
|
-
[x: string]: any;
|
|
25
|
-
info: any;
|
|
26
|
-
}>>;
|
|
27
|
-
/**
|
|
28
|
-
* Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval. This operator functions similarly to a circular buffer internally and allows overlapping Epochs of data to be emitted (e.g. emitting the last one second of data every 100ms).
|
|
29
|
-
* @method epoch
|
|
30
|
-
* @example eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))
|
|
31
|
-
* @param {Object} options - Epoching options
|
|
32
|
-
* @param {number} [options.duration=256] Number of samples to include in each epoch
|
|
33
|
-
* @param {number} [options.interval=100] Time (ms) between emitted Epochs
|
|
34
|
-
* @param {number} [options.samplingRate=256] Sampling rate
|
|
35
|
-
* @param {string} [options.dataProp='data'] Name of the key associated with eeg data
|
|
36
|
-
* @returns {Observable} Epoch
|
|
37
|
-
*/
|
|
38
|
-
export declare const epoch: ({ duration, interval, samplingRate, dataProp }: {
|
|
39
|
-
duration: any;
|
|
40
|
-
interval: any;
|
|
41
|
-
samplingRate: any;
|
|
42
|
-
dataProp?: string;
|
|
43
|
-
}) => import("rxjs").UnaryFunction<import("rxjs").Observable<unknown>, import("rxjs").Observable<{
|
|
44
|
-
[x: string]: any;
|
|
45
|
-
info: any;
|
|
46
|
-
}>>;
|
package/dist/esm/utils/pipes.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { pipe } from "rxjs";
|
|
2
|
-
import { bufferCount, scan, filter, map } from "rxjs/operators";
|
|
3
|
-
const defaultDataProp = "data";
|
|
4
|
-
const defaultSamplingRate = 256;
|
|
5
|
-
const isObject = (object) => object instanceof Object && object === Object(object);
|
|
6
|
-
const isFunction = (object) => typeof object === "function";
|
|
7
|
-
const patch = (sample) => (info) => {
|
|
8
|
-
var _a;
|
|
9
|
-
return (Object.assign(Object.assign({}, sample), { info: Object.assign(Object.assign({}, ((_a = sample === null || sample === void 0 ? void 0 : sample.info) !== null && _a !== void 0 ? _a : {})), (info || {})) }));
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Annotates stream with user-defined metadata
|
|
13
|
-
* @method addInfo
|
|
14
|
-
* @example eeg$.pipe(addinfo({ samplingRate: 256, channelNames: ["Af7", "Fp1", "Fp2", "Af8"] })
|
|
15
|
-
* @param {Object} info Info to be added to the EEG stream. Relevant info may include: `samplingRate` and `channelNames`
|
|
16
|
-
* @returns {Observable<Sample|Epoch|PSD>}
|
|
17
|
-
*/
|
|
18
|
-
export const addInfo = (infoValue) => pipe(map((sample) => {
|
|
19
|
-
if (!isObject(sample) ||
|
|
20
|
-
(!isObject(infoValue) && !isFunction(infoValue))) {
|
|
21
|
-
return sample;
|
|
22
|
-
}
|
|
23
|
-
const info = isFunction(infoValue) ? infoValue(sample) : infoValue;
|
|
24
|
-
return patch(sample)(info);
|
|
25
|
-
}));
|
|
26
|
-
/**
|
|
27
|
-
* Get a 2D data array organized by channel from an array of Samples. Credit to Ken from Seattle's elegant transposition
|
|
28
|
-
* http://www.codesuck.com/2012/02/transpose-javascript-array-in-one-line.html
|
|
29
|
-
* @method groupByChannel
|
|
30
|
-
* @param {Array<Sample>} samplesBuffer Array of Samples to be grouped
|
|
31
|
-
* @param {string} [dataProp] Name of the key associated with EEG data
|
|
32
|
-
* @returns {Array<Array<number>>}
|
|
33
|
-
*/
|
|
34
|
-
const groupByChannel = (samplesBuffer, dataProp = defaultDataProp) => samplesBuffer[0][dataProp].map((_, channelIndex) => samplesBuffer.map((sample) => sample[dataProp][channelIndex]));
|
|
35
|
-
/**
|
|
36
|
-
* Takes an array or RxJS buffer of EEG Samples and returns an Epoch.
|
|
37
|
-
* @method bufferToEpoch
|
|
38
|
-
* @example eeg$.pipe(bufferTime(1000), bufferToEpoch({ samplingRate: 256 }))
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} options - Data structure options
|
|
41
|
-
* @param {number} [options.samplingRate] Sampling rate
|
|
42
|
-
* @param {string} [options.dataProp='data'] Name of the key associated with eeg data
|
|
43
|
-
*
|
|
44
|
-
* @returns {Observable<Epoch>}
|
|
45
|
-
*/
|
|
46
|
-
export const bufferToEpoch = ({ samplingRate = defaultSamplingRate, dataProp = defaultDataProp } = {}) => pipe(map((samplesArray) => ({
|
|
47
|
-
[dataProp]: groupByChannel(samplesArray, dataProp),
|
|
48
|
-
info: Object.assign(Object.assign({}, (samplesArray[0] && samplesArray[0].info
|
|
49
|
-
? samplesArray[0].info
|
|
50
|
-
: {})), { startTime: samplesArray[0].timestamp, samplingRate: samplesArray[0].info && samplesArray[0].info.samplingRate
|
|
51
|
-
? samplesArray[0].info.samplingRate
|
|
52
|
-
: samplingRate })
|
|
53
|
-
})));
|
|
54
|
-
/**
|
|
55
|
-
* Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval. This operator functions similarly to a circular buffer internally and allows overlapping Epochs of data to be emitted (e.g. emitting the last one second of data every 100ms).
|
|
56
|
-
* @method epoch
|
|
57
|
-
* @example eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))
|
|
58
|
-
* @param {Object} options - Epoching options
|
|
59
|
-
* @param {number} [options.duration=256] Number of samples to include in each epoch
|
|
60
|
-
* @param {number} [options.interval=100] Time (ms) between emitted Epochs
|
|
61
|
-
* @param {number} [options.samplingRate=256] Sampling rate
|
|
62
|
-
* @param {string} [options.dataProp='data'] Name of the key associated with eeg data
|
|
63
|
-
* @returns {Observable} Epoch
|
|
64
|
-
*/
|
|
65
|
-
export const epoch = ({ duration, interval, samplingRate, dataProp = defaultDataProp }) => pipe(bufferCount(interval), scan((acc, val) => acc.concat(val).slice(acc.length < duration ? 0 : -duration)), filter((samplesArray) => samplesArray.length === duration), bufferToEpoch({ samplingRate, dataProp }));
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare const MODEL_VERSION_1 = "1";
|
|
2
|
-
export declare const MODEL_VERSION_2 = "2";
|
|
3
|
-
export declare const MODEL_VERSION_3 = "3";
|
|
4
|
-
export declare const FEATURE_HAPTICS = "haptics";
|
|
5
|
-
export declare const FEATURE_ACCEL = "accel";
|
|
6
|
-
export declare const HAPTIC_P7 = "P7";
|
|
7
|
-
export declare const HAPTIC_P8 = "P8";
|
|
8
|
-
export declare const platformFeaturesByModelVersion: {
|
|
9
|
-
1: any[];
|
|
10
|
-
2: string[];
|
|
11
|
-
3: string[];
|
|
12
|
-
};
|
|
13
|
-
export declare const platformConfigByModelVersion: {
|
|
14
|
-
1: {};
|
|
15
|
-
2: {
|
|
16
|
-
motorByMotorName: {
|
|
17
|
-
P7: any[];
|
|
18
|
-
P8: any[];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
3: {
|
|
22
|
-
motorByMotorName: {
|
|
23
|
-
P7: any[];
|
|
24
|
-
P8: any[];
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare const supportsHaptics: (modelVersion: string) => boolean;
|
|
29
|
-
export declare const supportsAccel: (modelVersion: string) => boolean;
|
|
30
|
-
export declare const getPlatformHapticMotors: (modelVersion: string) => any;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const MODEL_VERSION_1 = "1";
|
|
2
|
-
export const MODEL_VERSION_2 = "2";
|
|
3
|
-
export const MODEL_VERSION_3 = "3";
|
|
4
|
-
export const FEATURE_HAPTICS = "haptics";
|
|
5
|
-
export const FEATURE_ACCEL = "accel";
|
|
6
|
-
export const HAPTIC_P7 = "P7";
|
|
7
|
-
export const HAPTIC_P8 = "P8";
|
|
8
|
-
export const platformFeaturesByModelVersion = {
|
|
9
|
-
[MODEL_VERSION_1]: [],
|
|
10
|
-
[MODEL_VERSION_2]: [FEATURE_HAPTICS, FEATURE_ACCEL],
|
|
11
|
-
[MODEL_VERSION_3]: [FEATURE_HAPTICS, FEATURE_ACCEL]
|
|
12
|
-
};
|
|
13
|
-
export const platformConfigByModelVersion = {
|
|
14
|
-
[MODEL_VERSION_1]: {},
|
|
15
|
-
[MODEL_VERSION_2]: {
|
|
16
|
-
motorByMotorName: {
|
|
17
|
-
[HAPTIC_P7]: [],
|
|
18
|
-
[HAPTIC_P8]: []
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
[MODEL_VERSION_3]: {
|
|
22
|
-
motorByMotorName: {
|
|
23
|
-
[HAPTIC_P7]: [],
|
|
24
|
-
[HAPTIC_P8]: []
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
export const supportsHaptics = (modelVersion) => {
|
|
29
|
-
const platformFeaturesForModel = platformFeaturesByModelVersion[modelVersion];
|
|
30
|
-
return platformFeaturesForModel.includes(FEATURE_HAPTICS);
|
|
31
|
-
};
|
|
32
|
-
export const supportsAccel = (modelVersion) => {
|
|
33
|
-
const platformFeaturesForModel = platformFeaturesByModelVersion[modelVersion];
|
|
34
|
-
return platformFeaturesForModel.includes(FEATURE_ACCEL);
|
|
35
|
-
};
|
|
36
|
-
export const getPlatformHapticMotors = (modelVersion) => {
|
|
37
|
-
var _a;
|
|
38
|
-
const platformConfigForModel = platformConfigByModelVersion[modelVersion];
|
|
39
|
-
const platformMotorByMotorName = (_a = platformConfigForModel === null || platformConfigForModel === void 0 ? void 0 : platformConfigForModel.motorByMotorName) !== null && _a !== void 0 ? _a : {};
|
|
40
|
-
return Object.assign({}, platformMotorByMotorName);
|
|
41
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SDKOptions } from "../types/options";
|
|
2
|
-
export declare const isMetric: (metric: string) => boolean;
|
|
3
|
-
export declare const getLabels: (metric: string) => string[];
|
|
4
|
-
export declare const hasInvalidLabels: (metric: string, labels: string[]) => boolean;
|
|
5
|
-
export declare const isMetricDisallowed: (metricName: string, options: SDKOptions) => boolean;
|
|
6
|
-
export declare const validate: (metric: string, labels: string[], options: SDKOptions) => Error | false;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { metrics } from "@neurosity/ipk";
|
|
2
|
-
import * as errors from "../utils/errors";
|
|
3
|
-
export const isMetric = (metric) => Object.keys(metrics).includes(metric);
|
|
4
|
-
export const getLabels = (metric) => Object.keys(metrics[metric]);
|
|
5
|
-
export const hasInvalidLabels = (metric, labels) => {
|
|
6
|
-
const validLabels = getLabels(metric);
|
|
7
|
-
return !labels.every((label) => validLabels.includes(label));
|
|
8
|
-
};
|
|
9
|
-
export const isMetricDisallowed = (metricName, options) => "skill" in options &&
|
|
10
|
-
"metrics" in options.skill &&
|
|
11
|
-
!options.skill.metrics.includes(metricName);
|
|
12
|
-
export const validate = (metric, labels, options) => {
|
|
13
|
-
const validLabels = getLabels(metric).join(", ");
|
|
14
|
-
if (!labels.length) {
|
|
15
|
-
return new Error(`${errors.prefix}At least one label is required for ${metric} metric. Please add one of the following labels: ${validLabels}`);
|
|
16
|
-
}
|
|
17
|
-
if (isMetricDisallowed(metric, options)) {
|
|
18
|
-
return new Error(`${errors.prefix}No permission to access the ${metric} metric. To access this metric, edit the skill's permissions`);
|
|
19
|
-
}
|
|
20
|
-
if (hasInvalidLabels(metric, labels)) {
|
|
21
|
-
return new Error(`${errors.prefix}One ore more labels provided to ${metric} are invalid. The valid labels for ${metric} are ${validLabels}`);
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare type TransferDeviceByEmail = {
|
|
2
|
-
recipientsEmail: string;
|
|
3
|
-
deviceId: string;
|
|
4
|
-
};
|
|
5
|
-
export declare type TransferDeviceByUserId = {
|
|
6
|
-
recipientsUserId: string;
|
|
7
|
-
deviceId: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type TransferDeviceOptions = TransferDeviceByEmail | TransferDeviceByUserId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
import { DeviceStatus } from "../types/status";
|
|
3
|
-
declare type Options = {
|
|
4
|
-
status$: Observable<DeviceStatus>;
|
|
5
|
-
allowWhileOnSleepMode: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function whileOnline({ status$, allowWhileOnSleepMode }: Options): import("rxjs").UnaryFunction<Observable<unknown>, Observable<any>>;
|
|
8
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { pipe, of, EMPTY } from "rxjs";
|
|
2
|
-
import { mergeMap, withLatestFrom } from "rxjs/operators";
|
|
3
|
-
export function whileOnline({ status$, allowWhileOnSleepMode }) {
|
|
4
|
-
return pipe(withLatestFrom(status$), mergeMap(([value, status]) => shouldAllowMetrics(status, allowWhileOnSleepMode)
|
|
5
|
-
? of(value)
|
|
6
|
-
: EMPTY));
|
|
7
|
-
}
|
|
8
|
-
function shouldAllowMetrics(status, allowWhileOnSleepMode) {
|
|
9
|
-
return (status.state === "online" &&
|
|
10
|
-
(allowWhileOnSleepMode ? true : !status.sleepMode));
|
|
11
|
-
}
|
package/dist/examples/auth.html
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Neurosity SDK - Auth Inheritance</title></head><body> <pre>View source</pre> <script src="//www.gstatic.com/firebasejs/7.2.0/firebase-app.js"></script> <script src="//www.gstatic.com/firebasejs/7.2.0/firebase-auth.js"></script> <script src="//www.gstatic.com/firebasejs/7.2.0/firebase-database.js"></script> <script type="module">
|
|
2
|
-
import { Neurosity } from "./neurosity.mjs";
|
|
3
|
-
|
|
4
|
-
const 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
|
-
};
|
|
12
|
-
|
|
13
|
-
firebase.initializeApp(config);
|
|
14
|
-
|
|
15
|
-
(async () => {
|
|
16
|
-
await firebase.auth().signInWithEmailAndPassword("email", "password");
|
|
17
|
-
|
|
18
|
-
firebase.auth().onAuthStateChanged((user) => {
|
|
19
|
-
console.log("app user", user ? user.uid : null);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const neurosity = new Neurosity({
|
|
23
|
-
deviceId: "deviceId"
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Neurosity login is not required since a previously
|
|
27
|
-
// defined neurosity firebase app is used for Neurosity
|
|
28
|
-
|
|
29
|
-
const info = await neurosity.getInfo();
|
|
30
|
-
console.log("info", info);
|
|
31
|
-
})();
|
|
32
|
-
</script> </body></html>
|
package/dist/examples/cloud.html
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Neurosity SDK - Cloud mode</title></head><body> <pre>View source</pre> <script type="module">
|
|
2
|
-
import { Neurosity } from "./neurosity.mjs";
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
const neurosity = new Neurosity({
|
|
6
|
-
deviceId: process.env.NEUROSITY_DEVICE_ID
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
await neurosity.login({
|
|
10
|
-
email: process.env.NEUROSITY_EMAIL,
|
|
11
|
-
password: process.env.NEUROSITY_PASSWORD
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const info = await neurosity.getInfo();
|
|
15
|
-
console.log("info", info);
|
|
16
|
-
})();
|
|
17
|
-
</script> </body></html>
|
package/dist/examples/index.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Neurosity SDK - Examples</title></head><body> <ul> <li><a href="/auth.html">Auth</a></li> <li><a href="/cloud.html">Cloud</a></li> <li><a href="/training.html">Training</a></li> </ul> </body></html>
|