@reclaimprotocol/attestor-core 3.0.1
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/README.md +39 -0
- package/lib/avs/abis/avsDirectoryABI.d.ts +60 -0
- package/lib/avs/abis/avsDirectoryABI.js +344 -0
- package/lib/avs/abis/delegationABI.d.ts +126 -0
- package/lib/avs/abis/delegationABI.js +5 -0
- package/lib/avs/abis/registryABI.d.ts +136 -0
- package/lib/avs/abis/registryABI.js +729 -0
- package/lib/avs/client/create-claim-on-avs.d.ts +10 -0
- package/lib/avs/client/create-claim-on-avs.js +147 -0
- package/lib/avs/config.d.ts +7 -0
- package/lib/avs/config.js +24 -0
- package/lib/avs/contracts/ReclaimServiceManager.d.ts +697 -0
- package/lib/avs/contracts/ReclaimServiceManager.js +3 -0
- package/lib/avs/contracts/common.d.ts +21 -0
- package/lib/avs/contracts/common.js +3 -0
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.d.ts +888 -0
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +1174 -0
- package/lib/avs/contracts/factories/index.d.ts +1 -0
- package/lib/avs/contracts/factories/index.js +9 -0
- package/lib/avs/contracts/index.d.ts +3 -0
- package/lib/avs/contracts/index.js +30 -0
- package/lib/avs/tests/test.operator.d.ts +11 -0
- package/lib/avs/tests/test.operator.js +313 -0
- package/lib/avs/tests/utils.d.ts +2 -0
- package/lib/avs/tests/utils.js +50 -0
- package/lib/avs/types/index.d.ts +55 -0
- package/lib/avs/types/index.js +3 -0
- package/lib/avs/utils/contracts.d.ts +21 -0
- package/lib/avs/utils/contracts.js +38 -0
- package/lib/avs/utils/register.d.ts +27 -0
- package/lib/avs/utils/register.js +76 -0
- package/lib/avs/utils/tasks.d.ts +22 -0
- package/lib/avs/utils/tasks.js +45 -0
- package/lib/client/create-claim.d.ts +5 -0
- package/lib/client/create-claim.js +357 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +20 -0
- package/lib/client/tunnels/make-rpc-tcp-tunnel.d.ts +16 -0
- package/lib/client/tunnels/make-rpc-tcp-tunnel.js +60 -0
- package/lib/client/tunnels/make-rpc-tls-tunnel.d.ts +25 -0
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +135 -0
- package/lib/client/utils/attestor-pool.d.ts +6 -0
- package/lib/client/utils/attestor-pool.js +28 -0
- package/lib/client/utils/client-socket.d.ts +9 -0
- package/lib/client/utils/client-socket.js +77 -0
- package/lib/client/utils/message-handler.d.ts +4 -0
- package/lib/client/utils/message-handler.js +93 -0
- package/lib/config/index.d.ts +23 -0
- package/lib/config/index.js +35 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +39 -0
- package/lib/proto/api.d.ts +414 -0
- package/lib/proto/api.js +2756 -0
- package/lib/providers/http/index.d.ts +3 -0
- package/lib/providers/http/index.js +472 -0
- package/lib/providers/http/utils.d.ts +44 -0
- package/lib/providers/http/utils.js +302 -0
- package/lib/providers/index.d.ts +4 -0
- package/lib/providers/index.js +11 -0
- package/lib/scripts/check-avs-registration.d.ts +1 -0
- package/lib/scripts/check-avs-registration.js +28 -0
- package/lib/scripts/generate-provider-types.d.ts +5 -0
- package/lib/scripts/generate-provider-types.js +82 -0
- package/lib/scripts/generate-receipt.d.ts +9 -0
- package/lib/scripts/generate-receipt.js +93 -0
- package/lib/scripts/register-avs-operator.d.ts +1 -0
- package/lib/scripts/register-avs-operator.js +6 -0
- package/lib/scripts/start-server.d.ts +1 -0
- package/lib/scripts/start-server.js +6 -0
- package/lib/scripts/verify-root-ca.d.ts +1 -0
- package/lib/scripts/verify-root-ca.js +51 -0
- package/lib/server/create-server.d.ts +7 -0
- package/lib/server/create-server.js +85 -0
- package/lib/server/handlers/claimTunnel.d.ts +2 -0
- package/lib/server/handlers/claimTunnel.js +55 -0
- package/lib/server/handlers/completeClaimOnChain.d.ts +2 -0
- package/lib/server/handlers/completeClaimOnChain.js +28 -0
- package/lib/server/handlers/createClaimOnChain.d.ts +2 -0
- package/lib/server/handlers/createClaimOnChain.js +31 -0
- package/lib/server/handlers/createTunnel.d.ts +2 -0
- package/lib/server/handlers/createTunnel.js +65 -0
- package/lib/server/handlers/disconnectTunnel.d.ts +2 -0
- package/lib/server/handlers/disconnectTunnel.js +10 -0
- package/lib/server/handlers/index.d.ts +4 -0
- package/lib/server/handlers/index.js +18 -0
- package/lib/server/handlers/init.d.ts +2 -0
- package/lib/server/handlers/init.js +21 -0
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +21 -0
- package/lib/server/socket.d.ts +11 -0
- package/lib/server/socket.js +95 -0
- package/lib/server/tunnels/make-tcp-tunnel.d.ts +20 -0
- package/lib/server/tunnels/make-tcp-tunnel.js +182 -0
- package/lib/server/utils/apm.d.ts +11 -0
- package/lib/server/utils/apm.js +39 -0
- package/lib/server/utils/assert-valid-claim-request.d.ts +29 -0
- package/lib/server/utils/assert-valid-claim-request.js +189 -0
- package/lib/server/utils/config-env.d.ts +1 -0
- package/lib/server/utils/config-env.js +7 -0
- package/lib/server/utils/generics.d.ts +22 -0
- package/lib/server/utils/generics.js +59 -0
- package/lib/server/utils/iso.d.ts +1 -0
- package/lib/server/utils/iso.js +260 -0
- package/lib/server/utils/keep-alive.d.ts +7 -0
- package/lib/server/utils/keep-alive.js +42 -0
- package/lib/server/utils/process-handshake.d.ts +13 -0
- package/lib/server/utils/process-handshake.js +179 -0
- package/lib/server/utils/verify-server-certificates.d.ts +7 -0
- package/lib/server/utils/verify-server-certificates.js +102 -0
- package/lib/tests/describe-with-server.d.ts +21 -0
- package/lib/tests/describe-with-server.js +67 -0
- package/lib/tests/mock-provider-server.d.ts +13 -0
- package/lib/tests/mock-provider-server.js +65 -0
- package/lib/tests/mocks.d.ts +4 -0
- package/lib/tests/mocks.js +23 -0
- package/lib/tests/test.claim-creation.d.ts +1 -0
- package/lib/tests/test.claim-creation.js +187 -0
- package/lib/tests/test.http-parser.d.ts +1 -0
- package/lib/tests/test.http-parser.js +118 -0
- package/lib/tests/test.http-provider-utils.d.ts +1 -0
- package/lib/tests/test.http-provider-utils.js +1932 -0
- package/lib/tests/test.http-provider.d.ts +1 -0
- package/lib/tests/test.http-provider.js +43 -0
- package/lib/tests/test.rpc-communication.d.ts +1 -0
- package/lib/tests/test.rpc-communication.js +64 -0
- package/lib/tests/test.rpc-tunnel.d.ts +1 -0
- package/lib/tests/test.rpc-tunnel.js +168 -0
- package/lib/tests/test.signatures.d.ts +1 -0
- package/lib/tests/test.signatures.js +24 -0
- package/lib/tests/test.tcp-tunnel.d.ts +1 -0
- package/lib/tests/test.tcp-tunnel.js +64 -0
- package/lib/tests/test.zk.d.ts +1 -0
- package/lib/tests/test.zk.js +169 -0
- package/lib/tests/utils.d.ts +12 -0
- package/lib/tests/utils.js +49 -0
- package/lib/types/claims.d.ts +64 -0
- package/lib/types/claims.js +3 -0
- package/lib/types/client.d.ts +136 -0
- package/lib/types/client.js +3 -0
- package/lib/types/general.d.ts +39 -0
- package/lib/types/general.js +3 -0
- package/lib/types/handlers.d.ts +10 -0
- package/lib/types/handlers.js +3 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/index.js +26 -0
- package/lib/types/providers.d.ts +135 -0
- package/lib/types/providers.gen.d.ts +414 -0
- package/lib/types/providers.gen.js +14 -0
- package/lib/types/providers.js +3 -0
- package/lib/types/rpc.d.ts +35 -0
- package/lib/types/rpc.js +3 -0
- package/lib/types/signatures.d.ts +28 -0
- package/lib/types/signatures.js +3 -0
- package/lib/types/tunnel.d.ts +18 -0
- package/lib/types/tunnel.js +3 -0
- package/lib/types/zk.d.ts +16 -0
- package/lib/types/zk.js +3 -0
- package/lib/utils/benchmark.d.ts +1 -0
- package/lib/utils/benchmark.js +70 -0
- package/lib/utils/claims.d.ts +33 -0
- package/lib/utils/claims.js +112 -0
- package/lib/utils/env.d.ts +3 -0
- package/lib/utils/env.js +20 -0
- package/lib/utils/error.d.ts +27 -0
- package/lib/utils/error.js +43 -0
- package/lib/utils/generics.d.ts +112 -0
- package/lib/utils/generics.js +348 -0
- package/lib/utils/http-parser.d.ts +55 -0
- package/lib/utils/http-parser.js +249 -0
- package/lib/utils/index.d.ts +10 -0
- package/lib/utils/index.js +27 -0
- package/lib/utils/logger.d.ts +13 -0
- package/lib/utils/logger.js +100 -0
- package/lib/utils/prepare-packets.d.ts +16 -0
- package/lib/utils/prepare-packets.js +61 -0
- package/lib/utils/redactions.d.ts +41 -0
- package/lib/utils/redactions.js +111 -0
- package/lib/utils/retries.d.ts +12 -0
- package/lib/utils/retries.js +28 -0
- package/lib/utils/signatures/eth.d.ts +2 -0
- package/lib/utils/signatures/eth.js +33 -0
- package/lib/utils/signatures/index.d.ts +5 -0
- package/lib/utils/signatures/index.js +11 -0
- package/lib/utils/socket-base.d.ts +21 -0
- package/lib/utils/socket-base.js +89 -0
- package/lib/utils/tls.d.ts +2 -0
- package/lib/utils/tls.js +32 -0
- package/lib/utils/validation.d.ts +2 -0
- package/lib/utils/validation.js +46 -0
- package/lib/utils/ws.d.ts +12 -0
- package/lib/utils/ws.js +21 -0
- package/lib/utils/zk.d.ts +50 -0
- package/lib/utils/zk.js +282 -0
- package/lib/window-rpc/index.d.ts +3 -0
- package/lib/window-rpc/index.js +20 -0
- package/lib/window-rpc/setup-window-rpc.d.ts +5 -0
- package/lib/window-rpc/setup-window-rpc.js +239 -0
- package/lib/window-rpc/types.d.ts +184 -0
- package/lib/window-rpc/types.js +3 -0
- package/lib/window-rpc/utils.d.ts +13 -0
- package/lib/window-rpc/utils.js +76 -0
- package/lib/window-rpc/window-rpc-zk.d.ts +11 -0
- package/lib/window-rpc/window-rpc-zk.js +72 -0
- package/package.json +117 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ProviderClaimData } from 'src/proto/api';
|
|
2
|
+
import type { IAttestorClient } from 'src/types/client';
|
|
3
|
+
import type { CompleteTLSPacket, Logger } from 'src/types/general';
|
|
4
|
+
import type { ProofGenerationStep, ProviderName, ProviderParams, ProviderSecretParams } from 'src/types/providers';
|
|
5
|
+
import { Transcript } from 'src/types/tunnel';
|
|
6
|
+
import type { PrepareZKProofsBaseOpts } from 'src/types/zk';
|
|
7
|
+
/**
|
|
8
|
+
* Uniquely identifies a claim.
|
|
9
|
+
* Hash of claim info.
|
|
10
|
+
* Utilise `getIdentifierFromClaimInfo` to obtain this.
|
|
11
|
+
*/
|
|
12
|
+
export type ClaimID = ProviderClaimData['identifier'];
|
|
13
|
+
export type ClaimInfo = Pick<ProviderClaimData, 'context' | 'provider' | 'parameters'>;
|
|
14
|
+
export type AnyClaimInfo = ClaimInfo | {
|
|
15
|
+
identifier: ClaimID;
|
|
16
|
+
};
|
|
17
|
+
export type CompleteClaimData = Pick<ProviderClaimData, 'owner' | 'timestampS' | 'epoch'> & AnyClaimInfo;
|
|
18
|
+
export type CreateClaimOnAttestorOpts<N extends ProviderName> = {
|
|
19
|
+
/** name of the provider to generate signed receipt for */
|
|
20
|
+
name: N;
|
|
21
|
+
/**
|
|
22
|
+
* secrets that are used to make the API request;
|
|
23
|
+
* not included in the receipt & cannot be viewed by anyone
|
|
24
|
+
* outside this client
|
|
25
|
+
*/
|
|
26
|
+
secretParams: ProviderSecretParams<N>;
|
|
27
|
+
params: ProviderParams<N>;
|
|
28
|
+
/**
|
|
29
|
+
* Some metadata context to be included in the claim
|
|
30
|
+
*/
|
|
31
|
+
context?: {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
onStep?(step: ProofGenerationStep): void;
|
|
35
|
+
/**
|
|
36
|
+
* Private key in hex format,
|
|
37
|
+
* prefixed with '0x'
|
|
38
|
+
*/
|
|
39
|
+
ownerPrivateKey: string;
|
|
40
|
+
/**
|
|
41
|
+
* Provide either the client or the URL
|
|
42
|
+
* to the server -- so a client can be created internally.
|
|
43
|
+
*
|
|
44
|
+
* The created client will go into the global client pool.
|
|
45
|
+
*/
|
|
46
|
+
client: IAttestorClient | {
|
|
47
|
+
url: string | URL;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Optionally set the timestamp of the claim
|
|
51
|
+
* in unix seconds. If not provided, the current
|
|
52
|
+
* time will be used.
|
|
53
|
+
*/
|
|
54
|
+
timestampS?: number;
|
|
55
|
+
logger?: Logger;
|
|
56
|
+
/**
|
|
57
|
+
* Optionally update the provider parameters
|
|
58
|
+
* based on the transcript
|
|
59
|
+
*/
|
|
60
|
+
updateProviderParams?(transcript: Transcript<CompleteTLSPacket>, tlsVersion: string): Promise<{
|
|
61
|
+
params: Partial<ProviderParams<N>>;
|
|
62
|
+
secretParams: Partial<ProviderSecretParams<N>>;
|
|
63
|
+
}>;
|
|
64
|
+
} & PrepareZKProofsBaseOpts;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhaW1zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL2NsYWltcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { InitRequest, RPCMessage, RPCMessages, ServiceSignatureType, TunnelMessage } from 'src/proto/api';
|
|
2
|
+
import type { Logger } from 'src/types/general';
|
|
3
|
+
import type { RPCEvent, RPCEventMap, RPCEventType, RPCRequestData, RPCResponseData, RPCType } from 'src/types/rpc';
|
|
4
|
+
import type { TCPSocketProperties, Tunnel } from 'src/types/tunnel';
|
|
5
|
+
import type { WebSocket as WSWebSocket } from 'ws';
|
|
6
|
+
/**
|
|
7
|
+
* Any WebSocket implementation -- either the native
|
|
8
|
+
* WebSocket or the WebSocket from the `ws` package.
|
|
9
|
+
*/
|
|
10
|
+
export type AnyWebSocket = WebSocket | WSWebSocket;
|
|
11
|
+
export type AnyWebSocketConstructor = new (url: string | URL) => AnyWebSocket;
|
|
12
|
+
export type IAttestorClientCreateOpts = {
|
|
13
|
+
/**
|
|
14
|
+
* Attestor WS URL
|
|
15
|
+
*/
|
|
16
|
+
url: string | URL;
|
|
17
|
+
signatureType?: ServiceSignatureType;
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
/**
|
|
20
|
+
* Initial messages to send to the server
|
|
21
|
+
* in the query parameter used to establish
|
|
22
|
+
* the connection.
|
|
23
|
+
*/
|
|
24
|
+
initMessages?: Partial<RPCMessage>[];
|
|
25
|
+
/**
|
|
26
|
+
* Provide a custom WebSocket implementation,
|
|
27
|
+
* will use the native WebSocket if not provided.
|
|
28
|
+
*/
|
|
29
|
+
Websocket?: AnyWebSocketConstructor;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Base layer for the WebSocket connection on
|
|
33
|
+
* the client and server.
|
|
34
|
+
*/
|
|
35
|
+
export declare class IAttestorSocket {
|
|
36
|
+
metadata: InitRequest;
|
|
37
|
+
logger: Logger;
|
|
38
|
+
/**
|
|
39
|
+
* Is the WebSocket connection open?
|
|
40
|
+
*/
|
|
41
|
+
isOpen: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Has the WebSocket connection been closed
|
|
44
|
+
*/
|
|
45
|
+
isClosed: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the WebSocket has been initialised
|
|
48
|
+
* by receiving an "init-response" message.
|
|
49
|
+
*/
|
|
50
|
+
isInitialised: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Sends RPC messages to the server in a single packet.
|
|
53
|
+
* If the ID is not provided, it will be generated.
|
|
54
|
+
*
|
|
55
|
+
* Promisify the `send` method if using the `ws` package's
|
|
56
|
+
* WebSocket implementation.
|
|
57
|
+
*/
|
|
58
|
+
sendMessage(...msgs: Partial<RPCMessage>[]): Promise<RPCMessages>;
|
|
59
|
+
/**
|
|
60
|
+
* Sends a "terminateConnectionAlert" message to the server
|
|
61
|
+
* with the specified error (if any), if the connection is
|
|
62
|
+
* still open and then closes the connection.
|
|
63
|
+
*/
|
|
64
|
+
terminateConnection(err?: Error): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Use this to listen to events on the WebSocket.
|
|
67
|
+
*/
|
|
68
|
+
addEventListener<K extends RPCEventType>(type: K, listener: (data: RPCEvent<K>) => void): void;
|
|
69
|
+
removeEventListener<K extends RPCEventType>(type: K, listener: (data: RPCEvent<K>) => void): void;
|
|
70
|
+
/**
|
|
71
|
+
* Syntactic sugar for emitting events on the WebSocket.
|
|
72
|
+
* Wraps the `makeRpcEvent` call internally
|
|
73
|
+
*/
|
|
74
|
+
dispatchRPCEvent<K extends RPCEventType>(type: K, data: RPCEventMap[K]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Starts processing RPC messages from the WebSocket
|
|
77
|
+
* & emits events for each message type. These can be
|
|
78
|
+
* captured by the `addEventListener` method.
|
|
79
|
+
*
|
|
80
|
+
* Will also listen to "error" & "close" events on the WebSocket
|
|
81
|
+
* and emit a "attestor-error" event with the error.
|
|
82
|
+
* So, you only need to listen to the "attestor-error"
|
|
83
|
+
* event to capture anything you're interested in.
|
|
84
|
+
*/
|
|
85
|
+
constructor(ws: WebSocket, metadata: InitRequest, logger: Logger);
|
|
86
|
+
}
|
|
87
|
+
export declare class IAttestorServerSocket extends IAttestorSocket {
|
|
88
|
+
/**
|
|
89
|
+
* Unique identifier for this WebSocket connection
|
|
90
|
+
*/
|
|
91
|
+
sessionId: number;
|
|
92
|
+
/**
|
|
93
|
+
* Set of tunnels this client created. Only available
|
|
94
|
+
* when WS is created by the server
|
|
95
|
+
*/
|
|
96
|
+
tunnels: {
|
|
97
|
+
[id: TunnelMessage['tunnelId']]: Tunnel<TCPSocketProperties>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Fetches a tunnel by its ID.
|
|
101
|
+
* If the tunnel does not exist, it will throw an error.
|
|
102
|
+
*/
|
|
103
|
+
getTunnel(tunnelId: TunnelMessage['tunnelId']): Tunnel<TCPSocketProperties>;
|
|
104
|
+
}
|
|
105
|
+
export declare class IAttestorClient extends IAttestorSocket {
|
|
106
|
+
constructor(opts: IAttestorClientCreateOpts);
|
|
107
|
+
/**
|
|
108
|
+
* Waits for a particular message to come in.
|
|
109
|
+
* If the connection is closed before the message is received,
|
|
110
|
+
* the promise will reject.
|
|
111
|
+
*/
|
|
112
|
+
waitForResponse<T extends RPCType>(id: number): Promise<RPCResponseData<T>>;
|
|
113
|
+
/**
|
|
114
|
+
* Make an RPC request to the other end of the WebSocket.
|
|
115
|
+
*/
|
|
116
|
+
rpc<T extends RPCType>(type: T, request: Partial<RPCRequestData<T>>): Promise<RPCResponseData<T>>;
|
|
117
|
+
/**
|
|
118
|
+
* Waits for the "init" request to be responded to
|
|
119
|
+
*/
|
|
120
|
+
waitForInit(): Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
interface WebSocketWithServerSocket {
|
|
123
|
+
/**
|
|
124
|
+
* Our RPC socket instance
|
|
125
|
+
*/
|
|
126
|
+
serverSocket?: IAttestorServerSocket;
|
|
127
|
+
}
|
|
128
|
+
declare module 'ws' {
|
|
129
|
+
namespace WebSocket {
|
|
130
|
+
interface WebSocket extends WebSocketWithServerSocket {
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
interface WebSocket extends WebSocketWithServerSocket {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL2NsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Logger as TLSLogger, TLSPacketContext, TLSProtocolVersion } from '@reclaimprotocol/tls';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a slice of any array or string
|
|
4
|
+
*/
|
|
5
|
+
export type ArraySlice = {
|
|
6
|
+
fromIndex: number;
|
|
7
|
+
toIndex: number;
|
|
8
|
+
};
|
|
9
|
+
export type Logger = TLSLogger & {
|
|
10
|
+
child: (opts: {
|
|
11
|
+
[_: string]: any;
|
|
12
|
+
}) => Logger;
|
|
13
|
+
};
|
|
14
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'trace' | 'fatal';
|
|
15
|
+
export type ZKRevealInfo = {
|
|
16
|
+
type: 'zk';
|
|
17
|
+
redactedPlaintext: Uint8Array;
|
|
18
|
+
};
|
|
19
|
+
export type MessageRevealInfo = {
|
|
20
|
+
type: 'complete';
|
|
21
|
+
} | ZKRevealInfo;
|
|
22
|
+
export type CompleteTLSPacket = TLSPacketContext & {
|
|
23
|
+
/**
|
|
24
|
+
* Full data that was sent/recv across the wire
|
|
25
|
+
*/
|
|
26
|
+
data: Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
export type IDecryptedTranscriptMessage = {
|
|
29
|
+
sender: 'client' | 'server';
|
|
30
|
+
redacted: boolean;
|
|
31
|
+
message: Uint8Array;
|
|
32
|
+
plaintextLength: number;
|
|
33
|
+
recordHeader: Uint8Array;
|
|
34
|
+
};
|
|
35
|
+
export type IDecryptedTranscript = {
|
|
36
|
+
transcript: IDecryptedTranscriptMessage[];
|
|
37
|
+
tlsVersion: TLSProtocolVersion;
|
|
38
|
+
hostname: string;
|
|
39
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9nZW5lcmFsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Transaction } from 'elastic-apm-node';
|
|
2
|
+
import { IAttestorServerSocket } from 'src/types/client';
|
|
3
|
+
import { Logger } from 'src/types/general';
|
|
4
|
+
import { RPCRequestData, RPCResponseData, RPCType } from 'src/types/rpc';
|
|
5
|
+
export type RPCHandlerMetadata = {
|
|
6
|
+
logger: Logger;
|
|
7
|
+
tx?: Transaction;
|
|
8
|
+
client: IAttestorServerSocket;
|
|
9
|
+
};
|
|
10
|
+
export type RPCHandler<R extends RPCType> = (data: RPCRequestData<R>, ctx: RPCHandlerMetadata) => Promise<RPCResponseData<R>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaGFuZGxlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./providers"), exports);
|
|
18
|
+
__exportStar(require("./general"), exports);
|
|
19
|
+
__exportStar(require("./signatures"), exports);
|
|
20
|
+
__exportStar(require("./claims"), exports);
|
|
21
|
+
__exportStar(require("./zk"), exports);
|
|
22
|
+
__exportStar(require("./client"), exports);
|
|
23
|
+
__exportStar(require("./rpc"), exports);
|
|
24
|
+
__exportStar(require("./tunnel"), exports);
|
|
25
|
+
__exportStar(require("./handlers"), exports);
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhDQUEyQjtBQUMzQiw0Q0FBeUI7QUFDekIsK0NBQTRCO0FBQzVCLDJDQUF3QjtBQUN4Qix1Q0FBb0I7QUFDcEIsMkNBQXdCO0FBQ3hCLHdDQUFxQjtBQUNyQiwyQ0FBd0I7QUFDeEIsNkNBQTBCIn0=
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
|
|
2
|
+
import type { ProviderClaimData } from 'src/proto/api';
|
|
3
|
+
import type { ArraySlice } from 'src/types/general';
|
|
4
|
+
import type { ProvidersConfig } from 'src/types/providers.gen';
|
|
5
|
+
import type { Transcript } from 'src/types/tunnel';
|
|
6
|
+
export type AttestorData = {
|
|
7
|
+
id: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
type CreateRequestResult = {
|
|
11
|
+
/**
|
|
12
|
+
* Raw request to be sent
|
|
13
|
+
* If a string, it is assumed to be an
|
|
14
|
+
* ASCII encoded string. If it contains
|
|
15
|
+
* non-ASCII characters, the redactions
|
|
16
|
+
* may not work as expected
|
|
17
|
+
*/
|
|
18
|
+
data: Uint8Array | string;
|
|
19
|
+
redactions: ArraySlice[];
|
|
20
|
+
};
|
|
21
|
+
export type ProviderName = keyof ProvidersConfig;
|
|
22
|
+
export type ProviderParams<T extends ProviderName> = ProvidersConfig[T]['parameters'];
|
|
23
|
+
export type ProviderSecretParams<T extends ProviderName> = ProvidersConfig[T]['secretParameters'];
|
|
24
|
+
export type RedactionMode = 'key-update' | 'zk';
|
|
25
|
+
export type ProviderField<Params, T> = T | ((params: Params) => T);
|
|
26
|
+
/**
|
|
27
|
+
* Generic interface for a provider that can be used to verify
|
|
28
|
+
* claims on a TLS receipt
|
|
29
|
+
*
|
|
30
|
+
* @notice "Params" are the parameters you want to claim against.
|
|
31
|
+
* These would typically be found in the response body
|
|
32
|
+
*
|
|
33
|
+
* @notice "SecretParams" are the parameters that are used to make the API request.
|
|
34
|
+
* These must be redacted in the request construction in "createRequest" & cannot be viewed by anyone
|
|
35
|
+
*/
|
|
36
|
+
export interface Provider<N extends ProviderName, Params = ProviderParams<N>, SecretParams = ProviderSecretParams<N>> {
|
|
37
|
+
/**
|
|
38
|
+
* host:port to connect to for this provider;
|
|
39
|
+
* the protocol establishes a connection to the first one
|
|
40
|
+
* when a request is received from a user.
|
|
41
|
+
*
|
|
42
|
+
* Run on attestor side when creating a new session
|
|
43
|
+
*
|
|
44
|
+
* Eg. "www.google.com:443", (p) => p.url.host
|
|
45
|
+
* */
|
|
46
|
+
hostPort: ProviderField<Params, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Which geo location to send the request from
|
|
49
|
+
* Provide 2 letter country code, or a function
|
|
50
|
+
* that returns the country code
|
|
51
|
+
* @example "US", "IN"
|
|
52
|
+
*/
|
|
53
|
+
geoLocation?: ProviderField<Params, string | undefined>;
|
|
54
|
+
/** extra options to pass to the client like root CA certificates */
|
|
55
|
+
additionalClientOptions?: ProviderField<Params, TLSConnectionOptions | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* default redaction mode to use. If not specified,
|
|
58
|
+
* the default is 'key-update'.
|
|
59
|
+
*
|
|
60
|
+
* It's switched to 'zk' for TLS1.2 requests as TLS1.2
|
|
61
|
+
* don't support key updates
|
|
62
|
+
*
|
|
63
|
+
* @default 'key-update'
|
|
64
|
+
*/
|
|
65
|
+
writeRedactionMode?: ProviderField<Params, RedactionMode | undefined>;
|
|
66
|
+
/** generate the raw request to be sent to through the TLS receipt */
|
|
67
|
+
createRequest(secretParams: SecretParams, params: Params): CreateRequestResult;
|
|
68
|
+
/**
|
|
69
|
+
* Return the slices of the response to redact
|
|
70
|
+
* Eg. if the response is "hello my secret is xyz",
|
|
71
|
+
* and you want to redact "xyz", you would return
|
|
72
|
+
* [{start: 17, end: 20}]
|
|
73
|
+
*
|
|
74
|
+
* This is run on the client side, to selct which portions of
|
|
75
|
+
* the server response to send to the attestor
|
|
76
|
+
* */
|
|
77
|
+
getResponseRedactions?(response: Uint8Array, params: Params): ArraySlice[];
|
|
78
|
+
/**
|
|
79
|
+
* verify a generated TLS receipt against given parameters
|
|
80
|
+
* to ensure the receipt does contain the claims the
|
|
81
|
+
* user is claiming to have
|
|
82
|
+
*
|
|
83
|
+
* This is run on the attestor side.
|
|
84
|
+
* @param receipt application data messages exchanged in the TLS session
|
|
85
|
+
* @param params the parameters to verify the receipt against.
|
|
86
|
+
* Eg. `{"email": "abcd@gmail.com"}`
|
|
87
|
+
* @returns sucessful verification or throws an error message.
|
|
88
|
+
* Optionally return parameters extracted from the receipt
|
|
89
|
+
* that will then be included in the claim context
|
|
90
|
+
* */
|
|
91
|
+
assertValidProviderReceipt(receipt: Transcript<Uint8Array>, params: Params): void | Promise<void> | {
|
|
92
|
+
extractedParameters: {
|
|
93
|
+
[key: string]: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export type ProofGenerationStep = {
|
|
98
|
+
name: 'connecting';
|
|
99
|
+
} | {
|
|
100
|
+
name: 'sending-request-data';
|
|
101
|
+
} | {
|
|
102
|
+
name: 'waiting-for-response';
|
|
103
|
+
} | {
|
|
104
|
+
name: 'generating-zk-proofs';
|
|
105
|
+
proofsDone: number;
|
|
106
|
+
proofsTotal: number;
|
|
107
|
+
/**
|
|
108
|
+
* approximate time left in seconds.
|
|
109
|
+
* Only computed after the first block
|
|
110
|
+
* is done
|
|
111
|
+
* */
|
|
112
|
+
approxTimeLeftS?: number;
|
|
113
|
+
} | {
|
|
114
|
+
name: 'waiting-for-verification';
|
|
115
|
+
};
|
|
116
|
+
type StepData = {
|
|
117
|
+
timestampS: number;
|
|
118
|
+
epoch: number;
|
|
119
|
+
attestors: AttestorData[];
|
|
120
|
+
};
|
|
121
|
+
export type CreateStep = ({
|
|
122
|
+
name: 'creating';
|
|
123
|
+
} & StepData) | ({
|
|
124
|
+
name: 'attestor-progress';
|
|
125
|
+
currentAttestor: AttestorData;
|
|
126
|
+
step: ProofGenerationStep;
|
|
127
|
+
} & StepData) | {
|
|
128
|
+
name: 'attestor-done';
|
|
129
|
+
timestampS: number;
|
|
130
|
+
epoch: number;
|
|
131
|
+
attestorsLeft: AttestorData[];
|
|
132
|
+
claimData: ProviderClaimData;
|
|
133
|
+
signaturesDone: string[];
|
|
134
|
+
};
|
|
135
|
+
export {};
|