@floegence/flowersec-core 8.0.0 → 8.2.0

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 (57) hide show
  1. package/THIRD_PARTY_NOTICES.md +8 -5
  2. package/dist/browser/connectSessionV3.d.ts +4 -0
  3. package/dist/browser/connectSessionV3.js +15 -8
  4. package/dist/browser/index.d.ts +1 -1
  5. package/dist/browser/index.js +1 -1
  6. package/dist/facade.d.ts +4 -0
  7. package/dist/facade.js +3 -0
  8. package/dist/framing/jsonframe.d.ts +1 -1
  9. package/dist/framing/jsonframe.js +13 -6
  10. package/dist/node/connectSessionV3.d.ts +6 -2
  11. package/dist/node/connectSessionV3.js +12 -6
  12. package/dist/node/index.d.ts +1 -1
  13. package/dist/node/index.js +1 -1
  14. package/dist/node/nativeTransportAddon.d.ts +4 -3
  15. package/dist/node/nativeTransportAddon.js +3 -2
  16. package/dist/node/rawQuicAdapterV3.d.ts +2 -2
  17. package/dist/node/rawQuicAdapterV3.js +5 -3
  18. package/dist/public/sessionHandlers.d.ts +3 -1
  19. package/dist/public/sessionHandlers.js +11 -3
  20. package/dist/rpc/server.js +3 -3
  21. package/dist/tunnelAuth/artifact.d.ts +34 -0
  22. package/dist/tunnelAuth/artifact.js +74 -0
  23. package/dist/tunnelAuth/credentials.d.ts +17 -0
  24. package/dist/tunnelAuth/credentials.js +40 -0
  25. package/dist/tunnelAuth/hpke.d.ts +36 -0
  26. package/dist/tunnelAuth/hpke.js +124 -0
  27. package/dist/v3/artifact.d.ts +27 -8
  28. package/dist/v3/artifact.js +78 -42
  29. package/dist/v3/artifactLease.d.ts +4 -2
  30. package/dist/v3/artifactLease.js +13 -1
  31. package/dist/v3/browserRuntime.js +5 -3
  32. package/dist/v3/connectionController.d.ts +2 -2
  33. package/dist/v3/connectionController.js +8 -4
  34. package/dist/v3/connectorRPCLimits.d.ts +7 -0
  35. package/dist/v3/connectorRPCLimits.js +14 -0
  36. package/dist/v3/handshake.d.ts +22 -21
  37. package/dist/v3/handshake.js +58 -60
  38. package/dist/v3/nodeRuntime.js +4 -1
  39. package/dist/v3/protocol.d.ts +17 -16
  40. package/dist/v3/protocol.js +60 -64
  41. package/dist/v3/publicApi.d.ts +1 -0
  42. package/dist/v3/publicApi.js +7 -0
  43. package/dist/v3/runtimeAdapters.d.ts +2 -2
  44. package/dist/v3/runtimeAdapters.js +2 -1
  45. package/dist/v3/security.d.ts +1 -1
  46. package/dist/v3/session.d.ts +14 -4
  47. package/dist/v3/session.js +174 -114
  48. package/dist/v3/sessionConnector.d.ts +2 -2
  49. package/dist/v3/sessionConnector.js +24 -13
  50. package/dist/v3/tunnelIngress.js +2 -1
  51. package/dist/v3/unreliableMessage.d.ts +3 -0
  52. package/dist/v3/unreliableMessage.js +24 -22
  53. package/dist/v3/wireProfile.d.ts +52 -0
  54. package/dist/v3/wireProfile.js +20 -0
  55. package/package.json +5 -3
  56. package/sbom/cyclonedx.json +133 -31
  57. package/sbom/spdx.json +110 -39
@@ -4,10 +4,12 @@ import { expand } from "@noble/hashes/hkdf.js";
4
4
  import { hmac } from "@noble/hashes/hmac.js";
5
5
  import { sha256 } from "@noble/hashes/sha2.js";
