@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,414 @@
|
|
|
1
|
+
type BinaryData = Uint8Array | string;
|
|
2
|
+
export interface HttpProviderParameters {
|
|
3
|
+
/**
|
|
4
|
+
* which URL does the request have to be made to Has to be a valid https URL for eg. https://amazon.in/orders?q=abcd
|
|
5
|
+
*/
|
|
6
|
+
url: string;
|
|
7
|
+
method: "GET" | "POST" | "PUT" | "PATCH";
|
|
8
|
+
/**
|
|
9
|
+
* Specify the geographical location from where to proxy the request. 2-letter ISO country code
|
|
10
|
+
*/
|
|
11
|
+
geoLocation?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Any additional headers to be sent with the request Note: these will be revealed to the attestor & won't be redacted from the transcript. To add hidden headers, use 'secretParams.headers' instead
|
|
14
|
+
*/
|
|
15
|
+
headers?: {
|
|
16
|
+
[k: string]: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Body of the HTTP request
|
|
20
|
+
*/
|
|
21
|
+
body?: BinaryData;
|
|
22
|
+
/**
|
|
23
|
+
* If the API doesn't perform well with the "key-update" method of redaction, you can switch to "zk" mode by setting this to "zk"
|
|
24
|
+
*/
|
|
25
|
+
writeRedactionMode?: "zk" | "key-update";
|
|
26
|
+
/**
|
|
27
|
+
* Apply TLS configuration when creating the tunnel to the attestor.
|
|
28
|
+
*/
|
|
29
|
+
additionalClientOptions?: {
|
|
30
|
+
/**
|
|
31
|
+
* @minItems 1
|
|
32
|
+
*/
|
|
33
|
+
supportedProtocolVersions?: ("TLS1_2" | "TLS1_3")[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The attestor will use this list to check that the redacted response does indeed match all the provided strings/regexes
|
|
37
|
+
*
|
|
38
|
+
* @minItems 1
|
|
39
|
+
*/
|
|
40
|
+
responseMatches: {
|
|
41
|
+
/**
|
|
42
|
+
* "regex": the response must match the regex "contains": the response must contain the provided
|
|
43
|
+
* string exactly
|
|
44
|
+
*/
|
|
45
|
+
value: string;
|
|
46
|
+
/**
|
|
47
|
+
* The string/regex to match against
|
|
48
|
+
*/
|
|
49
|
+
type: "regex" | "contains";
|
|
50
|
+
/**
|
|
51
|
+
* Inverses the matching logic. Fail when match is found and proceed otherwise
|
|
52
|
+
*/
|
|
53
|
+
invert?: boolean;
|
|
54
|
+
}[];
|
|
55
|
+
/**
|
|
56
|
+
* which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. "HTTP/1.1 200 OK") * To disable any redactions, pass an empty array
|
|
57
|
+
*/
|
|
58
|
+
responseRedactions?: {
|
|
59
|
+
/**
|
|
60
|
+
* expect an HTML response, and to contain a certain xpath for eg. "/html/body/div.a1/div.a2/span.a5"
|
|
61
|
+
*/
|
|
62
|
+
xPath?: string;
|
|
63
|
+
/**
|
|
64
|
+
* expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'
|
|
65
|
+
*/
|
|
66
|
+
jsonPath?: string;
|
|
67
|
+
/**
|
|
68
|
+
* select a regex match from the response
|
|
69
|
+
*/
|
|
70
|
+
regex?: string;
|
|
71
|
+
}[];
|
|
72
|
+
/**
|
|
73
|
+
* A map of parameter values which are user in form of {{param}} in URL, responseMatches, responseRedactions, body, geolocation. Those in URL, responseMatches & geo will be put into context and signed This value will NOT be included in provider hash
|
|
74
|
+
*/
|
|
75
|
+
paramValues?: {
|
|
76
|
+
[k: string]: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare const HttpProviderParametersJson: {
|
|
80
|
+
title: string;
|
|
81
|
+
type: string;
|
|
82
|
+
required: string[];
|
|
83
|
+
properties: {
|
|
84
|
+
url: {
|
|
85
|
+
type: string;
|
|
86
|
+
format: string;
|
|
87
|
+
description: string;
|
|
88
|
+
};
|
|
89
|
+
method: {
|
|
90
|
+
type: string;
|
|
91
|
+
enum: string[];
|
|
92
|
+
};
|
|
93
|
+
geoLocation: {
|
|
94
|
+
type: string;
|
|
95
|
+
nullable: boolean;
|
|
96
|
+
pattern: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
headers: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
additionalProperties: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
body: {
|
|
107
|
+
description: string;
|
|
108
|
+
oneOf: ({
|
|
109
|
+
type: string;
|
|
110
|
+
format: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: string;
|
|
113
|
+
format?: undefined;
|
|
114
|
+
})[];
|
|
115
|
+
};
|
|
116
|
+
writeRedactionMode: {
|
|
117
|
+
type: string;
|
|
118
|
+
description: string;
|
|
119
|
+
enum: string[];
|
|
120
|
+
};
|
|
121
|
+
additionalClientOptions: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
nullable: boolean;
|
|
125
|
+
properties: {
|
|
126
|
+
supportedProtocolVersions: {
|
|
127
|
+
type: string;
|
|
128
|
+
minItems: number;
|
|
129
|
+
uniqueItems: boolean;
|
|
130
|
+
items: {
|
|
131
|
+
type: string;
|
|
132
|
+
enum: string[];
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
responseMatches: {
|
|
138
|
+
type: string;
|
|
139
|
+
minItems: number;
|
|
140
|
+
uniqueItems: boolean;
|
|
141
|
+
description: string;
|
|
142
|
+
items: {
|
|
143
|
+
type: string;
|
|
144
|
+
required: string[];
|
|
145
|
+
properties: {
|
|
146
|
+
value: {
|
|
147
|
+
type: string;
|
|
148
|
+
description: string;
|
|
149
|
+
};
|
|
150
|
+
type: {
|
|
151
|
+
type: string;
|
|
152
|
+
description: string;
|
|
153
|
+
enum: string[];
|
|
154
|
+
};
|
|
155
|
+
invert: {
|
|
156
|
+
type: string;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
additionalProperties: boolean;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
responseRedactions: {
|
|
164
|
+
type: string;
|
|
165
|
+
uniqueItems: boolean;
|
|
166
|
+
description: string;
|
|
167
|
+
items: {
|
|
168
|
+
type: string;
|
|
169
|
+
properties: {
|
|
170
|
+
xPath: {
|
|
171
|
+
type: string;
|
|
172
|
+
nullable: boolean;
|
|
173
|
+
description: string;
|
|
174
|
+
};
|
|
175
|
+
jsonPath: {
|
|
176
|
+
type: string;
|
|
177
|
+
nullable: boolean;
|
|
178
|
+
description: string;
|
|
179
|
+
};
|
|
180
|
+
regex: {
|
|
181
|
+
type: string;
|
|
182
|
+
nullable: boolean;
|
|
183
|
+
description: string;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
additionalProperties: boolean;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
paramValues: {
|
|
190
|
+
type: string;
|
|
191
|
+
description: string;
|
|
192
|
+
additionalProperties: {
|
|
193
|
+
type: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
additionalProperties: boolean;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Secret parameters to be used with HTTP provider. None of the values in this object will be shown to the attestor
|
|
201
|
+
*/
|
|
202
|
+
export interface HttpProviderSecretParameters {
|
|
203
|
+
/**
|
|
204
|
+
* cookie string for authorisation.
|
|
205
|
+
*/
|
|
206
|
+
cookieStr?: string;
|
|
207
|
+
/**
|
|
208
|
+
* authorisation header value
|
|
209
|
+
*/
|
|
210
|
+
authorisationHeader?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Headers that need to be hidden from the attestor
|
|
213
|
+
*/
|
|
214
|
+
headers?: {
|
|
215
|
+
[k: string]: string;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* A map of parameter values which are user in form of {{param}} in body these parameters will NOT be shown to attestor and extracted
|
|
219
|
+
*/
|
|
220
|
+
paramValues?: {
|
|
221
|
+
[k: string]: string;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export declare const HttpProviderSecretParametersJson: {
|
|
225
|
+
title: string;
|
|
226
|
+
type: string;
|
|
227
|
+
description: string;
|
|
228
|
+
properties: {
|
|
229
|
+
cookieStr: {
|
|
230
|
+
type: string;
|
|
231
|
+
description: string;
|
|
232
|
+
};
|
|
233
|
+
authorisationHeader: {
|
|
234
|
+
type: string;
|
|
235
|
+
description: string;
|
|
236
|
+
};
|
|
237
|
+
headers: {
|
|
238
|
+
type: string;
|
|
239
|
+
description: string;
|
|
240
|
+
additionalProperties: {
|
|
241
|
+
type: string;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
paramValues: {
|
|
245
|
+
type: string;
|
|
246
|
+
description: string;
|
|
247
|
+
additionalProperties: {
|
|
248
|
+
type: string;
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
additionalProperties: boolean;
|
|
253
|
+
};
|
|
254
|
+
export interface ProvidersConfig {
|
|
255
|
+
http: {
|
|
256
|
+
parameters: HttpProviderParameters;
|
|
257
|
+
secretParameters: HttpProviderSecretParameters;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export declare const PROVIDER_SCHEMAS: {
|
|
261
|
+
http: {
|
|
262
|
+
parameters: {
|
|
263
|
+
title: string;
|
|
264
|
+
type: string;
|
|
265
|
+
required: string[];
|
|
266
|
+
properties: {
|
|
267
|
+
url: {
|
|
268
|
+
type: string;
|
|
269
|
+
format: string;
|
|
270
|
+
description: string;
|
|
271
|
+
};
|
|
272
|
+
method: {
|
|
273
|
+
type: string;
|
|
274
|
+
enum: string[];
|
|
275
|
+
};
|
|
276
|
+
geoLocation: {
|
|
277
|
+
type: string;
|
|
278
|
+
nullable: boolean;
|
|
279
|
+
pattern: string;
|
|
280
|
+
description: string;
|
|
281
|
+
};
|
|
282
|
+
headers: {
|
|
283
|
+
type: string;
|
|
284
|
+
description: string;
|
|
285
|
+
additionalProperties: {
|
|
286
|
+
type: string;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
body: {
|
|
290
|
+
description: string;
|
|
291
|
+
oneOf: ({
|
|
292
|
+
type: string;
|
|
293
|
+
format: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: string;
|
|
296
|
+
format?: undefined;
|
|
297
|
+
})[];
|
|
298
|
+
};
|
|
299
|
+
writeRedactionMode: {
|
|
300
|
+
type: string;
|
|
301
|
+
description: string;
|
|
302
|
+
enum: string[];
|
|
303
|
+
};
|
|
304
|
+
additionalClientOptions: {
|
|
305
|
+
type: string;
|
|
306
|
+
description: string;
|
|
307
|
+
nullable: boolean;
|
|
308
|
+
properties: {
|
|
309
|
+
supportedProtocolVersions: {
|
|
310
|
+
type: string;
|
|
311
|
+
minItems: number;
|
|
312
|
+
uniqueItems: boolean;
|
|
313
|
+
items: {
|
|
314
|
+
type: string;
|
|
315
|
+
enum: string[];
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
responseMatches: {
|
|
321
|
+
type: string;
|
|
322
|
+
minItems: number;
|
|
323
|
+
uniqueItems: boolean;
|
|
324
|
+
description: string;
|
|
325
|
+
items: {
|
|
326
|
+
type: string;
|
|
327
|
+
required: string[];
|
|
328
|
+
properties: {
|
|
329
|
+
value: {
|
|
330
|
+
type: string;
|
|
331
|
+
description: string;
|
|
332
|
+
};
|
|
333
|
+
type: {
|
|
334
|
+
type: string;
|
|
335
|
+
description: string;
|
|
336
|
+
enum: string[];
|
|
337
|
+
};
|
|
338
|
+
invert: {
|
|
339
|
+
type: string;
|
|
340
|
+
description: string;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
additionalProperties: boolean;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
responseRedactions: {
|
|
347
|
+
type: string;
|
|
348
|
+
uniqueItems: boolean;
|
|
349
|
+
description: string;
|
|
350
|
+
items: {
|
|
351
|
+
type: string;
|
|
352
|
+
properties: {
|
|
353
|
+
xPath: {
|
|
354
|
+
type: string;
|
|
355
|
+
nullable: boolean;
|
|
356
|
+
description: string;
|
|
357
|
+
};
|
|
358
|
+
jsonPath: {
|
|
359
|
+
type: string;
|
|
360
|
+
nullable: boolean;
|
|
361
|
+
description: string;
|
|
362
|
+
};
|
|
363
|
+
regex: {
|
|
364
|
+
type: string;
|
|
365
|
+
nullable: boolean;
|
|
366
|
+
description: string;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
additionalProperties: boolean;
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
paramValues: {
|
|
373
|
+
type: string;
|
|
374
|
+
description: string;
|
|
375
|
+
additionalProperties: {
|
|
376
|
+
type: string;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
additionalProperties: boolean;
|
|
381
|
+
};
|
|
382
|
+
secretParameters: {
|
|
383
|
+
title: string;
|
|
384
|
+
type: string;
|
|
385
|
+
description: string;
|
|
386
|
+
properties: {
|
|
387
|
+
cookieStr: {
|
|
388
|
+
type: string;
|
|
389
|
+
description: string;
|
|
390
|
+
};
|
|
391
|
+
authorisationHeader: {
|
|
392
|
+
type: string;
|
|
393
|
+
description: string;
|
|
394
|
+
};
|
|
395
|
+
headers: {
|
|
396
|
+
type: string;
|
|
397
|
+
description: string;
|
|
398
|
+
additionalProperties: {
|
|
399
|
+
type: string;
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
paramValues: {
|
|
403
|
+
type: string;
|
|
404
|
+
description: string;
|
|
405
|
+
additionalProperties: {
|
|
406
|
+
type: string;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
additionalProperties: boolean;
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* Generated file. Do not edit */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.PROVIDER_SCHEMAS = exports.HttpProviderSecretParametersJson = exports.HttpProviderParametersJson = void 0;
|
|
6
|
+
exports.HttpProviderParametersJson = { "title": "HttpProviderParameters", "type": "object", "required": ["url", "method", "responseMatches"], "properties": { "url": { "type": "string", "format": "url", "description": "which URL does the request have to be made to Has to be a valid https URL for eg. https://amazon.in/orders?q=abcd" }, "method": { "type": "string", "enum": ["GET", "POST", "PUT", "PATCH"] }, "geoLocation": { "type": "string", "nullable": true, "pattern": "^[A-Za-z]{0,2}$", "description": "Specify the geographical location from where to proxy the request. 2-letter ISO country code" }, "headers": { "type": "object", "description": "Any additional headers to be sent with the request Note: these will be revealed to the attestor & won't be redacted from the transcript. To add hidden headers, use 'secretParams.headers' instead", "additionalProperties": { "type": "string" } }, "body": { "description": "Body of the HTTP request", "oneOf": [{ "type": "string", "format": "binary" }, { "type": "string" }] }, "writeRedactionMode": { "type": "string", "description": "If the API doesn't perform well with the \"key-update\" method of redaction, you can switch to \"zk\" mode by setting this to \"zk\"", "enum": ["zk", "key-update"] }, "additionalClientOptions": { "type": "object", "description": "Apply TLS configuration when creating the tunnel to the attestor.", "nullable": true, "properties": { "supportedProtocolVersions": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "enum": ["TLS1_2", "TLS1_3"] } } } }, "responseMatches": { "type": "array", "minItems": 1, "uniqueItems": true, "description": "The attestor will use this list to check that the redacted response does indeed match all the provided strings/regexes", "items": { "type": "object", "required": ["value", "type"], "properties": { "value": { "type": "string", "description": "\"regex\": the response must match the regex \"contains\": the response must contain the provided\n string exactly" }, "type": { "type": "string", "description": "The string/regex to match against", "enum": ["regex", "contains"] }, "invert": { "type": "boolean", "description": "Inverses the matching logic. Fail when match is found and proceed otherwise" } }, "additionalProperties": false } }, "responseRedactions": { "type": "array", "uniqueItems": true, "description": "which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\") * To disable any redactions, pass an empty array", "items": { "type": "object", "properties": { "xPath": { "type": "string", "nullable": true, "description": "expect an HTML response, and to contain a certain xpath for eg. \"/html/body/div.a1/div.a2/span.a5\"" }, "jsonPath": { "type": "string", "nullable": true, "description": "expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'" }, "regex": { "type": "string", "nullable": true, "description": "select a regex match from the response" } }, "additionalProperties": false } }, "paramValues": { "type": "object", "description": "A map of parameter values which are user in form of {{param}} in URL, responseMatches, responseRedactions, body, geolocation. Those in URL, responseMatches & geo will be put into context and signed This value will NOT be included in provider hash", "additionalProperties": { "type": "string" } } }, "additionalProperties": false };
|
|
7
|
+
exports.HttpProviderSecretParametersJson = { "title": "HttpProviderSecretParameters", "type": "object", "description": "Secret parameters to be used with HTTP provider. None of the values in this object will be shown to the attestor", "properties": { "cookieStr": { "type": "string", "description": "cookie string for authorisation." }, "authorisationHeader": { "type": "string", "description": "authorisation header value" }, "headers": { "type": "object", "description": "Headers that need to be hidden from the attestor", "additionalProperties": { "type": "string" } }, "paramValues": { "type": "object", "description": "A map of parameter values which are user in form of {{param}} in body these parameters will NOT be shown to attestor and extracted", "additionalProperties": { "type": "string" } } }, "additionalProperties": false };
|
|
8
|
+
exports.PROVIDER_SCHEMAS = {
|
|
9
|
+
http: {
|
|
10
|
+
parameters: exports.HttpProviderParametersJson,
|
|
11
|
+
secretParameters: exports.HttpProviderSecretParametersJson
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZXJzLmdlbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9wcm92aWRlcnMuZ2VuLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxvQkFBb0I7QUFDcEIsaUNBQWlDOzs7QUFrRnBCLFFBQUEsMEJBQTBCLEdBQUcsRUFBQyxPQUFPLEVBQUMsd0JBQXdCLEVBQUMsTUFBTSxFQUFDLFFBQVEsRUFBQyxVQUFVLEVBQUMsQ0FBQyxLQUFLLEVBQUMsUUFBUSxFQUFDLGlCQUFpQixDQUFDLEVBQUMsWUFBW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UMsRUFBQyxNQUFNLEVBQUMsUUFBUSxFQUFDLEVBQUMsRUFBQyxFQUFDLHNCQUFzQixFQUFDLEtBQUssRUFBQyxDQUFBO0FBUTV3QixRQUFBLGdCQUFnQixHQUFHO0lBQy9CLElBQUksRUFBRTtRQUNMLFVBQVUsRUFBRSxrQ0FBMEI7UUFDdEMsZ0JBQWdCLEVBQUUsd0NBQWdDO0tBQ2xEO0NBQ0QsQ0FBQSJ9
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL3Byb3ZpZGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RPCMessage, TunnelDisconnectEvent, TunnelMessage } from 'src/proto/api';
|
|
2
|
+
import type { AttestorError } from 'src/utils/error';
|
|
3
|
+
type ExtractPrefix<T, S extends string> = T extends `${infer _}${S}` ? _ : never;
|
|
4
|
+
export type RPCType = ExtractPrefix<keyof RPCMessage, 'Request'>;
|
|
5
|
+
type RPCRequestType<T extends RPCType> = `${T}Request`;
|
|
6
|
+
type RPCResponseType<T extends RPCType> = `${T}Response`;
|
|
7
|
+
export type RPCRequestData<T extends RPCType> = Exclude<RPCMessage[RPCRequestType<T>], undefined>;
|
|
8
|
+
export type RPCResponseData<T extends RPCType> = Exclude<RPCMessage[RPCResponseType<T>], undefined>;
|
|
9
|
+
export type RPCRequest<T extends RPCType> = {
|
|
10
|
+
requestId: RPCMessage['id'];
|
|
11
|
+
type: T;
|
|
12
|
+
data: RPCRequestData<T>;
|
|
13
|
+
respond(res: RPCResponseData<T> | AttestorError): void;
|
|
14
|
+
};
|
|
15
|
+
export type RPCResponse<T extends RPCType> = {
|
|
16
|
+
id: RPCMessage['id'];
|
|
17
|
+
type: T;
|
|
18
|
+
data: RPCResponseData<T>;
|
|
19
|
+
} | {
|
|
20
|
+
id: RPCMessage['id'];
|
|
21
|
+
error: AttestorError;
|
|
22
|
+
};
|
|
23
|
+
export type RPCEventMap = {
|
|
24
|
+
'connection-terminated': AttestorError;
|
|
25
|
+
'tunnel-message': TunnelMessage;
|
|
26
|
+
'tunnel-disconnect-event': TunnelDisconnectEvent;
|
|
27
|
+
'rpc-request': RPCRequest<RPCType>;
|
|
28
|
+
'rpc-response': RPCResponse<RPCType>;
|
|
29
|
+
};
|
|
30
|
+
export type RPCEventType = keyof RPCEventMap;
|
|
31
|
+
export interface RPCEvent<T extends RPCEventType> extends Event {
|
|
32
|
+
type: T;
|
|
33
|
+
data: RPCEventMap[T];
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/lib/types/rpc.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type PrivateKey = string;
|
|
2
|
+
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
export type ServiceSignatureProvider = {
|
|
4
|
+
/**
|
|
5
|
+
* Returns public key in compressed (compact) format used in Reclaim RPC calls
|
|
6
|
+
* @param privateKey corresponding private key in raw o hex form
|
|
7
|
+
*/
|
|
8
|
+
getPublicKey(privateKey: PrivateKey): Uint8Array;
|
|
9
|
+
/**
|
|
10
|
+
* Returns address corresponding to the provided public key
|
|
11
|
+
* @param publicKey raw o hex form, compressed or uncompressed
|
|
12
|
+
*/
|
|
13
|
+
getAddress(publicKey: Uint8Array): string;
|
|
14
|
+
/**
|
|
15
|
+
* Signs data with the provided private key
|
|
16
|
+
* @param data raw data to be signed
|
|
17
|
+
* @param privateKey private key in raw or hex format
|
|
18
|
+
*/
|
|
19
|
+
sign(data: Uint8Array, privateKey: PrivateKey): Awaitable<Uint8Array>;
|
|
20
|
+
/**
|
|
21
|
+
* Verifies signature against provided data and an address
|
|
22
|
+
* @param data raw data to be verified. Must be same as used in sign() call
|
|
23
|
+
* @param signature signature bytes or string
|
|
24
|
+
* @param addressBytes address corresponding to a public key
|
|
25
|
+
*/
|
|
26
|
+
verify(data: Uint8Array, signature: Uint8Array | string, addressBytes: Uint8Array | string): Awaitable<boolean>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmF0dXJlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9zaWduYXR1cmVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CreateTunnelRequest } from 'src/proto/api';
|
|
2
|
+
export type MakeTunnelBaseOpts<O> = O & {
|
|
3
|
+
onClose?(err?: Error): void;
|
|
4
|
+
onMessage?(data: Uint8Array): void;
|
|
5
|
+
};
|
|
6
|
+
export type Tunnel<E> = E & {
|
|
7
|
+
write(data: Uint8Array): void;
|
|
8
|
+
close(err?: Error): void;
|
|
9
|
+
};
|
|
10
|
+
export type MakeTunnelFn<O, E = {}> = (opts: MakeTunnelBaseOpts<O>) => (Tunnel<E> | Promise<Tunnel<E>>);
|
|
11
|
+
export type Transcript<T> = {
|
|
12
|
+
sender: 'client' | 'server';
|
|
13
|
+
message: T;
|
|
14
|
+
}[];
|
|
15
|
+
export type TCPSocketProperties = {
|
|
16
|
+
transcript: Transcript<Uint8Array>;
|
|
17
|
+
createRequest: Pick<CreateTunnelRequest, 'host' | 'port' | 'geoLocation'>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHVubmVsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R5cGVzL3R1bm5lbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EncryptionAlgorithm, ZKOperator } from '@reclaimprotocol/circom-symmetric-crypto';
|
|
2
|
+
export type ZKOperators = {
|
|
3
|
+
[E in EncryptionAlgorithm]?: ZKOperator;
|
|
4
|
+
};
|
|
5
|
+
export type ZKEngine = 'snarkJS' | 'gnark';
|
|
6
|
+
export type PrepareZKProofsBaseOpts = {
|
|
7
|
+
/** get ZK operator for specified algorithm */
|
|
8
|
+
zkOperators?: ZKOperators;
|
|
9
|
+
/**
|
|
10
|
+
* max number of ZK proofs to generate concurrently
|
|
11
|
+
* @default 1
|
|
12
|
+
*/
|
|
13
|
+
zkProofConcurrency?: number;
|
|
14
|
+
maxZkChunks?: number;
|
|
15
|
+
zkEngine?: ZKEngine;
|
|
16
|
+
};
|
package/lib/types/zk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Benchmark(): Promise<string>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Benchmark = Benchmark;
|
|
4
|
+
const tls_1 = require("@reclaimprotocol/tls");
|
|
5
|
+
const logger_1 = require("src/utils/logger");
|
|
6
|
+
const zk_1 = require("src/utils/zk");
|
|
7
|
+
const ZK_CIPHER_SUITES = [
|
|
8
|
+
'TLS_CHACHA20_POLY1305_SHA256',
|
|
9
|
+
'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
|
|
10
|
+
'TLS_AES_128_GCM_SHA256'
|
|
11
|
+
];
|
|
12
|
+
async function Benchmark() {
|
|
13
|
+
let benchmarkRes = '';
|
|
14
|
+
for (const cipherSuite of ZK_CIPHER_SUITES) {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
const alg = cipherSuite.includes('CHACHA20')
|
|
17
|
+
? 'CHACHA20-POLY1305'
|
|
18
|
+
: (cipherSuite.includes('AES_256_GCM')
|
|
19
|
+
? 'AES-256-GCM'
|
|
20
|
+
: 'AES-128-GCM');
|
|
21
|
+
const keylength = alg === 'AES-128-GCM' ? 16 : 32;
|
|
22
|
+
const key = Buffer.alloc(keylength, 0);
|
|
23
|
+
const { ivLength: fixedIvLength, } = tls_1.SUPPORTED_CIPHER_SUITE_MAP[cipherSuite];
|
|
24
|
+
const fixedIv = Buffer.alloc(fixedIvLength, 0);
|
|
25
|
+
const encKey = await tls_1.crypto.importKey(alg, key);
|
|
26
|
+
const vectors = [
|
|
27
|
+
{
|
|
28
|
+
plaintext: 'My cool API secret is "my name jeff". Please don\'t reveal it'
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
const proofGenerator = await (0, zk_1.makeZkProofGenerator)({
|
|
32
|
+
logger: logger_1.logger,
|
|
33
|
+
cipherSuite,
|
|
34
|
+
});
|
|
35
|
+
for (const { plaintext } of vectors) {
|
|
36
|
+
const plaintextArr = (0, tls_1.strToUint8Array)(plaintext);
|
|
37
|
+
const { ciphertext, iv } = await (0, tls_1.encryptWrappedRecord)(plaintextArr, {
|
|
38
|
+
key: encKey,
|
|
39
|
+
iv: fixedIv,
|
|
40
|
+
recordNumber: 0,
|
|
41
|
+
recordHeaderOpts: {
|
|
42
|
+
type: 'WRAPPED_RECORD'
|
|
43
|
+
},
|
|
44
|
+
cipherSuite,
|
|
45
|
+
version: cipherSuite.includes('ECDHE_')
|
|
46
|
+
? 'TLS1_2'
|
|
47
|
+
: 'TLS1_3',
|
|
48
|
+
});
|
|
49
|
+
const packet = {
|
|
50
|
+
type: 'ciphertext',
|
|
51
|
+
encKey,
|
|
52
|
+
iv,
|
|
53
|
+
recordNumber: 0,
|
|
54
|
+
plaintext: plaintextArr,
|
|
55
|
+
ciphertext,
|
|
56
|
+
fixedIv: new Uint8Array(0),
|
|
57
|
+
data: ciphertext
|
|
58
|
+
};
|
|
59
|
+
await proofGenerator.addPacketToProve(packet, {
|
|
60
|
+
type: 'zk',
|
|
61
|
+
redactedPlaintext: plaintextArr,
|
|
62
|
+
}, () => { });
|
|
63
|
+
await proofGenerator.generateProofs();
|
|
64
|
+
}
|
|
65
|
+
benchmarkRes = benchmarkRes + `Benchmark ${alg} ok. Took ${Date.now() - now} ms \n`;
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.info(benchmarkRes);
|
|
68
|
+
return benchmarkRes;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVuY2htYXJrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2JlbmNobWFyay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQWlCQSw4QkErRUM7QUFoR0QsOENBSzZCO0FBRTdCLDZDQUF5QztBQUN6QyxxQ0FBbUQ7QUFHbkQsTUFBTSxnQkFBZ0IsR0FBa0I7SUFDdkMsOEJBQThCO0lBQzlCLHlDQUF5QztJQUN6Qyx3QkFBd0I7Q0FDeEIsQ0FBQTtBQUVNLEtBQUssVUFBVSxTQUFTO0lBRTlCLElBQUksWUFBWSxHQUFHLEVBQUUsQ0FBQTtJQUNyQixLQUFJLE1BQU0sV0FBVyxJQUFJLGdCQUFnQixFQUFFLENBQUM7UUFFM0MsTUFBTSxHQUFHLEdBQUcsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFBO1FBRXRCLE1BQU0sR0FBRyxHQUFHLFdBQVcsQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUFDO1lBQzNDLENBQUMsQ0FBQyxtQkFBbUI7WUFDckIsQ0FBQyxDQUFDLENBQ0QsV0FBVyxDQUFDLFFB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