@neurosity/sdk 6.5.4-next.0 → 6.5.4
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 +22665 -35025
- package/dist/browser/neurosity.js +42 -56
- 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 +7 -1
- package/dist/cjs/api/firebase/FirebaseUser.js +21 -8
- package/dist/cjs/api/firebase/deviceStore.js +8 -3
- package/dist/cjs/api/index.d.ts +2 -41
- package/dist/cjs/api/index.js +4 -1
- package/dist/electron/index.js +5 -5
- 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 +7 -1
- package/dist/esm/api/firebase/FirebaseUser.js +21 -8
- package/dist/esm/api/firebase/deviceStore.js +8 -3
- package/dist/esm/api/index.d.ts +2 -41
- package/dist/esm/api/index.js +4 -1
- package/dist/esm/neurosity.mjs +22668 -35028
- package/dist/examples/neurosity.iife.js +22665 -35025
- package/dist/examples/neurosity.js +42 -56
- package/dist/examples/neurosity.mjs +22668 -35028
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import firebase from "firebase/
|
|
2
|
-
import "firebase/
|
|
3
|
-
import "firebase/
|
|
4
|
-
import "firebase/
|
|
5
|
-
import "firebase/
|
|
1
|
+
import firebase from "firebase/app";
|
|
2
|
+
import "firebase/database";
|
|
3
|
+
import "firebase/auth";
|
|
4
|
+
import "firebase/functions";
|
|
5
|
+
import "firebase/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/
|
|
2
|
-
import "firebase/
|
|
3
|
-
import "firebase/
|
|
4
|
-
import "firebase/
|
|
5
|
-
import "firebase/
|
|
1
|
+
import firebase from "firebase/app";
|
|
2
|
+
import "firebase/database";
|
|
3
|
+
import "firebase/auth";
|
|
4
|
+
import "firebase/functions";
|
|
5
|
+
import "firebase/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/
|
|
10
|
+
import firebase from "firebase/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/
|
|
2
|
+
import firebase from "firebase/app";
|
|
3
3
|
import { User } from "@firebase/auth-types";
|
|
4
4
|
import { FirebaseApp } from "./FirebaseApp";
|
|
5
5
|
import { Credentials, EmailAndPassword, CustomToken } from "../../types/credentials";
|
|
@@ -8,6 +8,12 @@ import { DeviceInfo } from "../../types/deviceInfo";
|
|
|
8
8
|
import { OAuthRemoveResponse } from "../../types/oauth";
|
|
9
9
|
import { Experiment } from "../../types/experiment";
|
|
10
10
|
import { TransferDeviceOptions } from "../../utils/transferDevice";
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export declare type UserWithMetadata = User & {
|
|
15
|
+
selectedDevice: DeviceInfo | null;
|
|
16
|
+
};
|
|
11
17
|
/**
|
|
12
18
|
* @hidden
|
|
13
19
|
*/
|
|
@@ -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/
|
|
12
|
+
import firebase from "firebase/app";
|
|
13
13
|
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
14
14
|
/**
|
|
15
15
|
* @hidden
|
|
@@ -87,7 +87,9 @@ export class FirebaseUser {
|
|
|
87
87
|
}
|
|
88
88
|
onLogin() {
|
|
89
89
|
return new Observable((subscriber) => {
|
|
90
|
-
const unsubscribe = this.app
|
|
90
|
+
const unsubscribe = this.app
|
|
91
|
+
.auth()
|
|
92
|
+
.onAuthStateChanged((user) => {
|
|
91
93
|
if (!!user) {
|
|
92
94
|
subscriber.next(user);
|
|
93
95
|
subscriber.complete();
|
|
@@ -108,7 +110,9 @@ export class FirebaseUser {
|
|
|
108
110
|
}
|
|
109
111
|
if ("email" in credentials && "password" in credentials) {
|
|
110
112
|
const { email, password } = credentials;
|
|
111
|
-
return this.app
|
|
113
|
+
return this.app
|
|
114
|
+
.auth()
|
|
115
|
+
.signInWithEmailAndPassword(email, password);
|
|
112
116
|
}
|
|
113
117
|
throw new Error(`Either {email,password}, {customToken}, or {idToken,providerId} is required`);
|
|
114
118
|
}
|
|
@@ -236,7 +240,8 @@ export class FirebaseUser {
|
|
|
236
240
|
if (!userId) {
|
|
237
241
|
return Promise.reject(new Error(`transferDevice: auth is required.`));
|
|
238
242
|
}
|
|
239
|
-
if (!("recipientsEmail" in options) &&
|
|
243
|
+
if (!("recipientsEmail" in options) &&
|
|
244
|
+
!("recipientsUserId" in options)) {
|
|
240
245
|
return Promise.reject(new Error(`transferDevice: either 'recipientsEmail' or 'recipientsUserId' key is required.`));
|
|
241
246
|
}
|
|
242
247
|
if (!(options === null || options === void 0 ? void 0 : options.deviceId)) {
|
|
@@ -256,7 +261,9 @@ export class FirebaseUser {
|
|
|
256
261
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
262
|
// hex string of 32 characters
|
|
258
263
|
const hexRegEx = /[0-9A-Fa-f]{32}/g;
|
|
259
|
-
if (!deviceId ||
|
|
264
|
+
if (!deviceId ||
|
|
265
|
+
deviceId.length !== 32 ||
|
|
266
|
+
!hexRegEx.test(deviceId)) {
|
|
260
267
|
return Promise.reject("The device id is incorrectly formatted.");
|
|
261
268
|
}
|
|
262
269
|
const claimedByPath = this.getDeviceClaimedByPath(deviceId);
|
|
@@ -288,7 +295,9 @@ export class FirebaseUser {
|
|
|
288
295
|
return EMPTY;
|
|
289
296
|
}
|
|
290
297
|
const claimsUpdatedOnPath = this.getUserClaimsUpdatedOnPath();
|
|
291
|
-
const claimsUpdatedOnRef = this.app
|
|
298
|
+
const claimsUpdatedOnRef = this.app
|
|
299
|
+
.database()
|
|
300
|
+
.ref(claimsUpdatedOnPath);
|
|
292
301
|
return fromEventPattern((handler) => claimsUpdatedOnRef.on("value", handler), (handler) => claimsUpdatedOnRef.off("value", handler)).pipe(map(([snapshot]) => snapshot.val()), switchMap(() => {
|
|
293
302
|
// Force refresh of auth id token
|
|
294
303
|
return from(this.getIdToken(true)).pipe(switchMap(() => from(this.getClaims())));
|
|
@@ -323,11 +332,15 @@ export class FirebaseUser {
|
|
|
323
332
|
}
|
|
324
333
|
userDevicesToDeviceInfoList(userDevices) {
|
|
325
334
|
return __awaiter(this, void 0, void 0, function* () {
|
|
326
|
-
const devicesInfoSnapshots = Object.keys(userDevices !== null && userDevices !== void 0 ? userDevices : {}).map((deviceId) => this.app
|
|
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"));
|
|
327
339
|
const devicesList = yield Promise.all(devicesInfoSnapshots).then((snapshots) => snapshots.map((snapshot) => snapshot.val()));
|
|
328
340
|
const validDevices = devicesList.filter((device) => !!device);
|
|
329
341
|
validDevices.sort((a, b) => {
|
|
330
|
-
return (userDevices[a.deviceId].claimedOn -
|
|
342
|
+
return (userDevices[a.deviceId].claimedOn -
|
|
343
|
+
userDevices[b.deviceId].claimedOn);
|
|
331
344
|
});
|
|
332
345
|
return validDevices;
|
|
333
346
|
});
|
|
@@ -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/
|
|
10
|
+
import firebase from "firebase/app";
|
|
11
11
|
const SERVER_TIMESTAMP = firebase.database.ServerValue.TIMESTAMP;
|
|
12
12
|
/**
|
|
13
13
|
* @hidden
|
|
@@ -27,7 +27,9 @@ 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
|
|
30
|
+
const listener = deviceRef
|
|
31
|
+
.child(namespace)
|
|
32
|
+
.on(eventType, (snapshot) => {
|
|
31
33
|
callback(snapshot.val(), snapshot);
|
|
32
34
|
});
|
|
33
35
|
listenersToRemove.push(() => {
|
|
@@ -93,7 +95,10 @@ export const createDeviceStore = (app, deviceId, subscriptionManager) => {
|
|
|
93
95
|
});
|
|
94
96
|
});
|
|
95
97
|
listenersToRemove.push(() => {
|
|
96
|
-
app
|
|
98
|
+
app
|
|
99
|
+
.database()
|
|
100
|
+
.ref(".info/connected")
|
|
101
|
+
.off("value", connectedListener);
|
|
97
102
|
});
|
|
98
103
|
return {
|
|
99
104
|
set,
|
package/dist/esm/api/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { FirebaseApp, FirebaseUser, FirebaseDevice } from "./firebase";
|
|
3
|
+
import { UserWithMetadata } from "./firebase";
|
|
3
4
|
import { Timesync } from "../timesync";
|
|
4
5
|
import { SubscriptionManager } from "../subscriptions/SubscriptionManager";
|
|
5
6
|
import { Client } from "../types/client";
|
|
@@ -41,47 +42,7 @@ export declare class CloudClient implements Client {
|
|
|
41
42
|
getInfo(): Promise<any>;
|
|
42
43
|
login(credentials: Credentials): Promise<any>;
|
|
43
44
|
logout(): Promise<any>;
|
|
44
|
-
onAuthStateChanged(): Observable<
|
|
45
|
-
selectedDevice: DeviceInfo;
|
|
46
|
-
delete(): Promise<void>;
|
|
47
|
-
emailVerified: boolean;
|
|
48
|
-
getIdTokenResult(forceRefresh?: boolean): Promise<import("@firebase/auth-types").IdTokenResult>;
|
|
49
|
-
getIdToken(forceRefresh?: boolean): Promise<string>;
|
|
50
|
-
isAnonymous: boolean;
|
|
51
|
-
linkAndRetrieveDataWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
|
|
52
|
-
linkWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
|
|
53
|
-
linkWithPhoneNumber(phoneNumber: string, applicationVerifier: import("@firebase/auth-types").ApplicationVerifier): Promise<import("@firebase/auth-types").ConfirmationResult>;
|
|
54
|
-
linkWithPopup(provider: import("@firebase/auth-types").AuthProvider): Promise<import("@firebase/auth-types").UserCredential>;
|
|
55
|
-
linkWithRedirect(provider: import("@firebase/auth-types").AuthProvider): Promise<void>;
|
|
56
|
-
metadata: import("@firebase/auth-types").UserMetadata;
|
|
57
|
-
multiFactor: import("@firebase/auth-types").MultiFactorUser;
|
|
58
|
-
phoneNumber: string;
|
|
59
|
-
providerData: import("@firebase/auth-types").UserInfo[];
|
|
60
|
-
reauthenticateAndRetrieveDataWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
|
|
61
|
-
reauthenticateWithCredential(credential: import("@firebase/auth-types").AuthCredential): Promise<import("@firebase/auth-types").UserCredential>;
|
|
62
|
-
reauthenticateWithPhoneNumber(phoneNumber: string, applicationVerifier: import("@firebase/auth-types").ApplicationVerifier): Promise<import("@firebase/auth-types").ConfirmationResult>;
|
|
63
|
-
reauthenticateWithPopup(provider: import("@firebase/auth-types").AuthProvider): Promise<import("@firebase/auth-types").UserCredential>;
|
|
64
|
-
reauthenticateWithRedirect(provider: import("@firebase/auth-types").AuthProvider): Promise<void>;
|
|
65
|
-
refreshToken: string;
|
|
66
|
-
reload(): Promise<void>;
|
|
67
|
-
sendEmailVerification(actionCodeSettings?: import("@firebase/auth-types").ActionCodeSettings): Promise<void>;
|
|
68
|
-
tenantId: string;
|
|
69
|
-
toJSON(): Object;
|
|
70
|
-
unlink(providerId: string): Promise<import("@firebase/auth-types").User>;
|
|
71
|
-
updateEmail(newEmail: string): Promise<void>;
|
|
72
|
-
updatePassword(newPassword: string): Promise<void>;
|
|
73
|
-
updatePhoneNumber(phoneCredential: import("@firebase/auth-types").AuthCredential): Promise<void>;
|
|
74
|
-
updateProfile(profile: {
|
|
75
|
-
displayName?: string;
|
|
76
|
-
photoURL?: string;
|
|
77
|
-
}): Promise<void>;
|
|
78
|
-
verifyBeforeUpdateEmail(newEmail: string, actionCodeSettings?: import("@firebase/auth-types").ActionCodeSettings): Promise<void>;
|
|
79
|
-
displayName: string;
|
|
80
|
-
email: string;
|
|
81
|
-
photoURL: string;
|
|
82
|
-
providerId: string;
|
|
83
|
-
uid: string;
|
|
84
|
-
}>;
|
|
45
|
+
onAuthStateChanged(): Observable<UserWithMetadata>;
|
|
85
46
|
getDevices(): Promise<DeviceInfo[]>;
|
|
86
47
|
addDevice(deviceId: string): Promise<void>;
|
|
87
48
|
removeDevice(deviceId: string): Promise<void>;
|
package/dist/esm/api/index.js
CHANGED
|
@@ -135,7 +135,10 @@ export class CloudClient {
|
|
|
135
135
|
const selectedDevice = this.didSelectDevice()
|
|
136
136
|
? yield this.getSelectedDevice()
|
|
137
137
|
: yield this.setAutoSelectedDevice();
|
|
138
|
-
|
|
138
|
+
const userWithMetadata = Object.assign(user, {
|
|
139
|
+
selectedDevice
|
|
140
|
+
});
|
|
141
|
+
return userWithMetadata;
|
|
139
142
|
})));
|
|
140
143
|
}
|
|
141
144
|
getDevices() {
|