-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasyncTestV2.js
More file actions
96 lines (83 loc) · 3.26 KB
/
asyncTestV2.js
File metadata and controls
96 lines (83 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const axios = require('axios')
const tree_api_request = require('./tree')
const metadataRequest = require('./metadataRequest')
const crypto = require('crypto')
require('dotenv').config()
var payload = JSON.parse(JSON.stringify(tree_api_request))
var metaDataPayload = JSON.parse(JSON.stringify(metadataRequest))
let authConfig = {
headers:{
"Content-Type":"application/json"
}
}
let authPayload = {
"ServiceRequestDetail": {
"ServiceRequestVersion": "2.0",
"OwnerId": "41",
"BrowserIp": "192.168.74.31",
"ResponseType": "json"
},
"UserCredential": {
"UserName": "britecoagent",
"Password": "sKVSbX7wj8UYYAaar4amxQ=="
}
}
const invokeMetaData = (token,payload,tree)=>{
let metaDataHeader = {
headers:{
"Content-Type":"application/json",
"Environment":"15",
"MODE":"LIVE",
"Token":token
}
}
payload.ServiceRequestDetail.Token = token;
tree.data.map(async page=>{
let pageName = page.name;
let metaDataRequest = payload;
let applicationType = page.navigationParams.applicationType;
let applicationObjectName = page.navigationParams.applicationObjectName;
let subApplicationType = page.navigationParams.subApplicationType;
let subApplicationName = page.navigationParams.subApplicationName;
metaDataRequest.ObjectName = applicationObjectName;
metaDataRequest.ApplicationType = applicationType;
metaDataRequest.SubApplicationType = subApplicationType;
metaDataRequest.SubApplicationNameList = []
metaDataRequest.SubApplicationNameList.push({"SubApplicationName":subApplicationName})
await axios.post('https://uciapplicationservice.solartis.net/ApplicationServiceV5/ApplicationService5/getMetaDataV2',metaDataRequest,metaDataHeader)
.then(res=>{console.log(`Page name is ${pageName} and result is`+'%o',res.data.ApplicationDetail.SubApplicationDetailList[0].AttributeDetailList)})
.catch(err=>console.log(err))
})
}
const invokeTree = (token,payload)=>{
let treeHeader = {
headers:{
'Content-Type':'application/json',
'Token':token,
'EventName':'GetUINavigationTreeV1',
'MODE':'LIVE',
'Environment':'15'
}
}
payload.ServiceRequestDetail.Token = token;
axios.post('https://ucicomruntimev6-2.solartis.net/KnowledgeEngineV6_2/KnowledgeBase/FireEventV2',payload,treeHeader).then(res=>{
invokeMetaData(token,metaDataPayload,res.data)
}).catch(err=>console.log(err))
}
const authInvoke = async ()=>{
await axios.post('https://ucicommonservice.solartis.net/CommonServiceV2_1/AuthenticationServiceV2/requestService',authPayload,authConfig).then(response=>{
const token = response.data.Token;
payload.ServiceRequestDetail.Token = token;
invokeTree(token,payload)
}).catch(err=>console.log(err))
}
authInvoke()
const passwordEncryptor = ()=>{
let password = 'welcome1'
let KEY = '3FCCB01F507E8EB0'
const cipher = crypto.createCipher('aes128', KEY);
var encrypted = cipher.update(password,'utf8', 'base64');
encrypted += cipher.final('base64');
console.log(encrypted)
}
passwordEncryptor()