Skip to content
Snippets Groups Projects
Commit 84f6918a authored by Alexey Lunin's avatar Alexey Lunin
Browse files

Apply prettier

parent a10bc924
No related branches found
No related tags found
1 merge request!49Applied prettier to the VCL project
function CryptoData() {}
CryptoData.prototype.set = function(obj) {
for(var member in obj) {
this[member] = JSON.parse(JSON.stringify(obj[member]))
for (var member in obj) {
this[member] = JSON.parse(JSON.stringify(obj[member]));
}
};
CryptoData.prototype.serialize = function() {
return JSON.stringify(this)
return JSON.stringify(this);
};
CryptoData.prototype.deserialize = function(serialized) {
var obj = JSON.parse(serialized);
this.set(obj)
this.set(obj);
};
CryptoData.prototype.setPublicKey = function(publicKey) {
this["publicKey"] = publicKey
this["publicKey"] = publicKey;
};
CryptoData.prototype.getPublicKey = function() {
return this["publicKey"]
return this["publicKey"];
};
CryptoData.prototype.setPrivateKey = function(privateKey) {
this["privateKey"] = privateKey
this["privateKey"] = privateKey;
};
CryptoData.prototype.getPrivateKey = function() {
return this["privateKey"]
return this["privateKey"];
};
CryptoData.prototype.setx509Certificate = function(x509Certificate) {
this["x509Certificate"] = x509Certificate
this["x509Certificate"] = x509Certificate;
};
CryptoData.prototype.getx509Certificate = function() {
return this["x509Certificate"]
return this["x509Certificate"];
};
CryptoData.prototype.setKeyUUID = function(keyUUID) {
this["keyUUID"] = keyUUID
this["keyUUID"] = keyUUID;
};
CryptoData.prototype.getKeyUUID = function() {
return this["keyUUID"]
return this["keyUUID"];
};
CryptoData.prototype.setChain = function(chain) {
this["chain"] = chain
this["chain"] = chain;
};
CryptoData.prototype.getChain = function() {
return this["chain"]
return this["chain"];
};
export default CryptoData;
\ No newline at end of file
export default CryptoData;
export const LOGIN_MODES = {
SMS: 'sms',
PREVIOUSLY_ADDED_DEVICE: 'previousaddeddevice',
NEW_DEVICE: 'newdevice'
SMS: "sms",
PREVIOUSLY_ADDED_DEVICE: "previousaddeddevice",
NEW_DEVICE: "newdevice"
};
......@@ -347,5 +347,5 @@ export function getAttachment(mime, part) {
base64 = window.btoa(body);
}
return { contentType, base64 }
return { contentType, base64 };
}
const axios = require('axios');
const axios = require("axios");
function CollaboraAPI() {}
CollaboraAPI.prototype.discovery = function () {
CollaboraAPI.prototype.discovery = function() {
const requestConfig = {
url: `${window.COLLABORA_URL}hosting/discovery`,
method: 'GET'
method: "GET"
};
return axios(requestConfig).then(response => {
const apps = response.request.responseXML.querySelectorAll("net-zone[name='external-http'] app");
const apps = response.request.responseXML.querySelectorAll(
"net-zone[name='external-http'] app"
);
const results = [];
for (let i = 0; i < apps.length; i++) {
const app = apps[i];
const action = app.querySelector('action');
const mimeType = app.getAttribute('name');
const ext = action.getAttribute('ext');
const urlsrc = action.getAttribute('urlsrc');
const action = app.querySelector("action");
const mimeType = app.getAttribute("name");
const ext = action.getAttribute("ext");
const urlsrc = action.getAttribute("urlsrc");
results.push({
mimeType,
ext,
urlsrc
});
}
return results
return results;
});
};
......
This diff is collapsed.
const axios = require('axios');
const axios = require("axios");
function WopiAPI() {}
WopiAPI.prototype.getPassports = function (fileID) {
const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
WopiAPI.prototype.getPassports = function(fileID) {
const {
publicKey,
uuid,
token,
deviceHash
} = window.viamApi.getConfig().headers;
const requestConfig = {
url: `${window.WOPI_URL}getPassports`,
method: 'POST',
method: "POST",
headers: {
publicKey,
uuid,
......@@ -19,13 +24,18 @@ WopiAPI.prototype.getPassports = function (fileID) {
return axios(requestConfig);
};
WopiAPI.prototype.putDocument = function (path, accessToken, file) {
const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
WopiAPI.prototype.putDocument = function(path, accessToken, file) {
const {
publicKey,
uuid,
token,
deviceHash
} = window.viamApi.getConfig().headers;
path = path[0] === "/" ? path : `/${path}`;
path = encodeURI(path);
const requestConfig = {
url: `${window.WOPI_URL}files${path}/contents`,
method: 'POST',
method: "POST",
headers: {
publicKey,
uuid,
......
import { getCrypto } from 'pkijs';
import { getCrypto } from "pkijs";
export const createDeviceHash = async (publicKey) => {
export const createDeviceHash = async publicKey => {
try {
const stringToEncode = publicKey + navigator.userAgent;
const crypto = getCrypto();
......@@ -21,11 +21,12 @@ export const encodeResponse = (code, data, status) => {
};
export function makeid(len) {
if (typeof len === 'undefined') {
len = 10
if (typeof len === "undefined") {
len = 10;
}
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < len; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
......@@ -49,7 +50,12 @@ export function getTimeLeftInLocalStorage() {
let minutes = Math.floor((blockFinishTime - timeNow) / 60);
minutes %= 60;
const left = "Your identity has been locked. Try again in " + minutes + " minutes and " + seconds + " seconds.";
const left =
"Your identity has been locked. Try again in " +
minutes +
" minutes and " +
seconds +
" seconds.";
return left;
}
......@@ -58,16 +64,18 @@ export function listIdentitiesFromLocalStorage() {
var identities = JSON.parse(serializedIdentitiesList);
var identitiesResult = {};
for(var key in identities) {
var profile = JSON.parse(JSON.stringify(localStorage.getItem("profiles/" + key)));
if(profile != null && profile !== "") {
identitiesResult[key] = JSON.parse(profile)
for (var key in identities) {
var profile = JSON.parse(
JSON.stringify(localStorage.getItem("profiles/" + key))
);
if (profile != null && profile !== "") {
identitiesResult[key] = JSON.parse(profile);
} else {
identitiesResult[key] = {}
identitiesResult[key] = {};
}
}
return identitiesResult
return identitiesResult;
}
export function destroyIdentityFromLocalStorage(key) {
......@@ -83,12 +91,12 @@ export function destroyIdentityFromLocalStorage(key) {
delete identities[key];
localStorage.setItem("identities", JSON.stringify(identities))
localStorage.setItem("identities", JSON.stringify(identities));
}
export function failPincodeAttempt(password) {
let message = "Wrong pincode";
if (password !== '00000000') {
if (password !== "00000000") {
let attempt = localStorage.getItem("attempt") || 1;
attempt = parseInt(attempt);
if (attempt === 9) {
......@@ -120,4 +128,4 @@ export function canTryPincode() {
} else {
return false;
}
}
\ No newline at end of file
}
import dataUriToBlob from "data-uri-to-blob";
import libmime from 'libmime';
import union from 'lodash/union';
import libmime from "libmime";
import union from "lodash/union";
import {
fixNewLines,
......@@ -14,14 +14,16 @@ import {
import { getCertificateChain } from "./signingUtilities";
const SIGNATURE_CONTENT_TYPE = "application/pkcs7-signature";
export const DEFAULT_ATTACHMENT_NAME = 'attachment';
export const DEFAULT_ATTACHMENT_NAME = "attachment";
const splitParticipants = participantsList => {
if (!participantsList) {
return [];
}
const participants = participantsList.map(participants => participants.split(",").map(p => p.trim()));
const participants = participantsList.map(participants =>
participants.split(",").map(p => p.trim())
);
return union.apply(null, participants);
};
......@@ -84,14 +86,16 @@ export const parseSMIME = smimeString => {
* @returns {string} ('file.txt')
*/
export const getFilenameFromHeaders = headers => {
const headersToSearch = ['content-type', 'content-disposition'];
const headersToSearch = ["content-type", "content-disposition"];
const filename = headers && Object.keys(headers)
.filter(key => headersToSearch.includes(key))
.reduce((result, key) => {
const headerValue = libmime.parseHeaderValue(headers[key][0]);
return result || headerValue.params.name || headerValue.params.filename;
}, '');
const filename =
headers &&
Object.keys(headers)
.filter(key => headersToSearch.includes(key))
.reduce((result, key) => {
const headerValue = libmime.parseHeaderValue(headers[key][0]);
return result || headerValue.params.name || headerValue.params.filename;
}, "");
return filename || DEFAULT_ATTACHMENT_NAME;
};
......@@ -110,8 +114,9 @@ export const extractHtmlBodyFromString = string => {
if (bodyMatch && bodyMatch[1]) {
body = bodyMatch[1]
.replace(/>\s+</gm, '><')
.replace(/<!--[\s\S]*?-->/gm, '').trim()
.replace(/>\s+</gm, "><")
.replace(/<!--[\s\S]*?-->/gm, "")
.trim();
}
return body;
......
This diff is collapsed.
const Penpal = require('penpal').default;
const Penpal = require("penpal").default;
/**
* Sets up interaction with Vereign Restful API
......@@ -9,7 +9,14 @@ const Penpal = require('penpal').default;
* @param wopiUrl - WOPI URL used to acces WopiAPI
* @returns {*}
*/
function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl, collaboraUrl) {
function setupViamAPI(
divId,
methods,
iframeUrl,
apiUrl,
wopiUrl,
collaboraUrl
) {
if (!iframeUrl) {
iframeUrl = `${window.location.origin}/vcl/js/iframe`;
console.warn(`Iframe URL not specified. Fall back to ${iframeUrl}`); // eslint-disable-line no-console
......@@ -24,9 +31,9 @@ function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl, collaboraUrl)
methods
});
return connection.promise
.then((child) => child.initialize(apiUrl, wopiUrl, collaboraUrl).then(() => child));
return connection.promise.then(child =>
child.initialize(apiUrl, wopiUrl, collaboraUrl).then(() => child)
);
}
window.setupViamAPI = setupViamAPI;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment