@reclaimprotocol/attestor-core 3.1.1 → 4.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.
Files changed (110) hide show
  1. package/lib/avs/contracts/index.js +18 -8
  2. package/lib/avs/tests/test.operator.js +4 -4
  3. package/lib/avs/utils/tasks.d.ts +1 -1
  4. package/lib/client/create-claim.d.ts +2 -2
  5. package/lib/client/create-claim.js +100 -34
  6. package/lib/client/tunnels/make-rpc-tcp-tunnel.js +3 -3
  7. package/lib/client/tunnels/make-rpc-tls-tunnel.js +3 -3
  8. package/lib/client/utils/client-socket.d.ts +3 -1
  9. package/lib/client/utils/client-socket.js +25 -8
  10. package/lib/client/utils/message-handler.js +2 -2
  11. package/lib/config/index.d.ts +9 -2
  12. package/lib/config/index.js +10 -4
  13. package/lib/index.js +18 -8
  14. package/lib/proto/api.d.ts +81 -2
  15. package/lib/proto/api.js +859 -101
  16. package/lib/providers/http/index.js +220 -116
  17. package/lib/providers/http/utils.d.ts +3 -6
  18. package/lib/providers/http/utils.js +13 -11
  19. package/lib/providers/index.js +1 -3
  20. package/lib/scripts/check-avs-registration.js +2 -2
  21. package/lib/scripts/generate-provider-types.js +2 -2
  22. package/lib/scripts/generate-receipt.js +6 -3
  23. package/lib/scripts/generate-toprf-keys.d.ts +1 -0
  24. package/lib/scripts/generate-toprf-keys.js +23 -0
  25. package/lib/scripts/register-avs-operator.js +2 -2
  26. package/lib/scripts/start-server.js +10 -3
  27. package/lib/scripts/update-avs-metadata.js +2 -2
  28. package/lib/scripts/verify-root-ca.js +2 -2
  29. package/lib/scripts/whitelist-operator.js +2 -2
  30. package/lib/server/create-server.js +14 -7
  31. package/lib/server/handlers/claimTunnel.js +34 -11
  32. package/lib/server/handlers/createTunnel.js +45 -9
  33. package/lib/server/handlers/disconnectTunnel.js +2 -2
  34. package/lib/server/handlers/index.js +4 -2
  35. package/lib/server/handlers/init.js +17 -2
  36. package/lib/server/handlers/toprf.d.ts +2 -0
  37. package/lib/server/handlers/toprf.js +21 -0
  38. package/lib/server/socket.d.ts +5 -3
  39. package/lib/server/socket.js +28 -8
  40. package/lib/server/tunnels/make-tcp-tunnel.js +22 -29
  41. package/lib/server/utils/apm.js +9 -5
  42. package/lib/server/utils/assert-valid-claim-request.d.ts +3 -3
  43. package/lib/server/utils/assert-valid-claim-request.js +27 -16
  44. package/lib/server/utils/dns.d.ts +1 -0
  45. package/lib/server/utils/dns.js +22 -0
  46. package/lib/server/utils/generics.d.ts +1 -1
  47. package/lib/tests/describe-with-server.d.ts +0 -2
  48. package/lib/tests/describe-with-server.js +1 -4
  49. package/lib/tests/mock-provider-server.d.ts +1 -1
  50. package/lib/tests/test.auth.d.ts +1 -0
  51. package/lib/tests/test.auth.js +75 -0
  52. package/lib/tests/test.bgp-listener.d.ts +1 -0
  53. package/lib/tests/test.bgp-listener.js +169 -0
  54. package/lib/tests/test.claim-creation.js +101 -8
  55. package/lib/tests/test.http-parser.d.ts +1 -1
  56. package/lib/tests/test.http-parser.js +7 -5
  57. package/lib/tests/test.http-provider-utils.js +489 -211
  58. package/lib/tests/test.http-provider.js +77 -6
  59. package/lib/tests/test.rpc-tunnel.js +10 -6
  60. package/lib/tests/test.zk.d.ts +1 -1
  61. package/lib/tests/test.zk.js +180 -12
  62. package/lib/tests/utils.d.ts +6 -0
  63. package/lib/tests/utils.js +16 -1
  64. package/lib/types/bgp.d.ts +11 -0
  65. package/lib/types/bgp.js +3 -0
  66. package/lib/types/claims.d.ts +14 -5
  67. package/lib/types/client.d.ts +30 -3
  68. package/lib/types/general.d.ts +12 -0
  69. package/lib/types/handlers.d.ts +4 -4
  70. package/lib/types/index.d.ts +1 -0
  71. package/lib/types/index.js +2 -1
  72. package/lib/types/providers.d.ts +25 -10
  73. package/lib/types/providers.gen.d.ts +14 -155
  74. package/lib/types/providers.gen.js +2 -6
  75. package/lib/types/tunnel.d.ts +2 -2
  76. package/lib/types/zk.d.ts +11 -3
  77. package/lib/utils/auth.d.ts +7 -0
  78. package/lib/utils/auth.js +64 -0
  79. package/lib/utils/b64-json.d.ts +2 -0
  80. package/lib/utils/b64-json.js +23 -0
  81. package/lib/utils/bgp-listener.d.ts +7 -0
  82. package/lib/utils/bgp-listener.js +126 -0
  83. package/lib/utils/claims.js +3 -3
  84. package/lib/utils/generics.d.ts +5 -5
  85. package/lib/utils/generics.js +3 -3
  86. package/lib/utils/http-parser.d.ts +4 -0
  87. package/lib/utils/http-parser.js +4 -2
  88. package/lib/utils/index.d.ts +2 -0
  89. package/lib/utils/index.js +3 -1
  90. package/lib/utils/redactions.d.ts +19 -6
  91. package/lib/utils/redactions.js +41 -4
  92. package/lib/utils/socket-base.d.ts +3 -2
  93. package/lib/utils/socket-base.js +7 -2
  94. package/lib/utils/ws.d.ts +5 -5
  95. package/lib/utils/ws.js +27 -10
  96. package/lib/utils/zk.d.ts +12 -7
  97. package/lib/utils/zk.js +261 -67
  98. package/lib/window-rpc/setup-window-rpc.js +29 -8
  99. package/lib/window-rpc/types.d.ts +16 -21
  100. package/lib/window-rpc/utils.d.ts +2 -1
  101. package/lib/window-rpc/utils.js +28 -2
  102. package/lib/window-rpc/window-rpc-zk.d.ts +8 -3
  103. package/lib/window-rpc/window-rpc-zk.js +58 -45
  104. package/package.json +25 -22
  105. package/lib/providers/httpb64/index.d.ts +0 -3
  106. package/lib/providers/httpb64/index.js +0 -209
  107. package/lib/providers/httpb64/utils.d.ts +0 -77
  108. package/lib/providers/httpb64/utils.js +0 -358
  109. package/lib/server/utils/verify-server-certificates.d.ts +0 -7
  110. package/lib/server/utils/verify-server-certificates.js +0 -101
