Socket
Socket
Sign inDemoInstall

@firebase/messaging

Package Overview
Dependencies
Maintainers
3
Versions
3277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/messaging - npm Package Compare versions

Comparing version 0.2.0-canary.b6b4e2f to 0.2.0-canary.cde4e44

dist/cjs/src/models/clean-v1-undefined.d.ts

2

dist/cjs/src/controllers/sw-controller.d.ts

@@ -65,3 +65,3 @@ import ControllerInterface from './controller-interface';

*/
attemptToMessageClient_(client: any, message: any): Promise<void>;
attemptToMessageClient_(client: any, message: any): Promise<never>;
/**

@@ -68,0 +68,0 @@ * @private

@@ -17,13 +17,4 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var controller_interface_1 = require("./controller-interface");

@@ -35,3 +26,3 @@ var errors_1 = require("../models/errors");

var SWController = /** @class */ (function (_super) {
__extends(SWController, _super);
tslib_1.__extends(SWController, _super);
function SWController(app) {

@@ -264,9 +255,13 @@ var _this = _super.call(this, app) || this;

SWController.prototype.attemptToMessageClient_ = function (client, message) {
// NOTE: This returns a promise in case this API is abstracted later on to
// do additional work
if (!client) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.NO_WINDOW_CLIENT_TO_MSG));
}
client.postMessage(message);
return Promise.resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// NOTE: This returns a promise in case this API is abstracted later on to
// do additional work
if (!client) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.NO_WINDOW_CLIENT_TO_MSG))];
}
client.postMessage(message);
return [2 /*return*/];
});
});
};

@@ -273,0 +268,0 @@ /**

@@ -40,3 +40,3 @@ import { FirebaseMessaging } from '@firebase/messaging-types';

*/
requestPermission(): Promise<void> | Promise<{}>;
requestPermission(): Promise<{}>;
/**

@@ -43,0 +43,0 @@ * This method allows a developer to override the default service worker and

@@ -17,13 +17,4 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var controller_interface_1 = require("./controller-interface");

@@ -38,3 +29,3 @@ var errors_1 = require("../models/errors");

var WindowController = /** @class */ (function (_super) {
__extends(WindowController, _super);
tslib_1.__extends(WindowController, _super);
/**

@@ -130,3 +121,2 @@ * A service that provides a MessagingService instance.

// We only want to error if we KNOW that the gcm_sender_id is incorrect.
return Promise.resolve();
})

@@ -154,26 +144,30 @@ .then(function (manifestContent) {

WindowController.prototype.requestPermission = function () {
var _this = this;
if (Notification.permission === notification_permission_1.default.granted) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
var managePermissionResult = function (result) {
if (result === notification_permission_1.default.granted) {
return resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
if (Notification.permission === notification_permission_1.default.granted) {
return [2 /*return*/];
}
else if (result === notification_permission_1.default.denied) {
return reject(_this.errorFactory_.create(errors_1.default.codes.PERMISSION_BLOCKED));
}
else {
return reject(_this.errorFactory_.create(errors_1.default.codes.PERMISSION_DEFAULT));
}
};
// The Notification.requestPermission API was changed to
// return a promise so now have to handle both in case
// browsers stop support callbacks for promised version
var permissionPromise = Notification.requestPermission(managePermissionResult);
if (permissionPromise) {
// Prefer the promise version as it's the future API.
permissionPromise.then(managePermissionResult);
}
return [2 /*return*/, new Promise(function (resolve, reject) {
var managePermissionResult = function (result) {
if (result === notification_permission_1.default.granted) {
return resolve();
}
else if (result === notification_permission_1.default.denied) {
return reject(_this.errorFactory_.create(errors_1.default.codes.PERMISSION_BLOCKED));
}
else {
return reject(_this.errorFactory_.create(errors_1.default.codes.PERMISSION_DEFAULT));
}
};
// The Notification.requestPermission API was changed to
// return a promise so now have to handle both in case
// browsers stop support callbacks for promised version
var permissionPromise = Notification.requestPermission(managePermissionResult);
if (permissionPromise) {
// Prefer the promise version as it's the future API.
permissionPromise.then(managePermissionResult);
}
})];
});
});

