[rs-commit] r50 - /redwax-signtext/trunk/src/linux/firefox/content.js
rs-commit at redwax.eu
rs-commit at redwax.eu
Thu Sep 15 12:26:05 CEST 2022
Author: minfrin at redwax.eu
Date: Thu Sep 15 12:26:04 2022
New Revision: 50
Log:
Remove unused code.
Modified:
redwax-signtext/trunk/src/linux/firefox/content.js
Modified: redwax-signtext/trunk/src/linux/firefox/content.js
==============================================================================
--- redwax-signtext/trunk/src/linux/firefox/content.js (original)
+++ redwax-signtext/trunk/src/linux/firefox/content.js Thu Sep 15 12:26:04 2022
@@ -42,138 +42,6 @@
function uuidv4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
- );
- }
-
- function signTextReader(requestStream, options, ...CAs) {
- const uuid = uuidv4();
- const reader = requestStream.getReader();
-
-console.log("signtextreader: ");
-
- underlyingSource = new window.wrappedJSObject.Object();
-
- underlyingSource.start = exportFunction(
- function(controller) {
-
- function push() {
- reader.read().then(({
- done,
- value
- }) => {
-
- try {
- if (!done) {
- port.postMessage({
- protocol: location.protocol,
- hostname: location.hostname,
- contentType: 'text/plain',
- uuid: uuid,
- request: value
- });
- } else {
- port.postMessage({
- protocol: location.protocol,
- hostname: location.hostname,
- contentType: 'text/plain',
- uuid: uuid,
- request: {
- signText: options,
- CAs: CAs
- }
- });
- }
-
- } catch (exception) {
-
- const response = new window.wrappedJSObject.Error('error:postMessageFailed');
-
- return new window.wrappedJSObject.Promise(
- exportFunction(
- function(resolve, reject) {
- reject(response);
- }, window.wrappedJSObject
- )
- );
- }
- });
- }
-
- const signTextHandler = function(e) {
- /* message not for us */
- if (!(e.uuid === undefined) && !(e.uuid === uuid)) {
- /* do nothing */
- }
- /* an error was received, cancel the stream */
- else if (e.error) {
- const error = new window.wrappedJSObject.Error(e.error);
- controller.enqueue(error);
- controller.close();
- port.onMessage.removeListener(signTextHandler);
- }
- /* an ack was received, send the next chunk */
- else if (e.response === true) {
- push();
- }
- /* an eos was received, we're done */
- else if (e.response === false) {
- controller.close();
- port.onMessage.removeListener(signTextHandler);
- }
- /* a response was received, enqueue the response */
- else {
- controller.enqueue(e.response);
- }
- };
-
- /* add our listener */
- port.onMessage.addListener(signTextHandler);
-
- port.onDisconnect.addListener((p) => {
- if (p.error) {
- console.log(`Redwax SignText: disconnected due to an error: ${p.error.message}`);
- } else {
- console.log(`Redwax SignText: disconnected`);
- }
- });
-
- /* fire off initial request */
- push();
-
- }, window.wrappedJSObject
- );
-
-// underlyingSource.type = "bytes";
-
- return new ReadableStream(underlyingSource);
- }
-
- function readerStreamToString(stream, stringResolve, stringReject) {
- const reader = stream.getReader();
- let result = '';
-
-console.log("readerStreamToString: ");
-
- let processText = exportFunction(
- function processText({done, value}) {
- if (Object.prototype.toString.call(value) === "[object Error]") {
- stringReject(value);
- } else if (done) {
- console.log("Stream complete:" + result);
- stringResolve(result);
- } else {
- result += value;
- reader.read().then(processText);
- }
- }, window.wrappedJSObject
- );
-
- return new window.wrappedJSObject.Promise(
- exportFunction(
- function(resolve, reject) {
- resolve( reader.read().then(processText) );
- }, window.wrappedJSObject
- )
);
}
More information about the rs-commit
mailing list