@reclaimprotocol/attestor-core 5.0.1-beta.7 → 5.0.1-beta.9

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.
@@ -1 +1,21 @@
1
- export { areUint8ArraysEqual, asciiToUint8Array, concatenateUint8Arrays, crypto, decryptWrappedRecord, encryptWrappedRecord, generateIV, makeTLSClient, setCryptoImplementation, uint8ArrayToBinaryStr, uint8ArrayToDataView, CONTENT_TYPE_MAP, PACKET_TYPE, SUPPORTED_CIPHER_SUITE_MAP, SUPPORTED_NAMED_CURVES, } from '@reclaimprotocol/tls';
1
+ /**
2
+ * Convert ASCII string to Uint8Array
3
+ */
4
+ export declare function asciiToUint8Array(str: string): Uint8Array;
5
+ /**
6
+ * Concatenate multiple Uint8Arrays into one
7
+ */
8
+ export declare function concatenateUint8Arrays(arrays: Uint8Array[]): Uint8Array;
9
+ /**
10
+ * Check if two Uint8Arrays are equal
11
+ */
12
+ export declare function areUint8ArraysEqual(a: Uint8Array, b: Uint8Array): boolean;
13
+ /**
14
+ * Convert Uint8Array to binary string
15
+ */
16
+ export declare function uint8ArrayToBinaryStr(arr: Uint8Array): string;
17
+ /**
18
+ * Convert Uint8Array to DataView
19
+ */
20
+ export declare function uint8ArrayToDataView(arr: Uint8Array): DataView;
21
+ export { crypto, decryptWrappedRecord, encryptWrappedRecord, generateIV, makeTLSClient, setCryptoImplementation, CONTENT_TYPE_MAP, PACKET_TYPE, SUPPORTED_CIPHER_SUITE_MAP, SUPPORTED_NAMED_CURVES, } from '@reclaimprotocol/tls';
@@ -1,15 +1,52 @@
1
+ function asciiToUint8Array(str) {
2
+ const bytes = new Uint8Array(str.length);
3
+ for (let i = 0; i < str.length; i++) {
4
+ const charCode = str.charCodeAt(i);
5
+ if (charCode < 0 || charCode > 255) {
6
+ throw new Error(`Invalid ASCII character at index ${i}: ${str[i]}`);
7
+ }
8
+ bytes[i] = charCode;
9
+ }
10
+ return bytes;
11
+ }
12
+ function concatenateUint8Arrays(arrays) {
13
+ const totalLength = arrays.reduce((acc, curr) => acc + curr.length, 0);
14
+ const result = new Uint8Array(totalLength);
15
+ let offset = 0;
16
+ for (const arr of arrays) {
17
+ result.set(arr, offset);
18
+ offset += arr.length;
19
+ }
20
+ return result;
21
+ }
22
+ function areUint8ArraysEqual(a, b) {
23
+ if (a.length !== b.length) {
24
+ return false;
25
+ }
26
+ for (let i = 0; i < a.length; i++) {
27
+ if (a[i] !== b[i]) {
28
+ return false;
29
+ }
30
+ }
31
+ return true;
32
+ }
33
+ function uint8ArrayToBinaryStr(arr) {
34
+ let str = "";
35
+ for (const byte of arr) {
36
+ str += String.fromCharCode(byte);
37
+ }
38
+ return str;
39
+ }
40
+ function uint8ArrayToDataView(arr) {
41
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
42
+ }
1
43
  import {
2
- areUint8ArraysEqual,
3
- asciiToUint8Array,
4
- concatenateUint8Arrays,
5
44
  crypto,
6
45
  decryptWrappedRecord,
7
46
  encryptWrappedRecord,
8
47
  generateIV,
9
48
  makeTLSClient,
10
49
  setCryptoImplementation,
11
- uint8ArrayToBinaryStr,
12
- uint8ArrayToDataView,
13
50
  CONTENT_TYPE_MAP,
14
51
  PACKET_TYPE,
15
52
  SUPPORTED_CIPHER_SUITE_MAP,
@@ -1 +1,21 @@
1
- export { areUint8ArraysEqual, asciiToUint8Array, concatenateUint8Arrays, crypto, decryptWrappedRecord, encryptWrappedRecord, generateIV, makeTLSClient, setCryptoImplementation, uint8ArrayToBinaryStr, uint8ArrayToDataView, CONTENT_TYPE_MAP, PACKET_TYPE, SUPPORTED_CIPHER_SUITE_MAP, SUPPORTED_NAMED_CURVES, } from '@reclaimprotocol/tls';
1
+ /**
2
+ * Convert ASCII string to Uint8Array
3
+ */
4
+ export declare function asciiToUint8Array(str: string): Uint8Array;
5
+ /**
6
+ * Concatenate multiple Uint8Arrays into one
7
+ */
8
+ export declare function concatenateUint8Arrays(arrays: Uint8Array[]): Uint8Array;
9
+ /**
10
+ * Check if two Uint8Arrays are equal
11
+ */
12
+ export declare function areUint8ArraysEqual(a: Uint8Array, b: Uint8Array): boolean;
13
+ /**
14
+ * Convert Uint8Array to binary string
15
+ */
16
+ export declare function uint8ArrayToBinaryStr(arr: Uint8Array): string;
17
+ /**
18
+ * Convert Uint8Array to DataView
19
+ */
20
+ export declare function uint8ArrayToDataView(arr: Uint8Array): DataView;
21
+ export { crypto, decryptWrappedRecord, encryptWrappedRecord, generateIV, makeTLSClient, setCryptoImplementation, CONTENT_TYPE_MAP, PACKET_TYPE, SUPPORTED_CIPHER_SUITE_MAP, SUPPORTED_NAMED_CURVES, } from '@reclaimprotocol/tls';
@@ -1,15 +1,52 @@
1
+ function asciiToUint8Array(str) {
2
+ const bytes = new Uint8Array(str.length);
3
+ for (let i = 0; i < str.length; i++) {
4
+ const charCode = str.charCodeAt(i);
5
+ if (charCode < 0 || charCode > 255) {
6
+ throw new Error(`Invalid ASCII character at index ${i}: ${str[i]}`);
7
+ }
8
+ bytes[i] = charCode;
9
+ }
10
+ return bytes;
11
+ }
12
+ function concatenateUint8Arrays(arrays) {
13
+ const totalLength = arrays.reduce((acc, curr) => acc + curr.length, 0);
14
+ const result = new Uint8Array(totalLength);
15
+ let offset = 0;
16
+ for (const arr of arrays) {
17
+ result.set(arr, offset);
18
+ offset += arr.length;
19
+ }
20
+ return result;
21
+ }
22
+ function areUint8ArraysEqual(a, b) {
23
+ if (a.length !== b.length) {
24
+ return false;
25
+ }
26
+ for (let i = 0; i < a.length; i++) {
27
+ if (a[i] !== b[i]) {
28
+ return false;
29
+ }
30
+ }
31
+ return true;
32
+ }
33
+ function uint8ArrayToBinaryStr(arr) {
34
+ let str = "";
35
+ for (const byte of arr) {
36
+ str += String.fromCharCode(byte);
37
+ }
38
+ return str;
39
+ }
40
+ function uint8ArrayToDataView(arr) {
41
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
42
+ }
1
43
  import {
2
- areUint8ArraysEqual,
3
- asciiToUint8Array,
4
- concatenateUint8Arrays,
5
44
  crypto,
6
45
  decryptWrappedRecord,
7
46
  encryptWrappedRecord,
8
47
  generateIV,
9
48
  makeTLSClient,
10
49
  setCryptoImplementation,
11
- uint8ArrayToBinaryStr,
12
- uint8ArrayToDataView,
13
50
  CONTENT_TYPE_MAP,
14
51
  PACKET_TYPE,
15
52
  SUPPORTED_CIPHER_SUITE_MAP,
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@reclaimprotocol/attestor-core",
3
- "version": "5.0.1-beta.7",
3
+ "version": "5.0.1-beta.9",
4
4
  "description": "",
5
5
  "type": "module",
6
+ "main": "./lib/index.js",
7
+ "browser": "./lib/browser/index.js",
8
+ "types": "./lib/index.d.ts",
6
9
  "imports": {
7
10
  "#src/*.ts": "./src/*.ts"
8
11
  },