New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lz-api-client

Package Overview
Dependencies
Maintainers
0
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lz-api-client - npm Package Compare versions

Comparing version 0.14.1 to 0.14.2

65

dist/__tests__/account-service.test.js

@@ -15,2 +15,3 @@ "use strict";

const lz_schema_1 = require("lz-schema");
const auth_1 = require("./helpers/auth");
(0, vitest_1.describe)('AccountService.verifyEmail', {}, () => {

@@ -40,2 +41,66 @@ (0, vitest_1.test)('should return failure if not token', () => __awaiter(void 0, void 0, void 0, function* () {

});
(0, vitest_1.describe)('AccountService.uploadProfileImage', {}, () => {
(0, vitest_1.test)('should return failure if file is not image', () => __awaiter(void 0, void 0, void 0, function* () {
try {
const { bearerToken } = yield (0, auth_1.signIn)();
console.log('bearerToken', bearerToken);
const client = (0, mocks_1.getClientWithMockedBearerToken)(bearerToken);
const file = new File([''], 'filename');
yield client.account.uploadProfileImage(file);
throw new Error('This test should have failed');
}
catch (error) {
(0, vitest_1.expect)(error).toHaveProperty('status', lz_schema_1.ResponseStatus.Fail);
(0, vitest_1.expect)(error).toHaveProperty('message', 'Validation error');
(0, vitest_1.expect)(error).toHaveProperty('data', {
file: 'Invalid file type. Allowed types are: jpeg, png, webp, avif, gif, svg, tiff',
});
}
}));
(0, vitest_1.test)('should return failure if file is too large', () => __awaiter(void 0, void 0, void 0, function* () {
try {
const { bearerToken } = yield (0, auth_1.signIn)();
const client = (0, mocks_1.getClientWithMockedBearerToken)(bearerToken);
const file = new File(['a'.repeat(6 * 1024 * 1024)], 'filename.jpg', { type: 'image/jpeg' });
yield client.account.uploadProfileImage(file);
throw new Error('This test should have failed');
}
catch (error) {
(0, vitest_1.expect)(error).toHaveProperty('status', lz_schema_1.ResponseStatus.Fail);
(0, vitest_1.expect)(error).toHaveProperty('message', 'Validation error');
(0, vitest_1.expect)(error).toHaveProperty('data', {
file: 'File size too large. Maximum size is 5MB',
});
}
}));
(0, vitest_1.test)('should return failure if no file is provided', () => __awaiter(void 0, void 0, void 0, function* () {
try {
const { bearerToken } = yield (0, auth_1.signIn)();
const client = (0, mocks_1.getClientWithMockedBearerToken)(bearerToken);
// biome-ignore lint/suspicious/noExplicitAny: To test validation error
yield client.account.uploadProfileImage(undefined);
throw new Error('This test should have failed');
}
catch (error) {
(0, vitest_1.expect)(error).toHaveProperty('status', lz_schema_1.ResponseStatus.Fail);
(0, vitest_1.expect)(error).toHaveProperty('message', 'Validation error');
(0, vitest_1.expect)(error).toHaveProperty('data', {
file: 'No file uploaded',
});
}
}));
(0, vitest_1.test)('should return failure if image upload fails', () => __awaiter(void 0, void 0, void 0, function* () {
try {
const { bearerToken } = yield (0, auth_1.signIn)();
const client = (0, mocks_1.getClientWithMockedBearerToken)(bearerToken);
const file = new File([''], 'filename.jpg', { type: 'image/jpeg' });
yield client.account.uploadProfileImage(file);
throw new Error('This test should have failed');
}
catch (error) {
(0, vitest_1.expect)(error).toHaveProperty('status', lz_schema_1.ResponseStatus.Error);
(0, vitest_1.expect)(error).toHaveProperty('message', 'Failed to compress image');
}
}));
});
//# sourceMappingURL=account-service.test.js.map

5

dist/Client.js

@@ -89,3 +89,6 @@ "use strict";

const url = new URL(path, this.apiURL);
const requestHeaders = this.buildRequestHeaders(Object.assign(Object.assign({}, headers), { 'Content-Type': 'multipart/form-data' }));
const requestHeaders = this.buildRequestHeaders(headers);
// Remove the content type header to allow the browser to set it automatically
// when sending a file. This way it will also add automatically the form boundary
requestHeaders.delete('Content-Type');
const formData = new FormData();

@@ -92,0 +95,0 @@ formData.append('file', file);

2

package.json
{
"name": "lz-api-client",
"version": "0.14.1",
"version": "0.14.2",
"description": "client sdk for layerZ api",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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