@zapo-js/fake-server 1.2.0 → 1.3.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Agent as HttpsAgent } from 'node:https';
|
|
2
2
|
import { type WaFakeAuthenticatedInfo, WaFakeConnectionPipeline } from '../infra/WaFakeConnectionPipeline';
|
|
3
|
+
import { type FakeNoiseRootCa } from '../protocol/auth/cert-chain';
|
|
3
4
|
import type { ParsedClientPayload } from '../protocol/auth/client-payload-validate';
|
|
4
5
|
import type { BuildSuccessNodeInput } from '../protocol/auth/success-node';
|
|
5
6
|
import type { BuildAbPropsResultInput } from '../protocol/iq/abprops';
|
|
@@ -63,6 +64,22 @@ export interface FakeWaServerOptions {
|
|
|
63
64
|
readonly host?: string;
|
|
64
65
|
readonly port?: number;
|
|
65
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Root of the Noise certificate chain the server presents. Defaults to a
|
|
69
|
+
* fresh random CA per {@link FakeWaServer.listen}, read back from
|
|
70
|
+
* {@link FakeWaServer.noiseRootCa}.
|
|
71
|
+
*
|
|
72
|
+
* A client in a separate process cannot read it back: it has to pin the
|
|
73
|
+
* anchor before it dials, while the server is not listening yet. Pass a CA
|
|
74
|
+
* both sides derive from a shared seed to make it knowable ahead of time.
|
|
75
|
+
*
|
|
76
|
+
* Carries the signing half, unlike the public-only
|
|
77
|
+
* {@link FakeWaServerNoiseRootCa} this server exposes. It signs a chain no
|
|
78
|
+
* real client trusts, so it is test material rather than a secret — but a
|
|
79
|
+
* seed committed beside the tests is the intended source, not one shared
|
|
80
|
+
* with anything that matters.
|
|
81
|
+
*/
|
|
82
|
+
readonly noiseRootCa?: FakeNoiseRootCa;
|
|
66
83
|
}
|
|
67
84
|
export interface FakeSessionKeyInfo {
|
|
68
85
|
readonly clientPayload: ParsedClientPayload;
|
package/dist/api/FakeWaServer.js
CHANGED
|
@@ -432,7 +432,7 @@ class FakeWaServer {
|
|
|
432
432
|
}
|
|
433
433
|
;
|
|
434
434
|
[this.rootCa, this.serverStaticKeyPair] = await Promise.all([
|
|
435
|
-
(0, cert_chain_1.generateFakeNoiseRootCa)(),
|
|
435
|
+
this.options.noiseRootCa ?? (0, cert_chain_1.generateFakeNoiseRootCa)(),
|
|
436
436
|
crypto_1.X25519.generateKeyPair()
|
|
437
437
|
]);
|
|
438
438
|
const mediaHandler = this.buildMediaRequestHandler();
|
|
@@ -428,7 +428,7 @@ export class FakeWaServer {
|
|
|
428
428
|
}
|
|
429
429
|
;
|
|
430
430
|
[this.rootCa, this.serverStaticKeyPair] = await Promise.all([
|
|
431
|
-
generateFakeNoiseRootCa(),
|
|
431
|
+
this.options.noiseRootCa ?? generateFakeNoiseRootCa(),
|
|
432
432
|
X25519.generateKeyPair()
|
|
433
433
|
]);
|
|
434
434
|
const mediaHandler = this.buildMediaRequestHandler();
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export { FakePeer } from './api/FakePeer';
|
|
|
6
6
|
export type { CreateFakePeerOptions, ExpectGroupMessageOptions, ExpectMessageOptions, ReceivedMessage, SendMessageOptions } from './api/FakePeer';
|
|
7
7
|
export { FakeServerSession, FakeWaServer } from './api/FakeWaServer';
|
|
8
8
|
export type { BinaryNode, ExpectIqOptions, ExpectStanzaOptions, FakeSessionKeyInfo, FakeWaServerNoiseRootCa, FakeWaServerOptions, FakeWaServerPipelineListener, StanzaMatcher, WaFakeAuthenticatedInfo, WaFakeConnectionPipeline } from './api/FakeWaServer';
|
|
9
|
+
/**
|
|
10
|
+
* Signing half of the Noise root, needed only to pin
|
|
11
|
+
* {@link FakeWaServerOptions.noiseRootCa}. Readers of `server.noiseRootCa` get
|
|
12
|
+
* the public-only {@link FakeWaServerNoiseRootCa} instead.
|
|
13
|
+
*/
|
|
14
|
+
export type { FakeNoiseRootCa } from './protocol/auth/cert-chain';
|
|
9
15
|
export { IqExpectation, Scenario } from './api/Scenario';
|
|
10
16
|
export type { AuthenticatedPipelineListener, ScenarioServer } from './api/Scenario';
|
|
11
17
|
export { WaFakeConnection } from './infra/WaFakeConnection';
|
package/package.json
CHANGED