@@ -1,4 +1,6 @@
1
- import type { InitRequest, RPCMessage, RPCMessages, ServiceSignatureType, TunnelMessage } from '../proto/api';
1
+ import type { IncomingMessage } from 'http';
2
+ import type { AuthenticationRequest, InitRequest, InitResponse, RPCMessage, RPCMessages, ServiceSignatureType, TunnelMessage } from '../proto/api';
3
+ import type { BGPListener } from '../types/bgp';
2
4
  import type { Logger } from '../types/general';
3
5
  import type { RPCEvent, RPCEventMap, RPCEventType, RPCRequestData, RPCResponseData, RPCType } from '../types/rpc';
4
6
  import type { TCPSocketProperties, Tunnel } from '../types/tunnel';
@@ -8,12 +10,30 @@ import type { WebSocket as WSWebSocket } from 'ws';
8
10
  * WebSocket or the WebSocket from the `ws` package.
9
11
  */
10
12
  export type AnyWebSocket = WebSocket | WSWebSocket;
11
- export type AnyWebSocketConstructor = new (url: string | URL) => AnyWebSocket;
13
+ export type MakeWebSocket = (url: string | URL) => AnyWebSocket;
14
+ export type AcceptNewConnectionOpts = {
15
+ req: IncomingMessage;
16
+ logger: Logger;
17
+ bgpListener?: BGPListener;
18
+ };
19
+ export type IAttestorClientInitParams = {
20
+ /**
21
+ * Attestor WS URL
22
+ */
23
+ url: string | URL;
24
+ /**
25
+ * If the attestor being connected to has authentication
26
+ * enabled, provide the authentication request here, or a
27
+ * function that will return the authentication request.
28
+ */
29
+ authRequest?: AuthenticationRequest | (() => Promise<AuthenticationRequest>);
30
+ };
12
31
  export type IAttestorClientCreateOpts = {
13
32
  /**
14
33
  * Attestor WS URL
15
34
  */
16
35
  url: string | URL;
36
+ authRequest?: AuthenticationRequest;
17
37
  signatureType?: ServiceSignatureType;
18
38
  logger?: Logger;
19
39
  /**
@@ -26,7 +46,7 @@ export type IAttestorClientCreateOpts = {
26
46
  * Provide a custom WebSocket implementation,
27
47
  * will use the native WebSocket if not provided.
28
48
  */
29
- Websocket?: AnyWebSocketConstructor;
49
+ makeWebSocket?: MakeWebSocket;
30
50
  };
