@btc-embedded/cdk-extensions 0.23.3 → 0.23.5

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.
Files changed (135) hide show
  1. package/.jsii +41 -41
  2. package/CHANGELOG.md +14 -0
  3. package/assets/cli/catnip.js +154 -166
  4. package/lib/constructs/EventPipe.js +1 -1
  5. package/lib/constructs/ExportedService.js +1 -1
  6. package/lib/constructs/S3Bucket.js +1 -1
  7. package/lib/constructs/SecureRestApi.js +1 -1
  8. package/lib/constructs/SecureRestApiV2.js +1 -1
  9. package/lib/constructs/api-keys/ApiKeyClientAuthorization.js +1 -1
  10. package/lib/constructs/api-keys/ApiKeyManagement.js +1 -1
  11. package/lib/constructs/api-keys/ApiKeyPreTokenHandler.js +1 -1
  12. package/lib/constructs/api-keys/ApiKeyStore.js +1 -1
  13. package/lib/extensions/ApiGatewayExtension.js +1 -1
  14. package/lib/extensions/ApplicationContainer.js +1 -1
  15. package/lib/extensions/ApplicationLoadBalancerExtension.js +1 -1
  16. package/lib/extensions/ApplicationLoadBalancerExtensionV2.js +1 -1
  17. package/lib/extensions/CloudMapExtension.js +1 -1
  18. package/lib/extensions/DeactivatableServiceExtension.js +1 -1
  19. package/lib/extensions/DeploymentConfigExtension.js +1 -1
  20. package/lib/extensions/DocumentDbAccessExtension.js +1 -1
  21. package/lib/extensions/DomainEventMessagingExtension.js +1 -1
  22. package/lib/extensions/EfsMountExtension.js +1 -1
  23. package/lib/extensions/ExtraContainerExtension.js +1 -1
  24. package/lib/extensions/HTTPApiExtension.js +1 -1
  25. package/lib/extensions/LogExtension.js +1 -1
  26. package/lib/extensions/ModifyContainerDefinitionExtension.js +1 -1
  27. package/lib/extensions/ModifyTaskDefinitionExtension.js +1 -1
  28. package/lib/extensions/OpenIdExtension.js +1 -1
  29. package/lib/extensions/OpenTelemetryExtension.js +1 -1
  30. package/lib/extensions/PostgresDbAccessExtension.js +1 -1
  31. package/lib/extensions/SharedVolumeExtension.js +1 -1
  32. package/lib/extensions/TcpKeepAliveExtension.js +1 -1
  33. package/lib/platform/ApiGateway.js +1 -1
  34. package/lib/platform/ApiGatewayVpcLink.js +2 -2
  35. package/lib/platform/ApplicationLoadBalancer.js +1 -1
  36. package/lib/platform/ApplicationLoadBalancerV2.d.ts +1 -0
  37. package/lib/platform/ApplicationLoadBalancerV2.js +10 -3
  38. package/lib/platform/AuroraPostgresDB.js +5 -4
  39. package/lib/platform/BTCLogGroup.js +1 -1
  40. package/lib/platform/CognitoUserPool.js +2 -2
  41. package/lib/platform/DefaultUserPoolClients.js +1 -1
  42. package/lib/platform/DocumentDB.js +2 -2
  43. package/lib/platform/EcsCluster.js +1 -1
  44. package/lib/platform/EfsFileSystem.js +1 -1
  45. package/lib/platform/HostedZone.js +1 -1
  46. package/lib/platform/PrivateDnsNamespace.js +1 -1
  47. package/lib/platform/ResourceServer.js +1 -1
  48. package/lib/platform/Vpc.js +1 -1
  49. package/lib/platform/VpcV2.js +1 -1
  50. package/lib/stacks/ApplicationStack.js +1 -1
  51. package/lib/utils/BasePlatformStackResolver.js +1 -1
  52. package/lib/utils/StackParameter.js +1 -1
  53. package/node_modules/@nodable/entities/README.md +41 -0
  54. package/node_modules/@nodable/entities/package.json +54 -0
  55. package/node_modules/@nodable/entities/src/EntityDecoder.js +543 -0
  56. package/node_modules/@nodable/entities/src/EntityEncoder.js +194 -0
  57. package/node_modules/@nodable/entities/src/entities.js +1177 -0
  58. package/node_modules/@nodable/entities/src/entityTries.js +49 -0
  59. package/node_modules/@nodable/entities/src/index.d.ts +264 -0
  60. package/node_modules/@nodable/entities/src/index.js +29 -0
  61. package/node_modules/fast-xml-builder/CHANGELOG.md +40 -0
  62. package/node_modules/fast-xml-builder/LICENSE +21 -0
  63. package/node_modules/fast-xml-builder/README.md +74 -0
  64. package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  65. package/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
  66. package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  67. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  68. package/node_modules/fast-xml-builder/package.json +81 -0
  69. package/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
  70. package/node_modules/fast-xml-builder/src/fxb.js +599 -0
  71. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
  72. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +359 -0
  73. package/node_modules/fast-xml-builder/src/util.js +16 -0
  74. package/node_modules/fast-xml-parser/CHANGELOG.md +165 -0
  75. package/node_modules/fast-xml-parser/README.md +21 -44
  76. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
  77. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
  78. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
  79. package/node_modules/fast-xml-parser/lib/fxp.d.cts +343 -31
  80. package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
  81. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
  82. package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
  83. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
  84. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +1 -1
  85. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -1
  86. package/node_modules/fast-xml-parser/package.json +13 -8
  87. package/node_modules/fast-xml-parser/src/fxp.d.ts +335 -30
  88. package/node_modules/fast-xml-parser/src/fxp.js +1 -1
  89. package/node_modules/fast-xml-parser/src/util.js +18 -25
  90. package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +89 -87
  91. package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +10 -10
  92. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +23 -23
  93. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +29 -29
  94. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +1 -1
  95. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +39 -39
  96. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +21 -21
  97. package/node_modules/fast-xml-parser/src/v6/XMLParser.js +22 -22
  98. package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +85 -85
  99. package/node_modules/fast-xml-parser/src/validator.js +34 -34
  100. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +5 -284
  101. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +335 -293
  102. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +160 -43
  103. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +540 -308
  104. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +26 -26
  105. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +99 -41
  106. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +10 -10
  107. package/node_modules/path-expression-matcher/LICENSE +21 -0
  108. package/node_modules/path-expression-matcher/README.md +872 -0
  109. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  110. package/node_modules/path-expression-matcher/lib/pem.d.cts +634 -0
  111. package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  112. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  113. package/node_modules/path-expression-matcher/package.json +78 -0
  114. package/node_modules/path-expression-matcher/src/Expression.js +232 -0
  115. package/node_modules/path-expression-matcher/src/ExpressionSet.js +209 -0
  116. package/node_modules/path-expression-matcher/src/Matcher.js +570 -0
  117. package/node_modules/path-expression-matcher/src/index.d.ts +523 -0
  118. package/node_modules/path-expression-matcher/src/index.js +29 -0
  119. package/node_modules/strnum/CHANGELOG.md +12 -2
  120. package/node_modules/strnum/README.md +1 -0
  121. package/node_modules/strnum/package.json +5 -4
  122. package/node_modules/strnum/strnum.js +99 -65
  123. package/node_modules/xml-naming/README.md +189 -0
  124. package/node_modules/xml-naming/package.json +54 -0
  125. package/node_modules/xml-naming/src/index.d.ts +74 -0
  126. package/node_modules/xml-naming/src/index.js +270 -0
  127. package/package.json +3 -2
  128. package/renovate.json5 +1 -0
  129. package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +0 -134
  130. package/node_modules/strnum/.github/SECURITY.md +0 -5
  131. package/node_modules/strnum/.vscode/launch.json +0 -25
  132. package/node_modules/strnum/algo.stflow +0 -84
  133. package/node_modules/strnum/strnum.test.js +0 -173
  134. package/node_modules/strnum/test.js +0 -9
  135. /package/node_modules/{fast-xml-parser/src/xmlbuilder → fast-xml-builder/src}/prettifyJs2Xml.js +0 -0
