Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
child(path) {
if (!isString(path)) {
throw new Error("snapshot().child(*) 'path' must be a string value");
}
let value = deepGet(this._snapshot.value, path);
if (value === undefined) {
value = null;
}
const childRef = this._ref.child(path);
return new DatabaseDataSnapshot(childRef, {
value,
key: childRef.key,
exists: value !== null,
childKeys: isObject(value) ? Object.keys(value) : [],
if (hasOwnProperty(textMessage, 'isLocalUser')) {
if (!isBoolean(textMessage.isLocalUser)) {
throw new Error("'textMessage.isLocalUser' expected boolean value");
}
out.isLocalUser = textMessage.isLocalUser;
}
if (out.isLocalUser && hasOwnProperty(textMessage, 'userId')) {
throw new Error(
"'textMessage.userId' expected 'textMessage.isLocalUser' to be false when setting a user ID.",
);
} else if (!out.isLocalUser && !hasOwnProperty(textMessage, 'userId')) {
throw new Error("'textMessage.userId' expected a string value");
} else if (!out.isLocalUser && hasOwnProperty(textMessage, 'userId')) {
if (!isString(textMessage.userId)) {
throw new Error("'textMessage.userId' expected a string value");
}
if (textMessage.userId.length === 0) {
throw new Error("'textMessage.userId' expected string value to not be empty");
}
out.userId = textMessage.userId;
}
return out;
}
constructor(app, config, bucketUrl) {
super(app, config, bucketUrl);
if (bucketUrl === undefined) {
this._customUrlOrRegion = `gs://${app.options.storageBucket}`;
} else if (!isString(bucketUrl) || !bucketUrl.startsWith('gs://')) {
throw new Error(
"firebase.app().storage(*) bucket url must be a string and begin with 'gs://'",
);
}
this.emitter.addListener(
this.eventNameForApp(nativeEvents[0]),
handleStorageEvent.bind(null, this),
);
this._maxUploadRetryTime = this.native.maxUploadRetryTime || 0;
this._maxDownloadRetryTime = this.native.maxDownloadRetryTime || 0;
this._maxOperationRetryTime = this.native.maxOperationRetryTime || 0;
}
static fromBase64String(base64) {
if (!isString(base64) || base64.length < 1) {
throw new Error(
'firestore.Blob.fromBase64String expects a string of at least 1 character in length',
);
}
return new FirestoreBlob(true, Base64.atob(base64));
}
setAttribute(name, value) {
if (!isString(name)) {
throw new Error(
'firebase.crashlytics().setAttribute(*, _): The supplied property name must be a string.',
);
}
if (!isString(value)) {
throw new Error(
'firebase.crashlytics().setAttribute(_, *): The supplied property value must be a string value.',
);
}
return this.native.setAttribute(name, value);
}
equalTo(value, key) {
if (!isNumber(value) && !isString(value) && !isBoolean(value) && !isNull(value)) {
throw new Error(
"firebase.database().ref().equalTo(*) 'value' must be a number, string, boolean or null value.",
);
}
if (!isUndefined(key) && !isString(key)) {
throw new Error(
"firebase.database().ref().equalTo(_, *) 'key' must be a string value if defined.",
);
}
if (this._modifiers.hasStartAt()) {
throw new Error(
'firebase.database().ref().equalTo() Starting point was already set (by another call to startAt or equalTo).',
);
}
throw new Error(`'options.networkExtras' expected a string value for object key "${key}"`);
}
});
out.networkExtras = options.networkExtras;
}
if (options.keywords) {
if (!isArray(options.keywords)) {
throw new Error("'options.keywords' expected an array containing string values");
}
for (let i = 0; i < options.keywords.length; i++) {
const keyword = options.keywords[i];
if (!isString(keyword)) {
throw new Error("'options.keywords' expected an array containing string values");
}
}
out.keywords = options.keywords;
}
if (options.testDevices) {
if (!isArray(options.testDevices)) {
throw new Error("'options.testDevices' expected an array containing string values");
}
for (let i = 0; i < options.testDevices.length; i++) {
const device = options.testDevices[i];
if (!isString(device)) {
if (!isObject(iosParams)) {
throw new Error("'dynamicLinksParams.ios' must be an object.");
}
const params = {};
if (iosParams.appStoreId) {
if (!isString(iosParams.appStoreId)) {
throw new Error("'dynamicLinksParams.ios.appStoreId' must be a string.");
}
params.appStoreId = iosParams.appStoreId;
}
if (iosParams.bundleId) {
if (!isString(iosParams.bundleId)) {
throw new Error("'dynamicLinksParams.ios.bundleId' must be a string.");
}
params.bundleId = iosParams.bundleId;
}
if (iosParams.customScheme) {
if (!isString(iosParams.customScheme)) {
throw new Error("'dynamicLinksParams.ios.customScheme' must be a string.");
}
params.customScheme = iosParams.customScheme;
}
if (iosParams.fallbackUrl) {
if (!isString(iosParams.fallbackUrl)) {
where(fieldPath, opStr, value) {
if (!isString(fieldPath) && !(fieldPath instanceof FirestoreFieldPath)) {
throw new Error(
"firebase.firestore().collection().where(*) 'fieldPath' must be a string or instance of FieldPath.",
);
}
let path;
if (isString(fieldPath)) {
try {
path = fromDotSeparatedString(fieldPath);
} catch (e) {
throw new Error(`firebase.firestore().collection().where(*) 'fieldPath' ${e.message}.`);
}
} else {
path = fieldPath;
}
if (!this._modifiers.isValidOperator(opStr)) {
throw new Error(
"firebase.firestore().collection().where(_, *) 'opStr' is invalid. Expected one of '==', '>', '>=', '<', '<=' or 'array-contains'.",
);
}
if (isUndefined(value)) {