@premai/reticle 0.4.8 → 0.5.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 +63 -26
- package/package.json +1 -1
- package/reticle.d.ts +48 -32
- package/reticle.js +1 -1
- package/reticle_bg.js +219 -186
- package/reticle_bg.wasm +0 -0
- package/reticle_main.cjs +223 -188
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @premai/reticle
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { ClientBuilder } from "@premai/reticle";
|
|
15
15
|
|
|
16
|
-
const client = new ClientBuilder("https://attestation.example.com")
|
|
16
|
+
const client = await new ClientBuilder("https://attestation.example.com")
|
|
17
17
|
.build();
|
|
18
18
|
|
|
19
19
|
// End-to-end attestation: discovers modules, generates nonces,
|
|
@@ -28,13 +28,14 @@ console.log("GPU:", result.modules().gpu()); // GpuModule.Nvidia or undefined
|
|
|
28
28
|
|
|
29
29
|
### `ClientBuilder`
|
|
30
30
|
|
|
31
|
-
Creates and configures a `Client` instance.
|
|
31
|
+
Creates and configures a `Client` instance. `build()` is async.
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
const client = new ClientBuilder(url)
|
|
34
|
+
const client = await new ClientBuilder(url)
|
|
35
35
|
.with_authorization("Bearer <token>") // optional: set Authorization header
|
|
36
36
|
.with_kds(new Kds(kdsUrl)) // optional: custom AMD KDS cache
|
|
37
37
|
.with_pcs(new Pcs(pcsUrl)) // optional: custom Intel PCS cache
|
|
38
|
+
.with_policies_url(policiesUrl) // optional: custom OPA policies index URL
|
|
38
39
|
.build();
|
|
39
40
|
```
|
|
40
41
|
|
|
@@ -44,23 +45,52 @@ const client = new ClientBuilder(url)
|
|
|
44
45
|
|
|
45
46
|
These methods handle nonce generation, request, and full cryptographic verification in a single call:
|
|
46
47
|
|
|
47
|
-
| Method | Description |
|
|
48
|
-
|
|
49
|
-
| `client.attest(
|
|
50
|
-
| `client.attest_sev(
|
|
51
|
-
| `client.attest_tdx(
|
|
52
|
-
| `client.attest_nvidia(
|
|
48
|
+
| Method | Returns | Description |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `client.attest()` | `Promise<AttestResult>` | Full attestation of all available modules (CPU + GPU) |
|
|
51
|
+
| `client.attest_sev()` | `Promise<void>` | AMD SEV-SNP attestation only |
|
|
52
|
+
| `client.attest_tdx()` | `Promise<void>` | Intel TDX attestation only |
|
|
53
|
+
| `client.attest_nvidia()` | `Promise<ResponseHeaders>` | NVIDIA GPU attestation only |
|
|
54
|
+
|
|
55
|
+
To pass custom query parameters, call `set_query` before attesting:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const query = new QueryParams()
|
|
59
|
+
.with("model", "my-model")
|
|
60
|
+
.with("version", "1.0");
|
|
61
|
+
|
|
62
|
+
client.set_query(query);
|
|
63
|
+
await client.attest();
|
|
64
|
+
```
|
|
53
65
|
|
|
54
66
|
#### Low-level
|
|
55
67
|
|
|
56
68
|
These methods fetch and parse attestation evidence (**discouraged**) — useful when you need to inspect raw data or implement custom validation:
|
|
57
69
|
|
|
58
|
-
| Method | Description |
|
|
59
|
-
|
|
60
|
-
| `client.request_modules(
|
|
61
|
-
| `client.request_sev(nonce
|
|
62
|
-
| `client.request_tdx(nonce
|
|
63
|
-
| `client.request_nvidia(nonce
|
|
70
|
+
| Method | Returns | Description |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `client.request_modules()` | `Promise<Modules>` | List available attestation modules on the server |
|
|
73
|
+
| `client.request_sev(nonce: SevNonce)` | `Promise<ParsedAttestation>` | Fetch raw SEV-SNP attestation report |
|
|
74
|
+
| `client.request_tdx(nonce: TdxNonce)` | `Promise<TdxQuote>` | Fetch raw TDX quote |
|
|
75
|
+
| `client.request_nvidia(nonce: NvidiaNonce)` | `Promise<NvidiaAttestResult>` | Fetch raw NVIDIA EAT attestation result |
|
|
76
|
+
|
|
77
|
+
### `AttestResult`
|
|
78
|
+
|
|
79
|
+
Returned by `client.attest()`.
|
|
80
|
+
|
|
81
|
+
| Method | Returns | Description |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `result.modules()` | `Modules` | CPU and GPU module info |
|
|
84
|
+
| `result.headers()` | `AttestHeaders` | HTTP response headers from attestation requests |
|
|
85
|
+
|
|
86
|
+
`Modules` exposes:
|
|
87
|
+
- `.cpu()` → `CpuModule` (`CpuModule.Sev` or `CpuModule.Tdx`)
|
|
88
|
+
- `.gpu()` → `GpuModule | undefined` (`GpuModule.Nvidia` or `undefined`)
|
|
89
|
+
- `.has_gpu()` → `boolean`
|
|
90
|
+
|
|
91
|
+
`AttestHeaders` exposes:
|
|
92
|
+
- `.cpu()` → `ResponseHeaders | undefined`
|
|
93
|
+
- `.gpu()` → `ResponseHeaders | undefined`
|
|
64
94
|
|
|
65
95
|
### `QueryParams`
|
|
66
96
|
|
|
@@ -71,26 +101,33 @@ const query = new QueryParams()
|
|
|
71
101
|
.with("model", "my-model")
|
|
72
102
|
.with("version", "1.0");
|
|
73
103
|
|
|
74
|
-
|
|
104
|
+
client.set_query(query);
|
|
75
105
|
```
|
|
76
106
|
|
|
77
|
-
###
|
|
107
|
+
### Low-level sub-module usage
|
|
78
108
|
|
|
79
|
-
Lower-level types
|
|
109
|
+
Lower-level types are available as top-level named exports:
|
|
80
110
|
|
|
81
111
|
```typescript
|
|
82
|
-
import {
|
|
112
|
+
import {
|
|
113
|
+
fetch_keychain,
|
|
114
|
+
EATToken,
|
|
115
|
+
Kds,
|
|
116
|
+
NvidiaNonce,
|
|
117
|
+
SevNonce,
|
|
118
|
+
} from "@premai/reticle";
|
|
83
119
|
|
|
84
120
|
// NVIDIA: manual token parsing and verification
|
|
85
|
-
const keychain = await
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
claims.
|
|
121
|
+
const keychain = await fetch_keychain();
|
|
122
|
+
const nonce = NvidiaNonce.generate();
|
|
123
|
+
const token = EATToken.parse(rawJwt);
|
|
124
|
+
const claims = token.verify(keychain, nonce);
|
|
89
125
|
|
|
90
126
|
// AMD SEV-SNP: manual certificate chain verification
|
|
91
|
-
const kds = new
|
|
127
|
+
const kds = new Kds("https://kds.example.com");
|
|
128
|
+
const sevNonce = SevNonce.generate();
|
|
92
129
|
const chain = await kds.fetch_certificates(attestation);
|
|
93
|
-
attestation.verify(chain,
|
|
130
|
+
attestation.verify(chain, sevNonce);
|
|
94
131
|
```
|
|
95
132
|
|
|
96
133
|
## Memory management
|
|
@@ -98,7 +135,7 @@ attestation.verify(chain, nonce);
|
|
|
98
135
|
WASM objects are not garbage-collected automatically. Call `.free()` when done, or use `using` (TypeScript 5.2+) for automatic disposal:
|
|
99
136
|
|
|
100
137
|
```typescript
|
|
101
|
-
using client = new ClientBuilder(url).build();
|
|
138
|
+
using client = await new ClientBuilder(url).build();
|
|
102
139
|
using result = await client.attest();
|
|
103
140
|
// automatically freed at end of scope
|
|
104
141
|
```
|
package/package.json
CHANGED
package/reticle.d.ts
CHANGED
|
@@ -17,6 +17,20 @@ export class AttestResult {
|
|
|
17
17
|
modules(): Modules;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export class AzureNonce {
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
static generate(): AzureNonce;
|
|
25
|
+
to_hex(): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class AzureQuote {
|
|
29
|
+
private constructor();
|
|
30
|
+
free(): void;
|
|
31
|
+
[Symbol.dispose](): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
/**
|
|
21
35
|
* A parsed certificate revocation list
|
|
22
36
|
*/
|
|
@@ -46,6 +60,7 @@ export class Client {
|
|
|
46
60
|
* - Returns the list of attested modules
|
|
47
61
|
*/
|
|
48
62
|
attest(): Promise<AttestResult>;
|
|
63
|
+
attest_azure(): Promise<void>;
|
|
49
64
|
/**
|
|
50
65
|
* Completes end-to-end nvidia attestation. Generates nonce and validates claims all in one
|
|
51
66
|
*/
|
|
@@ -58,6 +73,10 @@ export class Client {
|
|
|
58
73
|
* Performs end-to-end tdx attestation. Generates nonce and validates claims all in one
|
|
59
74
|
*/
|
|
60
75
|
attest_tdx(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Requests and parses an Azure Quote
|
|
78
|
+
*/
|
|
79
|
+
request_azure(nonce: AzureNonce): Promise<AzureQuote>;
|
|
61
80
|
/**
|
|
62
81
|
* Gather available attestable modules from remote attestation endpoint
|
|
63
82
|
*/
|
|
@@ -79,7 +98,7 @@ export class Client {
|
|
|
79
98
|
* or measurement checks on the attestation. If you want to perform end-to-end attestation
|
|
80
99
|
* please refer to [`Self::attest_sev`]
|
|
81
100
|
*/
|
|
82
|
-
request_sev(nonce: SevNonce): Promise<
|
|
101
|
+
request_sev(nonce: SevNonce): Promise<SevQuote>;
|
|
83
102
|
/**
|
|
84
103
|
* Requests and parses a TDX quote
|
|
85
104
|
*
|
|
@@ -110,7 +129,7 @@ export class ClientBuilder {
|
|
|
110
129
|
*/
|
|
111
130
|
with_pcs(pcs: Pcs): ClientBuilder;
|
|
112
131
|
/**
|
|
113
|
-
* sets
|
|
132
|
+
* sets the confidential policy provider to URL source with the specified url
|
|
114
133
|
*/
|
|
115
134
|
with_policies_url(url: string): ClientBuilder;
|
|
116
135
|
}
|
|
@@ -124,6 +143,7 @@ export class Collateral {
|
|
|
124
143
|
export enum CpuModule {
|
|
125
144
|
Sev = 0,
|
|
126
145
|
Tdx = 1,
|
|
146
|
+
Azure = 2,
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
export class DecodedClaims {
|
|
@@ -163,11 +183,11 @@ export enum GpuModule {
|
|
|
163
183
|
export class Kds {
|
|
164
184
|
free(): void;
|
|
165
185
|
[Symbol.dispose](): void;
|
|
166
|
-
fetch_certificates(attestation:
|
|
186
|
+
fetch_certificates(attestation: SevQuote): Promise<VerifiedChain>;
|
|
167
187
|
/**
|
|
168
188
|
* Fetches the certificate revocation list from AMD's KDS
|
|
169
189
|
*/
|
|
170
|
-
fetch_crl(attestation:
|
|
190
|
+
fetch_crl(attestation: SevQuote): Promise<CRL>;
|
|
171
191
|
constructor(cache_url: string);
|
|
172
192
|
}
|
|
173
193
|
|
|
@@ -200,26 +220,6 @@ export class NvidiaNonce {
|
|
|
200
220
|
to_hex(): string;
|
|
201
221
|
}
|
|
202
222
|
|
|
203
|
-
/**
|
|
204
|
-
* Represents a parsed attestation report with some already
|
|
205
|
-
* parsed commonly accessed fields
|
|
206
|
-
*/
|
|
207
|
-
export class ParsedAttestation {
|
|
208
|
-
private constructor();
|
|
209
|
-
free(): void;
|
|
210
|
-
[Symbol.dispose](): void;
|
|
211
|
-
cpu_fam_id(): number;
|
|
212
|
-
cpu_mod_id(): number;
|
|
213
|
-
/**
|
|
214
|
-
* Parses and constructs a new attestation report from a stream of binary data
|
|
215
|
-
*/
|
|
216
|
-
static new(bytes: Uint8Array): ParsedAttestation;
|
|
217
|
-
/**
|
|
218
|
-
* Verifies the attestation report against a certificate chain
|
|
219
|
-
*/
|
|
220
|
-
verify(chain: VerifiedChain, nonce: SevNonce): void;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
223
|
export class Pcs {
|
|
224
224
|
free(): void;
|
|
225
225
|
[Symbol.dispose](): void;
|
|
@@ -244,13 +244,6 @@ export class QueryParams {
|
|
|
244
244
|
with(key: string, value: string): QueryParams;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
export class QuoteVerifier {
|
|
248
|
-
free(): void;
|
|
249
|
-
[Symbol.dispose](): void;
|
|
250
|
-
constructor(collateral: Collateral, quote: TdxQuote);
|
|
251
|
-
verify(nonce: TdxNonce): void;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
247
|
export class ResponseHeaders {
|
|
255
248
|
private constructor();
|
|
256
249
|
free(): void;
|
|
@@ -267,6 +260,22 @@ export class SevNonce {
|
|
|
267
260
|
to_hex(): string;
|
|
268
261
|
}
|
|
269
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Represents a parsed attestation report with some already
|
|
265
|
+
* parsed commonly accessed fields
|
|
266
|
+
*/
|
|
267
|
+
export class SevQuote {
|
|
268
|
+
private constructor();
|
|
269
|
+
free(): void;
|
|
270
|
+
[Symbol.dispose](): void;
|
|
271
|
+
cpu_fam_id(): number;
|
|
272
|
+
cpu_mod_id(): number;
|
|
273
|
+
/**
|
|
274
|
+
* Parses and constructs a new attestation report from a stream of binary data
|
|
275
|
+
*/
|
|
276
|
+
static new(bytes: Uint8Array): SevQuote;
|
|
277
|
+
}
|
|
278
|
+
|
|
270
279
|
export class TcbLevels {
|
|
271
280
|
private constructor();
|
|
272
281
|
free(): void;
|
|
@@ -274,9 +283,10 @@ export class TcbLevels {
|
|
|
274
283
|
}
|
|
275
284
|
|
|
276
285
|
export class TdxNonce {
|
|
286
|
+
private constructor();
|
|
277
287
|
free(): void;
|
|
278
288
|
[Symbol.dispose](): void;
|
|
279
|
-
|
|
289
|
+
static generate(): TdxNonce;
|
|
280
290
|
to_hex(): string;
|
|
281
291
|
}
|
|
282
292
|
|
|
@@ -290,6 +300,12 @@ export class TdxQuote {
|
|
|
290
300
|
static from_bytes(quote: Uint8Array): TdxQuote;
|
|
291
301
|
}
|
|
292
302
|
|
|
303
|
+
export class TdxQuoteVerifier {
|
|
304
|
+
free(): void;
|
|
305
|
+
[Symbol.dispose](): void;
|
|
306
|
+
constructor(collateral: Collateral);
|
|
307
|
+
}
|
|
308
|
+
|
|
293
309
|
/**
|
|
294
310
|
* A chain which has been cryptographically verified
|
|
295
311
|
*/
|
package/reticle.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./reticle_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
AttestHeaders, AttestResult, CRL, Client, ClientBuilder, Collateral, CpuModule, DecodedClaims, EATToken, ExportPem, GatewayError, GpuModule, Kds, KeyChain, Modules, NvidiaAttestResult, NvidiaNonce,
|
|
8
|
+
AttestHeaders, AttestResult, AzureNonce, AzureQuote, CRL, Client, ClientBuilder, Collateral, CpuModule, DecodedClaims, EATToken, ExportPem, GatewayError, GpuModule, Kds, KeyChain, Modules, NvidiaAttestResult, NvidiaNonce, Pcs, QueryParams, ResponseHeaders, SevNonce, SevQuote, TcbLevels, TdxNonce, TdxQuote, TdxQuoteVerifier, VerifiedChain, fetch, fetch_keychain
|
|
9
9
|
} from "./reticle_bg.js";
|