@@ -1,10 +1,10 @@
1
- import trimParser from "../valueParsers/trim";
2
- import booleanParser from "../valueParsers/booleanParser";
3
- import currencyParser from "../valueParsers/currency";
4
- import numberParser from "../valueParsers/number";
1
+ import trimParser from "../valueParsers/trim.js";
2
+ import booleanParser from "../valueParsers/booleanParser.js";
3
+ import currencyParser from "../valueParsers/currency.js";
4
+ import numberParser from "../valueParsers/number.js";
5
5
 
6
- const defaultOptions={
7
- nameFor:{
6
+ const defaultOptions = {
7
+ nameFor: {
8
8
  text: "#text",
9
9
  comment: "",
10
10
  cdata: "",
@@ -22,11 +22,11 @@ const defaultOptions={
22
22
  // "date",
23
23
  ]
24
24
  },
25
- attributes:{
25
+ attributes: {
26
26
  prefix: "@_",
27
27
  suffix: "",
28
28
  groupBy: "",
29
-
29
+
30
30
  valueParsers: [
31
31
  // "trim",
32
32
  // "boolean",
@@ -35,35 +35,35 @@ const defaultOptions={
35
35
  // "date",
36
36
  ]
37
37
  },
38
- dataType:{
38
+ dataType: {
39
39
 
40
40
  }
41
41
  }
42
42
 
43
43
  //TODO
44
- const withJoin = ["trim","join", /*"entities",*/"number","boolean","currency"/*, "date"*/]
45
- const withoutJoin = ["trim", /*"entities",*/"number","boolean","currency"/*, "date"*/]
44
+ const withJoin = ["trim", "join", /*"entities",*/"number", "boolean", "currency"/*, "date"*/]
45
+ const withoutJoin = ["trim", /*"entities",*/"number", "boolean", "currency"/*, "date"*/]
46
46
 
47
- export function buildOptions(options){
47
+ export function buildOptions(options) {
48
48
  //clone
49
- const finalOptions = { ... defaultOptions};
49
+ const finalOptions = { ...defaultOptions };
50
50
 
51
51
  //add config missed in cloning
52
52
  finalOptions.tags.valueParsers.push(...withJoin)
53
- if(!this.preserveOrder)
53
+ if (!this.preserveOrder)
54
54
  finalOptions.tags.valueParsers.push(...withoutJoin);
55
55
 
56
56
  //add config missed in cloning
57
57
  finalOptions.attributes.valueParsers.push(...withJoin)
58
58
 
59
59
  //override configuration
60
- copyProperties(finalOptions,options);
60
+ copyProperties(finalOptions, options);
61
61
  return finalOptions;
62
62
  }
63
63
 
64
64
  function copyProperties(target, source) {
65
65
  for (let key in source) {
66
- if (source.hasOwnProperty(key)) {
66
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
67
67
  if (typeof source[key] === 'object' && !Array.isArray(source[key])) {
68
68
  // Recursively copy nested properties
69
69
  if (typeof target[key] === 'undefined') {
@@ -78,16 +78,16 @@ function copyProperties(target, source) {
78
78
  }
79
79
  }
80
80
 
81
- export function registerCommonValueParsers(options){
81
+ export function registerCommonValueParsers(options) {
82
82
  return {
83
83
  "trim": new trimParser(),
84
84
  // "join": this.entityParser.parse,
85
85
  "boolean": new booleanParser(),
86
86
  "number": new numberParser({
87
- hex: true,
88
- leadingZeros: true,
89
- eNotation: true
90
- }),
87
+ hex: true,
88
+ leadingZeros: true,
89
+ eNotation: true
90
+ }),
91
91
  "currency": new currencyParser(),
92
92
  // "date": this.entityParser.parse,
93
93
  }
@@ -1,9 +1,9 @@
1
- import { buildOptions} from './OptionsBuilder.js';
1
+ import { buildOptions } from './OptionsBuilder.js';
2
2
  import Xml2JsParser from './Xml2JsParser.js';
3
3
 
4
- export default class XMLParser{
5
-
6
- constructor(options){
4
+ export default class XMLParser {
5
+
6
+ constructor(options) {
7
7
  this.externalEntities = {};
8
8
  this.options = buildOptions(options);
9
9
  // console.log(this.options)
@@ -13,17 +13,17 @@ export default class XMLParser{
13
13
  * @param {string|Buffer} xmlData
14
14
  * @param {boolean|Object} validationOption
15
15
  */
16
- parse(xmlData){
17
- if(Array.isArray(xmlData) && xmlData.byteLength !== undefined){
16
+ parse(xmlData) {
17
+ if (Array.isArray(xmlData) && xmlData.byteLength !== undefined) {
18
18
  return this.parse(xmlData);
19
- }else if( xmlData.toString){
19
+ } else if (xmlData.toString) {
20
20
  xmlData = xmlData.toString();
21
- }else{
21
+ } else {
22
22
  throw new Error("XML data is accepted in String or Bytes[] form.")
23
23
  }
24
24
  // if( validationOption){
25
25
  // if(validationOption === true) validationOption = {}; //validate with default options
26
-
26
+
27
27
  // const result = validator.validate(xmlData, validationOption);
28
28
  // if (result !== true) {
29
29
  // throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )
@@ -38,9 +38,9 @@ export default class XMLParser{
38
38
  * @param {string|Buffer} xmlData
39
39
  * @param {boolean|Object} validationOption
40
40
  */
41
- parseBytesArr(xmlData){
42
- if(Array.isArray(xmlData) && xmlData.byteLength !== undefined){
43
- }else{
41
+ parseBytesArr(xmlData) {
42
+ if (Array.isArray(xmlData) && xmlData.byteLength !== undefined) {
43
+ } else {
44
44
  throw new Error("XML data is accepted in Bytes[] form.")
45
45
  }
46
46
  const parser = new Xml2JsParser(this.options);
@@ -51,9 +51,9 @@ export default class XMLParser{
51
51
  * Parse XML data stream to JS object
52
52
  * @param {fs.ReadableStream} xmlDataStream
53
53
  */
54
- parseStream(xmlDataStream){
55
- if(!isStream(xmlDataStream)) throw new Error("FXP: Invalid stream input");
56
-
54
+ parseStream(xmlDataStream) {
55
+ if (!isStream(xmlDataStream)) throw new Error("FXP: Invalid stream input");
56
+
57
57
  const orderedObjParser = new Xml2JsParser(this.options);
58
58
  orderedObjParser.entityParser.addExternalEntities(this.externalEntities);
59
59
  return orderedObjParser.parseStream(xmlDataStream);
@@ -64,20 +64,20 @@ export default class XMLParser{
64
64
  * @param {string} key
65
65
  * @param {string} value
66
66
  */
67
- addEntity(key, value){
68
- if(value.indexOf("&") !== -1){
67
+ addEntity(key, value) {
68
+ if (value.indexOf("&") !== -1) {
69
69
  throw new Error("Entity value can't have '&'")
70
- }else if(key.indexOf("&") !== -1 || key.indexOf(";") !== -1){
70
+ } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
71
71
  throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'")
72
- }else if(value === "&"){
72
+ } else if (value === "&") {
73
73
  throw new Error("An entity with value '&' is not permitted");
74
- }else{
74
+ } else {
75
75
  this.externalEntities[key] = value;
76
76
  }
77
77
  }
78
78
  }
79
79
 
80
- function isStream(stream){
81
- if(stream && typeof stream.read === "function" && typeof stream.on === "function" && typeof stream.readableEnded === "boolean") return true;
80
+ function isStream(stream) {
81
+ if (stream && typeof stream.read === "function" && typeof stream.on === "function" && typeof stream.readableEnded === "boolean") return true;
82
82
  return false;
83
83
  }
@@ -1,105 +1,105 @@
1
- const ampEntity = { regex: /&(amp|#38|#x26);/g, val : "&"};
1
+ const ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
2
2
  const htmlEntities = {
3
- "space": { regex: /&(nbsp|#160);/g, val: " " },
4
- // "lt" : { regex: /&(lt|#60);/g, val: "<" },
5
- // "gt" : { regex: /&(gt|#62);/g, val: ">" },
6
- // "amp" : { regex: /&(amp|#38);/g, val: "&" },
7
- // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
8
- // "apos" : { regex: /&(apos|#39);/g, val: "'" },
9
- "cent" : { regex: /&(cent|#162);/g, val: "¢" },
10
- "pound" : { regex: /&(pound|#163);/g, val: "£" },
11
- "yen" : { regex: /&(yen|#165);/g, val: "¥" },
12
- "euro" : { regex: /&(euro|#8364);/g, val: "€" },
13
- "copyright" : { regex: /&(copy|#169);/g, val: "©" },
14
- "reg" : { regex: /&(reg|#174);/g, val: "®" },
15
- "inr" : { regex: /&(inr|#8377);/g, val: "₹" },
16
- "num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 10)) },
17
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
3
+ "space": { regex: /&(nbsp|#160);/g, val: " " },
4
+ // "lt" : { regex: /&(lt|#60);/g, val: "<" },
5
+ // "gt" : { regex: /&(gt|#62);/g, val: ">" },
6
+ // "amp" : { regex: /&(amp|#38);/g, val: "&" },
7
+ // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
8
+ // "apos" : { regex: /&(apos|#39);/g, val: "'" },
9
+ "cent": { regex: /&(cent|#162);/g, val: "¢" },
10
+ "pound": { regex: /&(pound|#163);/g, val: "£" },
11
+ "yen": { regex: /&(yen|#165);/g, val: "¥" },
12
+ "euro": { regex: /&(euro|#8364);/g, val: "€" },
13
+ "copyright": { regex: /&(copy|#169);/g, val: "©" },
14
+ "reg": { regex: /&(reg|#174);/g, val: "®" },
15
+ "inr": { regex: /&(inr|#8377);/g, val: "₹" },
16
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCodePoint(Number.parseInt(str, 10)) },
17
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
18
18
  };
19
19
 
20
- export default class EntitiesParser{
21
- constructor(replaceHtmlEntities) {
22
- this.replaceHtmlEntities = replaceHtmlEntities;
23
- this.docTypeEntities = {};
24
- this.lastEntities = {
25
- "apos" : { regex: /&(apos|#39|#x27);/g, val : "'"},
26
- "gt" : { regex: /&(gt|#62|#x3E);/g, val : ">"},
27
- "lt" : { regex: /&(lt|#60|#x3C);/g, val : "<"},
28
- "quot" : { regex: /&(quot|#34|#x22);/g, val : "\""},
29
- };
30
- }
20
+ export default class EntitiesParser {
21
+ constructor(replaceHtmlEntities) {
22
+ this.replaceHtmlEntities = replaceHtmlEntities;
23
+ this.docTypeEntities = {};
24
+ this.lastEntities = {
25
+ "apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
26
+ "gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
27
+ "lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
28
+ "quot": { regex: /&(quot|#34|#x22);/g, val: "\"" },
29
+ };
30
+ }
31
31
 
32
- addExternalEntities(externalEntities){
33
- const entKeys = Object.keys(externalEntities);
34
- for (let i = 0; i < entKeys.length; i++) {
35
- const ent = entKeys[i];
36
- this.addExternalEntity(ent,externalEntities[ent])
37
- }
32
+ addExternalEntities(externalEntities) {
33
+ const entKeys = Object.keys(externalEntities);
34
+ for (let i = 0; i < entKeys.length; i++) {
35
+ const ent = entKeys[i];
36
+ this.addExternalEntity(ent, externalEntities[ent])
38
37
  }
39
- addExternalEntity(key,val){
40
- validateEntityName(key);
41
- if(val.indexOf("&") !== -1) {
42
- reportWarning(`Entity ${key} is not added as '&' is found in value;`)
43
- return;
44
- }else{
45
- this.lastEntities[ent] = {
46
- regex: new RegExp("&"+key+";","g"),
47
- val : val
48
- }
38
+ }
39
+ addExternalEntity(key, val) {
40
+ validateEntityName(key);
41
+ if (val.indexOf("&") !== -1) {
42
+ reportWarning(`Entity ${key} is not added as '&' is found in value;`)
43
+ return;
44
+ } else {
45
+ this.lastEntities[ent] = {
46
+ regex: new RegExp("&" + key + ";", "g"),
47
+ val: val
49
48
  }
50
49
  }
50
+ }
51
51
 
52
- addDocTypeEntities(entities){
53
- const entKeys = Object.keys(entities);
54
- for (let i = 0; i < entKeys.length; i++) {
55
- const ent = entKeys[i];
56
- this.docTypeEntities[ent] = {
57
- regex: new RegExp("&"+ent+";","g"),
58
- val : entities[ent]
59
- }
60
- }
52
+ addDocTypeEntities(entities) {
53
+ const entKeys = Object.keys(entities);
54
+ for (let i = 0; i < entKeys.length; i++) {
55
+ const ent = entKeys[i];
56
+ this.docTypeEntities[ent] = {
57
+ regex: new RegExp("&" + ent + ";", "g"),
58
+ val: entities[ent]
59
+ }
61
60
  }
61
+ }
62
62
 
63
- parse(val){
64
- return this.replaceEntitiesValue(val)
65
- }
63
+ parse(val) {
64
+ return this.replaceEntitiesValue(val)
65
+ }
66
66
 
67
- /**
68
- * 1. Replace DOCTYPE entities
69
- * 2. Replace external entities
70
- * 3. Replace HTML entities if asked
71
- * @param {string} val
72
- */
73
- replaceEntitiesValue(val){
74
- if(typeof val === "string" && val.length > 0){
75
- for(let entityName in this.docTypeEntities){
76
- const entity = this.docTypeEntities[entityName];
77
- val = val.replace( entity.regx, entity.val);
78
- }
79
- for(let entityName in this.lastEntities){
80
- const entity = this.lastEntities[entityName];
81
- val = val.replace( entity.regex, entity.val);
82
- }
83
- if(this.replaceHtmlEntities){
84
- for(let entityName in htmlEntities){
85
- const entity = htmlEntities[entityName];
86
- val = val.replace( entity.regex, entity.val);
87
- }
88
- }
89
- val = val.replace( ampEntity.regex, ampEntity.val);
67
+ /**
68
+ * 1. Replace DOCTYPE entities
69
+ * 2. Replace external entities
70
+ * 3. Replace HTML entities if asked
71
+ * @param {string} val
72
+ */
73
+ replaceEntitiesValue(val) {
74
+ if (typeof val === "string" && val.length > 0) {
75
+ for (let entityName in this.docTypeEntities) {
76
+ const entity = this.docTypeEntities[entityName];
77
+ val = val.replace(entity.regx, entity.val);
78
+ }
79
+ for (let entityName in this.lastEntities) {
80
+ const entity = this.lastEntities[entityName];
81
+ val = val.replace(entity.regex, entity.val);
82
+ }
83
+ if (this.replaceHtmlEntities) {
84
+ for (let entityName in htmlEntities) {
85
+ const entity = htmlEntities[entityName];
86
+ val = val.replace(entity.regex, entity.val);
90
87
  }
91
- return val;
88
+ }
89
+ val = val.replace(ampEntity.regex, ampEntity.val);
92
90
  }
91
+ return val;
92
+ }
93
93
  };
94
94
 
95
95
  //an entity name should not contains special characters that may be used in regex
96
96
  //Eg !?\\\/[]$%{}^&*()<>
97
97
  const specialChar = "!?\\\/[]$%{}^&*()<>|+";
98
98
 
99
- function validateEntityName(name){
100
- for (let i = 0; i < specialChar.length; i++) {
101
- const ch = specialChar[i];
102
- if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
103
- }
104
- return name;
99
+ function validateEntityName(name) {
100
+ for (let i = 0; i < specialChar.length; i++) {
101
+ const ch = specialChar[i];
102
+ if (name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
103
+ }
104
+ return name;
105
105
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- import {getAllMatches, isName} from './util.js';
3
+ import { getAllMatches, isName } from './util.js';
4
4
 
5
5
  const defaultOptions = {
6
6
  allowBooleanAttributes: false, //A tag can have attributes without any value
@@ -24,19 +24,19 @@ export function validate(xmlData, options) {
24
24
  // check for byte order mark (BOM)
25
25
  xmlData = xmlData.substr(1);
26
26
  }
27
-
27
+
28
28
  for (let i = 0; i < xmlData.length; i++) {
29
29
 
30
- if (xmlData[i] === '<' && xmlData[i+1] === '?') {
31
- i+=2;
32
- i = readPI(xmlData,i);
30
+ if (xmlData[i] === '<' && xmlData[i + 1] === '?') {
31
+ i += 2;
32
+ i = readPI(xmlData, i);
33
33
  if (i.err) return i;
34
- }else if (xmlData[i] === '<') {
34
+ } else if (xmlData[i] === '<') {
35
35
  //starting of tag
36
36
  //read until you reach to '>' avoiding any '>' in attribute value
37
37
  let tagStartPos = i;
38
38
  i++;
39
-
39
+
40
40
  if (xmlData[i] === '!') {
41
41
  i = readCommentAndCDATA(xmlData, i);
42
42
  continue;
@@ -72,14 +72,14 @@ export function validate(xmlData, options) {
72
72
  if (tagName.trim().length === 0) {
73
73
  msg = "Invalid space after '<'.";
74
74
  } else {
75
- msg = "Tag '"+tagName+"' is an invalid name.";
75
+ msg = "Tag '" + tagName + "' is an invalid name.";
76
76
  }
77
77
  return getErrorObject('InvalidTag', msg, getLineNumberForPosition(xmlData, i));
78
78
  }
79
79
 
80
80
  const result = readAttributeStr(xmlData, i);
81
81
  if (result === false) {
82
- return getErrorObject('InvalidAttr', "Attributes for '"+tagName+"' have open quote.", getLineNumberForPosition(xmlData, i));
82
+ return getErrorObject('InvalidAttr', "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
83
83
  }
84
84
  let attrStr = result.value;
85
85
  i = result.index;
@@ -100,17 +100,17 @@ export function validate(xmlData, options) {
100
100
  }
101
101
  } else if (closingTag) {
102
102
  if (!result.tagClosed) {
103
- return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
103
+ return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
104
104
  } else if (attrStr.trim().length > 0) {
105
- return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
105
+ return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
106
106
  } else if (tags.length === 0) {
107
- return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
107
+ return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
108
108
  } else {
109
109
  const otg = tags.pop();
110
110
  if (tagName !== otg.tagName) {
111
111
  let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
112
112
  return getErrorObject('InvalidTag',
113
- "Expected closing tag '"+otg.tagName+"' (opened in line "+openPos.line+", col "+openPos.col+") instead of closing tag '"+tagName+"'.",
113
+ "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
114
114
  getLineNumberForPosition(xmlData, tagStartPos));
115
115
  }
116
116
 
@@ -131,10 +131,10 @@ export function validate(xmlData, options) {
131
131
  //if the root level has been reached before ...
132
132
  if (reachedRoot === true) {
133
133
  return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i));
134
- } else if(options.unpairedTags.indexOf(tagName) !== -1){
134
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) {
135
135
  //don't push into stack
136
136
  } else {
137
- tags.push({tagName, tagStartPos});
137
+ tags.push({ tagName, tagStartPos });
138
138
  }
139
139
  tagFound = true;
140
140
  }
@@ -148,10 +148,10 @@ export function validate(xmlData, options) {
148
148
  i++;
149
149
  i = readCommentAndCDATA(xmlData, i);
150
150
  continue;
151
- } else if (xmlData[i+1] === '?') {
151
+ } else if (xmlData[i + 1] === '?') {
152
152
  i = readPI(xmlData, ++i);
153
153
  if (i.err) return i;
154
- } else{
154
+ } else {
155
155
  break;
156
156
  }
157
157
  } else if (xmlData[i] === '&') {
@@ -159,7 +159,7 @@ export function validate(xmlData, options) {
159
159
  if (afterAmp == -1)
160
160
  return getErrorObject('InvalidChar', "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
161
161
  i = afterAmp;
162
- }else{
162
+ } else {
163
163
  if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
164
164
  return getErrorObject('InvalidXml', "Extra text at the end", getLineNumberForPosition(xmlData, i));
165
165
  }
@@ -170,28 +170,28 @@ export function validate(xmlData, options) {
170
170
  }
171
171
  }
172
172
  } else {
173
- if ( isWhiteSpace(xmlData[i])) {
173
+ if (isWhiteSpace(xmlData[i])) {
174
174
  continue;
175
175
  }
176
- return getErrorObject('InvalidChar', "char '"+xmlData[i]+"' is not expected.", getLineNumberForPosition(xmlData, i));
176
+ return getErrorObject('InvalidChar', "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
177
177
  }
178
178
  }
179
179
 
180
180
  if (!tagFound) {
181
181
  return getErrorObject('InvalidXml', 'Start tag expected.', 1);
182
- }else if (tags.length == 1) {
183
- return getErrorObject('InvalidTag', "Unclosed tag '"+tags[0].tagName+"'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
184
- }else if (tags.length > 0) {
185
- return getErrorObject('InvalidXml', "Invalid '"+
186
- JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\r?\n/g, '')+
187
- "' found.", {line: 1, col: 1});
182
+ } else if (tags.length == 1) {
183
+ return getErrorObject('InvalidTag', "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
184
+ } else if (tags.length > 0) {
185
+ return getErrorObject('InvalidXml', "Invalid '" +
186
+ JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\r?\n/g, '') +
187
+ "' found.", { line: 1, col: 1 });
188
188
  }
189
189
 
190
190
  return true;
191
191
  };
192
192
 
193
- function isWhiteSpace(char){
194
- return char === ' ' || char === '\t' || char === '\n' || char === '\r';
193
+ function isWhiteSpace(char) {
194
+ return char === ' ' || char === '\t' || char === '\n' || char === '\r';
195
195
  }
196
196
  /**
197
197
  * Read Processing insstructions and skip
@@ -327,25 +327,25 @@ function validateAttributeString(attrStr, options) {
327
327
  for (let i = 0; i < matches.length; i++) {
328
328
  if (matches[i][1].length === 0) {
329
329
  //nospace before attribute name: a="sd"b="saf"
330
- return getErrorObject('InvalidAttr', "Attribute '"+matches[i][2]+"' has no space in starting.", getPositionFromMatch(matches[i]))
330
+ return getErrorObject('InvalidAttr', "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]))
331
331
  } else if (matches[i][3] !== undefined && matches[i][4] === undefined) {
332
- return getErrorObject('InvalidAttr', "Attribute '"+matches[i][2]+"' is without value.", getPositionFromMatch(matches[i]));
332
+ return getErrorObject('InvalidAttr', "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
333
333
  } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {
334
334
  //independent attribute: ab
335
- return getErrorObject('InvalidAttr', "boolean attribute '"+matches[i][2]+"' is not allowed.", getPositionFromMatch(matches[i]));
335
+ return getErrorObject('InvalidAttr', "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
336
336
  }
337
337
  /* else if(matches[i][6] === undefined){//attribute without value: ab=
338
338
  return { err: { code:"InvalidAttr",msg:"attribute " + matches[i][2] + " has no value assigned."}};
339
339
  } */
340
340
  const attrName = matches[i][2];
341
341
  if (!validateAttrName(attrName)) {
342
- return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is an invalid name.", getPositionFromMatch(matches[i]));
342
+ return getErrorObject('InvalidAttr', "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
343
343
  }
344
- if (!attrNames.hasOwnProperty(attrName)) {
344
+ if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
345
345
  //check for duplicate attribute.
346
346
  attrNames[attrName] = 1;
347
347
  } else {
348
- return getErrorObject('InvalidAttr', "Attribute '"+attrName+"' is repeated.", getPositionFromMatch(matches[i]));
348
+ return getErrorObject('InvalidAttr', "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
349
349
  }
350
350
  }
351
351