@neurosity/sdk 6.5.2 → 6.5.4-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/browser/neurosity.iife.js +34780 -22417
- package/dist/browser/neurosity.js +55 -41
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/api/firebase/FirebaseApp.d.ts +5 -5
- package/dist/cjs/api/firebase/FirebaseApp.js +5 -5
- package/dist/cjs/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseDevice.js +1 -1
- package/dist/cjs/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseUser.js +8 -21
- package/dist/cjs/api/firebase/deviceStore.js +3 -8
- package/dist/cjs/types/accelerometer.d.ts +1 -0
- package/dist/electron/index.js +4 -4
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/api/firebase/FirebaseApp.d.ts +5 -5
- package/dist/esm/api/firebase/FirebaseApp.js +5 -5
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseDevice.js +1 -1
- package/dist/esm/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseUser.js +8 -21
- package/dist/esm/api/firebase/deviceStore.js +3 -8
- package/dist/esm/neurosity.mjs +34783 -22420
- package/dist/esm/types/accelerometer.d.ts +1 -0
- package/dist/examples/neurosity.iife.js +34780 -22417
- package/dist/examples/neurosity.js +55 -41
- package/dist/examples/neurosity.mjs +34783 -22420
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import firebase from "firebase/app";
|
|
2
|
-
import "firebase/database";
|
|
3
|
-
import "firebase/auth";
|
|
4
|
-
import "firebase/functions";
|
|
5
|
-
import "firebase/firestore";
|
|
1
|
+
import firebase from "firebase/compat/app";
|
|
2
|
+
import "firebase/compat/database";
|
|
3
|
+
import "firebase/compat/auth";
|
|
4
|
+
import "firebase/compat/functions";
|
|
5
|
+
import "firebase/compat/firestore";
|
|
6
6
|
import { SDKOptions } from "../../types/options";
|
|
7
7
|
export declare const SERVER_TIMESTAMP: Object;
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import firebase from "firebase/app";
|
|
2
|
-
import "firebase/database";
|
|
3
|
-
import "firebase/auth";
|
|
4
|
-
import "firebase/functions";
|
|
5
|
-
import "firebase/firestore";
|
|
1
|
+
import firebase from "firebase/compat/app";
|
|
2
|
+
import "firebase/compat/database";
|
|
3
|
+
import "firebase/compat/auth";
|
|
4
|
+
import "firebase/compat/functions";
|
|
5
|
+
import "firebase/compat/firestore";
|
|
6
6
|
import { config } from "./config";
|
|
7
7
|
export const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
8
8
|
/**
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import firebase from "firebase/app";
|
|
10
|
+
import firebase from "firebase/compat/app";
|
|
11
11
|
import { createDeviceStore } from "./deviceStore";
|
|
12
12
|
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
13
13
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
|
-
import firebase from "firebase/app";
|
|
2
|
+
import firebase from "firebase/compat/app";
|
|
3
3
|
import { User } from "@firebase/auth-types";
|
|
4
4
|
import { FirebaseApp } from "./FirebaseApp";
|
|
5
5
|
import { Credentials, EmailAndPassword, CustomToken } from "../../types/credentials";
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Observable, fromEventPattern, from, EMPTY } from "rxjs";
|
|
11
11
|
import { map, switchMap } from "rxjs/operators";
|
|
12
|
-
import firebase from "firebase/app";
|
|
12
|
+
import firebase from "firebase/compat/app";
|
|
13
13
|
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
14
14
|
/**
|
|
15
15
|
* @hidden
|
|
@@ -87,9 +87,7 @@ export class FirebaseUser {
|
|
|
87
87
|
}
|
|
88
88
|
onLogin() {
|
|
89
89
|
return new Observable((subscriber) => {
|
|
90
|
-
const unsubscribe = this.app
|
|
91
|
-
.auth()
|
|
92
|
-
.onAuthStateChanged((user) => {
|
|
90
|
+
const unsubscribe = this.app.auth().onAuthStateChanged((user) => {
|
|
93
91
|
if (!!user) {
|
|
94
92
|
subscriber.next(user);
|
|
95
93
|
subscriber.complete();
|
|
@@ -110,9 +108,7 @@ export class FirebaseUser {
|
|
|
110
108
|
}
|
|
111
109
|
if ("email" in credentials && "password" in credentials) {
|
|
112
110
|
const { email, password } = credentials;
|
|
113
|
-
return this.app
|
|
114
|
-
.auth()
|
|
115
|
-
.signInWithEmailAndPassword(email, password);
|
|
111
|
+
return this.app.auth().signInWithEmailAndPassword(email, password);
|
|
116
112
|
}
|
|
117
113
|
throw new Error(`Either {email,password}, {customToken}, or {idToken,providerId} is required`);
|
|
118
114
|
}
|
|
@@ -240,8 +236,7 @@ export class FirebaseUser {
|
|
|
240
236
|
if (!userId) {
|
|
241
237
|
return Promise.reject(new Error(`transferDevice: auth is required.`));
|
|
242
238
|
}
|
|
243
|
-
if (!("recipientsEmail" in options) &&
|
|
244
|
-
!("recipientsUserId" in options)) {
|
|
239
|
+
if (!("recipientsEmail" in options) && !("recipientsUserId" in options)) {
|
|
245
240
|
return Promise.reject(new Error(`transferDevice: either 'recipientsEmail' or 'recipientsUserId' key is required.`));
|
|
246
241
|
}
|
|
247
242
|
if (!(options === null || options === void 0 ? void 0 : options.deviceId)) {
|
|
@@ -261,9 +256,7 @@ export class FirebaseUser {
|
|
|
261
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
262
257
|
// hex string of 32 characters
|
|
263
258
|
const hexRegEx = /[0-9A-Fa-f]{32}/g;
|
|
264
|
-
if (!deviceId ||
|
|
265
|
-
deviceId.length !== 32 ||
|
|
266
|
-
!hexRegEx.test(deviceId)) {
|
|
259
|
+
if (!deviceId || deviceId.length !== 32 || !hexRegEx.test(deviceId)) {
|
|
267
260
|
return Promise.reject("The device id is incorrectly formatted.");
|
|
268
261
|
}
|
|
269
262
|
const claimedByPath = this.getDeviceClaimedByPath(deviceId);
|
|
@@ -295,9 +288,7 @@ export class FirebaseUser {
|
|
|
295
288
|
return EMPTY;
|
|
296
289
|
}
|
|
297
290
|
const claimsUpdatedOnPath = this.getUserClaimsUpdatedOnPath();
|
|
298
|
-
const claimsUpdatedOnRef = this.app
|
|
299
|
-
.database()
|
|
300
|
-
.ref(claimsUpdatedOnPath);
|
|
291
|
+
const claimsUpdatedOnRef = this.app.database().ref(claimsUpdatedOnPath);
|
|
301
292
|
return fromEventPattern((handler) => claimsUpdatedOnRef.on("value", handler), (handler) => claimsUpdatedOnRef.off("value", handler)).pipe(map(([snapshot]) => snapshot.val()), switchMap(() => {
|
|
302
293
|
// Force refresh of auth id token
|
|
303
294
|
return from(this.getIdToken(true)).pipe(switchMap(() => from(this.getClaims())));
|
|
@@ -332,15 +323,11 @@ export class FirebaseUser {
|
|
|
332
323
|
}
|
|
333
324
|
userDevicesToDeviceInfoList(userDevices) {
|
|
334
325
|
return __awaiter(this, void 0, void 0, function* () {
|
|
335
|
-
const devicesInfoSnapshots = Object.keys(userDevices !== null && userDevices !== void 0 ? userDevices : {}).map((deviceId) => this.app
|
|
336
|
-
.database()
|
|
337
|
-
.ref(this.getDeviceInfoPath(deviceId))
|
|
338
|
-
.once("value"));
|
|
326
|
+
const devicesInfoSnapshots = Object.keys(userDevices !== null && userDevices !== void 0 ? userDevices : {}).map((deviceId) => this.app.database().ref(this.getDeviceInfoPath(deviceId)).once("value"));
|
|
339
327
|
const devicesList = yield Promise.all(devicesInfoSnapshots).then((snapshots) => snapshots.map((snapshot) => snapshot.val()));
|
|
340
328
|
const validDevices = devicesList.filter((device) => !!device);
|
|
341
329
|
validDevices.sort((a, b) => {
|
|
342
|
-
return (userDevices[a.deviceId].claimedOn -
|
|
343
|
-
userDevices[b.deviceId].claimedOn);
|
|
330
|
+
return (userDevices[a.deviceId].claimedOn - userDevices[b.deviceId].claimedOn);
|
|
344
331
|
});
|
|
345
332
|
return validDevices;
|
|
346
333
|
});
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import firebase from "firebase/app";
|
|
10
|
+
import firebase from "firebase/compat/app";
|
|
11
11
|
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
12
12
|
/**
|
|
13
13
|
* @hidden
|
|
@@ -27,9 +27,7 @@ export const createDeviceStore = (app, deviceId, subscriptionManager) => {
|
|
|
27
27
|
return deviceRef.child(namespace).update(payload);
|
|
28
28
|
};
|
|
29
29
|
const on = (eventType = "value", namespace, callback) => {
|
|
30
|
-
const listener = deviceRef
|
|
31
|
-
.child(namespace)
|
|
32
|
-
.on(eventType, (snapshot) => {
|
|
30
|
+
const listener = deviceRef.child(namespace).on(eventType, (snapshot) => {
|
|
33
31
|
callback(snapshot.val(), snapshot);
|
|
34
32
|
});
|
|
35
33
|
listenersToRemove.push(() => {
|
|
@@ -95,10 +93,7 @@ export const createDeviceStore = (app, deviceId, subscriptionManager) => {
|
|
|
95
93
|
});
|
|
96
94
|
});
|
|
97
95
|
listenersToRemove.push(() => {
|
|
98
|
-
app
|
|
99
|
-
.database()
|
|
100
|
-
.ref(".info/connected")
|
|
101
|
-
.off("value", connectedListener);
|
|
96
|
+
app.database().ref(".info/connected").off("value", connectedListener);
|
|
102
97
|
});
|
|
103
98
|
return {
|
|
104
99
|
set,
|