@floegence/flowersec-core 8.1.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.
- package/THIRD_PARTY_NOTICES.md +8 -5
- package/dist/browser/connectSessionV3.d.ts +4 -0
- package/dist/browser/connectSessionV3.js +12 -4
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/facade.d.ts +4 -0
- package/dist/facade.js +3 -0
- package/dist/node/connectSessionV3.d.ts +4 -0
- package/dist/node/connectSessionV3.js +7 -0
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/nativeTransportAddon.d.ts +4 -3
- package/dist/node/nativeTransportAddon.js +3 -2
- package/dist/node/rawQuicAdapterV3.d.ts +2 -2
- package/dist/node/rawQuicAdapterV3.js +5 -3
- package/dist/tunnelAuth/artifact.d.ts +34 -0
- package/dist/tunnelAuth/artifact.js +74 -0
- package/dist/tunnelAuth/credentials.d.ts +17 -0
- package/dist/tunnelAuth/credentials.js +40 -0
- package/dist/tunnelAuth/hpke.d.ts +36 -0
- package/dist/tunnelAuth/hpke.js +124 -0
- package/dist/v3/artifact.d.ts +27 -8
- package/dist/v3/artifact.js +78 -42
- package/dist/v3/artifactLease.d.ts +4 -2
- package/dist/v3/artifactLease.js +13 -1
- package/dist/v3/browserRuntime.js +5 -3
- package/dist/v3/connectionController.d.ts +2 -2
- package/dist/v3/connectionController.js +8 -4
- package/dist/v3/handshake.d.ts +22 -21
- package/dist/v3/handshake.js +58 -60
- package/dist/v3/nodeRuntime.js +4 -1
- package/dist/v3/protocol.d.ts +17 -16
- package/dist/v3/protocol.js +60 -64
- package/dist/v3/runtimeAdapters.d.ts +2 -2
- package/dist/v3/runtimeAdapters.js +2 -1
- package/dist/v3/security.d.ts +1 -1
- package/dist/v3/session.d.ts +14 -4
- package/dist/v3/session.js +174 -114
- package/dist/v3/sessionConnector.d.ts +2 -2
- package/dist/v3/sessionConnector.js +24 -13
- package/dist/v3/tunnelIngress.js +2 -1
- package/dist/v3/unreliableMessage.d.ts +3 -0
- package/dist/v3/unreliableMessage.js +24 -22
- package/dist/v3/wireProfile.d.ts +52 -0
- package/dist/v3/wireProfile.js +20 -0
- package/package.json +5 -3
- package/sbom/cyclonedx.json +133 -31
- package/sbom/spdx.json +110 -39
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { base64urlDecode } from "../utils/base64url.js";
|
|
2
2
|
import { SDK_DEFAULTS } from "../defaults.js";
|
|
3
|
-
import { AdmissionStatusV3, admissionBindingV3, buildFSB3RequestV3,
|
|
3
|
+
import { AdmissionStatusV3, admissionBindingV3, buildFSB3RequestV3, buildEndpointAdmission, decodeFSA3ResponseV3, encodeFSB3RequestV3, validatedCandidates, } from "./artifact.js";
|
|
4
4
|
import { selectTunnelIngress } from "./tunnelIngress.js";
|
|
5
|
-
import {
|
|
5
|
+
import { requireEndpointCrypto } from "../tunnelAuth/hpke.js";
|
|
6
|
+
import { artifactLeaseStateV3, claimConnectionLeaseV3, claimedArtifactV3, claimedTunnelAuth, commitArtifactLeaseSpendV3, retireArtifactLeaseV3, } from "./artifactLease.js";
|
|
6
7
|
import { aggregateCandidateFailuresV3, } from "./controller.js";
|
|
7
8
|
import { projectSessionV3 } from "./publicSession.js";
|
|
8
9
|
import { ConnectErrorV3, VerifiedHybridRefusalV3, TransportFailureV3, snapshotTransportSecurityPolicyV3, } from "./security.js";
|
|
9
|
-
import { establishSessionV3, HybridUnavailableV3, } from "./session.js";
|
|
10
|
+
import { establishSessionV3, HybridUnavailableV3, SessionV3Error, } from "./session.js";
|
|
11
|
+
import { transportV5, tunnelAuthV1 } from "./wireProfile.js";
|
|
10
12
|
import { supportsCandidateSecurityV3, validateRuntimeCapabilityDescriptorV3, } from "./capability.js";
|
|
11
13
|
export async function connectArtifactLeaseV3(lease, runtime, signal) {
|
|
12
14
|
let claim;
|
|
@@ -85,9 +87,8 @@ async function connectClaimedArtifactLeaseV3(claim, runtime, signal, deadlineSta
|
|
|
85
87
|
try {
|
|
86
88
|
capability = runtime.capabilitySnapshot();
|
|
87
89
|
validateRuntimeCapabilityDescriptorV3(capability);
|
|
88
|
-
|
|
90
|
+
candidates = validatedCandidates(artifact).candidates;
|
|
89
91
|
assertArtifactFresh(artifact, now);
|
|
90
|
-
candidates = canonicalizeCandidatesV3(artifact.path.kind, artifact.path.candidates).candidates;
|
|
91
92
|
}
|
|
92
93
|
catch (error) {
|
|
93
94
|
await retireArtifactLeaseV3(claim);
|
|
@@ -158,6 +159,12 @@ async function attemptClaimedArtifactLeaseUnderSignalV3(context, runtime) {
|
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
async function attemptClaimedArtifactLeaseWithinDeadlineV3(context, runtime) {
|
|
162
|
+
if (context.artifact.v === 1) {
|
|
163
|
+
const capability = requireEndpointCrypto().catch(() => {
|
|
164
|
+
throw new ConnectErrorV3("endpoint_auth_unsupported", { kind: "terminal" });
|
|
165
|
+
});
|
|
166
|
+
await raceAbort(capability, context.signal);
|
|
167
|
+
}
|
|
161
168
|
const role = context.artifact.path.kind === "tunnel" && context.artifact.path.role === 2
|
|
162
169
|
? "server"
|
|
163
170
|
: "client";
|
|
@@ -259,8 +266,8 @@ async function attemptClaimedArtifactLeaseWithinDeadlineV3(context, runtime) {
|
|
|
259
266
|
}
|
|
260
267
|
try {
|
|
261
268
|
context.assertArtifactFresh();
|
|
262
|
-
const rawFSB3 = encodeFSB3RequestV3(buildFSB3RequestV3(context.artifact, winner.candidate.id));
|
|
263
|
-
const config = sessionConfigFromArtifactV3(context.artifact, rawFSB3, runtime);
|
|
269
|
+
const rawFSB3 = context.artifact.v === 1 ? buildEndpointAdmission(context.artifact, winner.candidate.id) : encodeFSB3RequestV3(buildFSB3RequestV3(context.artifact, winner.candidate.id));
|
|
270
|
+
const config = sessionConfigFromArtifactV3(context.artifact, rawFSB3, runtime, claimedTunnelAuth(context.claim));
|
|
264
271
|
const channel = await raceAbort(winner.openAdmissionChannel(context.signal), context.signal);
|
|
265
272
|
try {
|
|
266
273
|
context.assertArtifactFresh();
|
|
@@ -269,7 +276,7 @@ async function attemptClaimedArtifactLeaseWithinDeadlineV3(context, runtime) {
|
|
|
269
276
|
const response = channel.framing === "message"
|
|
270
277
|
? await exchangeMessage(channel, rawFSB3, context.signal)
|
|
271
278
|
: await exchangeStream(channel.stream, rawFSB3, context.signal);
|
|
272
|
-
const fsa3 = decodeFSA3ResponseV3(response);
|
|
279
|
+
const fsa3 = decodeFSA3ResponseV3(response, context.artifact.v === 1 ? tunnelAuthV1 : transportV5);
|
|
273
280
|
if (fsa3.status !== AdmissionStatusV3.Success) {
|
|
274
281
|
throw new ConnectErrorV3("connection_failed", {
|
|
275
282
|
kind: fsa3.status === AdmissionStatusV3.Retryable ? "retryable" : "terminal",
|
|
@@ -282,6 +289,9 @@ async function attemptClaimedArtifactLeaseWithinDeadlineV3(context, runtime) {
|
|
|
282
289
|
}
|
|
283
290
|
catch (error) {
|
|
284
291
|
carrier.abort({ code: 6, reason: "session establishment failed" });
|
|
292
|
+
if (config.endpointAuth && error instanceof SessionV3Error && (error.code === "protocol" || error.code === "endpoint_auth_failed")) {
|
|
293
|
+
throw new ConnectErrorV3("endpoint_auth_failed", { kind: "terminal" });
|
|
294
|
+
}
|
|
285
295
|
if (error instanceof HybridUnavailableV3 && config.role === "client")
|
|
286
296
|
throw new VerifiedHybridRefusalV3();
|
|
287
297
|
throw error instanceof ConnectErrorV3
|
|
@@ -308,19 +318,20 @@ async function attemptClaimedArtifactLeaseWithinDeadlineV3(context, runtime) {
|
|
|
308
318
|
};
|
|
309
319
|
}
|
|
310
320
|
}
|
|
311
|
-
function sessionConfigFromArtifactV3(artifact, rawFSB3, runtime) {
|
|
312
|
-
const localBinding = admissionBindingV3(rawFSB3);
|
|
321
|
+
function sessionConfigFromArtifactV3(artifact, rawFSB3, runtime, auth) {
|
|
322
|
+
const localBinding = admissionBindingV3(rawFSB3, artifact.v === 1 ? tunnelAuthV1 : transportV5);
|
|
323
|
+
if (artifact.v === 1 && (!auth || auth.role !== artifact.path.role || auth.mode !== artifact.session.auth_mode))
|
|
324
|
+
throw new ConnectErrorV3("artifact_invalid", { kind: "terminal" });
|
|
313
325
|
const tunnel = artifact.path.kind === "tunnel" ? artifact.path : undefined;
|
|
314
326
|
return {
|
|
315
327
|
role: tunnel?.role === 2 ? "server" : "client",
|
|
316
|
-
enableHybridKeyExchange: runtime.enableHybridKeyExchange === true,
|
|
328
|
+
enableHybridKeyExchange: artifact.v === 1 ? artifact.session.default_suite === 3 : runtime.enableHybridKeyExchange === true,
|
|
317
329
|
path: artifact.path.kind,
|
|
318
330
|
channelID: artifact.session.channel_id,
|
|
319
331
|
sessionContractHash: base64urlDecode(artifact.session.contract_hash_b64u),
|
|
320
332
|
suite: artifact.session.default_suite,
|
|
321
|
-
psk: base64urlDecode(artifact.session.e2ee_psk_b64u),
|
|
333
|
+
...(artifact.v === 1 ? { endpointAuth: auth, rendezvousGroupID: artifact.path.rendezvous_group_id, listenerAudience: artifact.path.listener_audience } : { psk: base64urlDecode(artifact.session.e2ee_psk_b64u), sessionContract: artifact.session }),
|
|
322
334
|
maxInboundStreams: artifact.session.max_inbound_streams,
|
|
323
|
-
sessionContract: artifact.session,
|
|
324
335
|
...(runtime.createRPCRouter === undefined ? {} : { rpcRouter: runtime.createRPCRouter() }),
|
|
325
336
|
rpcServerOptions: {
|
|
326
337
|
...(runtime.maxRpcFrameBytes === undefined ? {} : { maxFrameBytes: runtime.maxRpcFrameBytes }),
|
package/dist/v3/tunnelIngress.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeCandidateURL } from "./artifact.js";
|
|
2
2
|
import { ConnectErrorV3 } from "./security.js";
|
|
3
|
+
import { transportV5, tunnelAuthV1 } from "./wireProfile.js";
|
|
3
4
|
export function selectTunnelIngress(kind, candidates, url) {
|
|
4
5
|
if (url === undefined) {
|
|
5
6
|
if (kind !== "tunnel" || new Set(candidates.map(candidate => candidate.normalized_url)).size === 1)
|
|
@@ -8,7 +9,7 @@ export function selectTunnelIngress(kind, candidates, url) {
|
|
|
8
9
|
else if (kind === "tunnel" && typeof url === "string" && url.length <= 2048) {
|
|
9
10
|
const selected = candidates.filter(candidate => {
|
|
10
11
|
try {
|
|
11
|
-
return normalizeCandidateURL(kind, candidate.carrier, url) === candidate.normalized_url;
|
|
12
|
+
return normalizeCandidateURL(kind, candidate.carrier, url, candidate.wire_profile === tunnelAuthV1.name ? tunnelAuthV1 : transportV5) === candidate.normalized_url;
|
|
12
13
|
}
|
|
13
14
|
catch {
|
|
14
15
|
return false;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { CarrierUnreliableDatagramsV3 } from "./carrier.js";
|
|
2
2
|
import { CipherSuiteV3 } from "./protocol.js";
|
|
3
3
|
import type { DirectionV3 } from "./protocol.js";
|
|
4
|
+
import { type WireProfile } from "./wireProfile.js";
|
|
4
5
|
export declare const UNRELIABLE_MESSAGES_FEATURE_V3 = 1;
|
|
5
6
|
export declare const UNRELIABLE_MESSAGE_MAX_PLAINTEXT_BYTES_V3: 976;
|
|
6
7
|
export declare const UNRELIABLE_MESSAGE_WIRE_BYTES_V3: 1024;
|
|
7
8
|
export type InternalUnreliableMessageChannelV3Options = Readonly<{
|
|
9
|
+
profile?: WireProfile;
|
|
8
10
|
transport: CarrierUnreliableDatagramsV3;
|
|
9
11
|
suite: CipherSuiteV3;
|
|
10
12
|
h3: Uint8Array;
|
|
@@ -26,6 +28,7 @@ export type UnreliableMessageMaterialV3 = Readonly<{
|
|
|
26
28
|
noncePrefix: Uint8Array;
|
|
27
29
|
}>;
|
|
28
30
|
export type SealUnreliableMessageDatagramV3Options = Readonly<{
|
|
31
|
+
profile?: WireProfile;
|
|
29
32
|
suite: CipherSuiteV3;
|
|
30
33
|
epochSecret: Uint8Array;
|
|
31
34
|
h3: Uint8Array;
|
|
@@ -4,7 +4,7 @@ import { expand } from "@noble/hashes/hkdf.js";
|
|
|
4
4
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
5
5
|
import { CipherSuiteV3 } from "./protocol.js";
|
|
6
6
|
import { UnreliableMessageError } from "../public/contract.js";
|
|
7
|
-
import {
|
|
7
|
+
import { matchesFramePrefix, transportV5, writeFramePrefix } from "./wireProfile.js";
|
|
8
8
|
export const UNRELIABLE_MESSAGES_FEATURE_V3 = 0x00000001;
|
|
9
9
|
export const UNRELIABLE_MESSAGE_MAX_PLAINTEXT_BYTES_V3 = 976;
|
|
10
10
|
export const UNRELIABLE_MESSAGE_WIRE_BYTES_V3 = 1_024;
|
|
@@ -24,6 +24,7 @@ export function createInternalUnreliableMessageChannelV3(options) {
|
|
|
24
24
|
class InternalUnreliableMessageChannelV3 {
|
|
25
25
|
options;
|
|
26
26
|
maxMessageSize = UNRELIABLE_MESSAGE_MAX_PLAINTEXT_BYTES_V3;
|
|
27
|
+
profile;
|
|
27
28
|
replay = new Map();
|
|
28
29
|
now;
|
|
29
30
|
nextSequence = 0n;
|
|
@@ -35,6 +36,7 @@ class InternalUnreliableMessageChannelV3 {
|
|
|
35
36
|
throw new UnreliableMessageError("operation_failed");
|
|
36
37
|
}
|
|
37
38
|
this.now = options.now ?? Date.now;
|
|
39
|
+
this.profile = options.profile ?? transportV5;
|
|
38
40
|
}
|
|
39
41
|
async send(message, options) {
|
|
40
42
|
throwIfAborted(options.signal);
|
|
@@ -59,6 +61,7 @@ class InternalUnreliableMessageChannelV3 {
|
|
|
59
61
|
throw new UnreliableMessageError("closed");
|
|
60
62
|
const sequence = this.nextSequence++;
|
|
61
63
|
const sealed = sealUnreliableMessageDatagramV3({
|
|
64
|
+
profile: this.profile,
|
|
62
65
|
suite: this.options.suite,
|
|
63
66
|
epochSecret: roots.epochSecret,
|
|
64
67
|
h3: this.options.h3,
|
|
@@ -99,11 +102,11 @@ class InternalUnreliableMessageChannelV3 {
|
|
|
99
102
|
throw new UnreliableMessageError("canceled");
|
|
100
103
|
throw new UnreliableMessageError("closed");
|
|
101
104
|
}
|
|
102
|
-
if (isPreviousVersionDatagram(wire)) {
|
|
105
|
+
if (isPreviousVersionDatagram(wire, this.profile)) {
|
|
103
106
|
this.options.onProtocolFailure();
|
|
104
107
|
throw new UnreliableMessageError("closed");
|
|
105
108
|
}
|
|
106
|
-
const decoded = decodeHeader(wire);
|
|
109
|
+
const decoded = decodeHeader(wire, this.profile);
|
|
107
110
|
if (decoded === undefined || decoded.expiresAtUnixMs <= BigInt(Math.floor(this.now())))
|
|
108
111
|
continue;
|
|
109
112
|
const epochSecret = this.options.receiveEpochSecret(decoded.epoch);
|
|
@@ -112,9 +115,9 @@ class InternalUnreliableMessageChannelV3 {
|
|
|
112
115
|
const window = this.replay.get(decoded.epoch) ?? new ReplayWindow();
|
|
113
116
|
if (window.seen(decoded.sequence))
|
|
114
117
|
continue;
|
|
115
|
-
const material = deriveUnreliableMessageMaterialV3(epochSecret, this.options.h3, this.options.receiveDirection, decoded.epoch);
|
|
118
|
+
const material = deriveUnreliableMessageMaterialV3(epochSecret, this.options.h3, this.options.receiveDirection, decoded.epoch, this.profile);
|
|
116
119
|
const nonce = concat(material.noncePrefix, u64be(decoded.sequence));
|
|
117
|
-
const aad = labelWith(
|
|
120
|
+
const aad = labelWith(this.profile.labels["unreliable-aad"], this.options.h3, byte(this.options.receiveDirection), wire.subarray(0, HEADER_BYTES));
|
|
118
121
|
let plaintext;
|
|
119
122
|
try {
|
|
120
123
|
plaintext = cipher(this.options.suite, material.recordKey, nonce, aad).decrypt(wire.subarray(HEADER_BYTES));
|
|
@@ -132,22 +135,21 @@ class InternalUnreliableMessageChannelV3 {
|
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
|
-
function isPreviousVersionDatagram(wire) {
|
|
138
|
+
function isPreviousVersionDatagram(wire, profile) {
|
|
136
139
|
if (!(wire instanceof Uint8Array) || wire.byteLength < 5 ||
|
|
137
|
-
wire[0] !== 0x46 || wire[1] !==
|
|
140
|
+
wire[0] !== 0x46 || wire[1] !== profile.family || wire[2] !== 0x44)
|
|
138
141
|
return false;
|
|
139
|
-
return wire[3] >= 0x30 && wire[3] <= 0x39 && (wire[3] !==
|
|
142
|
+
return wire[3] >= 0x30 && wire[3] <= 0x39 && (wire[3] !== profile.digit || wire[4] !== profile.version);
|
|
140
143
|
}
|
|
141
144
|
/** @internal */
|
|
142
|
-
export function encodeUnreliableMessageHeaderV3(epoch, sequence, expiresAtUnixMs, ciphertextLength) {
|
|
145
|
+
export function encodeUnreliableMessageHeaderV3(epoch, sequence, expiresAtUnixMs, ciphertextLength, profile = transportV5) {
|
|
143
146
|
if (!isUint32(epoch) || !isUint64(sequence) || !isUint64(expiresAtUnixMs) ||
|
|
144
147
|
expiresAtUnixMs === 0n || !Number.isInteger(ciphertextLength) ||
|
|
145
148
|
ciphertextLength < MIN_CIPHERTEXT_BYTES || ciphertextLength > MAX_CIPHERTEXT_BYTES) {
|
|
146
149
|
throw new Error("invalid FSD3 header");
|
|
147
150
|
}
|
|
148
151
|
const header = new Uint8Array(HEADER_BYTES);
|
|
149
|
-
header
|
|
150
|
-
header[4] = 5;
|
|
152
|
+
writeFramePrefix(header, 0x44, profile);
|
|
151
153
|
header[5] = 0;
|
|
152
154
|
const view = new DataView(header.buffer);
|
|
153
155
|
view.setUint16(6, HEADER_BYTES, false);
|
|
@@ -157,11 +159,10 @@ export function encodeUnreliableMessageHeaderV3(epoch, sequence, expiresAtUnixMs
|
|
|
157
159
|
view.setUint32(28, ciphertextLength, false);
|
|
158
160
|
return header;
|
|
159
161
|
}
|
|
160
|
-
function decodeHeader(wire) {
|
|
162
|
+
function decodeHeader(wire, profile) {
|
|
161
163
|
if (!(wire instanceof Uint8Array) || wire.byteLength < HEADER_BYTES + TAG_BYTES ||
|
|
162
164
|
wire.byteLength > UNRELIABLE_MESSAGE_WIRE_BYTES_V3 ||
|
|
163
|
-
wire
|
|
164
|
-
wire[4] !== 5 || wire[5] !== 0)
|
|
165
|
+
!matchesFramePrefix(wire, 0x44, profile) || wire[5] !== 0)
|
|
165
166
|
return undefined;
|
|
166
167
|
const view = new DataView(wire.buffer, wire.byteOffset, HEADER_BYTES);
|
|
167
168
|
if (view.getUint16(6, false) !== HEADER_BYTES || view.getUint32(28, false) !== wire.byteLength - HEADER_BYTES) {
|
|
@@ -177,22 +178,23 @@ function decodeHeader(wire) {
|
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
180
|
/** @internal */
|
|
180
|
-
export function deriveUnreliableMessageMaterialV3(epochSecret, h3, direction, epoch) {
|
|
181
|
-
const unreliableRoot = expand(sha256, epochSecret, labelWith(
|
|
182
|
-
const materialSecret = expand(sha256, unreliableRoot, labelWith(
|
|
181
|
+
export function deriveUnreliableMessageMaterialV3(epochSecret, h3, direction, epoch, profile = transportV5) {
|
|
182
|
+
const unreliableRoot = expand(sha256, epochSecret, labelWith(profile.labels["unreliable-root"]), 32);
|
|
183
|
+
const materialSecret = expand(sha256, unreliableRoot, labelWith(profile.labels.unreliable, h3, byte(direction), u32be(epoch)), 32);
|
|
183
184
|
return {
|
|
184
185
|
unreliableRoot,
|
|
185
186
|
materialSecret,
|
|
186
|
-
recordKey: expand(sha256, materialSecret, labelWith(
|
|
187
|
-
noncePrefix: expand(sha256, materialSecret, labelWith(
|
|
187
|
+
recordKey: expand(sha256, materialSecret, labelWith(profile.labels["unreliable-key"]), 32),
|
|
188
|
+
noncePrefix: expand(sha256, materialSecret, labelWith(profile.labels["unreliable-nonce"]), 4),
|
|
188
189
|
};
|
|
189
190
|
}
|
|
190
191
|
/** @internal */
|
|
191
192
|
export function sealUnreliableMessageDatagramV3(options) {
|
|
192
|
-
const
|
|
193
|
-
const
|
|
193
|
+
const profile = options.profile ?? transportV5;
|
|
194
|
+
const header = encodeUnreliableMessageHeaderV3(options.epoch, options.sequence, options.expiresAtUnixMs, options.plaintext.byteLength + TAG_BYTES, profile);
|
|
195
|
+
const material = deriveUnreliableMessageMaterialV3(options.epochSecret, options.h3, options.direction, options.epoch, profile);
|
|
194
196
|
const nonce = concat(material.noncePrefix, u64be(options.sequence));
|
|
195
|
-
const aad = labelWith(
|
|
197
|
+
const aad = labelWith(profile.labels["unreliable-aad"], options.h3, byte(options.direction), header);
|
|
196
198
|
const ciphertext = cipher(options.suite, material.recordKey, nonce, aad).encrypt(options.plaintext);
|
|
197
199
|
return {
|
|
198
200
|
material,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const tunnelAuthProfile = "flowersec-tunnel-auth/1";
|
|
2
|
+
export declare const endpointIngress: Readonly<{
|
|
3
|
+
websocket: "/flowersec/tunnel-auth/v1";
|
|
4
|
+
webtransport: "/flowersec/webtransport/tunnel-auth/v1";
|
|
5
|
+
subprotocol: "flowersec.tunnel-auth.v1";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const transportV5: Readonly<{
|
|
8
|
+
readonly name: "flowersec/5";
|
|
9
|
+
readonly version: 5;
|
|
10
|
+
readonly family: 83;
|
|
11
|
+
readonly digit: 53;
|
|
12
|
+
readonly lastHandshakeType: 4;
|
|
13
|
+
readonly labels: Readonly<{
|
|
14
|
+
readonly "session-contract": "flowersec-v5-session-contract\0";
|
|
15
|
+
readonly candidates: "flowersec-v5-candidates\0";
|
|
16
|
+
readonly admission: "flowersec-v5-admission\0";
|
|
17
|
+
readonly "runtime-capability": "flowersec-v5-runtime-capability\0";
|
|
18
|
+
readonly handshake: "flowersec-v5-handshake\0";
|
|
19
|
+
readonly "server-finished": "flowersec v5 server finished";
|
|
20
|
+
readonly "client-finished": "flowersec v5 client finished";
|
|
21
|
+
readonly "epoch-zero": "flowersec v5 epoch zero";
|
|
22
|
+
readonly "control-root": "flowersec v5 control root";
|
|
23
|
+
readonly "stream-root": "flowersec v5 stream root";
|
|
24
|
+
readonly "setup-root": "flowersec v5 setup root";
|
|
25
|
+
readonly "rekey-root": "flowersec v5 rekey root";
|
|
26
|
+
readonly "next-epoch": "flowersec v5 next epoch";
|
|
27
|
+
readonly stream: "flowersec v5 stream";
|
|
28
|
+
readonly control: "flowersec v5 control";
|
|
29
|
+
readonly "record-key": "flowersec v5 record key";
|
|
30
|
+
readonly nonce: "flowersec v5 nonce";
|
|
31
|
+
readonly "unreliable-root": "flowersec v5 unreliable root";
|
|
32
|
+
readonly unreliable: "flowersec v5 unreliable";
|
|
33
|
+
readonly "unreliable-key": "flowersec v5 unreliable key";
|
|
34
|
+
readonly "unreliable-nonce": "flowersec v5 unreliable nonce";
|
|
35
|
+
readonly "unreliable-aad": "flowersec-v5-unreliable";
|
|
36
|
+
readonly "setup-mac": "flowersec-v5-setup\0";
|
|
37
|
+
readonly "record-aad": "flowersec-v5-record\0";
|
|
38
|
+
readonly open: "flowersec-v5-open\0";
|
|
39
|
+
readonly "acceptor-admissions": "flowersec-v5-acceptor-admissions\0";
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
export declare const tunnelAuthV1: Readonly<{
|
|
43
|
+
readonly name: "flowersec-tunnel-auth/1";
|
|
44
|
+
readonly version: 1;
|
|
45
|
+
readonly family: 84;
|
|
46
|
+
readonly digit: 49;
|
|
47
|
+
readonly lastHandshakeType: 3;
|
|
48
|
+
readonly labels: Readonly<Record<"acceptor-admissions" | "admission" | "candidates" | "client-finished" | "control" | "control-root" | "epoch-zero" | "handshake" | "next-epoch" | "nonce" | "open" | "record-aad" | "record-key" | "rekey-root" | "runtime-capability" | "server-finished" | "session-contract" | "setup-mac" | "setup-root" | "stream" | "stream-root" | "unreliable" | "unreliable-aad" | "unreliable-key" | "unreliable-nonce" | "unreliable-root", string>>;
|
|
49
|
+
}>;
|
|
50
|
+
export type WireProfile = typeof transportV5 | typeof tunnelAuthV1;
|
|
51
|
+
export declare function writeFramePrefix(out: Uint8Array, kind: number, profile: WireProfile): void;
|
|
52
|
+
export declare function matchesFramePrefix(raw: Uint8Array, kind: number, profile: WireProfile): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FLOWERSEC_V3_CRYPTO_LABELS, FLOWERSEC_V3_PROFILE } from "./transportConstants.js";
|
|
2
|
+
export const tunnelAuthProfile = "flowersec-tunnel-auth/1";
|
|
3
|
+
export const endpointIngress = Object.freeze({
|
|
4
|
+
websocket: "/flowersec/tunnel-auth/v1", webtransport: "/flowersec/webtransport/tunnel-auth/v1", subprotocol: "flowersec.tunnel-auth.v1",
|
|
5
|
+
});
|
|
6
|
+
const tunnelLabels = Object.freeze(Object.fromEntries(Object.entries(FLOWERSEC_V3_CRYPTO_LABELS).map(([name, label]) => [
|
|
7
|
+
name, label.replace(/^flowersec-v5-/, "flowersec-tunnel-auth-v1-").replace(/^flowersec v5 /, "flowersec tunnel-auth v1 "),
|
|
8
|
+
])));
|
|
9
|
+
export const transportV5 = Object.freeze({
|
|
10
|
+
name: FLOWERSEC_V3_PROFILE, version: 5, family: 0x53, digit: 0x35, lastHandshakeType: 4, labels: FLOWERSEC_V3_CRYPTO_LABELS,
|
|
11
|
+
});
|
|
12
|
+
export const tunnelAuthV1 = Object.freeze({
|
|
13
|
+
name: tunnelAuthProfile, version: 1, family: 0x54, digit: 0x31, lastHandshakeType: 3, labels: tunnelLabels,
|
|
14
|
+
});
|
|
15
|
+
export function writeFramePrefix(out, kind, profile) {
|
|
16
|
+
out.set([0x46, profile.family, kind, profile.digit, profile.version]);
|
|
17
|
+
}
|
|
18
|
+
export function matchesFramePrefix(raw, kind, profile) {
|
|
19
|
+
return raw[0] === 0x46 && raw[1] === profile.family && raw[2] === kind && raw[3] === profile.digit && raw[4] === profile.version;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/flowersec-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Flowersec core TypeScript library for carrier-neutral encrypted sessions and multiplexed streams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -75,6 +75,8 @@
|
|
|
75
75
|
"prepublishOnly": "npm run build && npm run verify:package"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
+
"@hpke/core": "1.10.1",
|
|
79
|
+
"@hpke/dhkem-x25519": "1.8.1",
|
|
78
80
|
"@types/node": "26.4.0",
|
|
79
81
|
"@noble/ciphers": "2.4.0",
|
|
80
82
|
"@noble/curves": "2.4.0",
|
|
@@ -100,7 +102,7 @@
|
|
|
100
102
|
"vitest": "4.1.12"
|
|
101
103
|
},
|
|
102
104
|
"optionalDependencies": {
|
|
103
|
-
"@floegence/flowersec-node-native": "8.
|
|
105
|
+
"@floegence/flowersec-node-native": "8.2.0"
|
|
104
106
|
},
|
|
105
|
-
"flowersecSourceCommit": "
|
|
107
|
+
"flowersecSourceCommit": "df3d9672ecb2f40e246e0dce53cda5e231de784f"
|
|
106
108
|
}
|
package/sbom/cyclonedx.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bomFormat": "CycloneDX",
|
|
3
3
|
"specVersion": "1.5",
|
|
4
|
-
"serialNumber": "urn:uuid:
|
|
4
|
+
"serialNumber": "urn:uuid:527067d2-7fe6-564a-885f-0116f9b644f3",
|
|
5
5
|
"version": 1,
|
|
6
6
|
"metadata": {
|
|
7
7
|
"component": {
|
|
8
8
|
"type": "library",
|
|
9
9
|
"name": "@floegence/flowersec-core",
|
|
10
|
-
"version": "8.
|
|
11
|
-
"purl": "pkg:npm/%40floegence/flowersec-core@8.
|
|
12
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-core@8.
|
|
10
|
+
"version": "8.2.0",
|
|
11
|
+
"purl": "pkg:npm/%40floegence/flowersec-core@8.2.0",
|
|
12
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-core@8.2.0"
|
|
13
13
|
},
|
|
14
14
|
"properties": [
|
|
15
15
|
{
|
|
16
16
|
"name": "flowersec:source-inventory-sha256",
|
|
17
|
-
"value": "
|
|
17
|
+
"value": "6d785a4ab94ca6d7ec556899c9746f172ffabc9acc7af7afc00753842307e383"
|
|
18
18
|
}
|
|
19
19
|
]
|
|
20
20
|
},
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
{
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "@floegence/flowersec-node-native",
|
|
25
|
-
"version": "8.
|
|
26
|
-
"purl": "pkg:npm/%40floegence/flowersec-node-native@8.
|
|
27
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native@8.
|
|
25
|
+
"version": "8.2.0",
|
|
26
|
+
"purl": "pkg:npm/%40floegence/flowersec-node-native@8.2.0",
|
|
27
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native@8.2.0",
|
|
28
28
|
"licenses": [
|
|
29
29
|
{
|
|
30
30
|
"expression": "MIT"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
"type": "library",
|
|
52
52
|
"name": "@floegence/flowersec-node-native-darwin-arm64",
|
|
53
|
-
"version": "8.
|
|
54
|
-
"purl": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.
|
|
55
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.
|
|
53
|
+
"version": "8.2.0",
|
|
54
|
+
"purl": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.2.0",
|
|
55
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.2.0",
|
|
56
56
|
"licenses": [
|
|
57
57
|
{
|
|
58
58
|
"expression": "MIT"
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
{
|
|
79
79
|
"type": "library",
|
|
80
80
|
"name": "@floegence/flowersec-node-native-darwin-x64",
|
|
81
|
-
"version": "8.
|
|
82
|
-
"purl": "pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.
|
|
83
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.
|
|
81
|
+
"version": "8.2.0",
|
|
82
|
+
"purl": "pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.2.0",
|
|
83
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.2.0",
|
|
84
84
|
"licenses": [
|
|
85
85
|
{
|
|
86
86
|
"expression": "MIT"
|
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
{
|
|
107
107
|
"type": "library",
|
|
108
108
|
"name": "@floegence/flowersec-node-native-linux-arm64-gnu",
|
|
109
|
-
"version": "8.
|
|
110
|
-
"purl": "pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.
|
|
111
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.
|
|
109
|
+
"version": "8.2.0",
|
|
110
|
+
"purl": "pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.2.0",
|
|
111
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.2.0",
|
|
112
112
|
"licenses": [
|
|
113
113
|
{
|
|
114
114
|
"expression": "MIT"
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
{
|
|
135
135
|
"type": "library",
|
|
136
136
|
"name": "@floegence/flowersec-node-native-linux-x64-gnu",
|
|
137
|
-
"version": "8.
|
|
138
|
-
"purl": "pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.
|
|
139
|
-
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.
|
|
137
|
+
"version": "8.2.0",
|
|
138
|
+
"purl": "pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.2.0",
|
|
139
|
+
"bom-ref": "pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.2.0",
|
|
140
140
|
"licenses": [
|
|
141
141
|
{
|
|
142
142
|
"expression": "MIT"
|
|
@@ -159,6 +159,90 @@
|
|
|
159
159
|
}
|
|
160
160
|
]
|
|
161
161
|
},
|
|
162
|
+
{
|
|
163
|
+
"type": "library",
|
|
164
|
+
"name": "@hpke/common",
|
|
165
|
+
"version": "1.13.0",
|
|
166
|
+
"purl": "pkg:npm/%40hpke/common@1.13.0",
|
|
167
|
+
"bom-ref": "pkg:npm/%40hpke/common@1.13.0",
|
|
168
|
+
"licenses": [
|
|
169
|
+
{
|
|
170
|
+
"expression": "MIT"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"externalReferences": [
|
|
174
|
+
{
|
|
175
|
+
"type": "distribution",
|
|
176
|
+
"url": "https://registry.npmjs.org/@hpke/common/-/common-1.13.0.tgz"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"properties": [
|
|
180
|
+
{
|
|
181
|
+
"name": "flowersec:declared-license",
|
|
182
|
+
"value": "MIT"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "flowersec:source-offer-required",
|
|
186
|
+
"value": "false"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"type": "library",
|
|
192
|
+
"name": "@hpke/core",
|
|
193
|
+
"version": "1.10.1",
|
|
194
|
+
"purl": "pkg:npm/%40hpke/core@1.10.1",
|
|
195
|
+
"bom-ref": "pkg:npm/%40hpke/core@1.10.1",
|
|
196
|
+
"licenses": [
|
|
197
|
+
{
|
|
198
|
+
"expression": "MIT"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"externalReferences": [
|
|
202
|
+
{
|
|
203
|
+
"type": "distribution",
|
|
204
|
+
"url": "https://registry.npmjs.org/@hpke/core/-/core-1.10.1.tgz"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
"properties": [
|
|
208
|
+
{
|
|
209
|
+
"name": "flowersec:declared-license",
|
|
210
|
+
"value": "MIT"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "flowersec:source-offer-required",
|
|
214
|
+
"value": "false"
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"type": "library",
|
|
220
|
+
"name": "@hpke/dhkem-x25519",
|
|
221
|
+
"version": "1.8.1",
|
|
222
|
+
"purl": "pkg:npm/%40hpke/dhkem-x25519@1.8.1",
|
|
223
|
+
"bom-ref": "pkg:npm/%40hpke/dhkem-x25519@1.8.1",
|
|
224
|
+
"licenses": [
|
|
225
|
+
{
|
|
226
|
+
"expression": "MIT"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"externalReferences": [
|
|
230
|
+
{
|
|
231
|
+
"type": "distribution",
|
|
232
|
+
"url": "https://registry.npmjs.org/@hpke/dhkem-x25519/-/dhkem-x25519-1.8.1.tgz"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"properties": [
|
|
236
|
+
{
|
|
237
|
+
"name": "flowersec:declared-license",
|
|
238
|
+
"value": "MIT"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "flowersec:source-offer-required",
|
|
242
|
+
"value": "false"
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
},
|
|
162
246
|
{
|
|
163
247
|
"type": "library",
|
|
164
248
|
"name": "@noble/ciphers",
|
|
@@ -414,9 +498,11 @@
|
|
|
414
498
|
],
|
|
415
499
|
"dependencies": [
|
|
416
500
|
{
|
|
417
|
-
"ref": "pkg:npm/%40floegence/flowersec-core@8.
|
|
501
|
+
"ref": "pkg:npm/%40floegence/flowersec-core@8.2.0",
|
|
418
502
|
"dependsOn": [
|
|
419
|
-
"pkg:npm/%40floegence/flowersec-node-native@8.
|
|
503
|
+
"pkg:npm/%40floegence/flowersec-node-native@8.2.0",
|
|
504
|
+
"pkg:npm/%40hpke/core@1.10.1",
|
|
505
|
+
"pkg:npm/%40hpke/dhkem-x25519@1.8.1",
|
|
420
506
|
"pkg:npm/%40noble/ciphers@2.4.0",
|
|
421
507
|
"pkg:npm/%40noble/curves@2.4.0",
|
|
422
508
|
"pkg:npm/%40noble/hashes@2.4.0",
|
|
@@ -427,30 +513,46 @@
|
|
|
427
513
|
]
|
|
428
514
|
},
|
|
429
515
|
{
|
|
430
|
-
"ref": "pkg:npm/%40floegence/flowersec-node-native@8.
|
|
516
|
+
"ref": "pkg:npm/%40floegence/flowersec-node-native@8.2.0",
|
|
431
517
|
"dependsOn": [
|
|
432
|
-
"pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.
|
|
433
|
-
"pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.
|
|
434
|
-
"pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.
|
|
435
|
-
"pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.
|
|
518
|
+
"pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.2.0",
|
|
519
|
+
"pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.2.0",
|
|
520
|
+
"pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.2.0",
|
|
521
|
+
"pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.2.0"
|
|
436
522
|
]
|
|
437
523
|
},
|
|
438
524
|
{
|
|
439
|
-
"ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.
|
|
525
|
+
"ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-arm64@8.2.0",
|
|
526
|
+
"dependsOn": []
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"ref": "pkg:npm/%40floegence/flowersec-node-native-darwin-x64@8.2.0",
|
|
440
530
|
"dependsOn": []
|
|
441
531
|
},
|
|
442
532
|
{
|
|
443
|
-
"ref": "pkg:npm/%40floegence/flowersec-node-native-
|
|
533
|
+
"ref": "pkg:npm/%40floegence/flowersec-node-native-linux-arm64-gnu@8.2.0",
|
|
444
534
|
"dependsOn": []
|
|
445
535
|
},
|
|
446
536
|
{
|
|
447
|
-
"ref": "pkg:npm/%40floegence/flowersec-node-native-linux-
|
|
537
|
+
"ref": "pkg:npm/%40floegence/flowersec-node-native-linux-x64-gnu@8.2.0",
|
|
448
538
|
"dependsOn": []
|
|
449
539
|
},
|
|
450
540
|
{
|
|
451
|
-
"ref": "pkg:npm/%
|
|
541
|
+
"ref": "pkg:npm/%40hpke/common@1.13.0",
|
|
452
542
|
"dependsOn": []
|
|
453
543
|
},
|
|
544
|
+
{
|
|
545
|
+
"ref": "pkg:npm/%40hpke/core@1.10.1",
|
|
546
|
+
"dependsOn": [
|
|
547
|
+
"pkg:npm/%40hpke/common@1.13.0"
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"ref": "pkg:npm/%40hpke/dhkem-x25519@1.8.1",
|
|
552
|
+
"dependsOn": [
|
|
553
|
+
"pkg:npm/%40hpke/common@1.13.0"
|
|
554
|
+
]
|
|
555
|
+
},
|
|
454
556
|
{
|
|
455
557
|
"ref": "pkg:npm/%40noble/ciphers@2.4.0",
|
|
456
558
|
"dependsOn": []
|