@reclaimprotocol/attestor-core 5.0.1-beta.6 → 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.
- package/lib/browser/client/create-claim.js +1 -1
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.d.ts +1 -1
- package/lib/browser/client/tunnels/make-rpc-tls-tunnel.js +1 -1
- package/lib/browser/external-rpc/benchmark.js +1 -1
- package/lib/browser/external-rpc/jsc-polyfills/1.js +1 -1
- package/lib/browser/external-rpc/setup-browser.js +1 -1
- package/lib/browser/external-rpc/setup-jsc.js +1 -1
- package/lib/browser/providers/http/index.js +1 -1
- package/lib/browser/providers/http/utils.js +1 -1
- package/lib/browser/utils/generics.d.ts +1 -1
- package/lib/browser/utils/generics.js +1 -1
- package/lib/browser/utils/http-parser.js +1 -1
- package/lib/browser/utils/index.browser.js +1 -0
- package/lib/browser/utils/index.d.ts +1 -0
- package/lib/browser/utils/index.js +1 -0
- package/lib/browser/utils/prepare-packets.js +1 -1
- package/lib/browser/utils/redactions.js +1 -1
- package/lib/browser/utils/tls-imports.d.ts +21 -0
- package/lib/browser/utils/tls-imports.js +71 -0
- package/lib/browser/utils/tls.js +1 -1
- package/lib/browser/utils/zk.js +1 -1
- package/lib/client/create-claim.js +1 -1
- package/lib/client/tunnels/make-rpc-tls-tunnel.d.ts +1 -1
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +1 -1
- package/lib/external-rpc/benchmark.js +1 -1
- package/lib/external-rpc/jsc-polyfills/1.js +1 -1
- package/lib/external-rpc/setup-browser.js +1 -1
- package/lib/external-rpc/setup-jsc.js +1 -1
- package/lib/providers/http/index.js +1 -1
- package/lib/providers/http/utils.js +1 -1
- package/lib/utils/generics.d.ts +1 -1
- package/lib/utils/generics.js +1 -1
- package/lib/utils/http-parser.js +1 -1
- package/lib/utils/index.browser.d.ts +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/prepare-packets.js +1 -1
- package/lib/utils/redactions.js +1 -1
- package/lib/utils/tls-imports.d.ts +21 -0
- package/lib/utils/tls-imports.js +71 -0
- package/lib/utils/tls.js +1 -1
- package/lib/utils/zk.js +1 -1
- package/package.json +4 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { asciiToUint8Array } from "@reclaimprotocol/tls";
|
|
2
1
|
import { makeRpcTlsTunnel } from "../client/tunnels/make-rpc-tls-tunnel.js";
|
|
3
2
|
import { getAttestorClientFromPool } from "../client/utils/attestor-pool.js";
|
|
4
3
|
import { DEFAULT_HTTPS_PORT, PROVIDER_CTX, TOPRF_DOMAIN_SEPARATOR } from "../config/index.js";
|
|
5
4
|
import { ClaimTunnelRequest } from "../proto/api.js";
|
|
6
5
|
import { providers } from "../providers/index.js";
|
|
7
6
|
import {
|
|
7
|
+
asciiToUint8Array,
|
|
8
8
|
AttestorError,
|
|
9
9
|
binaryHashToStr,
|
|
10
10
|
canonicalStringify,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
|
|
2
|
-
import { makeTLSClient } from '
|
|
2
|
+
import { makeTLSClient } from '#src/utils/tls-imports.ts';
|
|
3
3
|
import type { CreateTunnelRequest, RPCMessage } from '#src/proto/api.ts';
|
|
4
4
|
import type { CompleteTLSPacket, IAttestorClient, Logger, MakeTunnelFn, Transcript } from '#src/types/index.ts';
|
|
5
5
|
type ExtraTLSOptions = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concatenateUint8Arrays, makeTLSClient } from "
|
|
1
|
+
import { concatenateUint8Arrays, makeTLSClient } from "../../utils/tls-imports.js";
|
|
2
2
|
import { makeRpcTcpTunnel } from "../../client/tunnels/make-rpc-tcp-tunnel.js";
|
|
3
3
|
import { DEFAULT_HTTPS_PORT } from "../../config/index.js";
|
|
4
4
|
import { generateRpcMessageId, generateTunnelId } from "../../utils/index.js";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
crypto,
|
|
3
3
|
encryptWrappedRecord,
|
|
4
4
|
SUPPORTED_CIPHER_SUITE_MAP
|
|
5
|
-
} from "
|
|
5
|
+
} from "../utils/tls-imports.js";
|
|
6
6
|
import { strToUint8Array } from "../utils/generics.js";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import { makeZkProofGenerator } from "../utils/zk.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextDecoder, TextEncoder } from "@kayahr/text-encoding";
|
|
2
|
-
import { crypto, uint8ArrayToBinaryStr } from "
|
|
2
|
+
import { crypto, uint8ArrayToBinaryStr } from "../../utils/tls-imports.js";
|
|
3
3
|
import { fromByteArray, toByteArray } from "base64-js";
|
|
4
4
|
import { EventTarget } from "event-target-shim";
|
|
5
5
|
if (typeof global === "undefined") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setCryptoImplementation } from "@reclaimprotocol/tls";
|
|
2
1
|
import { webcryptoCrypto } from "@reclaimprotocol/tls/webcrypto";
|
|
2
|
+
import { setCryptoImplementation } from "../utils/tls-imports.js";
|
|
3
3
|
import { handleIncomingMessage } from "../external-rpc/handle-incoming-msg.js";
|
|
4
4
|
import { getWsApiUrlFromBaseUrl } from "../external-rpc/utils.js";
|
|
5
5
|
import { logger, makeLogger } from "../utils/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../external-rpc/jsc-polyfills/index.js";
|
|
2
2
|
1;
|
|
3
|
-
import { setCryptoImplementation } from "@reclaimprotocol/tls";
|
|
4
3
|
import { pureJsCrypto } from "@reclaimprotocol/tls/purejs-crypto";
|
|
4
|
+
import { setCryptoImplementation } from "../utils/tls-imports.js";
|
|
5
5
|
import * as AttestorRPCImport from "../external-rpc/index.js";
|
|
6
6
|
import { makeLogger } from "../utils/logger.js";
|
|
7
7
|
setCryptoImplementation(pureJsCrypto);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { areUint8ArraysEqual, concatenateUint8Arrays, uint8ArrayToBinaryStr } from "
|
|
1
|
+
import { areUint8ArraysEqual, concatenateUint8Arrays, uint8ArrayToBinaryStr } from "../../utils/tls-imports.js";
|
|
2
2
|
import { encodeBase64 } from "ethers";
|
|
3
3
|
import { DEFAULT_HTTPS_PORT, RECLAIM_USER_AGENT } from "../../config/index.js";
|
|
4
4
|
import { AttestorVersion } from "../../proto/api.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CipherSuite, TLSProtocolVersion } from '@reclaimprotocol/tls';
|
|
2
|
-
import { uint8ArrayToBinaryStr } from '
|
|
2
|
+
import { uint8ArrayToBinaryStr } from '#src/utils/tls-imports.ts';
|
|
3
3
|
import { RPCMessage, RPCMessages } from '#src/proto/api.ts';
|
|
4
4
|
import type { CompleteTLSPacket, IDecryptedTranscript, IDecryptedTranscriptMessage, ProviderField, RPCEvent, RPCEventMap, RPCEventType, RPCType, Transcript } from '#src/types/index.ts';
|
|
5
5
|
export { uint8ArrayToBinaryStr };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SUPPORTED_CIPHER_SUITE_MAP,
|
|
8
8
|
uint8ArrayToBinaryStr,
|
|
9
9
|
uint8ArrayToDataView
|
|
10
|
-
} from "
|
|
10
|
+
} from "../utils/tls-imports.js";
|
|
11
11
|
import { REDACTION_CHAR_CODE } from "@reclaimprotocol/zk-symmetric-crypto";
|
|
12
12
|
import { RPCMessage, RPCMessages } from "../proto/api.js";
|
|
13
13
|
const DEFAULT_REDACTION_DATA = new Uint8Array(4).fill(REDACTION_CHAR_CODE);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asciiToUint8Array, concatenateUint8Arrays } from "
|
|
1
|
+
import { asciiToUint8Array, concatenateUint8Arrays } from "../utils/tls-imports.js";
|
|
2
2
|
import { findIndexInUint8Array, uint8ArrayToStr } from "../utils/generics.js";
|
|
3
3
|
import { REDACTION_CHAR_CODE } from "../utils/redactions.js";
|
|
4
4
|
const HTTP_HEADER_LINE_END = asciiToUint8Array("\r\n");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { base64Encode } from "@bufbuild/protobuf/wire";
|
|
2
|
-
import { concatenateUint8Arrays } from "
|
|
2
|
+
import { concatenateUint8Arrays } from "../utils/tls-imports.js";
|
|
3
3
|
const REDACTION_CHAR = "*";
|
|
4
4
|
const REDACTION_CHAR_CODE = REDACTION_CHAR.charCodeAt(0);
|
|
5
5
|
function isRedactionCongruent(redacted, original) {
|
|
@@ -0,0 +1,21 @@
|
|
|
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';
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
}
|
|
43
|
+
import {
|
|
44
|
+
crypto,
|
|
45
|
+
decryptWrappedRecord,
|
|
46
|
+
encryptWrappedRecord,
|
|
47
|
+
generateIV,
|
|
48
|
+
makeTLSClient,
|
|
49
|
+
setCryptoImplementation,
|
|
50
|
+
CONTENT_TYPE_MAP,
|
|
51
|
+
PACKET_TYPE,
|
|
52
|
+
SUPPORTED_CIPHER_SUITE_MAP,
|
|
53
|
+
SUPPORTED_NAMED_CURVES
|
|
54
|
+
} from "@reclaimprotocol/tls";
|
|
55
|
+
export {
|
|
56
|
+
CONTENT_TYPE_MAP,
|
|
57
|
+
PACKET_TYPE,
|
|
58
|
+
SUPPORTED_CIPHER_SUITE_MAP,
|
|
59
|
+
SUPPORTED_NAMED_CURVES,
|
|
60
|
+
areUint8ArraysEqual,
|
|
61
|
+
asciiToUint8Array,
|
|
62
|
+
concatenateUint8Arrays,
|
|
63
|
+
crypto,
|
|
64
|
+
decryptWrappedRecord,
|
|
65
|
+
encryptWrappedRecord,
|
|
66
|
+
generateIV,
|
|
67
|
+
makeTLSClient,
|
|
68
|
+
setCryptoImplementation,
|
|
69
|
+
uint8ArrayToBinaryStr,
|
|
70
|
+
uint8ArrayToDataView
|
|
71
|
+
};
|
package/lib/browser/utils/tls.js
CHANGED
package/lib/browser/utils/zk.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { asciiToUint8Array } from "@reclaimprotocol/tls";
|
|
2
1
|
import { makeRpcTlsTunnel } from "../client/tunnels/make-rpc-tls-tunnel.js";
|
|
3
2
|
import { getAttestorClientFromPool } from "../client/utils/attestor-pool.js";
|
|
4
3
|
import { DEFAULT_HTTPS_PORT, PROVIDER_CTX, TOPRF_DOMAIN_SEPARATOR } from "../config/index.js";
|
|
5
4
|
import { ClaimTunnelRequest } from "../proto/api.js";
|
|
6
5
|
import { providers } from "../providers/index.js";
|
|
7
6
|
import {
|
|
7
|
+
asciiToUint8Array,
|
|
8
8
|
AttestorError,
|
|
9
9
|
binaryHashToStr,
|
|
10
10
|
canonicalStringify,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
|
|
2
|
-
import { makeTLSClient } from '
|
|
2
|
+
import { makeTLSClient } from '#src/utils/tls-imports.ts';
|
|
3
3
|
import type { CreateTunnelRequest, RPCMessage } from '#src/proto/api.ts';
|
|
4
4
|
import type { CompleteTLSPacket, IAttestorClient, Logger, MakeTunnelFn, Transcript } from '#src/types/index.ts';
|
|
5
5
|
type ExtraTLSOptions = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concatenateUint8Arrays, makeTLSClient } from "
|
|
1
|
+
import { concatenateUint8Arrays, makeTLSClient } from "../../utils/tls-imports.js";
|
|
2
2
|
import { makeRpcTcpTunnel } from "../../client/tunnels/make-rpc-tcp-tunnel.js";
|
|
3
3
|
import { DEFAULT_HTTPS_PORT } from "../../config/index.js";
|
|
4
4
|
import { generateRpcMessageId, generateTunnelId } from "../../utils/index.js";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
crypto,
|
|
3
3
|
encryptWrappedRecord,
|
|
4
4
|
SUPPORTED_CIPHER_SUITE_MAP
|
|
5
|
-
} from "
|
|
5
|
+
} from "../utils/tls-imports.js";
|
|
6
6
|
import { strToUint8Array } from "../utils/generics.js";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import { makeZkProofGenerator } from "../utils/zk.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextDecoder, TextEncoder } from "@kayahr/text-encoding";
|
|
2
|
-
import { crypto, uint8ArrayToBinaryStr } from "
|
|
2
|
+
import { crypto, uint8ArrayToBinaryStr } from "../../utils/tls-imports.js";
|
|
3
3
|
import { fromByteArray, toByteArray } from "base64-js";
|
|
4
4
|
import { EventTarget } from "event-target-shim";
|
|
5
5
|
if (typeof global === "undefined") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setCryptoImplementation } from "@reclaimprotocol/tls";
|
|
2
1
|
import { webcryptoCrypto } from "@reclaimprotocol/tls/webcrypto";
|
|
2
|
+
import { setCryptoImplementation } from "../utils/tls-imports.js";
|
|
3
3
|
import { handleIncomingMessage } from "../external-rpc/handle-incoming-msg.js";
|
|
4
4
|
import { getWsApiUrlFromBaseUrl } from "../external-rpc/utils.js";
|
|
5
5
|
import { logger, makeLogger } from "../utils/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../external-rpc/jsc-polyfills/index.js";
|
|
2
2
|
1;
|
|
3
|
-
import { setCryptoImplementation } from "@reclaimprotocol/tls";
|
|
4
3
|
import { pureJsCrypto } from "@reclaimprotocol/tls/purejs-crypto";
|
|
4
|
+
import { setCryptoImplementation } from "../utils/tls-imports.js";
|
|
5
5
|
import * as AttestorRPCImport from "../external-rpc/index.js";
|
|
6
6
|
import { makeLogger } from "../utils/logger.js";
|
|
7
7
|
setCryptoImplementation(pureJsCrypto);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { areUint8ArraysEqual, concatenateUint8Arrays, uint8ArrayToBinaryStr } from "
|
|
1
|
+
import { areUint8ArraysEqual, concatenateUint8Arrays, uint8ArrayToBinaryStr } from "../../utils/tls-imports.js";
|
|
2
2
|
import { encodeBase64 } from "ethers";
|
|
3
3
|
import { DEFAULT_HTTPS_PORT, RECLAIM_USER_AGENT } from "../../config/index.js";
|
|
4
4
|
import { AttestorVersion } from "../../proto/api.js";
|
package/lib/utils/generics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CipherSuite, TLSProtocolVersion } from '@reclaimprotocol/tls';
|
|
2
|
-
import { uint8ArrayToBinaryStr } from '
|
|
2
|
+
import { uint8ArrayToBinaryStr } from '#src/utils/tls-imports.ts';
|
|
3
3
|
import { RPCMessage, RPCMessages } from '#src/proto/api.ts';
|
|
4
4
|
import type { CompleteTLSPacket, IDecryptedTranscript, IDecryptedTranscriptMessage, ProviderField, RPCEvent, RPCEventMap, RPCEventType, RPCType, Transcript } from '#src/types/index.ts';
|
|
5
5
|
export { uint8ArrayToBinaryStr };
|
package/lib/utils/generics.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SUPPORTED_CIPHER_SUITE_MAP,
|
|
8
8
|
uint8ArrayToBinaryStr,
|
|
9
9
|
uint8ArrayToDataView
|
|
10
|
-
} from "
|
|
10
|
+
} from "../utils/tls-imports.js";
|
|
11
11
|
import { REDACTION_CHAR_CODE } from "@reclaimprotocol/zk-symmetric-crypto";
|
|
12
12
|
import { RPCMessage, RPCMessages } from "../proto/api.js";
|
|
13
13
|
const DEFAULT_REDACTION_DATA = new Uint8Array(4).fill(REDACTION_CHAR_CODE);
|
package/lib/utils/http-parser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asciiToUint8Array, concatenateUint8Arrays } from "
|
|
1
|
+
import { asciiToUint8Array, concatenateUint8Arrays } from "../utils/tls-imports.js";
|
|
2
2
|
import { findIndexInUint8Array, uint8ArrayToStr } from "../utils/generics.js";
|
|
3
3
|
import { REDACTION_CHAR_CODE } from "../utils/redactions.js";
|
|
4
4
|
const HTTP_HEADER_LINE_END = asciiToUint8Array("\r\n");
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/lib/utils/redactions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { base64Encode } from "@bufbuild/protobuf/wire";
|
|
2
|
-
import { concatenateUint8Arrays } from "
|
|
2
|
+
import { concatenateUint8Arrays } from "../utils/tls-imports.js";
|
|
3
3
|
const REDACTION_CHAR = "*";
|
|
4
4
|
const REDACTION_CHAR_CODE = REDACTION_CHAR.charCodeAt(0);
|
|
5
5
|
function isRedactionCongruent(redacted, original) {
|
|
@@ -0,0 +1,21 @@
|
|
|
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';
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
}
|
|
43
|
+
import {
|
|
44
|
+
crypto,
|
|
45
|
+
decryptWrappedRecord,
|
|
46
|
+
encryptWrappedRecord,
|
|
47
|
+
generateIV,
|
|
48
|
+
makeTLSClient,
|
|
49
|
+
setCryptoImplementation,
|
|
50
|
+
CONTENT_TYPE_MAP,
|
|
51
|
+
PACKET_TYPE,
|
|
52
|
+
SUPPORTED_CIPHER_SUITE_MAP,
|
|
53
|
+
SUPPORTED_NAMED_CURVES
|
|
54
|
+
} from "@reclaimprotocol/tls";
|
|
55
|
+
export {
|
|
56
|
+
CONTENT_TYPE_MAP,
|
|
57
|
+
PACKET_TYPE,
|
|
58
|
+
SUPPORTED_CIPHER_SUITE_MAP,
|
|
59
|
+
SUPPORTED_NAMED_CURVES,
|
|
60
|
+
areUint8ArraysEqual,
|
|
61
|
+
asciiToUint8Array,
|
|
62
|
+
concatenateUint8Arrays,
|
|
63
|
+
crypto,
|
|
64
|
+
decryptWrappedRecord,
|
|
65
|
+
encryptWrappedRecord,
|
|
66
|
+
generateIV,
|
|
67
|
+
makeTLSClient,
|
|
68
|
+
setCryptoImplementation,
|
|
69
|
+
uint8ArrayToBinaryStr,
|
|
70
|
+
uint8ArrayToDataView
|
|
71
|
+
};
|
package/lib/utils/tls.js
CHANGED
package/lib/utils/zk.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reclaimprotocol/attestor-core",
|
|
3
|
-
"version": "5.0.1-beta.
|
|
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
|
},
|