31
51
  /**
32
52
  * Base layer for the WebSocket connection on
@@ -101,8 +121,11 @@ export declare class IAttestorServerSocket extends IAttestorSocket {
101
121
  * If the tunnel does not exist, it will throw an error.
102
122
  */
103
123
  getTunnel(tunnelId: TunnelMessage['tunnelId']): Tunnel<TCPSocketProperties>;
124
+ removeTunnel(tunnelId: TunnelMessage['tunnelId']): void;
125
+ bgpListener?: BGPListener;
104
126
  }
105
127
  export declare class IAttestorClient extends IAttestorSocket {
128
+ initResponse?: InitResponse;
106
129
  constructor(opts: IAttestorClientCreateOpts);
107
130
  /**
108
131
  * Waits for a particular message to come in.
@@ -124,6 +147,10 @@ interface WebSocketWithServerSocket {
124
147
  * Our RPC socket instance
125
148
  */
126
149
  serverSocket?: IAttestorServerSocket;
150
+ /**
151
+ * Just promisified send
152
+ */
153
+ sendPromise?: (data: Uint8Array) => Promise<void>;
127
154
  }
128
155
  declare module 'ws' {
129
156
  namespace WebSocket {
@@ -1,4 +1,5 @@
1
1
  import type { Logger as TLSLogger, TLSPacketContext, TLSProtocolVersion } from '@reclaimprotocol/tls';
2
+ import type { TOPRFProofParams } from '../types/zk';
2
3
  /**
3
4
  * Represents a slice of any array or string
4
5
  */
@@ -6,6 +7,16 @@ export type ArraySlice = {
6
7
  fromIndex: number;
7
8
  toIndex: number;
8
9
  };
10
+ export type RedactedOrHashedArraySlice = {
11
+ fromIndex: number;
12
+ toIndex: number;
13
+ /**
14
+ * By default, the the data is redacted. Instead if you'd like
15
+ * a deterministic hash, set this to 'oprf'
16
+ * @default undefined
17
+ */
18
+ hash?: 'oprf';
19
+ };
9
20
  export type Logger = TLSLogger & {
10
21
  child: (opts: {
11
22
  [_: string]: any;
@@ -15,6 +26,7 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'trace' | 'fatal';
15
26
  export type ZKRevealInfo = {
16
27
  type: 'zk';
17
28
  redactedPlaintext: Uint8Array;
29
+ toprfs?: TOPRFProofParams[];
18
30
  };
19
31
  export type MessageRevealInfo = {
20
32
  type: 'complete';
@@ -1,7 +1,7 @@
1
- import { Transaction } from 'elastic-apm-node';
2
- import { IAttestorServerSocket } from '../types/client';
3
- import { Logger } from '../types/general';
4
- import { RPCRequestData, RPCResponseData, RPCType } from '../types/rpc';
1
+ import type { Transaction } from 'elastic-apm-node';
2
+ import type { IAttestorServerSocket } from '../types/client';
3
+ import type { Logger } from '../types/general';
4
+ import type { RPCRequestData, RPCResponseData, RPCType } from '../types/rpc';
5
5
  export type RPCHandlerMetadata = {
6
6
  logger: Logger;
7
7
  tx?: Transaction;
@@ -7,3 +7,4 @@ export * from './client';
7
7
  export * from './rpc';
8
8
  export * from './tunnel';
9
9
  export * from './handlers';
10
+ export * from './bgp';
@@ -23,4 +23,5 @@ __exportStar(require("./client"), exports);
23
23
  __exportStar(require("./rpc"), exports);
24
24
  __exportStar(require("./tunnel"), exports);
25
25
  __exportStar(require("./handlers"), exports);
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhDQUEyQjtBQUMzQiw0Q0FBeUI7QUFDekIsK0NBQTRCO0FBQzVCLDJDQUF3QjtBQUN4Qix1Q0FBb0I7QUFDcEIsMkNBQXdCO0FBQ3hCLHdDQUFxQjtBQUNyQiwyQ0FBd0I7QUFDeEIsNkNBQTBCIn0=
26
+ __exportStar(require("./bgp"), exports);
27
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDhDQUEyQjtBQUMzQiw0Q0FBeUI7QUFDekIsK0NBQTRCO0FBQzVCLDJDQUF3QjtBQUN4Qix1Q0FBb0I7QUFDcEIsMkNBQXdCO0FBQ3hCLHdDQUFxQjtBQUNyQiwyQ0FBd0I7QUFDeEIsNkNBQTBCO0FBQzFCLHdDQUFxQiJ9
@@ -1,6 +1,6 @@
1
1
  import type { TLSConnectionOptions } from '@reclaimprotocol/tls';
2
- import type { ProviderClaimData } from '../proto/api';
3
- import type { ArraySlice } from '../types/general';
2
+ import type { AttestorVersion, ProviderClaimData } from '../proto/api';
3
+ import type { ArraySlice, Logger, RedactedOrHashedArraySlice } from '../types/general';
4
4
  import type { ProvidersConfig } from '../types/providers.gen';
5
5
  import type { Transcript } from '../types/tunnel';
6
6
  export type AttestorData = {
@@ -22,7 +22,22 @@ export type ProviderName = keyof ProvidersConfig;
22
22
  export type ProviderParams<T extends ProviderName> = ProvidersConfig[T]['parameters'];
23
23
  export type ProviderSecretParams<T extends ProviderName> = ProvidersConfig[T]['secretParameters'];
24
24
  export type RedactionMode = 'key-update' | 'zk';
25
- export type ProviderField<Params, T> = T | ((params: Params) => T);
25
+ export type ProviderField<Params, SecretParams, T> = T | ((params: Params, secretParams?: SecretParams) => T);
26
+ export type ProviderCtx = {
27
+ version: AttestorVersion;
28
+ };
29
+ type GetResponseRedactionsOpts<P> = {
30
+ response: Uint8Array;
31
+ params: P;
32
+ logger: Logger;
33
+ ctx: ProviderCtx;
34
+ };
35
+ type AssertValidProviderReceipt<P> = {
36
+ receipt: Transcript<Uint8Array>;
37
+ params: P;
38
+ logger: Logger;
39
+ ctx: ProviderCtx;
40
+ };
26
41
  /**
27
42
  * Generic interface for a provider that can be used to verify
28
43
  * claims on a TLS receipt
@@ -43,16 +58,16 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
43
58
  *
44
59
  * Eg. "www.google.com:443", (p) => p.url.host
45
60
  * */
46
- hostPort: ProviderField<Params, string>;
61
+ hostPort: ProviderField<Params, SecretParams, string>;
47
62
  /**
48
63
  * Which geo location to send the request from
49
64
  * Provide 2 letter country code, or a function
50
65
  * that returns the country code
51
66
  * @example "US", "IN"
52
67
  */
53
- geoLocation?: ProviderField<Params, string | undefined>;
68
+ geoLocation?: ProviderField<Params, SecretParams, string | undefined>;
54
69
  /** extra options to pass to the client like root CA certificates */
55
- additionalClientOptions?: ProviderField<Params, TLSConnectionOptions | undefined>;
70
+ additionalClientOptions?: ProviderField<Params, SecretParams, TLSConnectionOptions | undefined>;
56
71
  /**
57
72
  * default redaction mode to use. If not specified,
58
73
  * the default is 'key-update'.
@@ -62,9 +77,9 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
62
77
  *
63
78
  * @default 'key-update'
64
79
  */
65
- writeRedactionMode?: ProviderField<Params, RedactionMode | undefined>;
80
+ writeRedactionMode?: ProviderField<Params, SecretParams, RedactionMode | undefined>;
66
81
  /** generate the raw request to be sent to through the TLS receipt */
67
- createRequest(secretParams: SecretParams, params: Params): CreateRequestResult;
82
+ createRequest(secretParams: SecretParams, params: Params, logger: Logger): CreateRequestResult;
68
83
  /**
69
84
  * Return the slices of the response to redact
70
85
  * Eg. if the response is "hello my secret is xyz",
@@ -74,7 +89,7 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
74
89
  * This is run on the client side, to selct which portions of
75
90
  * the server response to send to the attestor
76
91
  * */
77
- getResponseRedactions?(response: Uint8Array, params: Params): ArraySlice[];
92
+ getResponseRedactions?(opts: GetResponseRedactionsOpts<Params>): RedactedOrHashedArraySlice[];
78
93
  /**
79
94
  * verify a generated TLS receipt against given parameters
80
95
  * to ensure the receipt does contain the claims the
@@ -88,7 +103,7 @@ export interface Provider<N extends ProviderName, Params = ProviderParams<N>, Se
88
103
  * Optionally return parameters extracted from the receipt
89
104
  * that will then be included in the claim context
90
105
  * */
91
- assertValidProviderReceipt(receipt: Transcript<Uint8Array>, params: Params): void | Promise<void> | {
106
+ assertValidProviderReceipt(opts: AssertValidProviderReceipt<Params>): void | Promise<void> | {
92
107
  extractedParameters: {
93
108
  [key: string]: string;
94
109
  };
@@ -6,7 +6,7 @@ export interface HttpProviderParameters {
6
6
  url: string;
7
7
  method: "GET" | "POST" | "PUT" | "PATCH";
8
8
  /**
9
- * Specify the geographical location from where to proxy the request. 2-letter ISO country code
9
+ * Specify the geographical location from where to proxy the request. 2-letter ISO country code or parameter (public or secret)
10
10
  */
11
11
  geoLocation?: string;
12
12
  /**
@@ -68,6 +68,13 @@ export interface HttpProviderParameters {
68
68
  * select a regex match from the response
69
69
  */
70
70
  regex?: string;
71
+ /**
72
+ * If provided, the value inside will be hashed instead of being redacted. Useful for cases where the data inside is an identifiying piece of information that you don't want to reveal to the attestor, eg. an email address.
73
+ * If the hash function produces more bytes than the original value, the hash will be truncated.
74
+ * Eg. if hash is enabled, the original value is "hello", and hashed is "a1b2c", then the attestor will only see "a1b2c".
75
+ * Note: if a regex with named groups is provided, only the named groups will be hashed.
76
+ */
77
+ hash?: "oprf";
71
78
  }[];
72
79
  /**
73
80
  * 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
@@ -93,7 +100,6 @@ export declare const HttpProviderParametersJson: {
93
100
  geoLocation: {
94
101
  type: string;
95
102
  nullable: boolean;
96
- pattern: string;
97
103
  description: string;
98
104
  };
99
105
  headers: {
@@ -182,6 +188,11 @@ export declare const HttpProviderParametersJson: {
182
188
  nullable: boolean;
183
189
  description: string;
184
190
  };
191
+ hash: {
192
+ type: string;
193
+ description: string;
194
+ enum: string[];
195
+ };
185
196
  };
186
197
  additionalProperties: boolean;
187
198
  };
@@ -256,10 +267,6 @@ export interface ProvidersConfig {
256
267
  parameters: HttpProviderParameters;
257
268
  secretParameters: HttpProviderSecretParameters;
258
269
  };
259
- httpb64: {
260
- parameters: HttpProviderParameters;
261
- secretParameters: HttpProviderSecretParameters;
262
- };
263
270
  }
264
271
  export declare const PROVIDER_SCHEMAS: {
265
272
  http: {
@@ -280,7 +287,6 @@ export declare const PROVIDER_SCHEMAS: {
280
287
  geoLocation: {
281
288
  type: string;
282
289
  nullable: boolean;
283
- pattern: string;
284
290
  description: string;
285
291
  };
286
292
  headers: {
@@ -369,158 +375,11 @@ export declare const PROVIDER_SCHEMAS: {
369
375
  nullable: boolean;
370
376
  description: string;
371
377
  };
372
- };
373
- additionalProperties: boolean;
374
- };
375
- };
376
- paramValues: {
377
- type: string;
378
- description: string;
379
- additionalProperties: {
380
- type: string;
381
- };
382
- };
383
- };
384
- additionalProperties: boolean;
385
- };
386
- secretParameters: {
387
- title: string;
388
- type: string;
389
- description: string;
390
- properties: {
391
- cookieStr: {
392
- type: string;
393
- description: string;
394
- };
395
- authorisationHeader: {
396
- type: string;
397
- description: string;
398
- };
399
- headers: {
400
- type: string;
401
- description: string;
402
- additionalProperties: {
403
- type: string;
404
- };
405
- };
406
- paramValues: {
407
- type: string;
408
- description: string;
409
- additionalProperties: {
410
- type: string;
411
- };
412
- };
413
- };
414
- additionalProperties: boolean;
415
- };
416
- };
417
- httpb64: {
418
- parameters: {
419
- title: string;
420
- type: string;
421
- required: string[];
422
- properties: {
423
- url: {
424
- type: string;
425
- format: string;
426
- description: string;
427
- };
428
- method: {
429
- type: string;
430
- enum: string[];
431
- };
432
- geoLocation: {
433
- type: string;
434
- nullable: boolean;
435
- pattern: string;
436
- description: string;
437
- };
438
- headers: {
439
- type: string;
440
- description: string;
441
- additionalProperties: {
442
- type: string;
443
- };
444
- };
445
- body: {
446
- description: string;
447
- oneOf: ({
448
- type: string;
449
- format: string;
450
- } | {
451
- type: string;
452
- format?: undefined;
453
- })[];
454
- };
455
- writeRedactionMode: {
456
- type: string;
457
- description: string;
458
- enum: string[];
459
- };
460
- additionalClientOptions: {
461
- type: string;
462
- description: string;
463
- nullable: boolean;
464
- properties: {
465
- supportedProtocolVersions: {
466
- type: string;
467
- minItems: number;
468
- uniqueItems: boolean;
469
- items: {
470
- type: string;
471
- enum: string[];
472
- };
473
- };
474
- };
475
- };
476
- responseMatches: {
477
- type: string;
478
- minItems: number;
479
- uniqueItems: boolean;
480
- description: string;
481
- items: {
482
- type: string;
483
- required: string[];
484
- properties: {
485
- value: {
486
- type: string;
487
- description: string;
488
- };
489
- type: {
378
+ hash: {
490
379
  type: string;
491
380
  description: string;
492
381
  enum: string[];
493
382
  };
494
- invert: {
495
- type: string;
496
- description: string;
497
- };
498
- };
499
- additionalProperties: boolean;
500
- };
501
- };
502
- responseRedactions: {
503
- type: string;
504
- uniqueItems: boolean;
505
- description: string;
506
- items: {
507
- type: string;
508
- properties: {
509
- xPath: {
510
- type: string;
511
- nullable: boolean;
512
- description: string;
513
- };
514
- jsonPath: {
515
- type: string;
516
- nullable: boolean;
517
- description: string;
518
- };
519
- regex: {
520
- type: string;
521
- nullable: boolean;
522
- description: string;
523
- };
524
383
  };
525
384
  additionalProperties: boolean;
526
385
  };
@@ -3,16 +3,12 @@
3
3
  /* Generated file. Do not edit */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
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 };
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, "description": "Specify the geographical location from where to proxy the request. 2-letter ISO country code or parameter (public or secret)" }, "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" }, "hash": { "type": "string", "description": "If provided, the value inside will be hashed instead of being redacted. Useful for cases where the data inside is an identifiying piece of information that you don't want to reveal to the attestor, eg. an email address.\nIf the hash function produces more bytes than the original value, the hash will be truncated.\nEg. if hash is enabled, the original value is \"hello\", and hashed is \"a1b2c\", then the attestor will only see \"a1b2c\".\nNote: if a regex with named groups is provided, only the named groups will be hashed.", "enum": ["oprf"] } }, "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
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
8
  exports.PROVIDER_SCHEMAS = {
9
9
  http: {
10
10
  parameters: exports.HttpProviderParametersJson,
11
11
  secretParameters: exports.HttpProviderSecretParametersJson
12
12
  },
13
- httpb64: {
14
- parameters: exports.HttpProviderParametersJson,
15
- secretParameters: exports.HttpProviderSecretParametersJson
16
- },
17
13
  };
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZXJzLmdlbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9wcm92aWRlcnMuZ2VuLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxvQkFBb0I7QUFDcEIsaUNBQWlDOzs7QUFrRnBCLFFBQUEsMEJBQTBCLEdBQUcsRUFBQyxPQUFPLEVBQUMsd0JBQXdCLEVBQUMsTUFBTSxFQUFDLFFBQVEsRUFBQyxVQUFVLEVBQUMsQ0FBQyxLQUFLLEVBQUMsUUFBUSxFQUFDLGlCQUFpQixDQUFDLEVBQUMsWUFBWSxFQUFDLEVBQUMsS0FBSyxFQUFDLEVBQUMsTU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 +4,8 @@ export type MakeTunnelBaseOpts<O> = O & {
4
4
  onMessage?(data: Uint8Array): void;
5
5
  };
6
6
  export type Tunnel<E> = E & {
7
- write(data: Uint8Array): void;
8
- close(err?: Error): void;
7
+ write(data: Uint8Array): void | Promise<void>;
8
+ close(err?: Error): void | Promise<void>;
9
9
  };
10
10
  export type MakeTunnelFn<O, E = {}> = (opts: MakeTunnelBaseOpts<O>) => (Tunnel<E> | Promise<Tunnel<E>>);
11
11
  export type Transcript<T> = {
package/lib/types/zk.d.ts CHANGED
@@ -1,15 +1,23 @@
1
- import { EncryptionAlgorithm, ZKEngine, ZKOperator } from '@reclaimprotocol/zk-symmetric-crypto';
1
+ import { EncryptionAlgorithm, OPRFOperator, ZKEngine, ZKOperator } from '@reclaimprotocol/zk-symmetric-crypto';
2
+ import { TOPRFPayload } from '../proto/api';
2
3
  export type ZKOperators = {
3
4
  [E in EncryptionAlgorithm]?: ZKOperator;
4
5
  };
6
+ export type OPRFOperators = {
7
+ [E in EncryptionAlgorithm]?: OPRFOperator;
8
+ };
5
9
  export type PrepareZKProofsBaseOpts = {
6
10
  /** get ZK operator for specified algorithm */
7
11
  zkOperators?: ZKOperators;
12
+ oprfOperators?: OPRFOperators;
8
13
  /**
9
14
  * max number of ZK proofs to generate concurrently
10
- * @default 1
15
+ * @default 10
11
16
  */
12
17
  zkProofConcurrency?: number;
13
- maxZkChunks?: number;
14
18
  zkEngine?: ZKEngine;
15
19
  };
20
+ export type TOPRFProofParams = TOPRFPayload & {
21
+ mask: Uint8Array;
22
+ plaintext: Uint8Array;
23
+ };
@@ -0,0 +1,7 @@
1
+ import { AuthenticatedUserData, AuthenticationRequest, ServiceSignatureType } from '../proto/api';
2
+ export declare function assertValidAuthRequest(request: AuthenticationRequest | undefined, signatureType: ServiceSignatureType): Promise<void>;
3
+ /**
4
+ * Create an authentication request with the given data and private key,
5
+ * which can then be used to authenticate with the service.
6
+ */
7
+ export declare function createAuthRequest(_data: Partial<AuthenticatedUserData>, privateKey: string): Promise<AuthenticationRequest>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertValidAuthRequest = assertValidAuthRequest;
4
+ exports.createAuthRequest = createAuthRequest;
5
+ const ethers_1 = require("ethers");
6
+ const config_1 = require("../config");
7
+ const api_1 = require("../proto/api");
8
+ const env_1 = require("../utils/env");
9
+ const error_1 = require("../utils/error");
10
+ const generics_1 = require("../utils/generics");
11
+ const signatures_1 = require("../utils/signatures");
12
+ async function assertValidAuthRequest(request, signatureType) {
13
+ const publicKey = (0, env_1.getEnvVariable)('AUTHENTICATION_PUBLIC_KEY');
14
+ // nothing to verify
15
+ if (!request) {
16
+ // if pub key is provided -- but user didn't attempt to
17
+ // authenticate, then we should throw an error
18
+ if (publicKey) {
19
+ throw new error_1.AttestorError('ERROR_AUTHENTICATION_FAILED', 'User must be authenticated');
20
+ }
21
+ return;
22
+ }
23
+ if (!publicKey) {
24
+ throw new error_1.AttestorError('ERROR_BAD_REQUEST', 'The attestor is not configured for authentication');
25
+ }
26
+ const { signature, data } = request;
27
+ if (!data) {
28
+ throw new error_1.AttestorError('ERROR_AUTHENTICATION_FAILED', 'Missing data in auth request');
29
+ }
30
+ if (data.expiresAt < (0, generics_1.unixTimestampSeconds)()) {
31
+ throw new error_1.AttestorError('ERROR_AUTHENTICATION_FAILED', 'Authentication request has expired');
32
+ }
33
+ const proto = api_1.AuthenticatedUserData.encode(data).finish();
34
+ const signatureAlg = signatures_1.SIGNATURES[signatureType];
35
+ const address = signatureAlg.getAddress(await ethers_1.ethers.utils.arrayify(publicKey));
36
+ const verified = await signatureAlg
37
+ .verify(proto, signature, address);
38
+ if (!verified) {
39
+ throw new error_1.AttestorError('ERROR_AUTHENTICATION_FAILED', 'Signature verification failed');
40
+ }
41
+ }
42
+ /**
43
+ * Create an authentication request with the given data and private key,
44
+ * which can then be used to authenticate with the service.
45
+ */
46
+ async function createAuthRequest(_data, privateKey) {
47
+ const createdAt = (0, generics_1.unixTimestampSeconds)();
48
+ const data = {
49
+ createdAt,
50
+ expiresAt: createdAt + config_1.DEFAULT_AUTH_EXPIRY_S,
51
+ id: '',
52
+ hostWhitelist: [],
53
+ ..._data,
54
+ };
55
+ const proto = api_1.AuthenticatedUserData.encode(data).finish();
56
+ const signature = await signatures_1.SelectedServiceSignature
57
+ .sign(proto, privateKey);
58
+ const request = {
59
+ data,
60
+ signature
61
+ };
62
+ return request;
63
+ }
64
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9hdXRoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBUUEsd0RBc0RDO0FBTUQsOENBcUJDO0FBekZELG1DQUErQjtBQUMvQix1Q0FBa0Q7QUFDbEQsdUNBQWtHO0FBQ2xHLHVDQUE4QztBQUM5QywyQ0FBK0M7QUFDL0MsaURBQXlEO0FBQ3pELHFEQUEyRTtBQUVwRSxLQUFLLFVBQVUsc0JBQXNCLENBQzNDLE9BQTBDLEVBQzFDLGFBQW1DO0lBRW5DLE1BQU0sU0FBUyxHQUFHLElBQUEsb0JBQWMsRUFBQywyQkFBMkIsQ0FBQyxDQUFBO0lBQzdELG9CQUFvQjtJQUNwQixJQUFHLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDYix1REFBdUQ7UUFDdkQsOENBQThDO1FBQzlDLElBQUcsU0FBUyxFQUFFLENBQUM7WUFDZCxNQUFNLElBQUkscUJBQWEsQ0FDdEIsNkJBQTZCLEVBQzdCLDRCQUE0QixDQUM1QixDQUFBO1FBQ0YsQ0FBQztRQUVELE9BQU07SUFDUCxDQUFDO0lBRUQsSUFBRyxDQUFDLFNBQVMsRUFBRSxDQUFDO1FBQ2YsTUFBTSxJQUFJLHFCQUFhLENBQ3RCLG1CQUFtQixFQUNuQixtREFBbUQsQ0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yxJQUFBLCtCQUFvQixHQUFFLENBQUE7SUFDeEMsTUFBTSxJQUFJLEdBQTBCO1FBQ25DLFNBQVM7UUFDVCxTQUFTLEVBQUUsU0FBUyxHQUFHLDhCQUFxQjtRQUM1QyxFQUFFLEVBQUUsRUFBRTtRQUNOLGFBQWEsRUFBRSxFQUFFO1FBQ2pCLEdBQUcsS0FBSztLQUNSLENBQUE7SUFDRCxNQUFNLEtBQUssR0FBRywyQkFBcUIsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUE7SUFDekQsTUFBTSxTQUFTLEdBQUcsTUFBTSxxQ0FBd0I7U0FDOUMsSUFBSSxDQUFDLEtBQUssRUFBRSxVQUFVLENBQUMsQ0FBQTtJQUN6QixNQUFNLE9BQU8sR0FBMEI7UUFDdEMsSUFBSTtRQUNKLFNBQVM7S0FDVCxDQUFBO0lBRUQsT0FBTyxPQUFPLENBQUE7QUFDZixDQUFDIn0=
@@ -0,0 +1,2 @@
1
+ export declare const B64_JSON_REPLACER: (key: string, value: any) => any;
2
+ export declare const B64_JSON_REVIVER: (key: string, value: any) => any;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.B64_JSON_REVIVER = exports.B64_JSON_REPLACER = void 0;
4
+ const utils_1 = require("ethers/lib/utils");
5
+ const B64_JSON_REPLACER = (key, value) => {
6
+ if (value instanceof Uint8Array
7
+ || (typeof value === 'object'
8
+ && value
9
+ && 'buffer' in value
10
+ && value.buffer instanceof ArrayBuffer)) {
11
+ return { type: 'uint8array', value: utils_1.base64.encode(value) };
12
+ }
13
+ return value;
14
+ };
15
+ exports.B64_JSON_REPLACER = B64_JSON_REPLACER;
16
+ const B64_JSON_REVIVER = (key, value) => {
17
+ if ((value === null || value === void 0 ? void 0 : value.type) === 'uint8array') {
18
+ return utils_1.base64.decode(value.value);
19
+ }
20
+ return value;
21
+ };
22
+ exports.B64_JSON_REVIV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BGPListener } from '../types';
3
+ /**
4
+ * Listens for BGP announcements and emits events whenever
5
+ * an announcement overlaps with a target IP.
6
+ */
7
+ export declare function createBgpListener(logger: Logger): BGPListener;