@d4l/collect-lib 1.10.1 → 1.11.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/dist/index.mjs CHANGED
@@ -797,9 +797,100 @@ var RECORDING_SIGNAL_MODEL_CURRENT_VERSION = "1.0.0";
797
797
  import * as secpUtils from "@noble/curves/abstract/utils";
798
798
  import { secp256k1 } from "@noble/curves/secp256k1";
799
799
  import * as bip39 from "@scure/bip39";
800
- import { Buffer as Buffer2 } from "buffer/";
800
+ import { Buffer as Buffer3 } from "buffer/";
801
801
  import * as forge from "node-forge";
802
802
 
803
+ // src/helper/converter.ts
804
+ import { Buffer as Buffer2 } from "buffer/";
805
+ var binaryStringToUint8Array = (binaryString) => {
806
+ return new Uint8Array(binaryString.split("").map((c) => c.charCodeAt(0)));
807
+ };
808
+ var uint8ArrayToBinaryString = (array) => {
809
+ return String.fromCharCode.apply(null, array);
810
+ };
811
+ var utf8ToUint8Array = (string) => {
812
+ const result = [];
813
+ const size = string.length;
814
+ for (let index = 0; index < size; index++) {
815
+ let point = string.charCodeAt(index);
816
+ if (point >= 55296 && point <= 56319 && size > index + 1) {
817
+ const second = string.charCodeAt(index + 1);
818
+ if (second >= 56320 && second <= 57343) {
819
+ point = (point - 55296) * 1024 + second - 56320 + 65536;
820
+ index += 1;
821
+ }
822
+ }
823
+ if (point < 128) {
824
+ result.push(point);
825
+ continue;
826
+ }
827
+ if (point < 2048) {
828
+ result.push(point >> 6 | 192);
829
+ result.push(point & 63 | 128);
830
+ continue;
831
+ }
832
+ if (point < 55296 || point >= 57344 && point < 65536) {
833
+ result.push(point >> 12 | 224);
834
+ result.push(point >> 6 & 63 | 128);
835
+ result.push(point & 63 | 128);
836
+ continue;
837
+ }
838
+ if (point >= 65536 && point <= 1114111) {
839
+ result.push(point >> 18 | 240);
840
+ result.push(point >> 12 & 63 | 128);
841
+ result.push(point >> 6 & 63 | 128);
842
+ result.push(point & 63 | 128);
843
+ continue;
844
+ }
845
+ result.push(239, 191, 189);
846
+ }
847
+ return new Uint8Array(result);
848
+ };
849
+ var WebConverter = class {
850
+ constructor() {
851
+ this.arrayBufferToBase64 = (buffer) => {
852
+ let binary = "";
853
+ const bytes = new Uint8Array(buffer);
854
+ const len = bytes.byteLength;
855
+ for (let i = 0; i < len; i++) {
856
+ binary += String.fromCharCode(bytes[i]);
857
+ }
858
+ return btoa(binary);
859
+ };
860
+ this.base64ToArrayBuffer = (string) => {
861
+ const base64 = atob(string);
862
+ const buffer = new ArrayBuffer(base64.length);
863
+ const bufferView = new Uint8Array(buffer);
864
+ for (let i = 0, base64Len = base64.length; i < base64Len; i++) {
865
+ bufferView[i] = base64.charCodeAt(i);
866
+ }
867
+ return buffer;
868
+ };
869
+ // convert Uint8Array to base64 string
870
+ this.uint8ArrayToBase64 = (array) => {
871
+ return btoa(String.fromCharCode(...array));
872
+ };
873
+ /**
874
+ * Convert a base64 encoded string into Uint8Array
875
+ * @param string The string that needs to be converted into an Uint8Array
876
+ * @returns A Uint8Array
877
+ */
878
+ this.base64ToUint8Array = (string) => new Uint8Array(this.base64ToArrayBuffer(string));
879
+ /**
880
+ * Convert a base64 encoded Uint8Array into a UTF-8 encoded string
881
+ * @param uint The base64 encoded Uint8Array
882
+ * @returns The UTF-8 encoded string
883
+ */
884
+ this.uint8ArrayToUTF8 = (uint) => {
885
+ const decoder = new TextDecoder();
886
+ const str = decoder.decode(uint);
887
+ return Buffer2.from(str, "base64").toString("utf8");
888
+ };
889
+ this.base64ToHex = (base64String) => Buffer2.from(base64String, "base64").toString("hex");
890
+ this.hexToBase64 = (hexString) => Buffer2.from(hexString, "hex").toString("base64");
891
+ }
892
+ };
893
+
803
894
  // src/helper/wordlists.ts
804
895
  import { wordlist } from "@scure/bip39/wordlists/english";
