LG-3474: Reference Acuant SDK as static resource from root#4269
LG-3474: Reference Acuant SDK as static resource from root#4269
Conversation
**Why**: To avoid unnecessary server processing As a user, I don't want the document capture experience to take a long time to load, so that I can upload my images without being confronted by spinners
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM, we do serve the public/ directory via Nginx in prod currently, so this should work
|
One thing I should double-check here is whether this can work if we'd relied on the server to send CSP directives. These: identity-idp/app/controllers/acuant_sdk_controller.rb Lines 15 to 18 in b702ae1 |
We set our nginx headers here: https://github.com/18F/identity-devops/blob/master/kitchen/cookbooks/login_dot_gov/templates/default/nginx_server.conf.erb I forget if the way CSP works is if we need to set the unsafe-eval on the HTML document that loads the JS, or on the JS file itself? |
You need it on the document. We set them on the JS in the SDK controller because Safari has some weird behavior if a CSP header is present on JS files. The assets we are serving from |
Why: To avoid unnecessary server processing
As a user, I don't want the document capture experience to take a long time to load, so that I can upload my images without being confronted by spinners
Implementation notes:
From what I've been able to tell, Acuant SDK does make an attempt to load additional assets from the loaded script's directory, at least for
AcuantImageProcessingService.js.mem. This compiled binary is responsible for loadingAcuantImageProcessingWorker, which does load from the current directory. As such, only these files are necessary to load as relative, which could at least avoid server handlingAcuantJavascriptWebSdk.min.js(1MB) andAcuantImageProcessingService.js.mem(10KB).The relevant code is minified in the Acuant SDK (even in the non-minified source file), but there is an expanded copy in the React source example:
.wasm.js.memfile is located usinglocateFile(this code appears outdated. In Acuant v11.4, this.wasmfile was substituted with.js.mem. See LG-3357: Upgrade Acuant SDK to v11.4.1 #4128. This is obfuscated in the current version source file).locateFileappends givenpathargument toscriptDirectoryscriptDirectoryis set fromdocument.currentScript.srcOpen questions:
.js.memfile. This is no longer implemented. Locally, it falls back totext/plain, which at first glance does not appear to cause any problems.