Skip to content

Commit

Permalink
remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham committed Nov 25, 2024
1 parent 60c01d0 commit 449e6d6
Showing 1 changed file with 3 additions and 40 deletions.
43 changes: 3 additions & 40 deletions packages/siwe-parser/lib/abnf.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { grammar } from "./siwe-grammar";
import { cb } from "./callbacks";
import apgLib from "apg-js/src/apg-lib/node-exports";
// import * as fs from "node:fs";
// import { cwd } from "node:process";
const grammarObj = new grammar();

export class ParsedMessage {
Expand Down Expand Up @@ -30,7 +28,6 @@ export class ParsedMessage {
};

// and display it on an HTML page.
// constructor(msg: string, doTrace = false) {
constructor(msg: string) {
const parser = new apgLib.parser();
parser.callbacks["sign-in-with-ethereum"] = cb.signInWithEtherium;
Expand Down Expand Up @@ -102,25 +99,8 @@ export class ParsedMessage {
fragment: undefined,
},
};
// if (doTrace === true) {
// parser.trace = new apgLib.trace();
// parser.trace.filter.operators["<ALL>"] = true;
// }

const result = parser.parse(grammarObj, 0, msg, elements);
// if (doTrace === true) {
// const html = parser.trace.toHtmlPage("ascii", "siwe-parser trace");
// const dir = `${cwd()}/output`;
// const name = `${dir}/siwe-parser-trace.html`;
// try {
// fs.mkdirSync(dir);
// } catch (e) {
// if (e.code !== "EEXIST") {
// throw new Error(`fs.mkdir failed: ${e.message}`);
// }
// }
// fs.writeFileSync(name, html);
// console.log(`view "${name}" in any browser to display parser's trace`);
// }
let throwMsg = "";
for (let i = 0; i < elements.errors.length; i += 1) {
throwMsg += elements.errors[i] + "\n";
Expand Down Expand Up @@ -149,7 +129,6 @@ export class ParsedMessage {
}
}

// export const isUri = (uri: string, doTrace = false) => {
export const isUri = (uri: string) => {
const parser = new apgLib.parser();
parser.callbacks["IP-literal"] = cb.ipLiteral;
Expand All @@ -162,25 +141,9 @@ export const isUri = (uri: string) => {
parser.callbacks["h16cn"] = cb.h16;
parser.callbacks["dec-octet"] = cb.decOctet;
parser.callbacks["dec-digit"] = cb.decDigit;
// if (doTrace === true) {
// parser.trace = new apgLib.trace();
// parser.trace.filter.operators["<ALL>"] = true;
// }

const data = { errors: [] };
const result = parser.parse(grammarObj, "uri-r", uri, data);
// if (doTrace === true) {
// const html = parser.trace.toHtmlPage("ascii", "isUri trace");
// const dir = `${cwd()}/output`;
// const name = `${dir}/isUri-trace.html`;
// try {
// fs.mkdirSync(dir);
// } catch (e) {
// if (e.code !== "EEXIST") {
// throw new Error(`fs.mkdir failed: ${e.message}`);
// }
// }
// fs.writeFileSync(name, html);
// console.log(`view "${name}" in any browser to display parser's trace`);
// }

return result.success;
};

0 comments on commit 449e6d6

Please sign in to comment.