805
896
  var german = [
@@ -2914,12 +3005,12 @@ var KeyHandler = class {
2914
3005
  return "";
2915
3006
  };
2916
3007
  this.extendPublicKey = (publicKey) => {
2917
- let key = Buffer2.from(publicKey);
3008
+ let key = Buffer3.from(publicKey);
2918
3009
  if (key.length !== 65) {
2919
3010
  throw new Error("Invalid public key length");
2920
3011
  }
2921
3012
  key = key.slice(1);
2922
- const header = Buffer2.from([
3013
+ const header = Buffer3.from([
2923
3014
  48,
2924
3015
  86,
2925
3016
  48,
@@ -2945,7 +3036,7 @@ var KeyHandler = class {
2945
3036
  0,
2946
3037
  4
2947
3038
  ]);
2948
- return Buffer2.concat([header, key]).toString("base64");
3039
+ return Buffer3.concat([header, key]).toString("base64");
2949
3040
  };
2950
3041
  /**
2951
3042
  * Hash a message with SHA-256
@@ -2980,7 +3071,11 @@ var KeyHandler = class {
2980
3071
  */
2981
3072
  this.verify = async (message, signature, pub) => {
2982
3073
  const sha256 = this.hash(message);
2983
- return secp256k1.verify(signature, sha256, this.converter.base64ToHex(pub));
3074
+ return secp256k1.verify(
3075
+ signature,
3076
+ binaryStringToUint8Array(sha256),
3077
+ this.converter.base64ToUint8Array(pub)
3078
+ );
2984
3079
  };
2985
3080
  this.converter = converter;
2986
3081
  this.crypto = crypto;
@@ -3256,99 +3351,6 @@ var hasValidItems = (document) => Array.isArray(document.item) && document.item.
3256
3351
  // src/donation/hybridEncryption.ts
3257
3352
  import { Buffer as Buffer4 } from "buffer/";
3258
3353
  import * as forge2 from "node-forge";
3259
-
3260
- // src/helper/converter.ts
3261
- import { Buffer as Buffer3 } from "buffer/";
3262
- var binaryStringToUint8Array = (binaryString) => {
3263
- return new Uint8Array(binaryString.split("").map((c) => c.charCodeAt(0)));
3264
- };
3265
- var uint8ArrayToBinaryString = (array) => {
3266
- return String.fromCharCode.apply(null, array);
3267
- };
3268
- var utf8ToUint8Array = (string) => {
3269
- const result = [];
3270
- const size = string.length;
3271
- for (let index = 0; index < size; index++) {
3272
- let point = string.charCodeAt(index);
3273
- if (point >= 55296 && point <= 56319 && size > index + 1) {
3274
- const second = string.charCodeAt(index + 1);
3275
- if (second >= 56320 && second <= 57343) {
3276
- point = (point - 55296) * 1024 + second - 56320 + 65536;
3277
- index += 1;
3278
- }
3279
- }
3280
- if (point < 128) {
3281
- result.push(point);
3282
- continue;
3283
- }
3284
- if (point < 2048) {
3285
- result.push(point >> 6 | 192);
3286
- result.push(point & 63 | 128);
3287
- continue;
3288
- }
3289
- if (point < 55296 || point >= 57344 && point < 65536) {
3290
- result.push(point >> 12 | 224);
3291
- result.push(point >> 6 & 63 | 128);
3292
- result.push(point & 63 | 128);
3293
- continue;
3294
- }
3295
- if (point >= 65536 && point <= 1114111) {
3296
- result.push(point >> 18 | 240);
3297
- result.push(point >> 12 & 63 | 128);
3298
- result.push(point >> 6 & 63 | 128);
3299
- result.push(point & 63 | 128);
3300
- continue;
3301
- }
3302
- result.push(239, 191, 189);
3303
- }
3304
- return new Uint8Array(result);
3305
- };
3306
- var WebConverter = class {
3307
- constructor() {
3308
- this.arrayBufferToBase64 = (buffer) => {
3309
- let binary = "";
3310
- const bytes = new Uint8Array(buffer);
3311
- const len = bytes.byteLength;
3312
- for (let i = 0; i < len; i++) {
3313
- binary += String.fromCharCode(bytes[i]);
3314
- }
3315
- return btoa(binary);
3316
- };
3317
- this.base64ToArrayBuffer = (string) => {
3318
- const base64 = atob(string);
3319
- const buffer = new ArrayBuffer(base64.length);
3320
- const bufferView = new Uint8Array(buffer);
3321
- for (let i = 0, base64Len = base64.length; i < base64Len; i++) {
3322
- bufferView[i] = base64.charCodeAt(i);
3323
- }
3324
- return buffer;
3325
- };
3326
- // convert Uint8Array to base64 string
3327
- this.uint8ArrayToBase64 = (array) => {
3328
- return btoa(String.fromCharCode(...array));
3329
- };
3330
- /**
3331
- * Convert a base64 encoded string into Uint8Array
3332
- * @param string The string that needs to be converted into an Uint8Array
3333
- * @returns A Uint8Array
3334
- */
3335
- this.base64ToUint8Array = (string) => new Uint8Array(this.base64ToArrayBuffer(string));
3336
- /**
3337
- * Convert a base64 encoded Uint8Array into a UTF-8 encoded string
3338
- * @param uint The base64 encoded Uint8Array
3339
- * @returns The UTF-8 encoded string
3340
- */
3341
- this.uint8ArrayToUTF8 = (uint) => {
3342
- const decoder = new TextDecoder();
3343
- const str = decoder.decode(uint);
3344
- return Buffer3.from(str, "base64").toString("utf8");
3345
- };
3346
- this.base64ToHex = (base64String) => Buffer3.from(base64String, "base64").toString("hex");
3347
- this.hexToBase64 = (hexString) => Buffer3.from(hexString, "hex").toString("base64");
3348
- }
3349
- };
3350
-
3351
- // src/donation/hybridEncryption.ts
3352
3354
  var AES_BLOCKSIZE = 16;
3353
3355
  var TAG_LENGTH = 16;
3354
3356
  var KEY_LENGTH = 32;