6
6
  import { unicode151Assigned } from "../generated/unicode151.js";
7
- import { FLOWERSEC_V3_CRYPTO_LABELS } from "./transportConstants.js";
7
+ import { matchesFramePrefix, transportV5, tunnelAuthV1, writeFramePrefix } from "./wireProfile.js";
8
8
  const encoder = new TextEncoder();
9
- const recordMagic = encoder.encode("FSR5");
10
- const recordAADLabel = encoder.encode(FLOWERSEC_V3_CRYPTO_LABELS["record-aad"]);
9
+ const recordAADLabels = {
10
+ [transportV5.name]: encoder.encode(transportV5.labels["record-aad"]),
11
+ [tunnelAuthV1.name]: encoder.encode(tunnelAuthV1.labels["record-aad"]),
12
+ };
11
13
  const MAX_UINT32 = 0xffffffff;
12
14
  const MAX_UINT64 = (1n << 64n) - 1n;
13
15
  const SETUP_PREFACE_BYTES = 56;
@@ -59,61 +61,61 @@ export var InnerTypeV3;
59
61
  InnerTypeV3[InnerTypeV3["StreamKeyUpdateACK"] = 25] = "StreamKeyUpdateACK";
60
62
  InnerTypeV3[InnerTypeV3["SessionReadyConfirm"] = 26] = "SessionReadyConfirm";
61
63
  })(InnerTypeV3 || (InnerTypeV3 = {}));
62
- export function deriveEpochZero(sessionPRK, direction) {
64
+ export function deriveEpochZero(sessionPRK, direction, profile = transportV5) {
63
65
  assertBytes("session PRK", sessionPRK, 32);
64
66
  assertDirection(direction);
65
- const epochSecret = expand32(sessionPRK, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["epoch-zero"], byte(direction)));
66
- return deriveEpochRoots(epochSecret);
67
+ const epochSecret = expand32(sessionPRK, labelWith(profile.labels["epoch-zero"], byte(direction)));
68
+ return deriveEpochRoots(epochSecret, profile);
67
69
  }
68
- export function deriveEpochRoots(epochSecret) {
70
+ export function deriveEpochRoots(epochSecret, profile = transportV5) {
69
71
  assertBytes("epoch secret", epochSecret, 32);
70
72
  return {
71
73
  epochSecret: epochSecret.slice(),
72
- controlRoot: expand32(epochSecret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["control-root"])),
73
- streamRoot: expand32(epochSecret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["stream-root"])),
74
- setupRoot: expand32(epochSecret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["setup-root"])),
75
- rekeyRoot: expand32(epochSecret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["rekey-root"])),
74
+ controlRoot: expand32(epochSecret, labelWith(profile.labels["control-root"])),
75
+ streamRoot: expand32(epochSecret, labelWith(profile.labels["stream-root"])),
76
+ setupRoot: expand32(epochSecret, labelWith(profile.labels["setup-root"])),
77
+ rekeyRoot: expand32(epochSecret, labelWith(profile.labels["rekey-root"])),
76
78
  };
77
79
  }
78
- export function deriveNextEpoch(rekeyRoot, h3, direction, nextEpoch) {
80
+ export function deriveNextEpoch(rekeyRoot, h3, direction, nextEpoch, profile = transportV5) {
79
81
  assertBytes("rekey root", rekeyRoot, 32);
80
82
  assertBytes("H3", h3, 32);
81
83
  assertDirection(direction);
82
84
  assertU32("next epoch", nextEpoch);
83
- return expand32(rekeyRoot, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["next-epoch"], h3, byte(direction), u32be(nextEpoch)));
85
+ return expand32(rekeyRoot, labelWith(profile.labels["next-epoch"], h3, byte(direction), u32be(nextEpoch)));
84
86
  }
