@reclaimprotocol/attestor-core 5.0.3 → 5.0.5

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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Brings the attestor up in TEE mode:
3
+ * 1. Pull signing/OPRF secrets from GCP Secret Manager into process.env.
4
+ * 2. Load (or obtain via ACME) the TLS cert and start the renewal loop.
5
+ * 3. Start the attestation refresh loop, with the public key + cert hash
6
+ * as nonces.
7
+ *
8
+ * Must run before #src/server/index.ts is imported, since modules in that
9
+ * tree read PRIVATE_KEY at module load.
10
+ */
11
+ export declare function bootstrapTee(): Promise<void>;
@@ -0,0 +1,24 @@
1
+ import tls from 'tls';
2
+ export interface CertManagerConfig {
3
+ projectId: string;
4
+ domain: string;
5
+ email: string;
6
+ directoryUrl: string;
7
+ httpChallengePort: number;
8
+ }
9
+ export interface ActiveCertificate {
10
+ certPem: string;
11
+ keyPem: string;
12
+ notAfter: Date;
13
+ sha256Hex: string;
14
+ secureContext: tls.SecureContext;
15
+ }
16
+ /**
17
+ * Bootstraps the TLS certificate. Tries Secret Manager first; if absent or
18
+ * expiring within the renewal window, runs ACME against the configured
19
+ * directory URL and persists the result.
20
+ */
21
+ export declare function bootstrapCertificate(cfg: CertManagerConfig): Promise<ActiveCertificate>;
22
+ export declare function startRenewalLoop(cfg: CertManagerConfig): void;
23
+ export declare function stopRenewalLoop(): void;
24
+ export declare function getActiveCertificate(): ActiveCertificate | undefined;
@@ -0,0 +1,23 @@
1
+ import type { LogLevel } from '#src/types/index.ts';
2
+ interface CloudLoggingOptions {
3
+ projectId: string;
4
+ logName: string;
5
+ level?: LogLevel;
6
+ }
7
+ /**
8
+ * Replaces the default pino logger with one that forwards every log line
9
+ * to GCP Cloud Logging under the given log name. Idempotent.
10
+ *
11
+ * Probes the Cloud Logging client first by writing a no-op entry; if
12
+ * authentication or transport fails, leaves the default stdout logger in
13
+ * place rather than crashing the process. On Confidential Space VMs the
14
+ * launcher's `tee-container-log-redirect` ships stdout to Cloud Logging
15
+ * anyway, so the worst case is logs appear under
16
+ * `confidential-space-launcher` rather than the configured `logName`.
17
+ *
18
+ * We also install a process-wide `unhandledRejection` filter that
19
+ * swallows errors originating in `@google-cloud/logging`, since the SDK
20
+ * has internal lazy gRPC init that escapes our local `.catch()`.
21
+ */
22
+ export declare function installCloudLogging(opts: CloudLoggingOptions): void;
23
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Fetches the attestor's signing key and OPRF key material from GCP
3
+ * Secret Manager and writes them into process.env, so that the rest of
4
+ * the server (which reads these via getEnvVariable at module load) sees
5
+ * them as if they had been set in the environment.
6
+ *
7
+ * Must be called before any module that reads PRIVATE_KEY / TOPRF_* is
8
+ * imported, otherwise the reads happen before the values are populated.
9
+ */
10
+ export declare function loadSecretsIntoEnv(projectId: string): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export declare function accessLatestSecret(projectId: string, secretId: string): Promise<Uint8Array>;
2
+ export declare function createSecretIfNotExists(projectId: string, secretId: string): Promise<void>;
3
+ export declare function addSecretVersion(projectId: string, secretId: string, payload: Uint8Array): Promise<void>;
@@ -20,7 +20,7 @@ export declare function assertValidClaimRequest(request: ClaimTunnelRequest, met
20
20
  * Verify that the transcript contains a valid claim
21
21
  * for the provider.
22
22
  */
23
- export declare function assertValidProviderTranscript<T extends ProviderClaimInfo>(applData: Transcript<Uint8Array>, info: T, logger: Logger, providerCtx: ProviderCtx, oprfRawReplacements?: OPRFRawReplacement[]): Promise<T>;
23
+ export declare function assertValidProviderTranscript<T extends ProviderClaimInfo>(applData: Transcript<Uint8Array>, metadata: InitRequest, info: T, logger: Logger, providerCtx: ProviderCtx, oprfRawReplacements?: OPRFRawReplacement[]): Promise<T>;
24
24
  /**
25
25
  * Verify that the transcript provided by the client
26
26
  * matches the transcript of the tunnel, the server
@@ -20,3 +20,4 @@ export declare function niceParseJsonObject(data: string, key: string): any;
20
20
  * in the `messages` parameter.
21
21
  */
22
22
  export declare function getInitialMessagesFromQuery(req: IncomingMessage): import("#src/proto/api.ts").RPCMessage[];
23
+ export declare function getPublicAddresses(host: string): Promise<string[]>;
@@ -34,6 +34,7 @@ type GetResponseRedactionsOpts<P> = {
34
34
  ctx: ProviderCtx;
35
35
  };
36
36
  type AssertValidProviderReceipt<P> = {
37
+ clientVersion: AttestorVersion;
37
38
  receipt: Transcript<Uint8Array>;
38
39
  params: P;
39
40
  logger: Logger;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * GCP attestation validation utilities.
3
+ *
4
+ * Validates JWT attestation tokens from GCP Confidential Computing
5
+ * (Confidential Space). Browser-safe: uses `@peculiar/x509` for chain
6
+ * verification and `globalThis.crypto.subtle` for JWT signature
7
+ * verification. Both are available in Node 19+ and modern browsers.
8
+ */
9
+ import type { Logger } from '#src/types/general.ts';
10
+ export interface GcpValidationResult {
11
+ isValid: boolean;
12
+ errors: string[];
13
+ ethAddress?: Uint8Array;
14
+ userDataType?: string;
15
+ pcr0?: string;
16
+ envVars?: Record<string, string>;
17
+ }
18
+ export declare function validateGcpAttestationAndExtractKey(attestation: Uint8Array | string, logger?: Logger): Promise<GcpValidationResult>;
19
+ /**
20
+ * Extracts the container image digest from a previously-validated GCP
21
+ * attestation token. Re-validates the JWT before reading.
22
+ */
23
+ export declare function extractImageDigestFromGCPAttestation(token: Uint8Array | string, logger?: Logger): Promise<string>;
@@ -51,9 +51,10 @@ export declare function makeHttpResponseParser(): {
51
51
  */
52
52
  streamEnded(): void;
53
53
  };
54
+ export declare function extractRequestBufferFromTranscript(receipt: Transcript<Uint8Array>): Uint8Array<ArrayBufferLike>;
54
55
  /**
55
56
  * Read the HTTP request from a TLS receipt transcript.
56
57
  * @param receipt the transcript to read from or application messages if they were extracted beforehand
57
58
  * @returns the parsed HTTP request
58
59
  */
59
- export declare function getHttpRequestDataFromTranscript(receipt: Transcript<Uint8Array>): HttpRequest;
60
+ export declare function getHttpRequestDataFromTranscript(requestBuffer: Uint8Array): HttpRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reclaimprotocol/attestor-core",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "imports": {
@@ -97,6 +97,7 @@
97
97
  "esprima-next": "^5.8.4",
98
98
  "ethers": "^6.16.0",
99
99
  "https-proxy-agent": "^7.0.6",
100
+ "ip-address": "^10.2.0",
100
101
  "ip-cidr": "^3.1.0",
101
102
  "jsonpath-plus": "^10.4.0",
102
103
  "koffi": "^2.15.2",
@@ -106,7 +107,7 @@
106
107
  "pino": "^9.14.0",
107
108
  "re2": "^1.23.3",
108
109
  "serve-static": "^1.16.3",
109
- "snarkjs": "git+https://github.com/reclaimprotocol/snarkjs.git",
110
+ "snarkjs": "^0.7.6",
110
111
  "ws": "^8.20.0",
111
112
  "xpath": "^0.0.34"
112
113
  },