@tinycloud/sdk-services 3.11.0 → 3.12.0-beta.10

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 (71) hide show
  1. package/dist/{BaseService-Ma2MwJAd.d.ts → BaseService-BRDG69KR.d.ts} +1 -1
  2. package/dist/{BaseService-O0iyuFLk.d.cts → BaseService-CdBkfPGE.d.cts} +1 -1
  3. package/dist/{IHooksService-4QNODVy6.d.cts → IHooksService-C9p3stsB.d.cts} +1 -1
  4. package/dist/{IHooksService-CvTpJbQD.d.ts → IHooksService-D6eyZat1.d.ts} +1 -1
  5. package/dist/{ISQLService-Aly1CBsW.d.ts → ISQLService-B_4KcGA-.d.ts} +1 -1
  6. package/dist/{ISQLService-BOgWzHLT.d.cts → ISQLService-C6nNpcls.d.cts} +1 -1
  7. package/dist/context.cjs +4 -0
  8. package/dist/context.cjs.map +1 -1
  9. package/dist/context.d.cts +1 -1
  10. package/dist/context.d.ts +1 -1
  11. package/dist/context.js +4 -0
  12. package/dist/context.js.map +1 -1
  13. package/dist/encryption/index.cjs +276 -14
  14. package/dist/encryption/index.cjs.map +1 -1
  15. package/dist/encryption/index.d.cts +26 -28
  16. package/dist/encryption/index.d.ts +26 -28
  17. package/dist/encryption/index.js +268 -14
  18. package/dist/encryption/index.js.map +1 -1
  19. package/dist/encryption/named-keys.cjs +225 -14
  20. package/dist/encryption/named-keys.cjs.map +1 -1
  21. package/dist/encryption/named-keys.d.cts +7 -2
  22. package/dist/encryption/named-keys.d.ts +7 -2
  23. package/dist/encryption/named-keys.js +225 -14
  24. package/dist/encryption/named-keys.js.map +1 -1
  25. package/dist/encryption/resource.cjs.map +1 -1
  26. package/dist/encryption/resource.js.map +1 -1
  27. package/dist/feed/index.cjs +4 -0
  28. package/dist/feed/index.cjs.map +1 -1
  29. package/dist/feed/index.d.cts +3 -3
  30. package/dist/feed/index.d.ts +3 -3
  31. package/dist/feed/index.js +4 -0
  32. package/dist/feed/index.js.map +1 -1
  33. package/dist/index.cjs +509 -18
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +14 -12
  36. package/dist/index.d.ts +14 -12
  37. package/dist/index.js +499 -18
  38. package/dist/index.js.map +1 -1
  39. package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
  40. package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
  41. package/dist/kv/index.cjs +34 -0
  42. package/dist/kv/index.cjs.map +1 -1
  43. package/dist/kv/index.d.cts +4 -4
  44. package/dist/kv/index.d.ts +4 -4
  45. package/dist/kv/index.js +34 -0
  46. package/dist/kv/index.js.map +1 -1
  47. package/dist/kv/replication/index.cjs +39 -8
  48. package/dist/kv/replication/index.cjs.map +1 -1
  49. package/dist/kv/replication/index.d.cts +3 -3
  50. package/dist/kv/replication/index.d.ts +3 -3
  51. package/dist/kv/replication/index.js +38 -7
  52. package/dist/kv/replication/index.js.map +1 -1
  53. package/dist/{scope-DEgc9f-W.d.cts → scope-DtcbyRKY.d.cts} +1 -1
  54. package/dist/{scope-BZr0QwxX.d.ts → scope-J20PQP3u.d.ts} +1 -1
  55. package/dist/sql/index.cjs +36 -0
  56. package/dist/sql/index.cjs.map +1 -1
  57. package/dist/sql/index.d.cts +4 -4
  58. package/dist/sql/index.d.ts +4 -4
  59. package/dist/sql/index.js +36 -0
  60. package/dist/sql/index.js.map +1 -1
  61. package/dist/telemetry/requestLog.cjs +4 -0
  62. package/dist/telemetry/requestLog.cjs.map +1 -1
  63. package/dist/telemetry/requestLog.d.cts +1 -1
  64. package/dist/telemetry/requestLog.d.ts +1 -1
  65. package/dist/telemetry/requestLog.js +4 -0
  66. package/dist/telemetry/requestLog.js.map +1 -1
  67. package/dist/{types-D4XbIfFJ.d.cts → types-DfqNz9Nu.d.cts} +135 -6
  68. package/dist/{types-CSd0RYir.d.ts → types-DjAP8dve.d.cts} +4 -0
  69. package/dist/{types-CSd0RYir.d.cts → types-DjAP8dve.d.ts} +4 -0
  70. package/dist/{types-Bf91gup6.d.ts → types-Nvi_RckJ.d.ts} +135 -6
  71. package/package.json +4 -1
