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
2717
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.3-0 to 0.1.3-canary.2e6c4aa

.rpt2_cache/rpt2_613209ee846a3b74a09c1d42ecddbaaa8c947b6e/code/cache/03badcc63fb26f8163137b77902291b0b159b03c

16

dist/index.cjs.js

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

var version = "0.1.3-0";
var version = "0.1.3-canary.2e6c4aa";

@@ -220,3 +220,4 @@ /**

return [2 /*return*/, registeredInstallationEntry];
case 3: throw getErrorFromResponse('Create Installation', response);
case 3: return [4 /*yield*/, getErrorFromResponse('Create Installation', response)];
case 4: throw _b.sent();
}

@@ -681,3 +682,4 @@ });

return [2 /*return*/, completedAuthToken];
case 3: throw getErrorFromResponse('Generate Auth Token', response);
case 3: return [4 /*yield*/, getErrorFromResponse('Generate Auth Token', response)];
case 4: throw _a.sent();
}

@@ -948,6 +950,6 @@ });

response = _a.sent();
if (!response.ok) {
throw getErrorFromResponse('Delete Installation', response);
}
return [2 /*return*/];
if (!!response.ok) return [3 /*break*/, 3];
return [4 /*yield*/, getErrorFromResponse('Delete Installation', response)];
case 2: throw _a.sent();
case 3: return [2 /*return*/];
}

@@ -954,0 +956,0 @@ });

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

var version = "0.1.3-0";
var version = "0.1.3-canary.2e6c4aa";

@@ -215,3 +215,4 @@ /**

return [2 /*return*/, registeredInstallationEntry];
case 3: throw getErrorFromResponse('Create Installation', response);
case 3: return [4 /*yield*/, getErrorFromResponse('Create Installation', response)];
case 4: throw _b.sent();
}

@@ -676,3 +677,4 @@ });

return [2 /*return*/, completedAuthToken];
case 3: throw getErrorFromResponse('Generate Auth Token', response);
case 3: return [4 /*yield*/, getErrorFromResponse('Generate Auth Token', response)];
case 4: throw _a.sent();
}

@@ -943,6 +945,6 @@ });

response = _a.sent();
if (!response.ok) {
throw getErrorFromResponse('Delete Installation', response);
}
return [2 /*return*/];
if (!!response.ok) return [3 /*break*/, 3];
return [4 /*yield*/, getErrorFromResponse('Delete Installation', response)];
case 2: throw _a.sent();
case 3: return [2 /*return*/];
}

@@ -949,0 +951,0 @@ });

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

const version = "0.1.3-0";
const version = "0.1.3-canary.2e6c4aa";

