Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/installations

Package Overview
Dependencies
Maintainers
5
Versions
2729
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/installations - npm Package Compare versions

Comparing version 0.1.0-canary.96617d3 to 0.1.0-canary.9f25ab6

2

dist/index.cjs.js

@@ -236,3 +236,3 @@ 'use strict';

var PENDING_TIMEOUT_MS = 10000;
var PACKAGE_VERSION = 'w:0.1.0-canary.96617d3'; // Will be replaced by Rollup
var PACKAGE_VERSION = 'w:0.1.0-canary.9f25ab6'; // Will be replaced by Rollup
var INTERNAL_AUTH_VERSION = 'FIS_v2';

@@ -239,0 +239,0 @@ var INSTALLATIONS_API_URL = 'https://firebaseinstallations.googleapis.com/v1';

@@ -230,3 +230,3 @@ import firebase from '@firebase/app';

var PENDING_TIMEOUT_MS = 10000;
var PACKAGE_VERSION = 'w:0.1.0-canary.96617d3'; // Will be replaced by Rollup
var PACKAGE_VERSION = 'w:0.1.0-canary.9f25ab6'; // Will be replaced by Rollup
var INTERNAL_AUTH_VERSION = 'FIS_v2';

@@ -233,0 +233,0 @@ var INSTALLATIONS_API_URL = 'https://firebaseinstallations.googleapis.com/v1';

@@ -22,3 +22,3 @@ import firebase from '@firebase/app';

const PENDING_TIMEOUT_MS = 10000;
const PACKAGE_VERSION = 'w:0.1.0-canary.96617d3'; // Will be replaced by Rollup
const PACKAGE_VERSION = 'w:0.1.0-canary.9f25ab6'; // Will be replaced by Rollup
const INTERNAL_AUTH_VERSION = 'FIS_v2';

@@ -25,0 +25,0 @@ const INSTALLATIONS_API_URL = 'https://firebaseinstallations.googleapis.com/v1';

{
"name": "@firebase/installations",
"version": "0.1.0-canary.96617d3",
"version": "0.1.0-canary.9f25ab6",
"main": "dist/index.cjs.js",

@@ -48,10 +48,10 @@ "module": "dist/index.esm.js",

"peerDependencies": {
"@firebase/app": "0.3.16-canary.96617d3",
"@firebase/app-types": "0.3.9-canary.96617d3"
"@firebase/app": "0.3.17-canary.9f25ab6",
"@firebase/app-types": "0.3.10-canary.9f25ab6"
},
"dependencies": {
"@firebase/installations-types": "0.1.0-canary.96617d3",
"@firebase/util": "0.2.13-canary.96617d3",
"@firebase/installations-types": "0.1.0-canary.9f25ab6",
"@firebase/util": "0.2.14-canary.9f25ab6",
"idb": "3.0.2"
}
}