85
- export function deriveStreamMaterial(streamRoot, h3, logicalStreamID, direction, epoch) {
87
+ export function deriveStreamMaterial(streamRoot, h3, logicalStreamID, direction, epoch, profile = transportV5) {
86
88
  assertBytes("stream root", streamRoot, 32);
87
89
  assertBytes("H3", h3, 32);
88
90
  assertLogicalStreamID(logicalStreamID);
89
91
  assertDirection(direction);
90
92
  assertU32("epoch", epoch);
91
- const secret = expand32(streamRoot, labelWith(FLOWERSEC_V3_CRYPTO_LABELS.stream, h3, u64be(logicalStreamID), byte(direction), u32be(epoch)));
93
+ const secret = expand32(streamRoot, labelWith(profile.labels.stream, h3, u64be(logicalStreamID), byte(direction), u32be(epoch)));
92
94
  return {
93
95
  secret,
94
- recordKey: expand32(secret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["record-key"])),
95
- noncePrefix: expand(sha256, secret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS.nonce), 4),
96
+ recordKey: expand32(secret, labelWith(profile.labels["record-key"])),
97
+ noncePrefix: expand(sha256, secret, labelWith(profile.labels.nonce), 4),
96
98
  };
97
99
  }
98
- export function deriveControlMaterial(controlRoot, h3, direction, epoch) {
100
+ export function deriveControlMaterial(controlRoot, h3, direction, epoch, profile = transportV5) {
99
101
  assertBytes("control root", controlRoot, 32);
100
102
  assertBytes("H3", h3, 32);
101
103
  assertDirection(direction);
102
104
  assertU32("epoch", epoch);
103
- const secret = expand32(controlRoot, labelWith(FLOWERSEC_V3_CRYPTO_LABELS.control, h3, u64be(0n), byte(direction), u32be(epoch)));
105
+ const secret = expand32(controlRoot, labelWith(profile.labels.control, h3, u64be(0n), byte(direction), u32be(epoch)));
104
106
  return {
105
107
  secret,
106
- recordKey: expand32(secret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS["record-key"])),
107
- noncePrefix: expand(sha256, secret, labelWith(FLOWERSEC_V3_CRYPTO_LABELS.nonce), 4),
108
+ recordKey: expand32(secret, labelWith(profile.labels["record-key"])),
109
+ noncePrefix: expand(sha256, secret, labelWith(profile.labels.nonce), 4),
108
110
  };
109
111
  }
