Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_handleQueryCursor(cursor, docOrField, fields) {
const modifiers = this._modifiers._copy();
if (isUndefined(docOrField)) {
throw new Error(
`firebase.firestore().collection().${cursor}(*) Expected a DocumentSnapshot or list of field values but got undefined.`,
);
}
// Handles cases where the first arg is a DocumentSnapshot
if (docOrField instanceof FirestoreDocumentSnapshot) {
if (fields.length > 0) {
throw new Error(
`firebase.firestore().collection().${cursor}(*) Too many arguments provided. Expected DocumentSnapshot or list of field values.`,
);
}
const documentSnapshot = docOrField;
if (!documentSnapshot.exists) {
deleteToken(authorizedEntity, scope) {
if (!isUndefined(authorizedEntity) && !isString(authorizedEntity)) {
throw new Error(
"firebase.messaging().deleteToken(*) 'authorizedEntity' expected a string value.",
);
}
if (!isUndefined(scope) && !isString(scope)) {
throw new Error("firebase.messaging().deleteToken(_, *) 'scope' expected a string value.");
}
return this.native.deleteToken(
authorizedEntity || this.app.options.messagingSenderId,
scope || 'FCM',
);
}
docChanges(options) {
if (!isUndefined(options) && !isObject(options)) {
throw new Error(
"firebase.firestore() QuerySnapshot.docChanges(*) 'options' expected an object.",
);
}
let includeMetaDataChanges = false;
if (options) {
if (!isBoolean(options.includeMetadataChanges)) {
throw new Error(
"firebase.firestore() QuerySnapshot.docChanges(*) 'options.includeMetadataChanges' expected a boolean.",
);
}
includeMetaDataChanges = options.includeMetadataChanges;
}
let _string = string;
let _format = format;
let _metadata = metadata;
if (format === StorageStatics.StringFormat.RAW) {
_string = Base64.btoa(_string);
_format = StorageStatics.StringFormat.BASE64;
} else if (format === StorageStatics.StringFormat.DATA_URL) {
const { mediaType, base64String } = getDataUrlParts(_string);
if (isUndefined(base64String)) {
throw new Error(
'firebase.storage.StorageReference.putString(*, _, _) invalid data_url string provided.',
);
}
if (isUndefined(metadata) || isUndefined(metadata.contentType)) {
if (isUndefined(metadata)) {
_metadata = {};
}
_metadata.contentType = mediaType;
_string = base64String;
_format = StorageStatics.StringFormat.BASE64;
}
}
return new StorageUploadTask(this, task =>
this._storage.native.putString(this.toString(), _string, _format, _metadata, task._id),
);
}
showForm(options) {
if (!isUndefined(options) && !isObject(options)) {
throw new Error("firebase.admob.AdsConsent.showForm(*) 'options' expected an object value.");
}
if (!isValidUrl(options.privacyPolicy)) {
throw new Error(
"firebase.admob.AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.",
);
}
if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {
throw new Error(
"firebase.admob.AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.",
);
}
if (
export default function remoteMessageOptions(messagingSenderId, remoteMessage) {
const out = {};
if (isUndefined(remoteMessage) || !isObject(remoteMessage)) {
throw new Error("'remoteMessage' expected an object value");
}
if (!remoteMessage.to) {
out.to = `${messagingSenderId}@fcm.googleapis.com`;
} else if (!isString(remoteMessage.to)) {
throw new Error("'remoteMessage.to' expected a string value");
} else {
out.to = remoteMessage.to;
}
if (!remoteMessage.messageId) {
out.messageId = generateFirestoreId();
} else if (!isString(remoteMessage.messageId)) {
throw new Error("'remoteMessage.messageId' expected a string value");
} else {
once(eventType, successCallBack, failureCallbackOrContext, context) {
if (!eventTypes.includes(eventType)) {
throw new Error(
`firebase.database().ref().once(*) 'eventType' must be one of ${eventTypes.join(', ')}.`,
);
}
if (!isUndefined(successCallBack) && !isFunction(successCallBack)) {
throw new Error("firebase.database().ref().once(_, *) 'successCallBack' must be a function.");
}
if (
!isUndefined(failureCallbackOrContext) &&
(!isObject(failureCallbackOrContext) && !isFunction(failureCallbackOrContext))
) {
throw new Error(
"firebase.database().ref().once(_, _, *) 'failureCallbackOrContext' must be a function or context.",
);
}
if (!isUndefined(context) && !isObject(context)) {
throw new Error(
"firebase.database().ref().once(_, _, _, *) 'context' must be a context object.",
);
push(value, onComplete) {
if (!isUndefined(onComplete) && !isFunction(onComplete)) {
throw new Error(
"firebase.database().ref().push(_, *) 'onComplete' must be a function if provided.",
);
}
const id = generateDatabaseId(this._database._serverTimeOffset);
if (isUndefined(value) || isNull(value)) {
return new DatabaseThenableReference(
this._database,
pathChild(this.path, id),
Promise.resolve(this.child(id)),
);
}
const pushRef = this.child(id);
isEqual(other) {
if (isUndefined(other) || !(other instanceof FirestoreSnapshotMetadata)) {
throw new Error(
"firebase.firestore() SnapshotMetadata.isEqual(*) 'other' expected instance of SnapshotMetadata",
);
}
return this.fromCache === other.fromCache && this.hasPendingWrites === other.hasPendingWrites;
}
}