@@ -180,0 +174,0 @@ };

@@ -22,3 +22,3 @@ "use strict";

}
exports.default = function (arrayBuffer) {
exports.default = (function (arrayBuffer) {
var base64String = toBase64(arrayBuffer);

@@ -29,4 +29,4 @@ return base64String

.replace(/\//g, '_');
};
});
//# sourceMappingURL=array-buffer-to-base64.js.map

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = function (base64String) {
exports.default = (function (base64String) {
var padding = '='.repeat((4 - base64String.length % 4) % 4);

@@ -30,4 +30,4 @@ var base64 = (base64String + padding)

return outputArray;
};
});
//# sourceMappingURL=base64-to-array-buffer.js.map

@@ -28,3 +28,3 @@ import { ErrorFactory } from '@firebase/util';

*/
onDBUpgrade(db: any): void;
onDBUpgrade(db: IDBDatabase, event: IDBVersionChangeEvent): void;
}

@@ -53,3 +53,3 @@ /**

var db = event.target.result;
_this.onDBUpgrade(db);
_this.onDBUpgrade(db, event);
}

@@ -84,3 +84,3 @@ catch (err) {

*/
DBInterface.prototype.onDBUpgrade = function (db) {
DBInterface.prototype.onDBUpgrade = function (db, event) {
throw this.errorFactory_.create(errors_1.default.codes.SHOULD_BE_INHERITED);

@@ -87,0 +87,0 @@ };

import DBInterface from './db-interface';
export default class TokenDetailsModel extends DBInterface {
constructor();
static readonly DB_NAME: string;
onDBUpgrade(db: IDBDatabase, evt: IDBVersionChangeEvent): void;
/**
* @override
*/
onDBUpgrade(db: any): void;
/**
* This method takes an object and will check for known arguments and

@@ -17,3 +13,3 @@ * validate the input.

*/
validateInputs_(input: any): Promise<void>;
validateInputs_(input: any): Promise<never>;
/**

@@ -20,0 +16,0 @@ * Given a token, this method will look up the details in indexedDB.

@@ -17,18 +17,11 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var db_interface_1 = require("./db-interface");
var errors_1 = require("./errors");
var array_buffer_to_base64_1 = require("../helpers/array-buffer-to-base64");
var clean_v1_undefined_1 = require("./clean-v1-undefined");
var FCM_TOKEN_OBJ_STORE = 'fcm_token_object_Store';
var DB_VERSION = 1;
var DB_NAME = 'fcm_token_details_db';
var DB_VERSION = 2;
/** @record */

@@ -49,27 +42,26 @@ function ValidateInput() { }

var TokenDetailsModel = /** @class */ (function (_super) {
__extends(TokenDetailsModel, _super);
tslib_1.__extends(TokenDetailsModel, _super);
function TokenDetailsModel() {
return _super.call(this, TokenDetailsModel.DB_NAME, DB_VERSION) || this;
return _super.call(this, DB_NAME, DB_VERSION) || this;
}
Object.defineProperty(TokenDetailsModel, "DB_NAME", {
get: function () {
return 'fcm_token_details_db';
},
enumerable: true,
configurable: true
});
/**
* @override
*/
TokenDetailsModel.prototype.onDBUpgrade = function (db) {
var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {
keyPath: 'swScope'
});
// Make sure the sender ID can be searched
objectStore.createIndex('fcmSenderId', 'fcmSenderId', {
unique: false
});
objectStore.createIndex('fcmToken', 'fcmToken', {
unique: true
});
TokenDetailsModel.prototype.onDBUpgrade = function (db, evt) {
if (evt.oldVersion < 1) {
// New IDB instance
var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {
keyPath: 'swScope'
});
// Make sure the sender ID can be searched
objectStore.createIndex('fcmSenderId', 'fcmSenderId', {
unique: false
});
objectStore.createIndex('fcmToken', 'fcmToken', {
unique: true
});
}
if (evt.oldVersion < 2) {
// Prior to version 2, we were using either 'fcm_token_details_db'
// or 'undefined' as the database name due to bug in the SDK
// So remove the old tokens and databases.
clean_v1_undefined_1.cleanV1();
}
};

@@ -85,36 +77,40 @@ /**

TokenDetailsModel.prototype.validateInputs_ = function (input) {
if (input.fcmToken) {
if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_TOKEN));
}
}
if (input.swScope) {
if (typeof input.swScope !== 'string' || input.swScope.length === 0) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SCOPE));
}
}
if (input.vapidKey) {
if (!(input.vapidKey instanceof Uint8Array) ||
input.vapidKey.length !== 65) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_VAPID_KEY));
}
}
if (input.subscription) {
if (!(input.subscription instanceof PushSubscription)) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SUBSCRIPTION));
}
}
if (input.fcmSenderId) {
if (typeof input.fcmSenderId !== 'string' ||
input.fcmSenderId.length === 0) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SENDER_ID));
}
}
if (input.fcmPushSet) {
if (typeof input.fcmPushSet !== 'string' ||
input.fcmPushSet.length === 0) {
return Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_PUSH_SET));
}
}
return Promise.resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (input.fcmToken) {
if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_TOKEN))];
}
}
if (input.swScope) {
if (typeof input.swScope !== 'string' || input.swScope.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SCOPE))];
}
}
if (input.vapidKey) {
if (!(input.vapidKey instanceof Uint8Array) ||
input.vapidKey.length !== 65) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_VAPID_KEY))];
}
}
if (input.subscription) {
if (!(input.subscription instanceof PushSubscription)) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SUBSCRIPTION))];
}
}
if (input.fcmSenderId) {
if (typeof input.fcmSenderId !== 'string' ||
input.fcmSenderId.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_SENDER_ID))];
}
}
if (input.fcmPushSet) {
if (typeof input.fcmPushSet !== 'string' ||
input.fcmPushSet.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors_1.default.codes.BAD_PUSH_SET))];
}
}
return [2 /*return*/];
});
});
};