@@ -1,25 +1,9 @@
1
- import { B as BaseService } from '../BaseService-O0iyuFLk.cjs';
2
- import { c as IService, f as Result } from '../types-CSd0RYir.cjs';
3
- import { N as NetworkDescriptor, n as EncryptionError, I as InlineEncryptedEnvelope, D as DecryptCapabilityProof, j as DecryptResponseBody, E as EncryptionCrypto, h as DecryptInvocationSigner, p as ReceiverKeySigner, R as ReceiverKeyPair, i as DecryptRequestBody, g as DecryptInvocationFact, B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation } from '../types-D4XbIfFJ.cjs';
4
- export { C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, o as EncryptionErrorInput, J as Json, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalize, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from '../types-D4XbIfFJ.cjs';
1
+ import { B as BaseService } from '../BaseService-CdBkfPGE.cjs';
2
+ import { c as IService, f as Result } from '../types-DjAP8dve.cjs';
3
+ import { N as NetworkDescriptor, n as EncryptionError, I as InlineEncryptedEnvelope, D as DecryptCapabilityProof, j as DecryptResponseBody, E as EncryptionCrypto, h as DecryptInvocationSigner, s as ReceiverKeySigner, r as ReceiverKeyPair, i as DecryptRequestBody, g as DecryptInvocationFact, B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, Z as KeyWrapContext } from '../types-DfqNz9Nu.cjs';
4
+ export { C as CanonicalJson, _ as ColumnFormat, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, o as EncryptionErrorInput, J as Json, $ as KEY_WRAP_V2_ALG, a0 as KeyWrapV2Header, a1 as assertKeyWrapAlgorithm, a2 as assertKeyWrapContext, F as base64Decode, G as base64Encode, H as canonicalHashHex, K as canonicalize, a3 as decryptColumn, O as encryptionError, Q as hexDecode, S as hexEncode, a4 as isKeyWrapV2, a5 as openKeyV2, a6 as readKeyWrapV2, a7 as sealKeyV2, W as utf8Decode, X as utf8Encode } from '../types-DfqNz9Nu.cjs';
5
5
  export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
6
6
 
7
- /**
8
- * Network-descriptor discovery.
9
- *
10
- * Resolution order (per architecture):
11
- *
12
- * 1. The node's authoritative endpoint
13
- * `GET /encryption/networks/<networkId>` returns the current
14
- * descriptor (`state`, `publicEncryptionKey`, `keyVersion`, ...).
15
- * 2. If the node is unreachable, fall back to the cached discovery
16
- * record at `.well-known/encryption/network/<name>` inside the
17
- * owner's public space.
18
- *
19
- * The node DB is authoritative on conflict; cached records are
20
- * advisory only.
21
- */
22
-
23
7
  type DiscoverySource = "node" | "well-known";
24
8
  interface DiscoveredNetwork {
25
9
  descriptor: NetworkDescriptor;
@@ -45,8 +29,8 @@ interface DiscoverNetworkInput {
45
29
  wellKnown?: WellKnownDescriptorFetcher;
46
30
  }
47
31
  /**
48
- * Resolve a network descriptor. The node fetcher is preferred; the
49
- * well-known fallback is used only on transport failure.
32
+ * Resolve a network descriptor. The node fetcher is preferred. An optional
33
+ * well-known cache cannot override a typed registry, identity, or transport failure.
50
34
  *
51
35
  * The returned descriptor is sanity-checked: `networkId`, `ownerDid`,
52
36
  * and `name` must agree with the URN, and the public key field must
@@ -85,11 +69,13 @@ declare function ensureNetworkUsableForDecrypt(descriptor: NetworkDescriptor): {
85
69
  */
86
70
 
87
71
  interface EncryptToNetworkOptions {
72
+ /** Write TCW2 key wraps. Defaults to the service setting, otherwise false. */
73
+ keyWrapV2?: boolean;
88
74
  /** Exact named-key path to bind into the returned envelope. */
89
75
  keyPath?: string;
90
76
  /** Optional associated authenticated data (bytes). */
91
77
  aad?: Uint8Array;
92
- /** Ciphersuite override. Defaults to the network's alg. */
78
+ /** Ciphersuite override; must match the selected key-wrap writer. */
93
79
  alg?: string;
94
80
  /** Key version override. Defaults to the network's current key version. */
95
81
  keyVersion?: number;
@@ -131,6 +117,10 @@ interface IEncryptionService extends IService {
131
117
  *
132
118
  * The capability proof must root at the network owner DID embedded
133
119
  * in the envelope's networkId.
120
+ *
121
+ * Unresponsive decrypt transports use DECRYPTION_DEPENDENCY_UNAVAILABLE.
122
+ * HTTP failure, identity, registry and caller-cancellation classifications
123
+ * remain distinct; a failed request never returns partial plaintext.
134
124
  */
135
125
  decryptEnvelope(envelope: InlineEncryptedEnvelope, capabilityProof: DecryptCapabilityProof, options?: DecryptEnvelopeOptions): Promise<Result<Uint8Array, EncryptionError>>;
136
126
  }
@@ -168,11 +158,17 @@ interface DecryptTransport {
168
158
  }
169
159
 
170
160
  interface EncryptionServiceConfig {
161
+ /** Write TCW2 key wraps. Disabled by default. */
162
+ keyWrapV2?: boolean;
163
+ /** Require TCW2 incoming network-key wraps, not signed receiver responses. Disabled by default. */
164
+ requireKeyWrapV2?: boolean;
171
165
  crypto: EncryptionCrypto;
172
166
  signer: DecryptInvocationSigner;
173
167
  transport: DecryptTransport;
174
168
  node?: NodeDescriptorFetcher;
175
169
  wellKnown?: WellKnownDescriptorFetcher;
170
+ /** Verified registry destination; overrides descriptor order and caller hints. */
171
+ resolveTargetNode?: (networkId: string) => Promise<string>;
176
172
  /** Bound by an owning service graph to prevent cross-session authority use. */
177
173
  assertActive?: () => void;
178
174
  [key: string]: unknown;
@@ -281,6 +277,8 @@ interface EncryptToNetworkInput {
281
277
  keyVersion?: number;
282
278
  /** Caller-supplied envelope metadata. */
283
279
  metadata?: Record<string, string>;
280
+ /** Write TCW2 key wraps. Disabled by default. */
281
+ keyWrapV2?: boolean;
284
282
  }
285
283
  interface EncryptToNetworkResult {
286
284
  envelope: InlineEncryptedEnvelope;
@@ -297,7 +295,7 @@ declare function encryptToNetwork(crypto: EncryptionCrypto, input: EncryptToNetw
297
295
  * Validate an inline envelope shape. Returns an error if the envelope
298
296
  * is missing required fields or fails internal hash recomputation.
299
297
  */
300
- declare function validateEnvelope(crypto: EncryptionCrypto, envelope: unknown): {
298
+ declare function validateEnvelope(crypto: EncryptionCrypto, envelope: unknown, requireKeyWrapV2?: boolean): {
301
299
  ok: true;
302
300
  data: InlineEncryptedEnvelope;
303
301
  } | {
@@ -453,8 +451,8 @@ declare function buildDecryptInvocation(crypto: EncryptionCrypto, signer: Decryp
453
451
  * 1. Verify the node signature over the canonical response (excluding
454
452
  * the signature field).
455
453
  * 2. Recompute every binding hash and reject any mismatch.
456
- * 3. Confirm `targetNode`, `networkId`, `alg`, and `keyVersion` echo
457
- * what the SDK sent.
454
+ * 3. Confirm the target, network, and key version echo the request and
455
+ * the returned key-wrap algorithm is supported independently.
458
456
  *
459
457
  * After verification, the SDK opens `wrappedKey` with the per-request
460
458
  * receiver private key and uses the resulting symmetric key to
@@ -494,6 +492,6 @@ declare function verifyDecryptResponse(input: VerifyDecryptResponseInput): {
494
492
  * After verification, open the response's `wrappedKey` with the
495
493
  * per-request receiver private key and return the symmetric key.
496
494
  */
497
- declare function openWrappedKey(crypto: EncryptionCrypto, receiverPrivateKey: Uint8Array, response: DecryptResponseBody): Uint8Array;
495
+ declare function openWrappedKey(crypto: EncryptionCrypto, receiverPrivateKey: Uint8Array, response: DecryptResponseBody, expected?: KeyWrapContext): Uint8Array;
498
496
 
499
- export { type BuildCanonicalDecryptRequestInput, type BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, type CanonicalDecryptRequest, DecryptCapabilityProof, type DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, type DecryptTransport, type DiscoverNetworkInput, type DiscoveredNetwork, type DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, type EncryptToNetworkInput, type EncryptToNetworkOptions, type EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionService, type EncryptionServiceConfig, type IEncryptionService, InlineEncryptedEnvelope, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, type NodeDescriptorFetcher, type ParsedEncryptionResource, type ParsedNetworkId, type RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, type SignedReceiverKeyInput, type VerifyDecryptResponseInput, type WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse };
497
+ export { type BuildCanonicalDecryptRequestInput, type BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, type CanonicalDecryptRequest, DecryptCapabilityProof, type DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, type DecryptTransport, type DiscoverNetworkInput, type DiscoveredNetwork, type DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, type EncryptToNetworkInput, type EncryptToNetworkOptions, type EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionService, type EncryptionServiceConfig, type IEncryptionService, InlineEncryptedEnvelope, KeyWrapContext, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, type NodeDescriptorFetcher, type ParsedEncryptionResource, type ParsedNetworkId, type RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, type SignedReceiverKeyInput, type VerifyDecryptResponseInput, type WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse };
@@ -1,25 +1,9 @@
1
- import { B as BaseService } from '../BaseService-Ma2MwJAd.js';
2
- import { c as IService, f as Result } from '../types-CSd0RYir.js';
3
- import { N as NetworkDescriptor, n as EncryptionError, I as InlineEncryptedEnvelope, D as DecryptCapabilityProof, j as DecryptResponseBody, E as EncryptionCrypto, h as DecryptInvocationSigner, p as ReceiverKeySigner, R as ReceiverKeyPair, i as DecryptRequestBody, g as DecryptInvocationFact, B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation } from '../types-Bf91gup6.js';
4
- export { C as CanonicalJson, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, o as EncryptionErrorInput, J as Json, q as base64Decode, r as base64Encode, s as canonicalHashHex, t as canonicalize, u as encryptionError, v as hexDecode, w as hexEncode, x as utf8Decode, y as utf8Encode } from '../types-Bf91gup6.js';
1
+ import { B as BaseService } from '../BaseService-BRDG69KR.js';
2
+ import { c as IService, f as Result } from '../types-DjAP8dve.js';
3
+ import { N as NetworkDescriptor, n as EncryptionError, I as InlineEncryptedEnvelope, D as DecryptCapabilityProof, j as DecryptResponseBody, E as EncryptionCrypto, h as DecryptInvocationSigner, s as ReceiverKeySigner, r as ReceiverKeyPair, i as DecryptRequestBody, g as DecryptInvocationFact, B as BuildDecryptInvocationInput, a as BuiltDecryptInvocation, Z as KeyWrapContext } from '../types-Nvi_RckJ.js';
4
+ export { C as CanonicalJson, _ as ColumnFormat, b as DECRYPT_ACTION, c as DECRYPT_FACT_TYPE, d as DECRYPT_RESULT_TYPE, e as DEFAULT_ENCRYPTION_ALG, f as DEFAULT_KEY_VERSION, k as ENCRYPTION_SERVICE, l as ENCRYPTION_SERVICE_SHORT, m as ENVELOPE_VERSION, o as EncryptionErrorInput, J as Json, $ as KEY_WRAP_V2_ALG, a0 as KeyWrapV2Header, a1 as assertKeyWrapAlgorithm, a2 as assertKeyWrapContext, F as base64Decode, G as base64Encode, H as canonicalHashHex, K as canonicalize, a3 as decryptColumn, O as encryptionError, Q as hexDecode, S as hexEncode, a4 as isKeyWrapV2, a5 as openKeyV2, a6 as readKeyWrapV2, a7 as sealKeyV2, W as utf8Decode, X as utf8Encode } from '../types-Nvi_RckJ.js';
5
5
  export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
6
6
 
7
- /**
8
- * Network-descriptor discovery.
9
- *
10
- * Resolution order (per architecture):
11
- *
12
- * 1. The node's authoritative endpoint
13
- * `GET /encryption/networks/<networkId>` returns the current
14
- * descriptor (`state`, `publicEncryptionKey`, `keyVersion`, ...).
15
- * 2. If the node is unreachable, fall back to the cached discovery
16
- * record at `.well-known/encryption/network/<name>` inside the
17
- * owner's public space.
18
- *
19
- * The node DB is authoritative on conflict; cached records are
20
- * advisory only.
21
- */
22
-
23
7
  type DiscoverySource = "node" | "well-known";
24
8
  interface DiscoveredNetwork {
25
9
  descriptor: NetworkDescriptor;
@@ -45,8 +29,8 @@ interface DiscoverNetworkInput {
45
29
  wellKnown?: WellKnownDescriptorFetcher;
46
30
  }
47
31
  /**
48
- * Resolve a network descriptor. The node fetcher is preferred; the
49
- * well-known fallback is used only on transport failure.
32
+ * Resolve a network descriptor. The node fetcher is preferred. An optional
33
+ * well-known cache cannot override a typed registry, identity, or transport failure.
50
34
  *
51
35
  * The returned descriptor is sanity-checked: `networkId`, `ownerDid`,
52
36
  * and `name` must agree with the URN, and the public key field must
@@ -85,11 +69,13 @@ declare function ensureNetworkUsableForDecrypt(descriptor: NetworkDescriptor): {
85
69
  */
86
70
 
87
71
  interface EncryptToNetworkOptions {
72
+ /** Write TCW2 key wraps. Defaults to the service setting, otherwise false. */
73
+ keyWrapV2?: boolean;
88
74
  /** Exact named-key path to bind into the returned envelope. */
89
75
  keyPath?: string;
90
76
  /** Optional associated authenticated data (bytes). */
91
77
  aad?: Uint8Array;
92
- /** Ciphersuite override. Defaults to the network's alg. */
78
+ /** Ciphersuite override; must match the selected key-wrap writer. */
93
79
  alg?: string;
94
80
  /** Key version override. Defaults to the network's current key version. */
95
81
  keyVersion?: number;
@@ -131,6 +117,10 @@ interface IEncryptionService extends IService {
131
117
  *
132
118
  * The capability proof must root at the network owner DID embedded
133
119
  * in the envelope's networkId.
120
+ *
121
+ * Unresponsive decrypt transports use DECRYPTION_DEPENDENCY_UNAVAILABLE.
122
+ * HTTP failure, identity, registry and caller-cancellation classifications
123
+ * remain distinct; a failed request never returns partial plaintext.
134
124
  */
135
125
  decryptEnvelope(envelope: InlineEncryptedEnvelope, capabilityProof: DecryptCapabilityProof, options?: DecryptEnvelopeOptions): Promise<Result<Uint8Array, EncryptionError>>;
136
126
  }
@@ -168,11 +158,17 @@ interface DecryptTransport {
168
158
  }
169
159
 
170
160
  interface EncryptionServiceConfig {
161
+ /** Write TCW2 key wraps. Disabled by default. */
162
+ keyWrapV2?: boolean;
163
+ /** Require TCW2 incoming network-key wraps, not signed receiver responses. Disabled by default. */
164
+ requireKeyWrapV2?: boolean;
171
165
  crypto: EncryptionCrypto;
172
166
  signer: DecryptInvocationSigner;
173
167
  transport: DecryptTransport;
174
168
  node?: NodeDescriptorFetcher;
175
169
  wellKnown?: WellKnownDescriptorFetcher;
170
+ /** Verified registry destination; overrides descriptor order and caller hints. */
171
+ resolveTargetNode?: (networkId: string) => Promise<string>;
176
172
  /** Bound by an owning service graph to prevent cross-session authority use. */
177
173
  assertActive?: () => void;
178
174
  [key: string]: unknown;
@@ -281,6 +277,8 @@ interface EncryptToNetworkInput {
281
277
  keyVersion?: number;
282
278
  /** Caller-supplied envelope metadata. */
283
279
  metadata?: Record<string, string>;
280
+ /** Write TCW2 key wraps. Disabled by default. */
281
+ keyWrapV2?: boolean;
284
282
  }
285
283
  interface EncryptToNetworkResult {
286
284
  envelope: InlineEncryptedEnvelope;
@@ -297,7 +295,7 @@ declare function encryptToNetwork(crypto: EncryptionCrypto, input: EncryptToNetw
297
295
  * Validate an inline envelope shape. Returns an error if the envelope
298
296
  * is missing required fields or fails internal hash recomputation.
299
297
  */
300
- declare function validateEnvelope(crypto: EncryptionCrypto, envelope: unknown): {
298
+ declare function validateEnvelope(crypto: EncryptionCrypto, envelope: unknown, requireKeyWrapV2?: boolean): {
301
299
  ok: true;
302
300
  data: InlineEncryptedEnvelope;
303
301
  } | {
@@ -453,8 +451,8 @@ declare function buildDecryptInvocation(crypto: EncryptionCrypto, signer: Decryp
453
451
  * 1. Verify the node signature over the canonical response (excluding
454
452
  * the signature field).
455
453
  * 2. Recompute every binding hash and reject any mismatch.
456
- * 3. Confirm `targetNode`, `networkId`, `alg`, and `keyVersion` echo
457
- * what the SDK sent.
454
+ * 3. Confirm the target, network, and key version echo the request and
455
+ * the returned key-wrap algorithm is supported independently.
458
456
  *
459
457
  * After verification, the SDK opens `wrappedKey` with the per-request
460
458
  * receiver private key and uses the resulting symmetric key to
@@ -494,6 +492,6 @@ declare function verifyDecryptResponse(input: VerifyDecryptResponseInput): {
494
492
  * After verification, open the response's `wrappedKey` with the
495
493
  * per-request receiver private key and return the symmetric key.
496
494
  */
497
- declare function openWrappedKey(crypto: EncryptionCrypto, receiverPrivateKey: Uint8Array, response: DecryptResponseBody): Uint8Array;
495
+ declare function openWrappedKey(crypto: EncryptionCrypto, receiverPrivateKey: Uint8Array, response: DecryptResponseBody, expected?: KeyWrapContext): Uint8Array;
498
496
 
499
- export { type BuildCanonicalDecryptRequestInput, type BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, type CanonicalDecryptRequest, DecryptCapabilityProof, type DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, type DecryptTransport, type DiscoverNetworkInput, type DiscoveredNetwork, type DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, type EncryptToNetworkInput, type EncryptToNetworkOptions, type EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionService, type EncryptionServiceConfig, type IEncryptionService, InlineEncryptedEnvelope, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, type NodeDescriptorFetcher, type ParsedEncryptionResource, type ParsedNetworkId, type RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, type SignedReceiverKeyInput, type VerifyDecryptResponseInput, type WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse };
497
+ export { type BuildCanonicalDecryptRequestInput, type BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, type CanonicalDecryptRequest, DecryptCapabilityProof, type DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, type DecryptTransport, type DiscoverNetworkInput, type DiscoveredNetwork, type DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, type EncryptToNetworkInput, type EncryptToNetworkOptions, type EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionService, type EncryptionServiceConfig, type IEncryptionService, InlineEncryptedEnvelope, KeyWrapContext, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, type NodeDescriptorFetcher, type ParsedEncryptionResource, type ParsedNetworkId, type RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, type SignedReceiverKeyInput, type VerifyDecryptResponseInput, type WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalSignedResponse, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, isNetworkId, networkDiscoveryKey, openWrappedKey, parseEncryptionResource, parseNetworkId, validateEnvelope, verifyDecryptResponse };