110
- export function computeSetupMAC(setupRoot, h3, preface) {
112
+ export function computeSetupMAC(setupRoot, h3, preface, profile = transportV5) {
111
113
  assertBytes("setup root", setupRoot, 32);
112
114
  assertBytes("H3", h3, 32);
113
- const raw = encodeSetupPreface(preface);
114
- return hmac(sha256, setupRoot, exactLabelWith(FLOWERSEC_V3_CRYPTO_LABELS["setup-mac"], h3, raw.subarray(0, 24)));
115
+ const raw = encodeSetupPreface(preface, profile);
116
+ return hmac(sha256, setupRoot, exactLabelWith(profile.labels["setup-mac"], h3, raw.subarray(0, 24)));
115
117
  }
116
- export function encodeSetupPreface(preface) {
118
+ export function encodeSetupPreface(preface, profile = transportV5) {
117
119
  assertLogicalStreamID(preface.logicalStreamID);
118
120
  if ((preface.openerRole !== 1 && preface.openerRole !== 2) ||
119
121
  (preface.openerRole === 1 && (preface.logicalStreamID & 1n) !== 1n) ||
@@ -123,18 +125,16 @@ export function encodeSetupPreface(preface) {
123
125
  assertU32("initial send epoch", preface.initialSendEpoch);
124
126
  assertBytes("setup MAC", preface.setupMAC, 32);
125
127
  const out = new Uint8Array(SETUP_PREFACE_BYTES);
126
- out.set(encoder.encode("FSS5"), 0);
127
- out[4] = 5;
128
+ writeFramePrefix(out, 0x53, profile);
128
129
  out[5] = preface.openerRole;
129
130
  out.set(u64be(preface.logicalStreamID), 8);
130
131
  out.set(u32be(preface.initialSendEpoch), 16);
131
132
  out.set(preface.setupMAC, 24);
132
133
  return out;
133
134
  }
134
- export function decodeSetupPrefaceV3(raw) {
135
+ export function decodeSetupPrefaceV3(raw, profile = transportV5) {
135
136
  if (raw.length !== SETUP_PREFACE_BYTES ||
136
- raw[0] !== 0x46 || raw[1] !== 0x53 || raw[2] !== 0x53 || raw[3] !== 0x35 ||
137
- raw[4] !== 5 || raw[6] !== 0 || raw[7] !== 0 || readU32be(raw, 20) !== 0) {
137
+ !matchesFramePrefix(raw, 0x53, profile) || raw[6] !== 0 || raw[7] !== 0 || readU32be(raw, 20) !== 0) {
138
138
  throw new ProtocolV3Error("invalid FSS3 setup preface");
139
139
  }
140
140
  const openerRole = raw[5];
@@ -152,40 +152,35 @@ export function decodeSetupPrefaceV3(raw) {
152
152
  setupMAC: raw.slice(24, 56),
153
153
  };
154
154
  }
155
- export function verifySetupMAC(setupRoot, h3, preface) {
156
- const want = computeSetupMAC(setupRoot, h3, { ...preface, setupMAC: new Uint8Array(32) });
155
+ export function verifySetupMAC(setupRoot, h3, preface, profile = transportV5) {
156
+ const want = computeSetupMAC(setupRoot, h3, { ...preface, setupMAC: new Uint8Array(32) }, profile);
157
157
  return bytesEqual(want, preface.setupMAC);
158
158
  }
159
- export function computeFSS3HashV3(raw) {
160
- decodeSetupPrefaceV3(raw);
159
+ export function computeFSS3HashV3(raw, profile = transportV5) {
160
+ decodeSetupPrefaceV3(raw, profile);
161
161
  return computeValidatedFSS3HashV3Internal(raw);
162
162
  }
163
163
  /** @internal Hashes an FSS3 preface that was encoded or decoded by this module. */
164
164
  export function computeValidatedFSS3HashV3Internal(raw) {
165
165
  return sha256(raw);
166
166
  }
167
- export function encodeRecordHeader(header) {
167
+ export function encodeRecordHeader(header, profile = transportV5) {
168
168
  const out = new Uint8Array(RECORD_HEADER_BYTES);
169
- writeRecordHeader(out, header);
169
+ writeRecordHeader(out, header, profile);
170
170
  return out;
171
171
  }
172
- function writeRecordHeader(out, header) {
172
+ function writeRecordHeader(out, header, profile) {
173
173
  validateRecordHeader(header);
174
174
  const fields = new DataView(out.buffer, out.byteOffset, out.byteLength);
175
- out.set(recordMagic, 0);
176
- out[4] = 5;
175
+ writeFramePrefix(out, 0x52, profile);
177
176
  out[5] = RECORD_HEADER_BYTES;
178
177
  fields.setUint32(8, header.epoch, false);
179
178
  fields.setBigUint64(12, header.sequence, false);
180
179
  fields.setUint32(20, header.ciphertextLength, false);
181
180
  }
182
- export function decodeRecordHeader(raw) {
181
+ export function decodeRecordHeader(raw, profile = transportV5) {
183
182
  if (raw.length !== RECORD_HEADER_BYTES ||
184
- raw[0] !== 0x46 ||
185
- raw[1] !== 0x53 ||
186
- raw[2] !== 0x52 ||
187
- raw[3] !== 0x35 ||
188
- raw[4] !== 5 ||
183
+ !matchesFramePrefix(raw, 0x52, profile) ||
189
184
  raw[5] !== RECORD_HEADER_BYTES ||
190
185
  raw[6] !== 0 ||
191
186
  raw[7] !== 0) {
@@ -288,13 +283,13 @@ export function decodeOpenPayload(raw) {
288
283
  metadata,
289
284
  };
290
285
  }
291
- export function computeOpenHashV3(rawOpenPayload) {
286
+ export function computeOpenHashV3(rawOpenPayload, profile = transportV5) {
292
287
  decodeOpenPayload(rawOpenPayload);
293
- return computeValidatedOpenHashV3Internal(rawOpenPayload);
288
+ return computeValidatedOpenHashV3Internal(rawOpenPayload, profile);
294
289
  }
295
290
  /** @internal Hashes an OPEN payload that was encoded or decoded by this module. */
296
- export function computeValidatedOpenHashV3Internal(rawOpenPayload) {
297
- return sha256(concat(encoder.encode(FLOWERSEC_V3_CRYPTO_LABELS.open), u32be(rawOpenPayload.length), rawOpenPayload));
291
+ export function computeValidatedOpenHashV3Internal(rawOpenPayload, profile = transportV5) {
292
+ return sha256(concat(encoder.encode(profile.labels.open), u32be(rawOpenPayload.length), rawOpenPayload));
298
293
  }
299
294
  export function encodeOpenACKV3(openHash) {
300
295
  assertBytes("OPEN hash", openHash, 32);
@@ -345,15 +340,16 @@ export function decodeStreamKeyUpdateACKV3(raw) {
345
340
  throw new ProtocolV3Error("stream rekey epoch must be non-zero");
346
341
  return value;
347
342
  }
348
- export function buildRecordAAD(h3, logicalStreamID, direction, rawHeader) {
343
+ export function buildRecordAAD(h3, logicalStreamID, direction, rawHeader, profile = transportV5) {
349
344
  assertBytes("H3", h3, 32);
350
345
  assertU64("logical stream ID", logicalStreamID);
351
346
  assertDirection(direction);
352
- decodeRecordHeader(rawHeader);
353
- return buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader);
347
+ decodeRecordHeader(rawHeader, profile);
348
+ return buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader, profile);
354
349
  }
355
- function buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader) {
350
+ function buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader, profile) {
356
351
  assertU64("uint64", logicalStreamID);
352
+ const recordAADLabel = recordAADLabels[profile.name];
357
353
  const streamOffset = recordAADLabel.length + h3.length;
358
354
  const aad = new Uint8Array(streamOffset + 9 + rawHeader.length);
359
355
  aad.set(recordAADLabel);
@@ -370,31 +366,31 @@ function recordNonce(prefix, sequence) {
370
366
  new DataView(nonce.buffer).setBigUint64(prefix.length, sequence, false);
371
367
  return nonce;
372
368
  }
373
- export function sealRecord(suite, material, h3, logicalStreamID, direction, header, plaintext) {
369
+ export function sealRecord(suite, material, h3, logicalStreamID, direction, header, plaintext, profile = transportV5) {
374
370
  assertBytes("H3", h3, 32);
375
371
  assertDirection(direction);
376
372
  validateMaterial(material);
377
373
  if (plaintext.length + 16 !== header.ciphertextLength) {
378
374
  throw new ProtocolV3Error("FSR3 plaintext length does not match the header");
379
375
  }
380
- const rawHeader = encodeRecordHeader(header);
376
+ const rawHeader = encodeRecordHeader(header, profile);
381
377
  const nonce = recordNonce(material.noncePrefix, header.sequence);
382
- const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader);
378
+ const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader, profile);
383
379
  return cipher(suite, material.recordKey, nonce, aad).encrypt(plaintext);
384
380
  }
385
381
  /** @internal Seals an inner record in the buffer used for the carrier write. */
386
- export function sealRecordWireV3Internal(suite, material, h3, logicalStreamID, direction, epoch, sequence, type, payload) {
382
+ export function sealRecordWireV3Internal(suite, material, h3, logicalStreamID, direction, epoch, sequence, type, payload, profile = transportV5) {
387
383
  validateInnerPayload(type, payload.length);
388
384
  validateMaterial(material);
389
385
  const ciphertextLength = INNER_HEADER_BYTES + payload.length + 16;
390
386
  const wire = new Uint8Array(RECORD_HEADER_BYTES + ciphertextLength);
391
387
  const rawHeader = wire.subarray(0, RECORD_HEADER_BYTES);
392
- writeRecordHeader(rawHeader, { epoch, sequence, ciphertextLength });
388
+ writeRecordHeader(rawHeader, { epoch, sequence, ciphertextLength }, profile);
393
389
  const body = wire.subarray(RECORD_HEADER_BYTES);
394
390
  const inner = body.subarray(0, -16);
395
391
  writeInnerRecord(inner, type, payload);
396
392
  const nonce = recordNonce(material.noncePrefix, sequence);
397
- const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader);
393
+ const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader, profile);
398
394
  if (suite === CipherSuiteV3.ChaCha20Poly1305 || suite === CipherSuiteV3.XWing) {
399
395
  chacha20poly1305(material.recordKey, nonce, aad).encrypt(inner, body);
400
396
  }
@@ -403,20 +399,20 @@ export function sealRecordWireV3Internal(suite, material, h3, logicalStreamID, d
403
399
  }
404
400
  return wire;
405
401
  }
406
- export function openRecord(suite, material, h3, logicalStreamID, direction, header, ciphertext) {
402
+ export function openRecord(suite, material, h3, logicalStreamID, direction, header, ciphertext, profile = transportV5) {
407
403
  assertBytes("H3", h3, 32);
408
404
  assertDirection(direction);
409
- const rawHeader = encodeRecordHeader(header);
410
- return openRecordWithRawHeaderV3Internal(suite, material, h3, logicalStreamID, direction, header, rawHeader, ciphertext);
405
+ const rawHeader = encodeRecordHeader(header, profile);
406
+ return openRecordWithRawHeaderV3Internal(suite, material, h3, logicalStreamID, direction, header, rawHeader, ciphertext, profile);
411
407
  }
412
408
  /** @internal Opens a record whose exact raw header was already decoded by this module. */
413
- export function openRecordWithRawHeaderV3Internal(suite, material, h3, logicalStreamID, direction, header, rawHeader, ciphertext) {
409
+ export function openRecordWithRawHeaderV3Internal(suite, material, h3, logicalStreamID, direction, header, rawHeader, ciphertext, profile = transportV5) {
414
410
  validateMaterial(material);
415
411
  if (ciphertext.length !== header.ciphertextLength) {
416
412
  throw new ProtocolV3Error("FSR3 ciphertext length does not match the header");
417
413
  }
418
414
  const nonce = recordNonce(material.noncePrefix, header.sequence);
419
- const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader);
415
+ const aad = buildValidatedRecordAAD(h3, logicalStreamID, direction, rawHeader, profile);
420
416
  try {
421
417
  return cipher(suite, material.recordKey, nonce, aad).decrypt(ciphertext);
422
418
  }
@@ -2,6 +2,7 @@ import { type ArtifactLeaseV3 } from "./artifactLease.js";
2
2
  export declare class ArtifactHandleV3 {
3
3
  private readonly artifactHandleBrand;
4
4
  private constructor();
5
+ lookupKey(): string;
5
6
  }
6
7
  export type ArtifactParseErrorCodeV3 = "artifact_too_large" | "invalid_artifact";
7
8
  export declare class ArtifactParseErrorV3 extends Error {
@@ -1,8 +1,15 @@
1
+ import { sha256 } from "@noble/hashes/sha2.js";
2
+ import { base64urlEncode } from "../utils/base64url.js";
1
3
  import { ArtifactV3Error, decodeArtifactV3JSON, validateArtifactV3, } from "./artifact.js";
2
4
  import { createArtifactLeaseV3Internal, } from "./artifactLease.js";
3
5
  const artifacts = new WeakMap();
4
6
  export class ArtifactHandleV3 {
5
7
  constructor() { }
8
+ lookupKey() {
9
+ const artifact = unwrapArtifactHandleV3(this);
10
+ const token = artifact.path.kind === "direct" ? artifact.path.routing_token : artifact.path.token;
11
+ return base64urlEncode(sha256(new TextEncoder().encode(token)));
12
+ }
6
13
  }
7
14
  export class ArtifactParseErrorV3 extends Error {
8
15
  code;
@@ -1,9 +1,9 @@
1
1
  import { type WebSocketLike } from "../ws-client/binaryTransport.js";
2
- import type { ArtifactV3, CanonicalArtifactCandidateV3 } from "./artifact.js";
2
+ import type { ConnectionArtifact, CanonicalArtifactCandidateV3 } from "./artifact.js";
3
3
  import { type NativeCarrierSessionV3 } from "./carrier.js";
4
4
  import type { ReadyAdmissionTransportV3 } from "./sessionConnector.js";
5
5
  export type WebSocketLikeV3 = WebSocketLike & Readonly<{
6
6
  protocol?: string;
7
7
  }>;
8
- export declare function readyWebSocketAdmissionV3(candidate: CanonicalArtifactCandidateV3, artifact: ArtifactV3, socket: WebSocketLikeV3, signal: AbortSignal): Promise<ReadyAdmissionTransportV3>;
8
+ export declare function readyWebSocketAdmissionV3(candidate: CanonicalArtifactCandidateV3, artifact: ConnectionArtifact, socket: WebSocketLikeV3, signal: AbortSignal): Promise<ReadyAdmissionTransportV3>;
9
9
  export declare function readyNativeAdmissionV3(candidate: CanonicalArtifactCandidateV3, carrier: NativeCarrierSessionV3): ReadyAdmissionTransportV3;
@@ -1,10 +1,11 @@
1
1
  import { WebSocketBinaryTransport } from "../ws-client/binaryTransport.js";
2
+ import { endpointIngress } from "./wireProfile.js";
2
3
  import { adaptNativeCarrierSessionV3, } from "./carrier.js";
3
4
  import { TransportFailureV3 } from "./security.js";
4
5
  import { createWebSocketCarrierSessionV3 } from "./webSocketCarrier.js";
5
6
  import { websocketSubprotocolForPathV3 } from "./transportConstants.js";
6
7
  export async function readyWebSocketAdmissionV3(candidate, artifact, socket, signal) {
7
- const subprotocol = websocketSubprotocolForPathV3(artifact.path.kind);
8
+ const subprotocol = artifact.v === 1 ? endpointIngress.subprotocol : websocketSubprotocolForPathV3(artifact.path.kind);
8
9
  await waitForWebSocketOpen(socket, subprotocol, signal);
9
10
  const transport = new WebSocketBinaryTransport(socket);
10
11
  let finalized = false;
@@ -6,7 +6,7 @@ export declare class TransportFailureV3 extends Error {
6
6
  readonly detail?: TransportFailureDetailV3 | undefined;
7
7
  constructor(code: TransportFailureCodeV3, detail?: TransportFailureDetailV3 | undefined, cause?: unknown);
8
8
  }
9
- export type PublicConnectErrorCodeV3 = "hybrid_unavailable" | "tunnel_ingress_mismatch" | "artifact_invalid" | "expired_artifact" | "transport_security_unsupported" | "transport_security_failed" | "connection_failed";
9
+ export type PublicConnectErrorCodeV3 = "endpoint_auth_failed" | "endpoint_auth_unsupported" | "hybrid_unavailable" | "tunnel_ingress_mismatch" | "artifact_invalid" | "expired_artifact" | "transport_security_unsupported" | "transport_security_failed" | "connection_failed";
10
10
  export type RetryDispositionV3 = Readonly<{
11
11
  kind: "terminal";
12
12
  }> | Readonly<{
@@ -3,6 +3,8 @@ import { RpcRouter, type RpcServerOptions } from "../rpc/server.js";
3
3
  import type { InternalByteStreamV3 as ByteStreamV3, InternalIncomingStreamV3 as IncomingStreamV3, InternalRpcPeerV3, InternalSessionTerminationV3 as SessionTerminationV3, InternalSessionV3 as SessionV3Contract, OperationOptionsV3, PathKind, InternalStreamOpenOptionsV3, UnreliableMessageChannelV3 } from "./contract.js";
4
4
  import { type CarrierSessionV3, type CarrierStreamV3 } from "./carrier.js";
5
5
  import type { SessionContractV3 } from "./artifact.js";
6
+ import { type WireProfile } from "./wireProfile.js";
7
+ import { type TunnelAuth } from "../tunnelAuth/credentials.js";
6
8
  import { DirectionV3, InnerTypeV3, type EpochRootsV3, type RecordMaterialV3, type RecordHeaderV3, CipherSuiteV3 } from "./protocol.js";
7
9
  export type SessionRoleV3 = "client" | "server";
8
10
  export type SessionDeadlinePhaseV3 = "establish" | "rekey_prepare" | "rekey_completion";
@@ -24,7 +26,6 @@ export type SessionConfigV3 = Readonly<{
24
26
  channelID: string;
25
27
  sessionContractHash: Uint8Array;
26
28
  suite: CipherSuiteV3;
27
- psk: Uint8Array;
28
29
  maxInboundStreams: number;
29
30
  localAdmissionBinding: Uint8Array;
30
31
  peerAdmissionBinding: Uint8Array;
@@ -38,14 +39,22 @@ export type SessionConfigV3 = Readonly<{
38
39
  idleTimeoutMs?: number;
39
40
  closeTimeoutMs?: number;
40
41
  runtime: SessionProtocolRuntimeV3;
41
- }>;
42
+ }> & (Readonly<{
43
+ psk: Uint8Array;
44
+ endpointAuth?: never;
45
+ }> | Readonly<{
46
+ endpointAuth: TunnelAuth;
47
+ rendezvousGroupID: string;
48
+ listenerAudience: string;
49
+ psk?: never;
50
+ }>);
42
51
  export type SessionProtocolRuntimeV3 = Readonly<{
43
52
  entropy(length: number): Uint8Array;
44
53
  monotonicMilliseconds(): number;
45
54
  }>;
46
55
  export declare class SessionV3Error extends Error {
47
- readonly code: "aborted" | "closed" | "going_away" | "handshake" | "open_rejected" | "protocol" | "rekey_failed" | "resource_exhausted" | "stream_reset" | "timeout";
48
- constructor(code: "aborted" | "closed" | "going_away" | "handshake" | "open_rejected" | "protocol" | "rekey_failed" | "resource_exhausted" | "stream_reset" | "timeout", message: string);
56
+ readonly code: "aborted" | "closed" | "going_away" | "handshake" | "endpoint_auth_failed" | "open_rejected" | "protocol" | "rekey_failed" | "resource_exhausted" | "stream_reset" | "timeout";
57
+ constructor(code: "aborted" | "closed" | "going_away" | "handshake" | "endpoint_auth_failed" | "open_rejected" | "protocol" | "rekey_failed" | "resource_exhausted" | "stream_reset" | "timeout", message: string);
49
58
  }
50
59
  declare class SessionRpcPeerV3 implements InternalRpcPeerV3 {
51
60
  private readonly createClient;
@@ -147,6 +156,7 @@ export declare class SessionV3 implements SessionV3Contract {
147
156
  private readonly terminationState;
148
157
  private readonly terminationController;
149
158
  private readonly suite;
159
+ readonly wireProfile: WireProfile;
150
160
  private readonly runtime;
151
161
  private readonly deadlines;
152
162
  private readonly idleTimeoutMs;