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

Merge branch 'master' into 16-vcl-network-disconnection-issue-and-authentication

# Conflicts:
#	javascript/src/iframe/viamapi-iframe.js
parents be04bba0 f867fe34
Branches 16-vcl-network-disconnection-issue-and-authentication
No related tags found
1 merge request!27Resolve "Can't send email when the gmail was left open and the pc went to sleep for a while"
......@@ -28,6 +28,7 @@
"data-uri-to-blob": "^0.0.4",
"libmime": "^4.0.1",
"libqp": "^1.1.0",
"lodash": "^4.17.11",
"penpal": "^3.0.3",
"pkijs": "^2.1.69",
"pvutils": "^1.0.16",
......
export const STATUS_DEVICE_REVOKED = "Device revoked";
This diff is collapsed.
......@@ -19,4 +19,25 @@ WopiAPI.prototype.getPassports = function (fileID) {
return axios(requestConfig);
};
WopiAPI.prototype.putDocument = function (path, accessToken, file) {
const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
path = path[0] === "/" ? path : `/${path}`;
const requestConfig = {
url: `${window.WOPI_URL}files${path}/contents`,
method: 'POST',
headers: {
publicKey,
uuid,
token,
deviceHash
},
params: {
access_token: accessToken
},
data: file
};
return axios(requestConfig);
};
module.exports = WopiAPI;
......@@ -43,7 +43,6 @@ func buildPenpalMethods() string {
"export default {\n"
methods := generatePenpalRemoteMethods(endPoints)
methods += getWopiAPIPenpalMethods()
result += methods
......@@ -57,6 +56,7 @@ func buildViamAPI() string {
endPoints := server.GetEndPoints(prefixes)
result := "const axios = require('axios');\n"
result += "const merge = require('lodash/merge');\n"
var keys []string
for k := range endPoints {
......@@ -78,7 +78,6 @@ func buildViamAPI() string {
" }\n" +
"}\n\n"
result += "ViamAPI.prototype.setSessionData = function(uuid, token) {\n" +
" this.config.headers.uuid = uuid;\n" +
" this.config.headers.token = token;\n" +
......@@ -103,11 +102,6 @@ func buildViamAPI() string {
packageStr := splits[len(splits)-2]
/*if !packageCreated[packageStr] {
result += "ViamAPI.prototype.\"" + packageStr + "\" = {}\n\n"
packageCreated[packageStr] = true
}*/
methodStr := splits[len(splits)-1]
form := endPoints[url].Form
......@@ -129,7 +123,13 @@ func buildViamAPI() string {
}
}
result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(" + args + ") {\n" +
lastComma := ","
if args == "" {
lastComma = ""
}
result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(config" + lastComma + args + ") {\n" +
" return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', {\n"
for i := 0; i < lenFields; i++ {
......@@ -140,7 +140,7 @@ func buildViamAPI() string {
result += "\n"
}
result += " }, this.config);\n" +
result += " }, merge({}, this.config, config));\n" +
"};\n\n"
} else {
splits := strings.Split(url, "/")
......@@ -154,8 +154,8 @@ func buildViamAPI() string {
methodStr := splits[len(splits)-1]
result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function() {\n" +
" return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', {}, this.config);\n" +
result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(config, data) {\n" +
" return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', data || {}, merge({}, this.config, config));\n" +
"};\n\n"
}
}
......@@ -589,7 +589,7 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
privateCheckSnippet := `
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (authenticationPublicKey === null) {
result({
"data" : "",
......@@ -597,15 +597,15 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
"status" : "Identity not authenticated"
});
}
if (loadedIdentities[authenticationPublicKey] === null) {
result({
"data" : "",
"code" : "400",
"status" : "Identity not authenticated"
});
}
}
const success = extendPinCodeTtl(authenticationPublicKey);
if(success === false) {
......@@ -614,7 +614,7 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
"status" : "Identity not authenticated"
})
}
`
for i := 0; i < keysLen; i++ {
......@@ -627,7 +627,7 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
if url == "/identity/getIdentityProfileData" {
privateCheckSnippet = `
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (authenticationPublicKey === null) {
result({
"data" : "",
......@@ -635,15 +635,15 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
"status" : "Identity not authenticated"
});
}
if (loadedIdentities[authenticationPublicKey] === null) {
result({
"data" : "",
"code" : "400",
"status" : "Identity not authenticated"
});
}
}
`
}
......@@ -652,11 +652,6 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
packageStr := splits[len(splits)-2]
/*if !packageCreated[packageStr] {
result += "ViamAPI.prototype.\"" + packageStr + "\" = {}\n\n"
packageCreated[packageStr] = true
}*/
methodStr := splits[len(splits)-1]
form := endPoints[url].Form
......@@ -678,12 +673,6 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
}
}
/*identity_login(modeArg,codeArg,actionIDArg) {
return new Penpal.Promise(result => {
viamApi.identity_login(modeArg,codeArg,actionIDArg).then((response) => { result(response.data);});
});
}*/
snippet := ""
if endPoints[url].HandlerType == "private" {
......@@ -698,7 +687,7 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
method := packageStr + strings.Title(methodStr) + ": function(" + args + ") {\n" +
" return new Penpal.Promise(function(result) {\n" + snippet +
" executeRestfulFunction(\"" + endPoints[url].HandlerType + "\", viamApi, viamApi." + packageStr + strings.Title(methodStr) + lastComma + args + ").then(function(executeResult) {\n" +
" executeRestfulFunction(\"" + endPoints[url].HandlerType + "\", viamApi, viamApi." + packageStr + strings.Title(methodStr) + ", null" + lastComma + args + ").then(function(executeResult) {\n" +
" result(executeResult);\n" +
" });\n" +
" });\n" +
......@@ -716,11 +705,6 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
packageStr := splits[len(splits)-2]
/*if !packageCreated[packageStr] {
result += "ViamAPI.prototype.\"" + packageStr + "\" = {}\n\n"
packageCreated[packageStr] = true
}*/
methodStr := splits[len(splits)-1]
snippet := ""
......@@ -731,7 +715,7 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
method := packageStr + strings.Title(methodStr) + ": function() {\n" +
" return new Penpal.Promise(function(result) {\n" + snippet +
" executeRestfulFunction(\"" + endPoints[url].HandlerType + "\", viamApi, viamApi." + packageStr + strings.Title(methodStr) + ").then(function(executeResult) {\n" +
" executeRestfulFunction(\"" + endPoints[url].HandlerType + "\", viamApi, viamApi." + packageStr + strings.Title(methodStr) + ", null).then(function(executeResult) {\n" +
" result(executeResult);\n" +
" });\n" +
" });\n" +
......@@ -750,39 +734,3 @@ func generatePenpalRemoteMethods(endPoints map[string]*server.EndPoint) string {
return methods
}
func getWopiAPIPenpalMethods() string {
return `getPassports: function(fileID) {
return new Penpal.Promise(function(result) {
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (authenticationPublicKey === null) {
result({
"data" : "",
"code" : "400",
"status" : "Identity not authenticated"
});
}
if (loadedIdentities[authenticationPublicKey] === null) {
result({
"data" : "",
"code" : "400",
"status" : "Identity not authenticated"
});
}
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({"data" : "",
"code" : "400",
"status" : "Identity not authenticated"
});
}
wopiAPI.getPassports(fileID).then(function(response) {
result(response.data);
});
});
}`
}
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