Skip to content

Commit 2755bbd

Browse files
Anvil Authorsmeredydd
authored andcommitted
Anvil App Server v1.2
Changes: - Users service supports two-factor authentication - URLMedia fetch fixes - PDF rendering fix for apps with dependencies - Doc updates - OAuth fixes (MS and Google authentication) - Stricter bytes/str enforcement in BlobMedia construction - Downlink is more robust about cleaning up subprocesses Based-on: anvil 96b13c0b30d2acdab28a6e9e1ac02a49de06bc4d
2 parents 37a8ff7 + b1325b1 commit 2755bbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2933
-1412
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Port for outbound SMTP server (see `smtp-host`).
278278

279279
#### smtp-encryption
280280

281-
Enable TLS for connecting to outbound SMTP server (see `smtp-host`).
281+
Enable TLS for connecting to outbound SMTP server (see `smtp-host`). Takes "starttls" or "ssl" as a string value.
282282

283283
#### smtp-username
284284

client/js/lib/skulpt-stdlib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/js/lib/skulpt.min.js

Lines changed: 752 additions & 734 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/js/lib/skulpt.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/js/lib/unorm.js

Lines changed: 452 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/js/modules/anvil.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ module.exports = function(appOrigin, uncaughtExceptions) {
1313

1414
let ByteString = Sk.__future__.python3 ? Sk.builtin.bytes : Sk.builtin.str;
1515

16+
let arrayBufferToStr = arrayBuffer => {
17+
let binary = "";
18+
var bytes = new Uint8Array(arrayBuffer);
19+
var length = bytes.byteLength;
20+
for (var i = 0; i < length; i++) {
21+
binary += String.fromCharCode(bytes[i]);
22+
}
23+
return binary;
24+
}
25+
1626
/**
1727
id: anvil_module
1828
docs_url: /docs/client/python#the-anvil-module
@@ -164,7 +174,13 @@ module.exports = function(appOrigin, uncaughtExceptions) {
164174
let leafName = ps[ps.length-1];
165175
// Yes, sysmodules is indexed with JS strings.
166176
// No, this makes no sense.
167-
let pyFormMod = Sk.sysmodules.mp$subscript(window.anvilAppMainPackage + "." + formName);
177+
let pyFormMod;
178+
try {
179+
pyFormMod = Sk.sysmodules.mp$subscript(window.anvilAppMainPackage + "." + formName);
180+
} catch (e) {
181+
pyFormMod = Sk.sysmodules.mp$subscript(formName);
182+
}
183+
168184

169185
var formConstructor = pyFormMod.$d[leafName];
170186

@@ -299,7 +315,7 @@ module.exports = function(appOrigin, uncaughtExceptions) {
299315
$.ajax({
300316
url: self._url,
301317
type: "GET",
302-
dataType: "text",
318+
dataType: "binary",
303319
processData: false,
304320
}).then(function(r,ts,xhr) {
305321
window.setLoading(false);
@@ -326,7 +342,11 @@ module.exports = function(appOrigin, uncaughtExceptions) {
326342

327343
$loc["get_bytes"] = new Sk.builtin.func(function(self) {
328344
return new PyDefUtils.suspensionPromise(function(resolve, reject) {
329-
doFetch(self).then(function(r) { resolve(new ByteString(r.data)); }, reject);
345+
doFetch(self).then(function(r) {
346+
return r.data.arrayBuffer();
347+
}, reject).then(function(arrayBuffer) {
348+
resolve(new ByteString(arrayBufferToStr(arrayBuffer)))
349+
});
330350
});
331351
});
332352

@@ -407,13 +427,7 @@ module.exports = function(appOrigin, uncaughtExceptions) {
407427
fr.readAsBinaryString(self._data);
408428
} else {
409429
fr.onloadend = function() {
410-
let binary = "";
411-
var bytes = new Uint8Array(fr.result);
412-
var length = bytes.byteLength;
413-
for (var i = 0; i < length; i++) {
414-
binary += String.fromCharCode(bytes[i]);
415-
}
416-
resolve(new ByteString(binary));
430+
resolve(new ByteString(arrayBufferToStr(fr.result)));
417431
};
418432
fr.readAsArrayBuffer(self._data);
419433
}

client/js/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function loadApp(app, appId, appOrigin, preloadModules) {
228228

229229
var accumulatingPrints = null;
230230

231-
var sendLog = function(details) { console.log(logDetails); };
231+
var sendLog = function(details) { console.log(details); };
232232

233233
var stdout = function(text, fromServer) {
234234
if (text != "\n") {
@@ -301,7 +301,7 @@ function loadApp(app, appId, appOrigin, preloadModules) {
301301
}
302302
};
303303

304-
if (errorObj instanceof serverModuleAndLog.pyMod["SessionExpiredError"]) {
304+
if (serverModuleAndLog && errorObj instanceof serverModuleAndLog.pyMod["SessionExpiredError"]) {
305305
$("#session-expired-modal button.refresh").off("click").on("click", function() {
306306
document.location.href = window.anvilAppOrigin + "/" + (window.anvilParams.accessKey || '');
307307
});

client/js/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66

77
// We want to generate two bundles. One for runner. one for its Service Worker
88
entry: {
9-
runner: ['babel-polyfill', './runner.js'],
9+
runner: ['./runner.js'],
1010
sw: ['babel-polyfill', './sw.js'],
1111
},
1212

client/runner.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,14 @@ <h4 class="modal-title">Kerberos Authentication</h4>
254254
<script src="{{cdn-origin}}/runtime/node_modules/moment/min/moment.min.js?buildTime=0" crossorigin></script>
255255
<script src="{{cdn-origin}}/runtime/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js?buildTime=0" crossorigin></script>
256256
<script src="{{cdn-origin}}/runtime/js/lib/daterangepicker.js?buildTime=0" crossorigin></script>
257+
<script src="{{cdn-origin}}/runtime/js/lib/b64.js?buildTime=0" crossorigin></script>
257258
<script src="{{cdn-origin}}/runtime/js/lib/bootstrap-notify.min.js?buildTime=0" crossorigin></script>
258259

259260
<script src="{{cdn-origin}}/runtime/node_modules/js-yaml/dist/js-yaml.min.js?buildTime=0" crossorigin></script>
260261
<script src="{{cdn-origin}}/runtime/js/lib/mutationobserver.min.js?buildTime=0" crossorigin></script>
261262

263+
<script src="{{cdn-origin}}/runtime/node_modules/core-js/client/core.min.js?buildTime=0" crossorigin></script>
264+
262265
<script src="https://www.youtube.com/iframe_api"></script>
263266
<script>
264267
function gm_authFailure(e) { window.googleMapsAuthFailure = true; };
@@ -267,6 +270,7 @@ <h4 class="modal-title">Kerberos Authentication</h4>
267270

268271
<script src="https://checkout.stripe.com/checkout.js"></script>
269272

273+
<script src='{{cdn-origin}}/runtime/js/lib/unorm.js?buildTime=0' crossorigin></script>
270274

271275
<script src='{{cdn-origin}}/runtime/js/lib/skulpt.min.js?buildTime=0' crossorigin></script>
272276
<script src='{{cdn-origin}}/runtime/js/lib/skulpt-stdlib.js?buildTime=0' crossorigin></script>

client/user_email_confirmed.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<title>Email confirmed</title>
88

9-
<link rel="stylesheet" href="{{cdn-origin}}/runtime/core/css/bootstrap.css?buildTime=0">
10-
<link rel="stylesheet" href="{{cdn-origin}}/runtime/core/css/bootstrap-theme.min.css?buildTime=0">
9+
<link rel="stylesheet" href="{{cdn-origin}}/runtime/css/bootstrap.css?buildTime=0">
10+
<link rel="stylesheet" href="{{cdn-origin}}/runtime/css/bootstrap-theme.min.css?buildTime=0">
1111

12-
<script src="{{cdn-origin}}/runtime/core/node_modules/html5-boilerplate/dist/js/vendor/modernizr-3.8.0.min.js?buildTime=0"></script>
12+
<script src="{{cdn-origin}}/runtime/node_modules/html5-boilerplate/dist/js/vendor/modernizr-3.8.0.min.js?buildTime=0"></script>
1313

1414

15-
<script src="{{cdn-origin}}/runtime/core/node_modules/jquery/dist/jquery.min.js?buildTime=0"></script>
16-
<script src="{{cdn-origin}}/runtime/core/node_modules/bootstrap/dist/js/bootstrap.min.js?buildTime=0"></script>
15+
<script src="{{cdn-origin}}/runtime/node_modules/jquery/dist/jquery.min.js?buildTime=0"></script>
16+
<script src="{{cdn-origin}}/runtime/node_modules/bootstrap/dist/js/bootstrap.min.js?buildTime=0"></script>
1717

1818
</head>
1919
<body>

0 commit comments

Comments
 (0)