@@ -121,0 +117,0 @@ /**

import DBInterface from './db-interface';
export default class VapidDetailsModel extends DBInterface {
constructor();
static readonly DB_NAME: string;
/**

@@ -6,0 +5,0 @@ * @override

@@ -17,30 +17,15 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var db_interface_1 = require("./db-interface");
var errors_1 = require("./errors");
var FCM_VAPID_OBJ_STORE = 'fcm_vapid_object_Store';
var DB_NAME = 'fcm_vapid_details_db';
var DB_VERSION = 1;
var UNCOMPRESSED_PUBLIC_KEY_SIZE = 65;
var VapidDetailsModel = /** @class */ (function (_super) {
__extends(VapidDetailsModel, _super);
tslib_1.__extends(VapidDetailsModel, _super);
function VapidDetailsModel() {
return _super.call(this, VapidDetailsModel.DB_NAME, DB_VERSION) || this;
return _super.call(this, DB_NAME, DB_VERSION) || this;
}
Object.defineProperty(VapidDetailsModel, "DB_NAME", {
get: function () {
return 'fcm_vapid_details_db';
},
enumerable: true,
configurable: true
});
/**

@@ -47,0 +32,0 @@ * @override

@@ -65,3 +65,3 @@ import ControllerInterface from './controller-interface';

*/
attemptToMessageClient_(client: any, message: any): Promise<void>;
attemptToMessageClient_(client: any, message: any): Promise<never>;
/**

@@ -68,0 +68,0 @@ * @private

@@ -17,12 +17,3 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as tslib_1 from "tslib";
import ControllerInterface from './controller-interface';

@@ -34,3 +25,3 @@ import Errors from '../models/errors';

var SWController = /** @class */ (function (_super) {
__extends(SWController, _super);
tslib_1.__extends(SWController, _super);
function SWController(app) {

@@ -263,9 +254,13 @@ var _this = _super.call(this, app) || this;

SWController.prototype.attemptToMessageClient_ = function (client, message) {
// NOTE: This returns a promise in case this API is abstracted later on to
// do additional work
if (!client) {
return Promise.reject(this.errorFactory_.create(Errors.codes.NO_WINDOW_CLIENT_TO_MSG));
}
client.postMessage(message);
return Promise.resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// NOTE: This returns a promise in case this API is abstracted later on to
// do additional work
if (!client) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.NO_WINDOW_CLIENT_TO_MSG))];
}
client.postMessage(message);
return [2 /*return*/];
});
});
};

