@calimero-network/mero-js 19.26.0 → 19.27.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.
@@ -21,6 +21,13 @@
21
21
  *
22
22
  * # What it does not do
23
23
  *
24
+ * # Sealing the relay
25
+ *
26
+ * TLS in front of a relay ends outside its TD, at the host's ingress, where
27
+ * the warrant and the method's arguments are readable. Pass `seal` (a quote
28
+ * verifier) and every call to the relay is sealed to the key its attested TD
29
+ * holds, so they are readable only inside it.
30
+ *
24
31
  * It does not read state. A relay writes on the author's behalf; reads still
25
32
  * come from a node the client can query, or from the app's own projection of
26
33
  * the events it receives. `connectCloud` is deliberately narrow about this
@@ -31,6 +38,7 @@ import { CloudClient } from './cloud-client.js';
31
38
  import type { CloudClientConfig, CloudNamespace, CloudRelay } from './cloud-client.js';
32
39
  import { RelayClient } from '../relay/relay-client.js';
33
40
  import type { IntentResult, NonceSource } from '../relay/index.js';
41
+ import type { VerifyTransportQuote } from '../sealed/sealed.js';
34
42
  export interface ConnectCloudOptions {
35
43
  /** Defaults to the hosted cloud. */
36
44
  cloudBaseUrl?: string;
@@ -65,6 +73,17 @@ export interface ConnectCloudOptions {
65
73
  nonces?: NonceSource;
66
74
  /** Seconds a minted warrant stays presentable. Defaults to 300. */
67
75
  ttlSeconds?: number;
76
+ /**
77
+ * Seal every call to the relay to its attested TEE, verified with this — for
78
+ * example {@link createQuoteVerifier} with the MRTDs you trust. The warrant
79
+ * and the method's arguments then reach only the relay's TD, not whatever
80
+ * terminates TLS in front of it, and the relay is one this client checked
81
+ * itself rather than one the cloud vouched for. Calls to the cloud are not
82
+ * sealed; they carry no intent.
83
+ *
84
+ * Without it, calls to the relay are plain HTTPS.
85
+ */
86
+ seal?: VerifyTransportQuote;
68
87
  fetch?: typeof fetch;
69
88
  timeoutMs?: number;
70
89
  }
@@ -21,6 +21,13 @@
21
21
  *
22
22
  * # What it does not do
23
23
  *
24
+ * # Sealing the relay
25
+ *
26
+ * TLS in front of a relay ends outside its TD, at the host's ingress, where
27
+ * the warrant and the method's arguments are readable. Pass `seal` (a quote
28
+ * verifier) and every call to the relay is sealed to the key its attested TD
29
+ * holds, so they are readable only inside it.
30
+ *
24
31
  * It does not read state. A relay writes on the author's behalf; reads still
25
32
  * come from a node the client can query, or from the app's own projection of
26
33
  * the events it receives. `connectCloud` is deliberately narrow about this
@@ -31,6 +38,7 @@ import { CloudClient } from './cloud-client.js';
31
38
  import { RelayClient } from '../relay/relay-client.js';
32
39
  import { createLocalStorageNonceSource, createMemoryNonceSource } from '../relay/nonce-source.js';
33
40
  import { derivePublicKey, hex } from '../crypto/internal.js';
41
+ import { createAttestedSealedFetch } from '../sealed/sealed.js';
34
42
  /**
35
43
  * Sign in to the cloud and return a connection that can write.
36
44
  *
@@ -77,7 +85,15 @@ export async function connectCloud(options) {
77
85
  deviceSecret: options.deviceSecret,
78
86
  nonces: options.nonces ?? (await defaultNonceSource(options.deviceSecret)),
79
87
  ttlSeconds: options.ttlSeconds,
80
- fetch: options.fetch,
88
+ // Only the relay is sealed: a sealed fetch is bound to one node and refuses
89
+ // any other URL, and the cloud calls above carry no intent.
90
+ fetch: options.seal
91
+ ? createAttestedSealedFetch({
92
+ baseUrl: relayInfo.relayUrl,
93
+ verify: options.seal,
94
+ fetch: options.fetch,
95
+ })
96
+ : options.fetch,
81
97
  timeoutMs: options.timeoutMs,
82
98
  });
83
99
  return {