@neurosity/sdk 6.2.1-next.1 → 6.2.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Neurosity.d.ts +733 -0
- package/dist/api/bluetooth/BluetoothClient.d.ts +72 -0
- package/dist/api/bluetooth/constants.d.ts +4 -0
- package/dist/api/bluetooth/index.d.ts +5 -0
- package/dist/api/bluetooth/react-native/ReactNativeTransport.d.ts +70 -0
- package/dist/api/bluetooth/types/index.d.ts +31 -0
- package/dist/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
- package/dist/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
- package/dist/api/bluetooth/utils/encoding.d.ts +3 -0
- package/dist/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
- package/dist/api/bluetooth/utils/stitch.d.ts +5 -0
- package/dist/api/bluetooth/web/WebBluetoothTransport.d.ts +54 -0
- package/dist/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
- package/dist/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
- package/dist/api/firebase/FirebaseApp.d.ts +20 -0
- package/dist/api/firebase/FirebaseDevice.d.ts +68 -0
- package/dist/api/firebase/FirebaseUser.d.ts +53 -0
- package/dist/api/firebase/config.d.ts +8 -0
- package/dist/api/firebase/deviceStore.d.ts +26 -0
- package/dist/api/firebase/index.d.ts +3 -0
- package/dist/api/https/config.d.ts +1 -0
- package/dist/api/https/createOAuthURL.d.ts +3 -0
- package/dist/api/https/getOAuthToken.d.ts +3 -0
- package/dist/api/https/utils.d.ts +2 -0
- package/dist/api/index.d.ts +117 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -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/subscriptions/SubscriptionManager.d.ts +11 -0
- package/dist/timesync/Timesync.d.ts +20 -0
- package/dist/timesync/index.d.ts +1 -0
- package/dist/types/status.d.ts +26 -0
- package/dist/types/streaming.d.ts +15 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/filterInternalKeys.d.ts +3 -0
- package/dist/utils/hapticEffects.d.ts +123 -0
- package/dist/utils/heartbeat.d.ts +4 -0
- package/dist/utils/is-node.d.ts +1 -0
- package/dist/utils/metrics.d.ts +6 -0
- package/dist/utils/oauth.d.ts +9 -0
- package/dist/utils/pipes.d.ts +46 -0
- package/dist/utils/platform.d.ts +30 -0
- package/dist/utils/subscription.d.ts +6 -0
- package/dist/utils/whileOnline.d.ts +8 -0
- package/package.json +1 -2
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { CloudClient, createUser } from "./api/index";
|
|
3
|
+
import { SDKOptions } from "./types/options";
|
|
4
|
+
import { STREAMING_MODE, STREAMING_TYPE } from "./types/streaming";
|
|
5
|
+
import { Training } from "./types/training";
|
|
6
|
+
import { Credentials, EmailAndPassword } from "./types/credentials";
|
|
7
|
+
import { CustomToken } from "./types/credentials";
|
|
8
|
+
import { Settings, ChangeSettings } from "./types/settings";
|
|
9
|
+
import { SignalQuality } from "./types/signalQuality";
|
|
10
|
+
import { Kinesis } from "./types/kinesis";
|
|
11
|
+
import { Calm } from "./types/calm";
|
|
12
|
+
import { Focus } from "./types/focus";
|
|
13
|
+
import { BrainwavesLabel, Epoch, PowerByBand, PSD } from "./types/brainwaves";
|
|
14
|
+
import { Accelerometer } from "./types/accelerometer";
|
|
15
|
+
import { DeviceInfo } from "./types/deviceInfo";
|
|
16
|
+
import { DeviceStatus } from "./types/status";
|
|
17
|
+
import { Action } from "./types/actions";
|
|
18
|
+
import { HapticEffects } from "./types/hapticEffects";
|
|
19
|
+
import { OAuthConfig, OAuthQuery } from "./types/oauth";
|
|
20
|
+
import { OAuthQueryResult, OAuthRemoveResponse } from "./types/oauth";
|
|
21
|
+
import { UserClaims } from "./types/user";
|
|
22
|
+
import { Experiment } from "./types/experiment";
|
|
23
|
+
import { TransferDeviceOptions } from "./utils/transferDevice";
|
|
24
|
+
import { BluetoothClient } from "./api/bluetooth";
|
|
25
|
+
/**
|
|
26
|
+
* import StreamingModes from "@site/src/components/StreamingModes";
|
|
27
|
+
*
|
|
28
|
+
* Example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { Neurosity } from "@neurosity/sdk";
|
|
31
|
+
*
|
|
32
|
+
* const neurosity = new Neurosity();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class Neurosity {
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
protected options: SDKOptions;
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
43
|
+
protected cloudClient: CloudClient;
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
protected bluetoothClient: BluetoothClient;
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
protected isMissingBluetoothTransport: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
private streamingMode$;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
60
|
+
static credentialWithLink: Function;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
|
+
static createUser: typeof createUser;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @hidden
|
|
69
|
+
*/
|
|
70
|
+
static SERVER_TIMESTAMP: Object;
|
|
71
|
+
/**
|
|
72
|
+
* Creates new instance of the Neurosity SDK
|
|
73
|
+
*
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const neurosity = new Neurosity();
|
|
76
|
+
* ```
|
|
77
|
+
|
|
78
|
+
* @param options
|
|
79
|
+
*/
|
|
80
|
+
constructor(options?: SDKOptions);
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
85
|
+
_initStreamingMode(streamingMode: STREAMING_MODE, hasBluetoothTransport: boolean): void;
|
|
86
|
+
/**
|
|
87
|
+
* Subscribe to the device's streaming state changes and the current strategy
|
|
88
|
+
*
|
|
89
|
+
* Streams the current mode of streaming (wifi or bluetooth).
|
|
90
|
+
*
|
|
91
|
+
* ```typescript
|
|
92
|
+
* neurosity.streamingState().subscribe((streamingState) => {
|
|
93
|
+
* console.log(streamingState);
|
|
94
|
+
* // { streamingMode: "wifi-only", activeMode: "wifi", connected: true }
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
streamingState(): Observable<{
|
|
99
|
+
connected: boolean;
|
|
100
|
+
activeMode: STREAMING_TYPE;
|
|
101
|
+
streamingMode: STREAMING_MODE;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @hidden
|
|
106
|
+
*/
|
|
107
|
+
_withStreamingModeObservable<T>(streams: {
|
|
108
|
+
wifi: () => Observable<T>;
|
|
109
|
+
bluetooth: () => Observable<T>;
|
|
110
|
+
}): Observable<any>;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @hidden
|
|
114
|
+
*/
|
|
115
|
+
_withStreamingModePromise<T>(promises: {
|
|
116
|
+
wifi: () => Promise<T>;
|
|
117
|
+
bluetooth: () => Promise<T>;
|
|
118
|
+
}): Promise<T>;
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @hidden
|
|
122
|
+
*/
|
|
123
|
+
get bluetooth(): BluetoothClient;
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @hidden
|
|
127
|
+
*/
|
|
128
|
+
private _getCloudMetricDependencies;
|
|
129
|
+
/**
|
|
130
|
+
* Starts user session
|
|
131
|
+
*
|
|
132
|
+
* ```typescript
|
|
133
|
+
* await neurosity.login({
|
|
134
|
+
* email: "...",
|
|
135
|
+
* password: "..."
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param credentials
|
|
140
|
+
*/
|
|
141
|
+
login(credentials: Credentials): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Ends user session
|
|
144
|
+
*
|
|
145
|
+
* ```typescript
|
|
146
|
+
* await neurosity.logout();
|
|
147
|
+
* // session has ended
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
logout(): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* @internal
|
|
154
|
+
* Not user facing.
|
|
155
|
+
*/
|
|
156
|
+
__getApp(): import("firebase").default.app.App;
|
|
157
|
+
/**
|
|
158
|
+
* Subscribe to auth state changes
|
|
159
|
+
*
|
|
160
|
+
* Streams the state of the auth session. If user has logged in, the user object will be set. When logged out, the user object will be null.
|
|
161
|
+
*
|
|
162
|
+
* ```typescript
|
|
163
|
+
* neurosity.onAuthStateChanged().subscribe((user) => {
|
|
164
|
+
* console.log(user);
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
onAuthStateChanged(): Observable<any>;
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
* Not user facing yet
|
|
172
|
+
*/
|
|
173
|
+
addDevice(deviceId: string): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* @internal
|
|
176
|
+
* Not user facing yet
|
|
177
|
+
*/
|
|
178
|
+
removeDevice(deviceId: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* @internal
|
|
181
|
+
* Not user facing yet
|
|
182
|
+
*/
|
|
183
|
+
transferDevice(options: TransferDeviceOptions): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* @internal
|
|
186
|
+
* Not user facing yet
|
|
187
|
+
*/
|
|
188
|
+
onUserDevicesChange(): Observable<DeviceInfo[]>;
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
* Not user facing yet
|
|
192
|
+
*/
|
|
193
|
+
onUserClaimsChange(): Observable<UserClaims>;
|
|
194
|
+
/**
|
|
195
|
+
* Get user devices
|
|
196
|
+
*
|
|
197
|
+
* Returns a list of devices claimed by the user authenticated.
|
|
198
|
+
*
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const devices = await neurosity.getDevices();
|
|
201
|
+
* console.log(devices);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
getDevices(): Promise<DeviceInfo[]>;
|
|
205
|
+
/**
|
|
206
|
+
* Select Device
|
|
207
|
+
*
|
|
208
|
+
* Rarely necessary, but useful when the user owns multiple devices.
|
|
209
|
+
*
|
|
210
|
+
* A common use case for manually selecting a device is when you wish to build a device dropdown a user can select from, instead of collecting the Device Id from the user ahead of time.
|
|
211
|
+
*
|
|
212
|
+
* The 3 steps to manually selecting a device are:
|
|
213
|
+
*
|
|
214
|
+
* - Set `autoSelectDevice` to false when instantiating the `Neurosity` class.
|
|
215
|
+
* - Authenticate with your Neurosity account to access your devices by calling the `neurosity.login(...)` function.
|
|
216
|
+
* - Call the `neurosity.selectDevice(...)` function with a device selector function.
|
|
217
|
+
*
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const devices = await neurosity.selectDevice((devices) =>
|
|
220
|
+
* devices.find((device) => device.deviceNickname === "Crown-A1B")
|
|
221
|
+
* );
|
|
222
|
+
*
|
|
223
|
+
* console.log(devices);
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* > If you own multiple devices, and don't pass `autoSelectDevice`, then the first device on the list will be automatically selected.
|
|
227
|
+
*
|
|
228
|
+
* For more info, check out the "Device Selection" guide.
|
|
229
|
+
*/
|
|
230
|
+
selectDevice(deviceSelector: (devices: DeviceInfo[]) => DeviceInfo): Promise<DeviceInfo>;
|
|
231
|
+
/**
|
|
232
|
+
* Get selected device
|
|
233
|
+
*
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const selectedDevice = await neurosity.getSelectedDevice();
|
|
236
|
+
* console.log(selectedDevice);
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
getSelectedDevice(): Promise<DeviceInfo>;
|
|
240
|
+
/**
|
|
241
|
+
* ```typescript
|
|
242
|
+
* const info = await neurosity.getInfo();
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
getInfo(): Promise<DeviceInfo>;
|
|
246
|
+
/**
|
|
247
|
+
* Observes selected device
|
|
248
|
+
*
|
|
249
|
+
* ```typescript
|
|
250
|
+
* neurosity.onDeviceChange().subscribe(device => {
|
|
251
|
+
* console.log(device);
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
onDeviceChange(): Observable<DeviceInfo>;
|
|
256
|
+
/**
|
|
257
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
258
|
+
*
|
|
259
|
+
* Ends database connection
|
|
260
|
+
*
|
|
261
|
+
* ```typescript
|
|
262
|
+
* await neurosity.disconnect();
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
disconnect(): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
* Not user facing
|
|
271
|
+
*/
|
|
272
|
+
private dispatchAction;
|
|
273
|
+
/**
|
|
274
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
275
|
+
*
|
|
276
|
+
* Injects an EEG marker to data stream
|
|
277
|
+
*
|
|
278
|
+
* ```typescript
|
|
279
|
+
* neurosity.addMarker("eyes-closed");
|
|
280
|
+
*
|
|
281
|
+
* // later...
|
|
282
|
+
*
|
|
283
|
+
* neurosity.addMarker("eyes-open");
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* @param label Name the label to inject
|
|
287
|
+
*/
|
|
288
|
+
addMarker(label: string): Promise<Action>;
|
|
289
|
+
/**
|
|
290
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
291
|
+
*
|
|
292
|
+
* Queue haptic motor commands
|
|
293
|
+
*
|
|
294
|
+
* To queue haptic P7 only,
|
|
295
|
+
* ```typescript
|
|
296
|
+
* await neurosity.haptics({
|
|
297
|
+
* P7: ["tripleClick100"]
|
|
298
|
+
* });
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* To queue both motors at the same time
|
|
302
|
+
* ```typescript
|
|
303
|
+
* await neurosity.haptics({
|
|
304
|
+
* P7: [neurosity.getHapticEffects().strongClick100],
|
|
305
|
+
* P8: [neurosity.getHapticEffects().strongClick100]
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* You can queue different commands to the motors too
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const effects = neurosity.getHapticEffects();
|
|
312
|
+
* await neurosity.haptics({
|
|
313
|
+
* P7: [effects.transitionRampUpLongSmooth1_0_to_100,
|
|
314
|
+
* effects.transitionRampDownLongSmooth1_100_to_0],
|
|
315
|
+
* P8: [effects.strongClick100]
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* @param effects Effects to queue. The key of the object passed should be the location of the motor
|
|
320
|
+
* to queue. Each key can be an array of up to 7 commands. There is no haptic support for model
|
|
321
|
+
* version 1, Notion DK1. The Haptic motor's location is positioned in reference to the 10-10 EEG
|
|
322
|
+
* system used to label the channels of the Crown's EEG sensors. Notion 2 and Crown have haptics
|
|
323
|
+
* at P7 and P8. A list of haptic commands can be found on ./utils/hapticCodes.ts - there
|
|
324
|
+
* are about 127 of them!
|
|
325
|
+
*/
|
|
326
|
+
haptics(effects: any): Promise<any>;
|
|
327
|
+
/**
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const effects = neurosity.getHapticEffects();
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
getHapticEffects(): HapticEffects;
|
|
333
|
+
/**
|
|
334
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
335
|
+
*
|
|
336
|
+
* Observes accelerometer data
|
|
337
|
+
* Supported by the Crown and Notion 2 devices.
|
|
338
|
+
*
|
|
339
|
+
* ```typescript
|
|
340
|
+
* neurosity.accelerometer().subscribe(accelerometer => {
|
|
341
|
+
* console.log(accelerometer);
|
|
342
|
+
* });
|
|
343
|
+
*
|
|
344
|
+
* // { acceleration: ..., inclination: ..., orientation: ..., pitch: ..., roll: ..., x: ..., y: ..., z: ... }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @returns Observable of accelerometer metric events
|
|
348
|
+
*/
|
|
349
|
+
accelerometer(): Observable<Accelerometer>;
|
|
350
|
+
/**
|
|
351
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
352
|
+
*
|
|
353
|
+
* The `raw` brainwaves parameter emits epochs of 16 samples for Crown and 25 for Notion 1 and 2.
|
|
354
|
+
*
|
|
355
|
+
* Example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* neurosity.brainwaves("raw").subscribe(brainwaves => {
|
|
358
|
+
* console.log(brainwaves);
|
|
359
|
+
* });
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* Raw Unfiltered - The `rawUnfiltered` brainwaves parameter emits epochs of 16 samples for Crown and 25 for Notion 1 and 2.
|
|
363
|
+
|
|
364
|
+
* Example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* neurosity.brainwaves("rawUnfiltered").subscribe(brainwaves => {
|
|
367
|
+
* console.log(brainwaves);
|
|
368
|
+
* });
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* Power By Band - The `powerByBand` brainwaves parameter emits epochs 4 times a second. Every frequency label (e.g. beta) contains an average power value per channel.
|
|
372
|
+
*
|
|
373
|
+
* Example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* neurosity.brainwaves("powerByBand").subscribe(brainwaves => {
|
|
376
|
+
* console.log(brainwaves);
|
|
377
|
+
* });
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* Power Spectral Density (PSD) - The `psd` brainwaves parameter emits epochs 4 times a second. Every frequency label (e.g. alpha) contains the computed FFT (Fast Fourier transform) value per channel (see the `psd` property), as well as the frequency ranges (see the `freqs` property).
|
|
381
|
+
*
|
|
382
|
+
* Example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* neurosity.brainwaves("psd").subscribe(brainwaves => {
|
|
385
|
+
* console.log(brainwaves);
|
|
386
|
+
* });
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* @param label Name of metric properties to filter by
|
|
390
|
+
* @returns Observable of brainwaves metric events
|
|
391
|
+
*/
|
|
392
|
+
brainwaves(label: BrainwavesLabel): Observable<Epoch | PowerByBand | PSD>;
|
|
393
|
+
/**
|
|
394
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
395
|
+
*
|
|
396
|
+
* Example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* neurosity.calm().subscribe(calm => {
|
|
399
|
+
* console.log(calm.probability);
|
|
400
|
+
* });
|
|
401
|
+
*
|
|
402
|
+
* // 0.45
|
|
403
|
+
* // 0.47
|
|
404
|
+
* // 0.53
|
|
405
|
+
* // 0.51
|
|
406
|
+
* // ...
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @returns Observable of calm events - awareness/calm alias
|
|
410
|
+
*/
|
|
411
|
+
calm(): Observable<Calm>;
|
|
412
|
+
/**
|
|
413
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
414
|
+
*
|
|
415
|
+
* Observes signal quality data where each property is the name
|
|
416
|
+
* of the channel and the value includes the standard deviation and
|
|
417
|
+
* a status set by the device
|
|
418
|
+
*
|
|
419
|
+
* ```typescript
|
|
420
|
+
* neurosity.signalQuality().subscribe(signalQuality => {
|
|
421
|
+
* console.log(signalQuality);
|
|
422
|
+
* });
|
|
423
|
+
*
|
|
424
|
+
* // { FC6: { standardDeviation: 3.5, status: "good" }, C3: {...}, ... }
|
|
425
|
+
* ```
|
|
426
|
+
*
|
|
427
|
+
* @returns Observable of signalQuality metric events
|
|
428
|
+
*/
|
|
429
|
+
signalQuality(): Observable<SignalQuality>;
|
|
430
|
+
/**
|
|
431
|
+
* <StreamingModes wifi={true} />
|
|
432
|
+
*
|
|
433
|
+
* Observes last state of `settings` and all subsequent `settings` changes
|
|
434
|
+
*
|
|
435
|
+
* ```typescript
|
|
436
|
+
* neurosity.settings().subscribe(settings => {
|
|
437
|
+
* console.log(settings.lsl);
|
|
438
|
+
* });
|
|
439
|
+
*
|
|
440
|
+
* // true
|
|
441
|
+
* // ...
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @returns Observable of `settings` metric events
|
|
445
|
+
*/
|
|
446
|
+
settings(): Observable<Settings>;
|
|
447
|
+
/**
|
|
448
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
449
|
+
*
|
|
450
|
+
* Example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* neurosity.focus().subscribe(focus => {
|
|
453
|
+
* console.log(focus.probability);
|
|
454
|
+
* });
|
|
455
|
+
*
|
|
456
|
+
* // 0.56
|
|
457
|
+
* // 0.46
|
|
458
|
+
* // 0.31
|
|
459
|
+
* // 0.39
|
|
460
|
+
* // ...
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* @returns Observable of focus events - awareness/focus alias
|
|
464
|
+
*/
|
|
465
|
+
focus(): Observable<Focus>;
|
|
466
|
+
/**
|
|
467
|
+
* <StreamingModes wifi={true} />
|
|
468
|
+
*
|
|
469
|
+
* @param label Name of metric properties to filter by
|
|
470
|
+
* @returns Observable of kinesis metric events
|
|
471
|
+
*/
|
|
472
|
+
kinesis(label: string): Observable<Kinesis>;
|
|
473
|
+
/**
|
|
474
|
+
* <StreamingModes wifi={true} />
|
|
475
|
+
*
|
|
476
|
+
* @param label Name of metric properties to filter by
|
|
477
|
+
* @returns Observable of predictions metric events
|
|
478
|
+
*/
|
|
479
|
+
predictions(label: string): Observable<any>;
|
|
480
|
+
/**
|
|
481
|
+
* <StreamingModes wifi={true} bluetooth={true} />
|
|
482
|
+
*
|
|
483
|
+
* Observes last state of `status` and all subsequent `status` changes
|
|
484
|
+
*
|
|
485
|
+
* ```typescript
|
|
486
|
+
* neurosity.status().subscribe(status => {
|
|
487
|
+
* console.log(status.state);
|
|
488
|
+
* });
|
|
489
|
+
*
|
|
490
|
+
* // "online"
|
|
491
|
+
* // ...
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @returns Observable of `status` metric events
|
|
495
|
+
*/
|
|
496
|
+
status(): Observable<DeviceStatus>;
|
|
497
|
+
/**
|
|
498
|
+
* @internal
|
|
499
|
+
* Not user facing yet
|
|
500
|
+
*
|
|
501
|
+
* <StreamingModes wifi={true} />
|
|
502
|
+
*
|
|
503
|
+
* Changes device settings programmatically. These settings can be
|
|
504
|
+
* also changed from the developer console under device settings.
|
|
505
|
+
*
|
|
506
|
+
* Available settings [[ChangeSettings]]
|
|
507
|
+
*
|
|
508
|
+
* Example
|
|
509
|
+
* ```typescript
|
|
510
|
+
* neurosity.changeSettings({
|
|
511
|
+
* lsl: true
|
|
512
|
+
* });
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
changeSettings(settings: ChangeSettings): Promise<void>;
|
|
516
|
+
/**
|
|
517
|
+
* <StreamingModes wifi={true} />
|
|
518
|
+
*
|
|
519
|
+
* ```typescript
|
|
520
|
+
* neurosity.training.record({
|
|
521
|
+
* metric: "kinesis",
|
|
522
|
+
* label: "push"
|
|
523
|
+
* });
|
|
524
|
+
*
|
|
525
|
+
* neurosity.training.stop({
|
|
526
|
+
* metric: "kinesis",
|
|
527
|
+
* label: "push"
|
|
528
|
+
* });
|
|
529
|
+
* ```
|
|
530
|
+
*
|
|
531
|
+
* @returns Training methods
|
|
532
|
+
*/
|
|
533
|
+
get training(): Training;
|
|
534
|
+
/**
|
|
535
|
+
* @internal
|
|
536
|
+
* Proof of Concept for disconnecting db
|
|
537
|
+
*/
|
|
538
|
+
goOffline(): void;
|
|
539
|
+
/**
|
|
540
|
+
* @internal
|
|
541
|
+
* Proof of Concept for resuming db connection
|
|
542
|
+
*/
|
|
543
|
+
goOnline(): void;
|
|
544
|
+
/**
|
|
545
|
+
* @internal
|
|
546
|
+
* Not user facing yet
|
|
547
|
+
*
|
|
548
|
+
* Creates user account and automatically signs in with same credentials
|
|
549
|
+
*
|
|
550
|
+
* @param emailAndPasswordObject
|
|
551
|
+
* @returns user credential
|
|
552
|
+
*/
|
|
553
|
+
createAccount(credentials: EmailAndPassword): Promise<any>;
|
|
554
|
+
/**
|
|
555
|
+
* @internal
|
|
556
|
+
* Not user facing yet
|
|
557
|
+
*
|
|
558
|
+
* Removes all devices from an account and then deletes the account
|
|
559
|
+
*/
|
|
560
|
+
deleteAccount(): Promise<void>;
|
|
561
|
+
/**
|
|
562
|
+
* @internal
|
|
563
|
+
* Not user facing
|
|
564
|
+
*
|
|
565
|
+
* Creates token (JWT) designed to authenticate and authorize Bluetooth clients/centrals.
|
|
566
|
+
*
|
|
567
|
+
* @returns token
|
|
568
|
+
*/
|
|
569
|
+
createBluetoothToken(): Promise<string>;
|
|
570
|
+
/**
|
|
571
|
+
* @internal
|
|
572
|
+
* Not user facing yet
|
|
573
|
+
*
|
|
574
|
+
* Creates custom token (JWT) to use to login with `{ customToken }`.
|
|
575
|
+
*
|
|
576
|
+
* @returns custom token
|
|
577
|
+
*/
|
|
578
|
+
createCustomToken(): Promise<CustomToken>;
|
|
579
|
+
/**
|
|
580
|
+
* @internal
|
|
581
|
+
* Not user facing yet
|
|
582
|
+
*
|
|
583
|
+
* Gets the offset between the device's clock and the client's clock
|
|
584
|
+
* Requires option.timesync to be true
|
|
585
|
+
*
|
|
586
|
+
* @returns timesyncOffset
|
|
587
|
+
*/
|
|
588
|
+
getTimesyncOffset(): number;
|
|
589
|
+
/**
|
|
590
|
+
* Create OAuth URL
|
|
591
|
+
* 💡 OAuth requires developers to register their apps with Neurosity
|
|
592
|
+
* [Read full OAuth guide](/docs/oauth)
|
|
593
|
+
*
|
|
594
|
+
* Creates client-specific OAuth URL. This is the first step of the OAuth workflow. Use this function to create a URL you can use to redirect users to the Neurosity sign-in page.
|
|
595
|
+
* 💡 This function is designed to only run on the server side for security reasons, as it requires your client secret.
|
|
596
|
+
*
|
|
597
|
+
* ```typescript
|
|
598
|
+
* const { Neurosity } = require("@neurosity/sdk");
|
|
599
|
+
*
|
|
600
|
+
* const neurosity = new Neurosity({
|
|
601
|
+
* autoSelectDevice: false
|
|
602
|
+
* });
|
|
603
|
+
*
|
|
604
|
+
* exports.handler = async function (event) {
|
|
605
|
+
* return neurosity
|
|
606
|
+
* .createOAuthURL({
|
|
607
|
+
* clientId: process.env.NEUROSITY_OAUTH_CLIENT_ID,
|
|
608
|
+
* clientSecret: process.env.NEUROSITY_OAUTH_CLIENT_SECRET,
|
|
609
|
+
* redirectUri: process.env.NEUROSITY_OAUTH_CLIENT_REDIRECT_URI,
|
|
610
|
+
* responseType: "token",
|
|
611
|
+
* state: Math.random().toString().split(".")[1],
|
|
612
|
+
* scope: [
|
|
613
|
+
* "read:devices-info",
|
|
614
|
+
* "read:devices-status",
|
|
615
|
+
* "read:signal-quality",
|
|
616
|
+
* "read:brainwaves"
|
|
617
|
+
* ]
|
|
618
|
+
* })
|
|
619
|
+
* .then((url) => ({
|
|
620
|
+
* statusCode: 200,
|
|
621
|
+
* body: JSON.stringify({ url })
|
|
622
|
+
* }))
|
|
623
|
+
* .catch((error) => ({
|
|
624
|
+
* statusCode: 400,
|
|
625
|
+
* body: JSON.stringify(error.response.data)
|
|
626
|
+
* }));
|
|
627
|
+
* };
|
|
628
|
+
* ```
|
|
629
|
+
* @returns custom token
|
|
630
|
+
*/
|
|
631
|
+
createOAuthURL(config: OAuthConfig): Promise<string>;
|
|
632
|
+
/**
|
|
633
|
+
* Get OAuth Token
|
|
634
|
+
* 💡 OAuth requires developers to register their apps with Neurosity
|
|
635
|
+
* [Read full OAuth guide](/docs/oauth)
|
|
636
|
+
*
|
|
637
|
+
* Gets client-specific OAuth token for a given userId.
|
|
638
|
+
*
|
|
639
|
+
* 💡 This function is designed to only run on the server side for security reasons, as it requires your client secret.
|
|
640
|
+
* Here's an example of a cloud function that receives a `userId` via query params and loads the client id and client secret securely via environment variables.
|
|
641
|
+
*
|
|
642
|
+
*
|
|
643
|
+
* ```typescript
|
|
644
|
+
* const { Neurosity } = require("@neurosity/sdk");
|
|
645
|
+
*
|
|
646
|
+
* const neurosity = new Neurosity({
|
|
647
|
+
* autoSelectDevice: false
|
|
648
|
+
* });
|
|
649
|
+
*
|
|
650
|
+
* exports.handler = async function (event) {
|
|
651
|
+
* const userId = event.queryStringParameters?.userId;
|
|
652
|
+
*
|
|
653
|
+
* return neurosity
|
|
654
|
+
* .getOAuthToken({
|
|
655
|
+
* clientId: process.env.NEUROSITY_OAUTH_CLIENT_ID,
|
|
656
|
+
* clientSecret: process.env.NEUROSITY_OAUTH_CLIENT_SECRET,
|
|
657
|
+
* userId
|
|
658
|
+
* })
|
|
659
|
+
* .then((token) => ({
|
|
660
|
+
* statusCode: 200,
|
|
661
|
+
* body: JSON.stringify(token)
|
|
662
|
+
* }))
|
|
663
|
+
* .catch((error) => ({
|
|
664
|
+
* statusCode: 200,
|
|
665
|
+
* body: JSON.stringify(error.response.data)
|
|
666
|
+
* }));
|
|
667
|
+
* };
|
|
668
|
+
* ```
|
|
669
|
+
* @returns custom token
|
|
670
|
+
*/
|
|
671
|
+
getOAuthToken(query: OAuthQuery): Promise<OAuthQueryResult>;
|
|
672
|
+
/**
|
|
673
|
+
* Remove OAuth Access
|
|
674
|
+
* 💡 OAuth requires developers to register their apps with Neurosity
|
|
675
|
+
* [Read full OAuth guide](/docs/oauth)
|
|
676
|
+
*
|
|
677
|
+
* Removes client-specific OAuth token for a given userId. Requires SDK to be signed in with OAuth custom token.
|
|
678
|
+
*
|
|
679
|
+
* ```typescript
|
|
680
|
+
* await neurosity.removeOAuthAccess().catch((error) => {
|
|
681
|
+
* // handle error here...
|
|
682
|
+
* });
|
|
683
|
+
* ```
|
|
684
|
+
* @returns custom token
|
|
685
|
+
*/
|
|
686
|
+
removeOAuthAccess(): Promise<OAuthRemoveResponse>;
|
|
687
|
+
/**
|
|
688
|
+
* <StreamingModes wifi={true} />
|
|
689
|
+
*
|
|
690
|
+
* Observes and returns a list of all Kinesis `experiments` and all subsequent experiment changes.
|
|
691
|
+
* Here's an example of how to get a list of all Kinesis labels that have been trained:
|
|
692
|
+
*
|
|
693
|
+
* ```typescript
|
|
694
|
+
*
|
|
695
|
+
* const getUniqueLabels = (experiments) => {
|
|
696
|
+
* const labels = experiments.flatMap((experiment) => experiment.labels);
|
|
697
|
+
* // only return unique labels
|
|
698
|
+
* return [...new Set(labels)];
|
|
699
|
+
* }
|
|
700
|
+
*
|
|
701
|
+
* neurosity.onUserExperiments().subscribe((experiments) => {
|
|
702
|
+
* console.log(experiments);
|
|
703
|
+
* console.log("labels", getUniqueLabels(experiments));
|
|
704
|
+
* });
|
|
705
|
+
*
|
|
706
|
+
* // [{ id: '...', deviceId: '...', labels: [ 'drop' ], name: 'Lightgray cheetah', timestamp: 1577908381552, totalTrials: 16, userId: '...' }]
|
|
707
|
+
* // ["drop", "lift", "push"]
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @returns Observable of `experiments` events
|
|
711
|
+
*/
|
|
712
|
+
onUserExperiments(): Observable<Experiment[]>;
|
|
713
|
+
/**
|
|
714
|
+
* <StreamingModes wifi={true} />
|
|
715
|
+
*
|
|
716
|
+
* Deletes a specific experiment provided an experiment ID
|
|
717
|
+
*
|
|
718
|
+
* ```typescript
|
|
719
|
+
* await neurosity.deleteUserExperiment(experiment.id);
|
|
720
|
+
* ```
|
|
721
|
+
*
|
|
722
|
+
* @param experimentId The ID of the Experiment
|
|
723
|
+
* @returns void
|
|
724
|
+
*/
|
|
725
|
+
deleteUserExperiment(experimentId: string): Promise<void>;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* @hidden
|
|
729
|
+
* Deprecated class kept for backwards compatibility purposes.
|
|
730
|
+
*/
|
|
731
|
+
export declare class Notion extends Neurosity {
|
|
732
|
+
constructor(options?: SDKOptions);
|
|
733
|
+
}
|