@@ -272,0 +267,0 @@ /**

@@ -40,3 +40,3 @@ import { FirebaseMessaging } from '@firebase/messaging-types';

*/
requestPermission(): Promise<void> | Promise<{}>;
requestPermission(): Promise<{}>;
/**

@@ -43,0 +43,0 @@ * This method allows a developer to override the default service worker and

@@ -17,12 +17,3 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as tslib_1 from "tslib";
import ControllerInterface from './controller-interface';

@@ -37,3 +28,3 @@ import Errors from '../models/errors';

var WindowController = /** @class */ (function (_super) {
__extends(WindowController, _super);
tslib_1.__extends(WindowController, _super);
/**

@@ -129,3 +120,2 @@ * A service that provides a MessagingService instance.

// We only want to error if we KNOW that the gcm_sender_id is incorrect.
return Promise.resolve();
})

@@ -153,26 +143,30 @@ .then(function (manifestContent) {

WindowController.prototype.requestPermission = function () {
var _this = this;
if (Notification.permission === NOTIFICATION_PERMISSION.granted) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
var managePermissionResult = function (result) {
if (result === NOTIFICATION_PERMISSION.granted) {
return resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
if (Notification.permission === NOTIFICATION_PERMISSION.granted) {
return [2 /*return*/];
}
else if (result === NOTIFICATION_PERMISSION.denied) {
return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_BLOCKED));
}
else {
return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_DEFAULT));
}
};
// The Notification.requestPermission API was changed to
// return a promise so now have to handle both in case
// browsers stop support callbacks for promised version
var permissionPromise = Notification.requestPermission(managePermissionResult);
if (permissionPromise) {
// Prefer the promise version as it's the future API.
permissionPromise.then(managePermissionResult);
}
return [2 /*return*/, new Promise(function (resolve, reject) {
var managePermissionResult = function (result) {
if (result === NOTIFICATION_PERMISSION.granted) {
return resolve();
}
else if (result === NOTIFICATION_PERMISSION.denied) {
return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_BLOCKED));
}
else {
return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_DEFAULT));
}
};
// The Notification.requestPermission API was changed to
// return a promise so now have to handle both in case
// browsers stop support callbacks for promised version
var permissionPromise = Notification.requestPermission(managePermissionResult);
if (permissionPromise) {
// Prefer the promise version as it's the future API.
permissionPromise.then(managePermissionResult);
}
})];
});
});

@@ -179,0 +173,0 @@ };

@@ -20,3 +20,3 @@ /**

}
export default function (arrayBuffer) {
export default (function (arrayBuffer) {
var base64String = toBase64(arrayBuffer);

@@ -27,4 +27,4 @@ return base64String

.replace(/\//g, '_');
};
});
//# sourceMappingURL=array-buffer-to-base64.js.map

@@ -16,3 +16,3 @@ /**

*/
export default function (base64String) {
export default (function (base64String) {
var padding = '='.repeat((4 - base64String.length % 4) % 4);

@@ -28,4 +28,4 @@ var base64 = (base64String + padding)

return outputArray;
};
});
//# sourceMappingURL=base64-to-array-buffer.js.map

@@ -28,3 +28,3 @@ import { ErrorFactory } from '@firebase/util';

*/
onDBUpgrade(db: any): void;
onDBUpgrade(db: IDBDatabase, event: IDBVersionChangeEvent): void;
}

