@zlink-systems/stream-connector 0.30.1 → 0.30.2

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.
@@ -871,9 +871,9 @@ var ZlinkStreamConnectorBundle = (() => {
871
871
  if (typeof value !== "string" || !BASE64_PATTERN.test(value)) {
872
872
  schemaFailure(path, "padded RFC 4648 base64");
873
873
  }
874
- const bytes = decodeBase64(value);
875
- if (encodeBase64(bytes) !== value) schemaFailure(path, "canonical padded RFC 4648 base64");
876
- return decode ? Uint8Array.from(bytes) : value;
874
+ if (!hasCanonicalBase64Padding(value))
875
+ schemaFailure(path, "canonical padded RFC 4648 base64");
876
+ return decode ? decodeBase64(value) : value;
877
877
  }
878
878
  case "enum":
879
879
  if (typeof value !== "string" || !schema.names.includes(value)) {
@@ -1059,6 +1059,14 @@ var ZlinkStreamConnectorBundle = (() => {
1059
1059
  }
1060
1060
  };
1061
1061
  var BASE64_STRING_CHUNK_BYTES = 8192;
1062
+ var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1063
+ function hasCanonicalBase64Padding(value) {
1064
+ if (value.endsWith("=="))
1065
+ return (BASE64_ALPHABET.indexOf(value.charAt(value.length - 3)) & 15) === 0;
1066
+ if (value.endsWith("="))
1067
+ return (BASE64_ALPHABET.indexOf(value.charAt(value.length - 2)) & 3) === 0;
1068
+ return true;
1069
+ }
1062
1070
  function encodeBase64(bytes) {
1063
1071
  let binary = "";
1064
1072
  for (let offset = 0; offset < bytes.length; offset += BASE64_STRING_CHUNK_BYTES) {
@@ -826,9 +826,9 @@ function validateFrameworkJsonV1Value(value, schema, path, decode) {
826
826
  if (typeof value !== "string" || !BASE64_PATTERN.test(value)) {
827
827
  schemaFailure(path, "padded RFC 4648 base64");
828
828
  }
829
- const bytes = decodeBase64(value);
830
- if (encodeBase64(bytes) !== value) schemaFailure(path, "canonical padded RFC 4648 base64");
831
- return decode ? Uint8Array.from(bytes) : value;
829
+ if (!hasCanonicalBase64Padding(value))
830
+ schemaFailure(path, "canonical padded RFC 4648 base64");
831
+ return decode ? decodeBase64(value) : value;
832
832
  }
833
833
  case "enum":
834
834
  if (typeof value !== "string" || !schema.names.includes(value)) {
@@ -1013,6 +1013,14 @@ var JsonPropertyScanner = class {
1013
1013
  }
1014
1014
  };
1015
1015
  var BASE64_STRING_CHUNK_BYTES = 8192;
1016
+ var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1017
+ function hasCanonicalBase64Padding(value) {
1018
+ if (value.endsWith("=="))
1019
+ return (BASE64_ALPHABET.indexOf(value.charAt(value.length - 3)) & 15) === 0;
1020
+ if (value.endsWith("="))
1021
+ return (BASE64_ALPHABET.indexOf(value.charAt(value.length - 2)) & 3) === 0;
1022
+ return true;
1023
+ }
1016
1024
  function encodeBase64(bytes) {
1017
1025
  let binary = "";
1018
1026
  for (let offset = 0; offset < bytes.length; offset += BASE64_STRING_CHUNK_BYTES) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlink-systems/stream-connector",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,6 +22,6 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@zlink-systems/stream-wire": "0.30.1"
25
+ "@zlink-systems/stream-wire": "0.30.2"
26
26
  }
27
27
  }