@@ -55,3 +55,3 @@ /**

).callsFake(
() => sleep(50) // Request would take some time
() => sleep(100) // Request would take some time
);

@@ -61,3 +61,3 @@ });

it('resolves without calling server API if there is no installation', async () => {
await expect(deleteInstallation(app)).to.eventually.be.fulfilled;
await expect(deleteInstallation(app)).to.be.fulfilled;
expect(deleteInstallationSpy).not.to.have.been.called;

@@ -73,3 +73,3 @@ });

await expect(deleteInstallation(app)).to.eventually.be.fulfilled;
await expect(deleteInstallation(app)).to.be.fulfilled;
expect(deleteInstallationSpy).not.to.have.been.called;

@@ -87,3 +87,3 @@ await expect(get(appConfig)).to.eventually.be.undefined;

await expect(deleteInstallation(app)).to.eventually.be.rejectedWith(
await expect(deleteInstallation(app)).to.be.rejectedWith(
ErrorCode.DELETE_PENDING_REGISTRATION

@@ -109,3 +109,3 @@ );

await expect(deleteInstallation(app)).to.eventually.be.rejectedWith(
await expect(deleteInstallation(app)).to.be.rejectedWith(
ErrorCode.APP_OFFLINE

@@ -130,3 +130,3 @@ );

await expect(deleteInstallation(app)).to.eventually.be.fulfilled;
await expect(deleteInstallation(app)).to.be.fulfilled;
expect(deleteInstallationSpy).to.have.been.calledOnceWith(appConfig, entry);

@@ -133,0 +133,0 @@ await expect(get(appConfig)).to.eventually.be.undefined;

@@ -20,7 +20,7 @@ /**

import { expect } from 'chai';
import { SinonStub, stub } from 'sinon';
import { SinonFakeTimers, SinonStub, stub, useFakeTimers } from 'sinon';
import * as createInstallationModule from '../api/create-installation';
import * as generateAuthTokenModule from '../api/generate-auth-token';
import { extractAppConfig } from '../helpers/extract-app-config';
import { clear, get, set } from '../helpers/idb-manager';
import { get, set } from '../helpers/idb-manager';
import { AppConfig } from '../interfaces/app-config';

@@ -67,3 +67,3 @@ import {

};
set(appConfig, entry);
await set(appConfig, entry);
}

@@ -85,3 +85,3 @@ ],

};
set(appConfig, entry);
await set(appConfig, entry);
}

@@ -102,6 +102,6 @@ ],

set(appConfig, entry);
await set(appConfig, entry);
// Finish pending request in 10 ms
sleep(50).then(() => {
// Finish pending request after 500 ms
sleep(500).then(async () => {
const updatedEntry: RegisteredInstallationEntry = {

@@ -131,3 +131,3 @@ ...entry,

};
set(appConfig, entry);
await set(appConfig, entry);
}

@@ -144,6 +144,6 @@ ],

set(appConfig, entry);
await set(appConfig, entry);
// Finish pending request in 10 ms
sleep(50).then(async () => {
// Finish pending request after 500 ms
sleep(500).then(async () => {
const updatedEntry: RegisteredInstallationEntry = {

@@ -172,3 +172,3 @@ fid: FID,

set(appConfig, entry);
await set(appConfig, entry);
}

@@ -198,3 +198,3 @@ ]

).callsFake(async (_, installationEntry) => {
await sleep(50); // Request would take some time
await sleep(100); // Request would take some time
const result: RegisteredInstallationEntry = {

@@ -217,3 +217,3 @@ fid: installationEntry.fid,

).callsFake(async () => {
await sleep(50); // Request would take some time
await sleep(100); // Request would take some time
const result: CompletedAuthToken = {

@@ -229,13 +229,6 @@ token: AUTH_TOKEN,

afterEach(async () => {
// Clear the database after each test.
await clear();
});
describe('basic functionality', () => {
for (const [title, setup] of setupInstallationEntryMap.entries()) {
describe(`when ${title} in the DB`, () => {
beforeEach(() => {
setup(appConfig);
});
beforeEach(() => setup(appConfig));

@@ -289,3 +282,3 @@ it('resolves with an auth token', async () => {

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
});

@@ -324,3 +317,3 @@ });

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
});

@@ -331,3 +324,2 @@

generateAuthTokenSpy.callsFake(async () => {
await sleep(50); // Request would take some time
throw ERROR_FACTORY.create(ErrorCode.REQUEST_FAILED, {

@@ -341,3 +333,3 @@ requestName: 'Generate Auth Token',

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
await expect(get(appConfig)).to.eventually.be.undefined;

@@ -348,3 +340,2 @@ });

generateAuthTokenSpy.callsFake(async () => {
await sleep(50); // Request would take some time
throw ERROR_FACTORY.create(ErrorCode.REQUEST_FAILED, {

@@ -358,3 +349,3 @@ requestName: 'Generate Auth Token',

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
await expect(get(appConfig)).to.eventually.be.undefined;

@@ -365,3 +356,2 @@ });

generateAuthTokenSpy.callsFake(async () => {
await sleep(50); // Request would take some time
throw ERROR_FACTORY.create(ErrorCode.REQUEST_FAILED, {

@@ -375,3 +365,3 @@ requestName: 'Generate Auth Token',

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
await expect(get(appConfig)).to.eventually.deep.equal(

@@ -416,4 +406,6 @@ installationEntry

const DB_AUTH_TOKEN = 'authTokenFromDB';
let clock: SinonFakeTimers;
beforeEach(async () => {
clock = useFakeTimers({ shouldAdvanceTime: true });
const installationEntry: RegisteredInstallationEntry = {

@@ -427,3 +419,5 @@ fid: FID,

requestStatus: RequestStatus.COMPLETED,
creationTime: Date.now() - ONE_WEEK_MS + TOKEN_EXPIRATION_BUFFER + 10
creationTime:
// Expires in ten minutes
Date.now() - ONE_WEEK_MS + TOKEN_EXPIRATION_BUFFER + 10 * 60 * 1000
}

@@ -438,9 +432,8 @@ };

// Wait until token expiration
await sleep(100);
// Wait 30 minutes.
clock.tick('30:00');
const token2 = await getToken(app);
expect(token2).to.equal(AUTH_TOKEN);
expect(token1).not.to.equal(token2);
await expect(token2).to.equal(AUTH_TOKEN);
await expect(token2).not.to.equal(token1);
});

@@ -468,5 +461,5 @@ });

await expect(getToken(app)).to.eventually.be.rejected;
await expect(getToken(app)).to.be.rejected;
});
});
});

@@ -19,3 +19,3 @@ /**

import { AssertionError, expect } from 'chai';
import { SinonStub, stub } from 'sinon';
import { SinonFakeTimers, SinonStub, stub, useFakeTimers } from 'sinon';
import * as createInstallationModule from '../api/create-installation';

@@ -36,3 +36,3 @@ import { AppConfig } from '../interfaces/app-config';

import { getInstallationEntry } from './get-installation-entry';
import { clear, get, set } from './idb-manager';
import { get, set } from './idb-manager';

@@ -42,2 +42,3 @@ const FID = 'cry-of-the-black-birds';

describe('getInstallationEntry', () => {
let clock: SinonFakeTimers;
let appConfig: AppConfig;

@@ -50,2 +51,3 @@ let createInstallationSpy: SinonStub<

beforeEach(() => {
clock = useFakeTimers();
appConfig = getFakeAppConfig();

@@ -57,3 +59,3 @@ createInstallationSpy = stub(

async (_, installationEntry): Promise<RegisteredInstallationEntry> => {
await sleep(50); // Request would take some time
await sleep(100); // Request would take some time
const registeredInstallationEntry: RegisteredInstallationEntry = {

@@ -75,10 +77,2 @@ fid: installationEntry.fid,

afterEach(async () => {
// Wait until createInstallation completes
await sleep(100);
// Clear the database after each test.
await clear();
});
it('saves the InstallationEntry in the database before returning it', async () => {

@@ -119,3 +113,4 @@ const oldDbEntry = await get<InstallationEntry>(appConfig);

await registrationPromise;
clock.next(); // Finish registration request.
await expect(registrationPromise).to.be.fulfilled;

@@ -130,3 +125,3 @@ const newDbEntry = await get<InstallationEntry>(appConfig);

createInstallationSpy.callsFake(async () => {
await sleep(50); // Request would take some time
await sleep(100); // Request would take some time
throw ERROR_FACTORY.create(ErrorCode.REQUEST_FAILED, {

@@ -147,2 +142,3 @@ requestName: 'Create Installation',

);
expect(registrationPromise).to.be.an.instanceOf(Promise);

@@ -152,3 +148,4 @@ const oldDbEntry = await get<InstallationEntry>(appConfig);

await expect(registrationPromise).to.eventually.be.rejected;
clock.next(); // Finish registration request.
await expect(registrationPromise).to.be.rejected;

@@ -163,3 +160,3 @@ const newDbEntry = await get<InstallationEntry>(appConfig);

createInstallationSpy.callsFake(async () => {
await sleep(50); // Request would take some time
await sleep(100); // Request would take some time
throw ERROR_FACTORY.create(ErrorCode.REQUEST_FAILED, {

@@ -184,3 +181,4 @@ requestName: 'Create Installation',

await expect(registrationPromise).to.eventually.be.rejected;
clock.next(); // Finish registration request.
await expect(registrationPromise).to.be.rejected;

@@ -267,3 +265,4 @@ const newDbEntry = await get<InstallationEntry>(appConfig);

await promise1;
clock.next(); // Finish registration request.
await expect(promise1).to.be.fulfilled;

@@ -270,0 +269,0 @@ const { registrationPromise: promise2 } = await getInstallationEntry(

@@ -33,7 +33,2 @@ /**

afterEach(async () => {
// Clear the database after each test.
await clear();
});
describe('get / set', () => {

@@ -40,0 +35,0 @@ it('sets a value and then gets the same value back', async () => {

@@ -22,2 +22,3 @@ /**

import * as sinonChai from 'sinon-chai';
import { clear } from '../helpers/idb-manager';

@@ -27,4 +28,5 @@ use(chaiAsPromised);

afterEach(() => {
afterEach(async () => {
restore();
await clear();
});

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

beforeEach(() => {
clock = useFakeTimers();
clock = useFakeTimers({ shouldAdvanceTime: true });
});
afterEach(() => {
clock.restore();
});
it('returns a promise that resolves after a given amount of time', async () => {
const t0 = clock.now;
await sleep(100);
const t1 = clock.now;
it('returns a promise that resolves after a given amount of time', async () => {
const sleepPromise = sleep(100);
expect(sleepPromise).not.to.be.fulfilled;
clock.tick(99);
expect(sleepPromise).not.to.be.fulfilled;
clock.tick(1);
expect(sleepPromise).to.be.fulfilled;
expect(t1 - t0).to.equal(100);
});
});
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