@@ -52,3 +52,3 @@ /**

var db = event.target.result;
_this.onDBUpgrade(db);
_this.onDBUpgrade(db, event);
}

@@ -83,3 +83,3 @@ catch (err) {

*/
DBInterface.prototype.onDBUpgrade = function (db) {
DBInterface.prototype.onDBUpgrade = function (db, event) {
throw this.errorFactory_.create(Errors.codes.SHOULD_BE_INHERITED);

@@ -86,0 +86,0 @@ };

import DBInterface from './db-interface';
export default class TokenDetailsModel extends DBInterface {
constructor();
static readonly DB_NAME: string;
onDBUpgrade(db: IDBDatabase, evt: IDBVersionChangeEvent): void;
/**
* @override
*/
onDBUpgrade(db: any): void;
/**
* This method takes an object and will check for known arguments and

@@ -17,3 +13,3 @@ * validate the input.

*/
validateInputs_(input: any): Promise<void>;
validateInputs_(input: any): Promise<never>;
/**

@@ -20,0 +16,0 @@ * Given a token, this method will look up the details in indexedDB.

@@ -17,17 +17,10 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as tslib_1 from "tslib";
import DBInterface from './db-interface';
import Errors from './errors';
import arrayBufferToBase64 from '../helpers/array-buffer-to-base64';
import { cleanV1 } from './clean-v1-undefined';
var FCM_TOKEN_OBJ_STORE = 'fcm_token_object_Store';
var DB_VERSION = 1;
var DB_NAME = 'fcm_token_details_db';
var DB_VERSION = 2;
/** @record */

@@ -48,27 +41,26 @@ function ValidateInput() { }

var TokenDetailsModel = /** @class */ (function (_super) {
__extends(TokenDetailsModel, _super);
tslib_1.__extends(TokenDetailsModel, _super);
function TokenDetailsModel() {
return _super.call(this, TokenDetailsModel.DB_NAME, DB_VERSION) || this;
return _super.call(this, DB_NAME, DB_VERSION) || this;
}
Object.defineProperty(TokenDetailsModel, "DB_NAME", {
get: function () {
return 'fcm_token_details_db';
},
enumerable: true,
configurable: true
});
/**
* @override
*/
TokenDetailsModel.prototype.onDBUpgrade = function (db) {
var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {
keyPath: 'swScope'
});
// Make sure the sender ID can be searched
objectStore.createIndex('fcmSenderId', 'fcmSenderId', {
unique: false
});
objectStore.createIndex('fcmToken', 'fcmToken', {
unique: true
});
TokenDetailsModel.prototype.onDBUpgrade = function (db, evt) {
if (evt.oldVersion < 1) {
// New IDB instance
var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {
keyPath: 'swScope'
});
// Make sure the sender ID can be searched
objectStore.createIndex('fcmSenderId', 'fcmSenderId', {
unique: false
});
objectStore.createIndex('fcmToken', 'fcmToken', {
unique: true
});
}
if (evt.oldVersion < 2) {
// Prior to version 2, we were using either 'fcm_token_details_db'
// or 'undefined' as the database name due to bug in the SDK
// So remove the old tokens and databases.
cleanV1();
}
};

@@ -84,36 +76,40 @@ /**

TokenDetailsModel.prototype.validateInputs_ = function (input) {
if (input.fcmToken) {
if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_TOKEN));
}
}
if (input.swScope) {
if (typeof input.swScope !== 'string' || input.swScope.length === 0) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE));
}
}
if (input.vapidKey) {
if (!(input.vapidKey instanceof Uint8Array) ||
input.vapidKey.length !== 65) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_VAPID_KEY));
}
}
if (input.subscription) {
if (!(input.subscription instanceof PushSubscription)) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SUBSCRIPTION));
}
}
if (input.fcmSenderId) {
if (typeof input.fcmSenderId !== 'string' ||
input.fcmSenderId.length === 0) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SENDER_ID));
}
}
if (input.fcmPushSet) {
if (typeof input.fcmPushSet !== 'string' ||
input.fcmPushSet.length === 0) {
return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_PUSH_SET));
}
}
return Promise.resolve();
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (input.fcmToken) {
if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_TOKEN))];
}
}
if (input.swScope) {
if (typeof input.swScope !== 'string' || input.swScope.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE))];
}
}
if (input.vapidKey) {
if (!(input.vapidKey instanceof Uint8Array) ||
input.vapidKey.length !== 65) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_VAPID_KEY))];
}
}
if (input.subscription) {
if (!(input.subscription instanceof PushSubscription)) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SUBSCRIPTION))];
}
}
if (input.fcmSenderId) {
if (typeof input.fcmSenderId !== 'string' ||
input.fcmSenderId.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SENDER_ID))];
}
}
if (input.fcmPushSet) {
if (typeof input.fcmPushSet !== 'string' ||
input.fcmPushSet.length === 0) {
return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_PUSH_SET))];
}
}
return [2 /*return*/];
});
});
};