@@ -192,3 +192,3 @@ /**

else {
throw getErrorFromResponse('Create Installation', response);
throw await getErrorFromResponse('Create Installation', response);
}

@@ -555,3 +555,3 @@ }

else {
throw getErrorFromResponse('Generate Auth Token', response);
throw await getErrorFromResponse('Generate Auth Token', response);
}

@@ -740,3 +740,3 @@ }

if (!response.ok) {
throw getErrorFromResponse('Delete Installation', response);
throw await getErrorFromResponse('Delete Installation', response);
}

@@ -743,0 +743,0 @@ }

{
"name": "@firebase/installations",
"version": "0.1.3-0",
"version": "0.1.3-canary.2e6c4aa",
"main": "dist/index.cjs.js",

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

"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/app-types": "0.x"
"@firebase/app": "0.4.3-canary.2e6c4aa",
"@firebase/app-types": "0.4.0-canary.2e6c4aa"
},
"dependencies": {
"@firebase/installations-types": "0.1.1-0",
"@firebase/util": "0.2.17-0",
"@firebase/installations-types": "0.1.1-canary.2e6c4aa",
"@firebase/util": "0.2.17-canary.2e6c4aa",
"idb": "3.0.2",

@@ -56,0 +56,0 @@ "tslib": "1.9.3"

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

import { FirebaseError } from '@firebase/util';
import { expect } from 'chai';

@@ -39,3 +40,3 @@ import { SinonStub, stub } from 'sinon';

describe('api', () => {
describe('createInstallation', () => {
let appConfig: AppConfig;

@@ -53,51 +54,77 @@ let fetchSpy: SinonStub<[RequestInfo, RequestInit?], Promise<Response>>;

};
});
const response: CreateInstallationResponse = {
refreshToken: 'refreshToken',
authToken: {
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
expiresIn: '604800s'
}
};
describe('successful request', () => {
beforeEach(() => {
const response: CreateInstallationResponse = {
refreshToken: 'refreshToken',
authToken: {
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
expiresIn: '604800s'
}
};
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response))
);
});
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response))
);
});
it('registers a pending InstallationEntry', async () => {
const registeredInstallationEntry = await createInstallation(
appConfig,
inProgressInstallationEntry
);
expect(registeredInstallationEntry.registrationStatus).to.equal(
RequestStatus.COMPLETED
);
it('registers a pending InstallationEntry', async () => {
const registeredInstallationEntry = await createInstallation(
appConfig,
inProgressInstallationEntry
);
expect(registeredInstallationEntry.registrationStatus).to.equal(
RequestStatus.COMPLETED
);
});
it('calls the createInstallation server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
'x-goog-api-key': 'apiKey'
});
const expectedBody = {
fid: FID,
authVersion: INTERNAL_AUTH_VERSION,
appId: appConfig.appId,
sdkVersion: PACKAGE_VERSION
};
const expectedRequest: RequestInit = {
method: 'POST',
headers: expectedHeaders,
body: JSON.stringify(expectedBody)
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations`;
await createInstallation(appConfig, inProgressInstallationEntry);
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
});
});
it('calls the createInstallation server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
'x-goog-api-key': 'apiKey'
describe('failed request', () => {
beforeEach(() => {
const response = {
error: {
code: 409,
message: 'Requested entity already exists',
status: 'ALREADY_EXISTS'
}
};
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response), { status: 409 })
);
});
const expectedBody = {
fid: FID,
authVersion: INTERNAL_AUTH_VERSION,
appId: appConfig.appId,
sdkVersion: PACKAGE_VERSION
};
const expectedRequest: RequestInit = {
method: 'POST',
headers: expectedHeaders,
body: JSON.stringify(expectedBody)
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations`;
await createInstallation(appConfig, inProgressInstallationEntry);
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
it('throws a FirebaseError with the error information from the server', async () => {
await expect(
createInstallation(appConfig, inProgressInstallationEntry)
).to.be.rejectedWith(FirebaseError);
});
});
});

@@ -64,4 +64,4 @@ /**

} else {
throw getErrorFromResponse('Create Installation', response);
throw await getErrorFromResponse('Create Installation', response);
}
}

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

import { FirebaseError } from '@firebase/util';
import { expect } from 'chai';

@@ -53,25 +54,51 @@ import { SinonStub, stub } from 'sinon';

};
fetchSpy = stub(self, 'fetch').resolves(new Response());
});
it('calls the deleteInstallation server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `${INTERNAL_AUTH_VERSION} refreshToken`,
'x-goog-api-key': 'apiKey'
describe('successful request', () => {
beforeEach(() => {
fetchSpy = stub(self, 'fetch').resolves(new Response());
});
const expectedRequest: RequestInit = {
method: 'DELETE',
headers: expectedHeaders
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations/${FID}`;
await deleteInstallation(appConfig, registeredInstallationEntry);
it('calls the deleteInstallation server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `${INTERNAL_AUTH_VERSION} refreshToken`,
'x-goog-api-key': 'apiKey'
});
const expectedRequest: RequestInit = {
method: 'DELETE',
headers: expectedHeaders
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations/${FID}`;
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
await deleteInstallation(appConfig, registeredInstallationEntry);
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
});
});
describe('failed request', () => {
beforeEach(() => {
const response = {
error: {
code: 409,
message: 'Requested entity already exists',
status: 'ALREADY_EXISTS'
}
};
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response), { status: 409 })
);
});
it('throws a FirebaseError with the error information from the server', async () => {
await expect(
deleteInstallation(appConfig, registeredInstallationEntry)
).to.be.rejectedWith(FirebaseError);
});
});
});

@@ -40,3 +40,3 @@ /**

if (!response.ok) {
throw getErrorFromResponse('Delete Installation', response);
throw await getErrorFromResponse('Delete Installation', response);
}

@@ -43,0 +43,0 @@ }

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

import { FirebaseError } from '@firebase/util';
import { expect } from 'chai';

@@ -56,47 +57,75 @@ import { SinonStub, stub } from 'sinon';

};
});
const response: GenerateAuthTokenResponse = {
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
expiresIn: '604800s'
};
describe('successful request', () => {
beforeEach(() => {
const response: GenerateAuthTokenResponse = {
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
expiresIn: '604800s'
};
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response))
);
});
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response))
);
});
it('fetches a new Authentication Token', async () => {
const completedAuthToken: CompletedAuthToken = await generateAuthToken(
appConfig,
registeredInstallationEntry
);
expect(completedAuthToken.requestStatus).to.equal(RequestStatus.COMPLETED);
it('fetches a new Authentication Token', async () => {
const completedAuthToken: CompletedAuthToken = await generateAuthToken(
appConfig,
registeredInstallationEntry
);
expect(completedAuthToken.requestStatus).to.equal(
RequestStatus.COMPLETED
);
});
it('calls the generateAuthToken server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `${INTERNAL_AUTH_VERSION} refreshToken`,
'x-goog-api-key': 'apiKey'
});
const expectedBody = {
installation: {
sdkVersion: PACKAGE_VERSION
}
};
const expectedRequest: RequestInit = {
method: 'POST',
headers: expectedHeaders,
body: JSON.stringify(expectedBody)
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations/${FID}/authTokens:generate`;
await generateAuthToken(appConfig, registeredInstallationEntry);
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
});
});
it('calls the generateAuthToken server API with correct parameters', async () => {
const expectedHeaders = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `${INTERNAL_AUTH_VERSION} refreshToken`,
'x-goog-api-key': 'apiKey'
describe('failed request', () => {
beforeEach(() => {
const response = {
error: {
code: 409,
message: 'Requested entity already exists',
status: 'ALREADY_EXISTS'
}
};
fetchSpy = stub(self, 'fetch').resolves(
new Response(JSON.stringify(response), { status: 409 })
);
});
const expectedBody = {
installation: {
sdkVersion: PACKAGE_VERSION
}
};
const expectedRequest: RequestInit = {
method: 'POST',
headers: expectedHeaders,
body: JSON.stringify(expectedBody)
};
const expectedEndpoint = `${INSTALLATIONS_API_URL}/projects/projectId/installations/${FID}/authTokens:generate`;
await generateAuthToken(appConfig, registeredInstallationEntry);
expect(fetchSpy).to.be.calledOnceWith(expectedEndpoint, expectedRequest);
const actualHeaders = fetchSpy.lastCall.lastArg.headers;
compareHeaders(expectedHeaders, actualHeaders);
it('throws a FirebaseError with the error information from the server', async () => {
await expect(
generateAuthToken(appConfig, registeredInstallationEntry)
).to.be.rejectedWith(FirebaseError);
});
});
});

@@ -59,3 +59,3 @@ /**

} else {
throw getErrorFromResponse('Generate Auth Token', response);
throw await getErrorFromResponse('Generate Auth Token', response);
}

@@ -62,0 +62,0 @@ }

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