@reclaimprotocol/attestor-core 5.0.8 → 5.1.0
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/lib/external-rpc/index.js +221 -11
- package/lib/index.js +240 -6
- package/lib/providers/index.d.ts +1 -0
- package/package.json +9 -3
- package/browser/resources/attestor-browser.min.mjs +0 -4513
|
@@ -8427,22 +8427,232 @@ import {
|
|
|
8427
8427
|
} from "esprima-next";
|
|
8428
8428
|
import { JSONPath } from "jsonpath-plus";
|
|
8429
8429
|
import { parse } from "parse5";
|
|
8430
|
-
|
|
8430
|
+
|
|
8431
|
+
// node_modules/parse5-htmlparser2-tree-adapter/dist/index.js
|
|
8432
|
+
import { html } from "parse5";
|
|
8433
|
+
function enquoteDoctypeId(id) {
|
|
8434
|
+
const quote = id.includes('"') ? "'" : '"';
|
|
8435
|
+
return quote + id + quote;
|
|
8436
|
+
}
|
|
8437
|
+
function serializeDoctypeContent(name, publicId, systemId) {
|
|
8438
|
+
let str = "!DOCTYPE ";
|
|
8439
|
+
if (name) {
|
|
8440
|
+
str += name;
|
|
8441
|
+
}
|
|
8442
|
+
if (publicId) {
|
|
8443
|
+
str += ` PUBLIC ${enquoteDoctypeId(publicId)}`;
|
|
8444
|
+
} else if (systemId) {
|
|
8445
|
+
str += " SYSTEM";
|
|
8446
|
+
}
|
|
8447
|
+
if (systemId) {
|
|
8448
|
+
str += ` ${enquoteDoctypeId(systemId)}`;
|
|
8449
|
+
}
|
|
8450
|
+
return str;
|
|
8451
|
+
}
|
|
8452
|
+
var adapter = {
|
|
8453
|
+
// Re-exports from domhandler
|
|
8454
|
+
isCommentNode: isComment,
|
|
8455
|
+
isElementNode: isTag2,
|
|
8456
|
+
isTextNode: isText,
|
|
8457
|
+
//Node construction
|
|
8458
|
+
createDocument() {
|
|
8459
|
+
const node = new Document([]);
|
|
8460
|
+
node["x-mode"] = html.DOCUMENT_MODE.NO_QUIRKS;
|
|
8461
|
+
return node;
|
|
8462
|
+
},
|
|
8463
|
+
createDocumentFragment() {
|
|
8464
|
+
return new Document([]);
|
|
8465
|
+
},
|
|
8466
|
+
createElement(tagName, namespaceURI, attrs) {
|
|
8467
|
+
const attribs = /* @__PURE__ */ Object.create(null);
|
|
8468
|
+
const attribsNamespace = /* @__PURE__ */ Object.create(null);
|
|
8469
|
+
const attribsPrefix = /* @__PURE__ */ Object.create(null);
|
|
8470
|
+
for (let i = 0; i < attrs.length; i++) {
|
|
8471
|
+
const attrName = attrs[i].name;
|
|
8472
|
+
attribs[attrName] = attrs[i].value;
|
|
8473
|
+
attribsNamespace[attrName] = attrs[i].namespace;
|
|
8474
|
+
attribsPrefix[attrName] = attrs[i].prefix;
|
|
8475
|
+
}
|
|
8476
|
+
const node = new Element(tagName, attribs, []);
|
|
8477
|
+
node.namespace = namespaceURI;
|
|
8478
|
+
node["x-attribsNamespace"] = attribsNamespace;
|
|
8479
|
+
node["x-attribsPrefix"] = attribsPrefix;
|
|
8480
|
+
return node;
|
|
8481
|
+
},
|
|
8482
|
+
createCommentNode(data) {
|
|
8483
|
+
return new Comment2(data);
|
|
8484
|
+
},
|
|
8485
|
+
createTextNode(value) {
|
|
8486
|
+
return new Text2(value);
|
|
8487
|
+
},
|
|
8488
|
+
//Tree mutation
|
|
8489
|
+
appendChild(parentNode, newNode) {
|
|
8490
|
+
const prev = parentNode.children[parentNode.children.length - 1];
|
|
8491
|
+
if (prev) {
|
|
8492
|
+
prev.next = newNode;
|
|
8493
|
+
newNode.prev = prev;
|
|
8494
|
+
}
|
|
8495
|
+
parentNode.children.push(newNode);
|
|
8496
|
+
newNode.parent = parentNode;
|
|
8497
|
+
},
|
|
8498
|
+
insertBefore(parentNode, newNode, referenceNode) {
|
|
8499
|
+
const insertionIdx = parentNode.children.indexOf(referenceNode);
|
|
8500
|
+
const { prev } = referenceNode;
|
|
8501
|
+
if (prev) {
|
|
8502
|
+
prev.next = newNode;
|
|
8503
|
+
newNode.prev = prev;
|
|
8504
|
+
}
|
|
8505
|
+
referenceNode.prev = newNode;
|
|
8506
|
+
newNode.next = referenceNode;
|
|
8507
|
+
parentNode.children.splice(insertionIdx, 0, newNode);
|
|
8508
|
+
newNode.parent = parentNode;
|
|
8509
|
+
},
|
|
8510
|
+
setTemplateContent(templateElement, contentElement) {
|
|
8511
|
+
adapter.appendChild(templateElement, contentElement);
|
|
8512
|
+
},
|
|
8513
|
+
getTemplateContent(templateElement) {
|
|
8514
|
+
return templateElement.children[0];
|
|
8515
|
+
},
|
|
8516
|
+
setDocumentType(document, name, publicId, systemId) {
|
|
8517
|
+
const data = serializeDoctypeContent(name, publicId, systemId);
|
|
8518
|
+
let doctypeNode = document.children.find((node) => isDirective(node) && node.name === "!doctype");
|
|
8519
|
+
if (doctypeNode) {
|
|
8520
|
+
doctypeNode.data = data !== null && data !== void 0 ? data : null;
|
|
8521
|
+
} else {
|
|
8522
|
+
doctypeNode = new ProcessingInstruction("!doctype", data);
|
|
8523
|
+
adapter.appendChild(document, doctypeNode);
|
|
8524
|
+
}
|
|
8525
|
+
doctypeNode["x-name"] = name;
|
|
8526
|
+
doctypeNode["x-publicId"] = publicId;
|
|
8527
|
+
doctypeNode["x-systemId"] = systemId;
|
|
8528
|
+
},
|
|
8529
|
+
setDocumentMode(document, mode) {
|
|
8530
|
+
document["x-mode"] = mode;
|
|
8531
|
+
},
|
|
8532
|
+
getDocumentMode(document) {
|
|
8533
|
+
return document["x-mode"];
|
|
8534
|
+
},
|
|
8535
|
+
detachNode(node) {
|
|
8536
|
+
if (node.parent) {
|
|
8537
|
+
const idx = node.parent.children.indexOf(node);
|
|
8538
|
+
const { prev, next } = node;
|
|
8539
|
+
node.prev = null;
|
|
8540
|
+
node.next = null;
|
|
8541
|
+
if (prev) {
|
|
8542
|
+
prev.next = next;
|
|
8543
|
+
}
|
|
8544
|
+
if (next) {
|
|
8545
|
+
next.prev = prev;
|
|
8546
|
+
}
|
|
8547
|
+
node.parent.children.splice(idx, 1);
|
|
8548
|
+
node.parent = null;
|
|
8549
|
+
}
|
|
8550
|
+
},
|
|
8551
|
+
insertText(parentNode, text) {
|
|
8552
|
+
const lastChild = parentNode.children[parentNode.children.length - 1];
|
|
8553
|
+
if (lastChild && isText(lastChild)) {
|
|
8554
|
+
lastChild.data += text;
|
|
8555
|
+
} else {
|
|
8556
|
+
adapter.appendChild(parentNode, adapter.createTextNode(text));
|
|
8557
|
+
}
|
|
8558
|
+
},
|
|
8559
|
+
insertTextBefore(parentNode, text, referenceNode) {
|
|
8560
|
+
const prevNode = parentNode.children[parentNode.children.indexOf(referenceNode) - 1];
|
|
8561
|
+
if (prevNode && isText(prevNode)) {
|
|
8562
|
+
prevNode.data += text;
|
|
8563
|
+
} else {
|
|
8564
|
+
adapter.insertBefore(parentNode, adapter.createTextNode(text), referenceNode);
|
|
8565
|
+
}
|
|
8566
|
+
},
|
|
8567
|
+
adoptAttributes(recipient, attrs) {
|
|
8568
|
+
for (let i = 0; i < attrs.length; i++) {
|
|
8569
|
+
const attrName = attrs[i].name;
|
|
8570
|
+
if (recipient.attribs[attrName] === void 0) {
|
|
8571
|
+
recipient.attribs[attrName] = attrs[i].value;
|
|
8572
|
+
recipient["x-attribsNamespace"][attrName] = attrs[i].namespace;
|
|
8573
|
+
recipient["x-attribsPrefix"][attrName] = attrs[i].prefix;
|
|
8574
|
+
}
|
|
8575
|
+
}
|
|
8576
|
+
},
|
|
8577
|
+
//Tree traversing
|
|
8578
|
+
getFirstChild(node) {
|
|
8579
|
+
return node.children[0];
|
|
8580
|
+
},
|
|
8581
|
+
getChildNodes(node) {
|
|
8582
|
+
return node.children;
|
|
8583
|
+
},
|
|
8584
|
+
getParentNode(node) {
|
|
8585
|
+
return node.parent;
|
|
8586
|
+
},
|
|
8587
|
+
getAttrList(element) {
|
|
8588
|
+
return element.attributes;
|
|
8589
|
+
},
|
|
8590
|
+
//Node data
|
|
8591
|
+
getTagName(element) {
|
|
8592
|
+
return element.name;
|
|
8593
|
+
},
|
|
8594
|
+
getNamespaceURI(element) {
|
|
8595
|
+
return element.namespace;
|
|
8596
|
+
},
|
|
8597
|
+
getTextNodeContent(textNode) {
|
|
8598
|
+
return textNode.data;
|
|
8599
|
+
},
|
|
8600
|
+
getCommentNodeContent(commentNode) {
|
|
8601
|
+
return commentNode.data;
|
|
8602
|
+
},
|
|
8603
|
+
getDocumentTypeNodeName(doctypeNode) {
|
|
8604
|
+
var _a;
|
|
8605
|
+
return (_a = doctypeNode["x-name"]) !== null && _a !== void 0 ? _a : "";
|
|
8606
|
+
},
|
|
8607
|
+
getDocumentTypeNodePublicId(doctypeNode) {
|
|
8608
|
+
var _a;
|
|
8609
|
+
return (_a = doctypeNode["x-publicId"]) !== null && _a !== void 0 ? _a : "";
|
|
8610
|
+
},
|
|
8611
|
+
getDocumentTypeNodeSystemId(doctypeNode) {
|
|
8612
|
+
var _a;
|
|
8613
|
+
return (_a = doctypeNode["x-systemId"]) !== null && _a !== void 0 ? _a : "";
|
|
8614
|
+
},
|
|
8615
|
+
//Node types
|
|
8616
|
+
isDocumentTypeNode(node) {
|
|
8617
|
+
return isDirective(node) && node.name === "!doctype";
|
|
8618
|
+
},
|
|
8619
|
+
// Source code location
|
|
8620
|
+
setNodeSourceCodeLocation(node, location) {
|
|
8621
|
+
if (location) {
|
|
8622
|
+
node.startIndex = location.startOffset;
|
|
8623
|
+
node.endIndex = location.endOffset;
|
|
8624
|
+
}
|
|
8625
|
+
node.sourceCodeLocation = location;
|
|
8626
|
+
},
|
|
8627
|
+
getNodeSourceCodeLocation(node) {
|
|
8628
|
+
return node.sourceCodeLocation;
|
|
8629
|
+
},
|
|
8630
|
+
updateNodeSourceCodeLocation(node, endLocation) {
|
|
8631
|
+
if (endLocation.endOffset != null)
|
|
8632
|
+
node.endIndex = endLocation.endOffset;
|
|
8633
|
+
node.sourceCodeLocation = {
|
|
8634
|
+
...node.sourceCodeLocation,
|
|
8635
|
+
...endLocation
|
|
8636
|
+
};
|
|
8637
|
+
}
|
|
8638
|
+
};
|
|
8639
|
+
|
|
8640
|
+
// src/providers/http/utils.ts
|
|
8431
8641
|
import xpath from "xpath";
|
|
8432
|
-
function extractHTMLElement(
|
|
8433
|
-
const { start, end } = extractHTMLElementIndex(
|
|
8434
|
-
return
|
|
8642
|
+
function extractHTMLElement(html2, xpathExpression, contentsOnly) {
|
|
8643
|
+
const { start, end } = extractHTMLElementIndex(html2, xpathExpression, contentsOnly);
|
|
8644
|
+
return html2.slice(start, end);
|
|
8435
8645
|
}
|
|
8436
|
-
function extractHTMLElementIndex(
|
|
8437
|
-
return extractHTMLElementsIndexes(
|
|
8646
|
+
function extractHTMLElementIndex(html2, xpathExpression, contentsOnly) {
|
|
8647
|
+
return extractHTMLElementsIndexes(html2, xpathExpression, contentsOnly)[0];
|
|
8438
8648
|
}
|
|
8439
|
-
function extractHTMLElementsIndexes(
|
|
8440
|
-
return extractHTMLElementIndexesParse5(
|
|
8649
|
+
function extractHTMLElementsIndexes(html2, xpathExpression, contentsOnly) {
|
|
8650
|
+
return extractHTMLElementIndexesParse5(html2, xpathExpression, contentsOnly);
|
|
8441
8651
|
}
|
|
8442
|
-
function extractHTMLElementIndexesParse5(
|
|
8652
|
+
function extractHTMLElementIndexesParse5(html2, xpathExpression, contentsOnly) {
|
|
8443
8653
|
const domLight = parse(
|
|
8444
|
-
|
|
8445
|
-
{ treeAdapter:
|
|
8654
|
+
html2,
|
|
8655
|
+
{ treeAdapter: adapter, sourceCodeLocationInfo: true }
|
|
8446
8656
|
);
|
|
8447
8657
|
domLight["name"] = "root";
|
|
8448
8658
|
const parsedPath = xpath.parse(xpathExpression);
|
package/lib/index.js
CHANGED
|
@@ -6736,15 +6736,240 @@ import {
|
|
|
6736
6736
|
} from "esprima-next";
|
|
6737
6737
|
import { JSONPath } from "jsonpath-plus";
|
|
6738
6738
|
import { parse } from "parse5";
|
|
6739
|
-
|
|
6739
|
+
|
|
6740
|
+
// node_modules/parse5-htmlparser2-tree-adapter/dist/index.js
|
|
6741
|
+
import { html } from "parse5";
|
|
6742
|
+
function enquoteDoctypeId(id) {
|
|
6743
|
+
const quote = id.includes('"') ? "'" : '"';
|
|
6744
|
+
return quote + id + quote;
|
|
6745
|
+
}
|
|
6746
|
+
function serializeDoctypeContent(name, publicId, systemId) {
|
|
6747
|
+
let str = "!DOCTYPE ";
|
|
6748
|
+
if (name) {
|
|
6749
|
+
str += name;
|
|
6750
|
+
}
|
|
6751
|
+
if (publicId) {
|
|
6752
|
+
str += ` PUBLIC ${enquoteDoctypeId(publicId)}`;
|
|
6753
|
+
} else if (systemId) {
|
|
6754
|
+
str += " SYSTEM";
|
|
6755
|
+
}
|
|
6756
|
+
if (systemId) {
|
|
6757
|
+
str += ` ${enquoteDoctypeId(systemId)}`;
|
|
6758
|
+
}
|
|
6759
|
+
return str;
|
|
6760
|
+
}
|
|
6761
|
+
var adapter = {
|
|
6762
|
+
// Re-exports from domhandler
|
|
6763
|
+
isCommentNode: isComment,
|
|
6764
|
+
isElementNode: isTag2,
|
|
6765
|
+
isTextNode: isText,
|
|
6766
|
+
//Node construction
|
|
6767
|
+
createDocument() {
|
|
6768
|
+
const node = new Document([]);
|
|
6769
|
+
node["x-mode"] = html.DOCUMENT_MODE.NO_QUIRKS;
|
|
6770
|
+
return node;
|
|
6771
|
+
},
|
|
6772
|
+
createDocumentFragment() {
|
|
6773
|
+
return new Document([]);
|
|
6774
|
+
},
|
|
6775
|
+
createElement(tagName, namespaceURI, attrs) {
|
|
6776
|
+
const attribs = /* @__PURE__ */ Object.create(null);
|
|
6777
|
+
const attribsNamespace = /* @__PURE__ */ Object.create(null);
|
|
6778
|
+
const attribsPrefix = /* @__PURE__ */ Object.create(null);
|
|
6779
|
+
for (let i = 0; i < attrs.length; i++) {
|
|
6780
|
+
const attrName = attrs[i].name;
|
|
6781
|
+
attribs[attrName] = attrs[i].value;
|
|
6782
|
+
attribsNamespace[attrName] = attrs[i].namespace;
|
|
6783
|
+
attribsPrefix[attrName] = attrs[i].prefix;
|
|
6784
|
+
}
|
|
6785
|
+
const node = new Element(tagName, attribs, []);
|
|
6786
|
+
node.namespace = namespaceURI;
|
|
6787
|
+
node["x-attribsNamespace"] = attribsNamespace;
|
|
6788
|
+
node["x-attribsPrefix"] = attribsPrefix;
|
|
6789
|
+
return node;
|
|
6790
|
+
},
|
|
6791
|
+
createCommentNode(data) {
|
|
6792
|
+
return new Comment2(data);
|
|
6793
|
+
},
|
|
6794
|
+
createTextNode(value) {
|
|
6795
|
+
return new Text2(value);
|
|
6796
|
+
},
|
|
6797
|
+
//Tree mutation
|
|
6798
|
+
appendChild(parentNode, newNode) {
|
|
6799
|
+
const prev = parentNode.children[parentNode.children.length - 1];
|
|
6800
|
+
if (prev) {
|
|
6801
|
+
prev.next = newNode;
|
|
6802
|
+
newNode.prev = prev;
|
|
6803
|
+
}
|
|
6804
|
+
parentNode.children.push(newNode);
|
|
6805
|
+
newNode.parent = parentNode;
|
|
6806
|
+
},
|
|
6807
|
+
insertBefore(parentNode, newNode, referenceNode) {
|
|
6808
|
+
const insertionIdx = parentNode.children.indexOf(referenceNode);
|
|
6809
|
+
const { prev } = referenceNode;
|
|
6810
|
+
if (prev) {
|
|
6811
|
+
prev.next = newNode;
|
|
6812
|
+
newNode.prev = prev;
|
|
6813
|
+
}
|
|
6814
|
+
referenceNode.prev = newNode;
|
|
6815
|
+
newNode.next = referenceNode;
|
|
6816
|
+
parentNode.children.splice(insertionIdx, 0, newNode);
|
|
6817
|
+
newNode.parent = parentNode;
|
|
6818
|
+
},
|
|
6819
|
+
setTemplateContent(templateElement, contentElement) {
|
|
6820
|
+
adapter.appendChild(templateElement, contentElement);
|
|
6821
|
+
},
|
|
6822
|
+
getTemplateContent(templateElement) {
|
|
6823
|
+
return templateElement.children[0];
|
|
6824
|
+
},
|
|
6825
|
+
setDocumentType(document, name, publicId, systemId) {
|
|
6826
|
+
const data = serializeDoctypeContent(name, publicId, systemId);
|
|
6827
|
+
let doctypeNode = document.children.find((node) => isDirective(node) && node.name === "!doctype");
|
|
6828
|
+
if (doctypeNode) {
|
|
6829
|
+
doctypeNode.data = data !== null && data !== void 0 ? data : null;
|
|
6830
|
+
} else {
|
|
6831
|
+
doctypeNode = new ProcessingInstruction("!doctype", data);
|
|
6832
|
+
adapter.appendChild(document, doctypeNode);
|
|
6833
|
+
}
|
|
6834
|
+
doctypeNode["x-name"] = name;
|
|
6835
|
+
doctypeNode["x-publicId"] = publicId;
|
|
6836
|
+
doctypeNode["x-systemId"] = systemId;
|
|
6837
|
+
},
|
|
6838
|
+
setDocumentMode(document, mode) {
|
|
6839
|
+
document["x-mode"] = mode;
|
|
6840
|
+
},
|
|
6841
|
+
getDocumentMode(document) {
|
|
6842
|
+
return document["x-mode"];
|
|
6843
|
+
},
|
|
6844
|
+
detachNode(node) {
|
|
6845
|
+
if (node.parent) {
|
|
6846
|
+
const idx = node.parent.children.indexOf(node);
|
|
6847
|
+
const { prev, next } = node;
|
|
6848
|
+
node.prev = null;
|
|
6849
|
+
node.next = null;
|
|
6850
|
+
if (prev) {
|
|
6851
|
+
prev.next = next;
|
|
6852
|
+
}
|
|
6853
|
+
if (next) {
|
|
6854
|
+
next.prev = prev;
|
|
6855
|
+
}
|
|
6856
|
+
node.parent.children.splice(idx, 1);
|
|
6857
|
+
node.parent = null;
|
|
6858
|
+
}
|
|
6859
|
+
},
|
|
6860
|
+
insertText(parentNode, text) {
|
|
6861
|
+
const lastChild = parentNode.children[parentNode.children.length - 1];
|
|
6862
|
+
if (lastChild && isText(lastChild)) {
|
|
6863
|
+
lastChild.data += text;
|
|
6864
|
+
} else {
|
|
6865
|
+
adapter.appendChild(parentNode, adapter.createTextNode(text));
|
|
6866
|
+
}
|
|
6867
|
+
},
|
|
6868
|
+
insertTextBefore(parentNode, text, referenceNode) {
|
|
6869
|
+
const prevNode = parentNode.children[parentNode.children.indexOf(referenceNode) - 1];
|
|
6870
|
+
if (prevNode && isText(prevNode)) {
|
|
6871
|
+
prevNode.data += text;
|
|
6872
|
+
} else {
|
|
6873
|
+
adapter.insertBefore(parentNode, adapter.createTextNode(text), referenceNode);
|
|
6874
|
+
}
|
|
6875
|
+
},
|
|
6876
|
+
adoptAttributes(recipient, attrs) {
|
|
6877
|
+
for (let i = 0; i < attrs.length; i++) {
|
|
6878
|
+
const attrName = attrs[i].name;
|
|
6879
|
+
if (recipient.attribs[attrName] === void 0) {
|
|
6880
|
+
recipient.attribs[attrName] = attrs[i].value;
|
|
6881
|
+
recipient["x-attribsNamespace"][attrName] = attrs[i].namespace;
|
|
6882
|
+
recipient["x-attribsPrefix"][attrName] = attrs[i].prefix;
|
|
6883
|
+
}
|
|
6884
|
+
}
|
|
6885
|
+
},
|
|
6886
|
+
//Tree traversing
|
|
6887
|
+
getFirstChild(node) {
|
|
6888
|
+
return node.children[0];
|
|
6889
|
+
},
|
|
6890
|
+
getChildNodes(node) {
|
|
6891
|
+
return node.children;
|
|
6892
|
+
},
|
|
6893
|
+
getParentNode(node) {
|
|
6894
|
+
return node.parent;
|
|
6895
|
+
},
|
|
6896
|
+
getAttrList(element) {
|
|
6897
|
+
return element.attributes;
|
|
6898
|
+
},
|
|
6899
|
+
//Node data
|
|
6900
|
+
getTagName(element) {
|
|
6901
|
+
return element.name;
|
|
6902
|
+
},
|
|
6903
|
+
getNamespaceURI(element) {
|
|
6904
|
+
return element.namespace;
|
|
6905
|
+
},
|
|
6906
|
+
getTextNodeContent(textNode) {
|
|
6907
|
+
return textNode.data;
|
|
6908
|
+
},
|
|
6909
|
+
getCommentNodeContent(commentNode) {
|
|
6910
|
+
return commentNode.data;
|
|
6911
|
+
},
|
|
6912
|
+
getDocumentTypeNodeName(doctypeNode) {
|
|
6913
|
+
var _a;
|
|
6914
|
+
return (_a = doctypeNode["x-name"]) !== null && _a !== void 0 ? _a : "";
|
|
6915
|
+
},
|
|
6916
|
+
getDocumentTypeNodePublicId(doctypeNode) {
|
|
6917
|
+
var _a;
|
|
6918
|
+
return (_a = doctypeNode["x-publicId"]) !== null && _a !== void 0 ? _a : "";
|
|
6919
|
+
},
|
|
6920
|
+
getDocumentTypeNodeSystemId(doctypeNode) {
|
|
6921
|
+
var _a;
|
|
6922
|
+
return (_a = doctypeNode["x-systemId"]) !== null && _a !== void 0 ? _a : "";
|
|
6923
|
+
},
|
|
6924
|
+
//Node types
|
|
6925
|
+
isDocumentTypeNode(node) {
|
|
6926
|
+
return isDirective(node) && node.name === "!doctype";
|
|
6927
|
+
},
|
|
6928
|
+
// Source code location
|
|
6929
|
+
setNodeSourceCodeLocation(node, location) {
|
|
6930
|
+
if (location) {
|
|
6931
|
+
node.startIndex = location.startOffset;
|
|
6932
|
+
node.endIndex = location.endOffset;
|
|
6933
|
+
}
|
|
6934
|
+
node.sourceCodeLocation = location;
|
|
6935
|
+
},
|
|
6936
|
+
getNodeSourceCodeLocation(node) {
|
|
6937
|
+
return node.sourceCodeLocation;
|
|
6938
|
+
},
|
|
6939
|
+
updateNodeSourceCodeLocation(node, endLocation) {
|
|
6940
|
+
if (endLocation.endOffset != null)
|
|
6941
|
+
node.endIndex = endLocation.endOffset;
|
|
6942
|
+
node.sourceCodeLocation = {
|
|
6943
|
+
...node.sourceCodeLocation,
|
|
6944
|
+
...endLocation
|
|
6945
|
+
};
|
|
6946
|
+
}
|
|
6947
|
+
};
|
|
6948
|
+
|
|
6949
|
+
// src/providers/http/utils.ts
|
|
6740
6950
|
import xpath from "xpath";
|
|
6741
|
-
function
|
|
6742
|
-
|
|
6951
|
+
function extractHTMLElement(html2, xpathExpression, contentsOnly) {
|
|
6952
|
+
const { start, end } = extractHTMLElementIndex(html2, xpathExpression, contentsOnly);
|
|
6953
|
+
return html2.slice(start, end);
|
|
6954
|
+
}
|
|
6955
|
+
function extractHTMLElements(html2, xpathExpression, contentsOnly) {
|
|
6956
|
+
const indexes = extractHTMLElementsIndexes(html2, xpathExpression, contentsOnly);
|
|
6957
|
+
const res = [];
|
|
6958
|
+
for (const { start, end } of indexes) {
|
|
6959
|
+
res.push(html2.slice(start, end));
|
|
6960
|
+
}
|
|
6961
|
+
return res;
|
|
6743
6962
|
}
|
|
6744
|
-
function
|
|
6963
|
+
function extractHTMLElementIndex(html2, xpathExpression, contentsOnly) {
|
|
6964
|
+
return extractHTMLElementsIndexes(html2, xpathExpression, contentsOnly)[0];
|
|
6965
|
+
}
|
|
6966
|
+
function extractHTMLElementsIndexes(html2, xpathExpression, contentsOnly) {
|
|
6967
|
+
return extractHTMLElementIndexesParse5(html2, xpathExpression, contentsOnly);
|
|
6968
|
+
}
|
|
6969
|
+
function extractHTMLElementIndexesParse5(html2, xpathExpression, contentsOnly) {
|
|
6745
6970
|
const domLight = parse(
|
|
6746
|
-
|
|
6747
|
-
{ treeAdapter:
|
|
6971
|
+
html2,
|
|
6972
|
+
{ treeAdapter: adapter, sourceCodeLocationInfo: true }
|
|
6748
6973
|
);
|
|
6749
6974
|
domLight["name"] = "root";
|
|
6750
6975
|
const parsedPath = xpath.parse(xpathExpression);
|
|
@@ -6769,6 +6994,9 @@ function getNodeRange(node, contentsOnly) {
|
|
|
6769
6994
|
end: node.lastChild.endIndex
|
|
6770
6995
|
};
|
|
6771
6996
|
}
|
|
6997
|
+
function extractJSONValueIndex(json, jsonPath) {
|
|
6998
|
+
return extractJSONValueIndexes(json, jsonPath)[0];
|
|
6999
|
+
}
|
|
6772
7000
|
function extractJSONValueIndexes(json, jsonPath) {
|
|
6773
7001
|
const pointers = JSONPath({
|
|
6774
7002
|
path: jsonPath,
|
|
@@ -8394,7 +8622,13 @@ export {
|
|
|
8394
8622
|
ethersStructToPlainObject,
|
|
8395
8623
|
extractApplicationDataFromTranscript,
|
|
8396
8624
|
extractArrayBufferFromWsData,
|
|
8625
|
+
extractHTMLElement,
|
|
8626
|
+
extractHTMLElementIndex,
|
|
8627
|
+
extractHTMLElements,
|
|
8628
|
+
extractHTMLElementsIndexes,
|
|
8397
8629
|
extractHandshakeFromTranscript,
|
|
8630
|
+
extractJSONValueIndex,
|
|
8631
|
+
extractJSONValueIndexes,
|
|
8398
8632
|
extractRequestBufferFromTranscript,
|
|
8399
8633
|
findIndexInUint8Array,
|
|
8400
8634
|
generateRpcMessageId,
|
package/lib/providers/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Provider, ProviderName } from '../types/index.ts';
|
|
2
|
+
export { extractHTMLElement, extractHTMLElementIndex, extractHTMLElements, extractHTMLElementsIndexes, extractJSONValueIndex, extractJSONValueIndexes, } from '../providers/http/utils.ts';
|
|
2
3
|
export declare const providers: {
|
|
3
4
|
[T in ProviderName]: Provider<T>;
|
|
4
5
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reclaimprotocol/attestor-core",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
7
7
|
"#src/*.ts": "./src/*.ts",
|
|
8
8
|
"#src/*.js": "./lib/*.js"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/reclaimprotocol/attestor-core"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
10
17
|
"exports": {
|
|
11
18
|
".": {
|
|
12
19
|
"types": "./lib/index.d.ts",
|
|
@@ -47,8 +54,7 @@
|
|
|
47
54
|
"start:chain": "bash ./avs/utils/anvil/start-anvil-chain-with-el-and-avs-deployed.sh",
|
|
48
55
|
"commitlint": "commitlint --edit",
|
|
49
56
|
"download:zk-files": "node node_modules/@reclaimprotocol/zk-symmetric-crypto/lib/scripts/download-files",
|
|
50
|
-
"generate:toprf-keys": "npm run run:tsc -- src/scripts/generate-toprf-keys.ts"
|
|
51
|
-
"publish:pkg": "npm publish --access public"
|
|
57
|
+
"generate:toprf-keys": "npm run run:tsc -- src/scripts/generate-toprf-keys.ts"
|
|
52
58
|
},
|
|
53
59
|
"files": [
|
|
54
60
|
"lib/*",
|