@@ -120,0 +116,0 @@ /**

import DBInterface from './db-interface';
export default class VapidDetailsModel extends DBInterface {
constructor();
static readonly DB_NAME: string;
/**

@@ -6,0 +5,0 @@ * @override

@@ -17,29 +17,14 @@ /**

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as tslib_1 from "tslib";
import DBInterface from './db-interface';
import Errors from './errors';
var FCM_VAPID_OBJ_STORE = 'fcm_vapid_object_Store';
var DB_NAME = 'fcm_vapid_details_db';
var DB_VERSION = 1;
var UNCOMPRESSED_PUBLIC_KEY_SIZE = 65;
var VapidDetailsModel = /** @class */ (function (_super) {
__extends(VapidDetailsModel, _super);
tslib_1.__extends(VapidDetailsModel, _super);
function VapidDetailsModel() {
return _super.call(this, VapidDetailsModel.DB_NAME, DB_VERSION) || this;
return _super.call(this, DB_NAME, DB_VERSION) || this;
}
Object.defineProperty(VapidDetailsModel, "DB_NAME", {
get: function () {
return 'fcm_vapid_details_db';
},
enumerable: true,
configurable: true
});
/**

@@ -46,0 +31,0 @@ * @override

{
"name": "@firebase/messaging",
"version": "0.2.0-canary.b6b4e2f",
"version": "0.2.0-canary.cde4e44",
"description": "",

@@ -16,16 +16,17 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"peerDependencies": {
"@firebase/app": "0.1.9-canary.b6b4e2f"
"@firebase/app": "0.1.9-canary.cde4e44"
},
"dependencies": {
"@firebase/messaging-types": "0.1.1-canary.b6b4e2f",
"@firebase/util": "0.1.9-canary.b6b4e2f",
"lcov-result-merger": "^1.2.0"
"@firebase/messaging-types": "0.1.1-canary.cde4e44",
"@firebase/util": "0.1.9-canary.cde4e44",
"lcov-result-merger": "^2.0.0",
"tslib": "^1.9.0"
},
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/mocha": "^2.2.44",
"@types/sinon": "^2.3.7",
"@types/chai": "^4.1.2",
"@types/mocha": "^2.2.48",
"@types/sinon": "^4.1.3",
"chai": "^4.1.1",
"gulp": "gulpjs/gulp#4.0",
"karma": "^1.7.0",
"gulp": "^4.0.0",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",

@@ -36,10 +37,10 @@ "karma-cli": "^1.0.1",

"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.31",
"karma-webpack": "^2.0.4",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^2.0.9",
"npm-run-all": "^4.1.1",
"sinon": "^4.0.2",
"sinon": "^4.3.0",
"source-map-loader": "^0.2.3",
"ts-loader": "^3.1.0",
"typescript": "^2.4.2",
"webpack": "^3.8.1"
"ts-loader": "^3.5.0",
"typescript": "^2.7.2",
"webpack": "^3.11.0"
},

@@ -46,0 +47,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc