Skip to content
Snippets Groups Projects
Commit 56cf8855 authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Merge branch '10-implement-device-finger-print' into 'master'

Resolve "Implement Device Finger Print"

Closes #10

See merge request !8
parents 0b2b6240 69a74043
No related branches found
No related tags found
1 merge request!8Resolve "Implement Device Finger Print"
This diff is collapsed.
......@@ -2,21 +2,21 @@ const axios = require('axios');
function WopiAPI() {}
WopiAPI.prototype.getPassports = function(fileID) {
WopiAPI.prototype.getPassports = function (fileID) {
const requestConfig = {
headers: {
'publicKey': viamApi.getConfig().headers.publicKey,
'uuid': viamApi.getConfig().headers.uuid,
'token': viamApi.getConfig().headers.token,
'fileID': fileID
publicKey: window.viamApi.getConfig().headers.publicKey,
uuid: window.viamApi.getConfig().headers.uuid,
token: window.viamApi.getConfig().headers.token,
deviceHash: window.viamApi.getConfig().headers.deviceHash,
userAgent: window.viamApi.getConfig().headers.userAgent,
fileID
}
};
const [protocol, host] = window.API_HOST.split(':');
const url = `${protocol}${host}${window.WOPI_URI_PREFIX}/getPassports`;
// TODO: remove console log
console.log('Wopi', url);
return axios.post(url, {}, requestConfig);
};
......
import { getCrypto } from 'pkijs';
export const createDeviceHash = async (publicKey) => {
try {
const stringToEncode = publicKey + navigator.userAgent;
const crypto = getCrypto();
const buffer = new window.TextEncoder("utf-8").encode(stringToEncode);
return window.btoa(await crypto.digest({ name: "SHA-1" }, buffer));
} catch (error) {
console.warn(error); // eslint-disable-line no-console
}
};
......@@ -73,18 +73,23 @@ func buildViamAPI() string {
" headers: {\n" +
" 'publicKey': '',\n" +
" 'uuid': '',\n" +
" 'deviceHash': '',\n" +
" 'userAgent': '',\n" +
" 'token': ''\n" +
" }\n" +
" }\n" +
"}\n\n"
result += "ViamAPI.prototype.setSessionData = function(uuid, token) {\n" +
" this.config.headers.uuid = \" \" + uuid;\n" +
" this.config.headers.token = \" \" + token;\n" +
result += "ViamAPI.prototype.setSessionData = function(uuid, token, deviceHash, userAgent) {\n" +
" this.config.headers.uuid = uuid;\n" +
" this.config.headers.token = token;\n" +
" this.config.headers.deviceHash = deviceHash;\n" +
" this.config.headers.userAgent = userAgent;\n" +
"};\n\n"
result += "ViamAPI.prototype.setIdentity = function(authenticationPublicKey) {\n" +
" this.config.headers.publicKey = \" \" + window.btoa(authenticationPublicKey);\n" +
" this.config.headers.publicKey = window.btoa(authenticationPublicKey);\n" +
"};\n\n"
result += "ViamAPI.prototype.getConfig = function() {\n" +
......
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