@bchconnect/test-utils 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/index.cjs +329 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +408 -0
- package/dist/index.d.ts +408 -0
- package/dist/index.js +323 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -3
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { AbortedError, InvalidWalletResponseError, MethodUnsupportedError, RequestRejectedError } from "@bchconnect/core";
|
|
2
|
+
//#region src/fake-connector.ts
|
|
3
|
+
/** Key under which `connect()` records a session in its storage namespace. */
|
|
4
|
+
function storageKey(sessionId) {
|
|
5
|
+
return `session:${sessionId}`;
|
|
6
|
+
}
|
|
7
|
+
/** Key under which one session's listeners for one event are held. */
|
|
8
|
+
function listenerKey(sessionId, event) {
|
|
9
|
+
return `${sessionId}::${event}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds a connector that does exactly what its script says, and records
|
|
13
|
+
* everything the client asked of it.
|
|
14
|
+
*
|
|
15
|
+
* The protocol is passed explicitly: a partial method map and an optional
|
|
16
|
+
* session give inference nothing reliable to work from.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const connector = createFakeConnector<DemoProtocol>({
|
|
21
|
+
* protocol: "demo",
|
|
22
|
+
* session: demoSession({ id: "s1" }),
|
|
23
|
+
* methods: {
|
|
24
|
+
* get_balance: async () => ({ sats: 1_000n }),
|
|
25
|
+
* sign_message: "hang",
|
|
26
|
+
* },
|
|
27
|
+
* capabilities: ["message-signing"],
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const session = await connector.connect({});
|
|
31
|
+
* connector.emitProtocolEvent(session, "wallet_ready", { walletName: "Fake" });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
function createFakeConnector(script) {
|
|
37
|
+
const calls = [];
|
|
38
|
+
const log = [];
|
|
39
|
+
const pending = [];
|
|
40
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
41
|
+
const persist = script.persist ?? true;
|
|
42
|
+
const { interfaces } = script;
|
|
43
|
+
let context;
|
|
44
|
+
const nextSession = () => {
|
|
45
|
+
if (script.session === void 0) throw new Error(`Fake connector "${script.protocol}" has no session to connect with.`);
|
|
46
|
+
return typeof script.session === "function" ? script.session() : script.session;
|
|
47
|
+
};
|
|
48
|
+
const abortedError = (signal) => new AbortedError("Aborted by caller", { cause: signal.reason });
|
|
49
|
+
/** Never settles on its own; rejects when `signal` aborts. */
|
|
50
|
+
const hang = (signal, onSettle) => {
|
|
51
|
+
let settle;
|
|
52
|
+
let fail;
|
|
53
|
+
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
54
|
+
settle = (value) => resolvePromise(value);
|
|
55
|
+
fail = rejectPromise;
|
|
56
|
+
});
|
|
57
|
+
const done = () => {
|
|
58
|
+
signal?.removeEventListener("abort", onAbort);
|
|
59
|
+
onSettle?.();
|
|
60
|
+
};
|
|
61
|
+
const onAbort = () => {
|
|
62
|
+
if (signal !== void 0) fail?.(abortedError(signal));
|
|
63
|
+
done();
|
|
64
|
+
};
|
|
65
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
66
|
+
return {
|
|
67
|
+
promise,
|
|
68
|
+
resolve: (value) => {
|
|
69
|
+
settle?.(value);
|
|
70
|
+
done();
|
|
71
|
+
},
|
|
72
|
+
reject: (error) => {
|
|
73
|
+
fail?.(error);
|
|
74
|
+
done();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
protocol: script.protocol,
|
|
80
|
+
...script.metadata === void 0 ? {} : { methods: script.metadata },
|
|
81
|
+
...interfaces === void 0 ? {} : { capabilities(session, client) {
|
|
82
|
+
log.push({
|
|
83
|
+
kind: "capabilities",
|
|
84
|
+
sessionId: session.id
|
|
85
|
+
});
|
|
86
|
+
return interfaces(session, client);
|
|
87
|
+
} },
|
|
88
|
+
calls,
|
|
89
|
+
log,
|
|
90
|
+
pending,
|
|
91
|
+
emit(event, payload) {
|
|
92
|
+
if (context === void 0) throw new Error(`Fake connector "${script.protocol}" cannot emit before setup().`);
|
|
93
|
+
context.emit(event, payload);
|
|
94
|
+
},
|
|
95
|
+
emitProtocolEvent(session, event, payload) {
|
|
96
|
+
const registered = listeners.get(listenerKey(session.id, event));
|
|
97
|
+
if (registered === void 0) return;
|
|
98
|
+
for (const listener of [...registered]) listener(payload);
|
|
99
|
+
},
|
|
100
|
+
setup(ctx) {
|
|
101
|
+
log.push({ kind: "setup" });
|
|
102
|
+
if (script.setup === "throw") throw new Error(`Fake connector "${script.protocol}" failed setup.`);
|
|
103
|
+
context = ctx;
|
|
104
|
+
},
|
|
105
|
+
async connect(opts) {
|
|
106
|
+
log.push({
|
|
107
|
+
kind: "connect",
|
|
108
|
+
timeoutMs: opts.timeoutMs
|
|
109
|
+
});
|
|
110
|
+
if (opts.signal?.aborted === true) throw abortedError(opts.signal);
|
|
111
|
+
if (script.pairing !== void 0) opts.onPairing?.(script.pairing);
|
|
112
|
+
if (script.connect === "reject") throw new RequestRejectedError("Connection rejected", { by: "user" });
|
|
113
|
+
const session = script.connect === "hang" ? await hang(opts.signal).promise : typeof script.connect === "function" ? await script.connect(opts) : nextSession();
|
|
114
|
+
if (persist) await context?.storage.set(storageKey(session.id), "1");
|
|
115
|
+
return session;
|
|
116
|
+
},
|
|
117
|
+
async restore() {
|
|
118
|
+
log.push({ kind: "restore" });
|
|
119
|
+
if (script.restore === "throw") throw new Error(`Fake connector "${script.protocol}" failed restore.`);
|
|
120
|
+
if (typeof script.restore === "function") return [...await script.restore()];
|
|
121
|
+
return [...script.restore ?? []];
|
|
122
|
+
},
|
|
123
|
+
async disconnect(session) {
|
|
124
|
+
log.push({
|
|
125
|
+
kind: "disconnect",
|
|
126
|
+
sessionId: session.id
|
|
127
|
+
});
|
|
128
|
+
if (persist) await context?.storage.delete(storageKey(session.id));
|
|
129
|
+
if (script.disconnect === "throw") throw new Error(`Fake connector "${script.protocol}" failed to disconnect.`);
|
|
130
|
+
},
|
|
131
|
+
request(session, method, params, opts) {
|
|
132
|
+
calls.push({
|
|
133
|
+
sessionId: session.id,
|
|
134
|
+
method,
|
|
135
|
+
params,
|
|
136
|
+
opts,
|
|
137
|
+
signal: opts?.signal
|
|
138
|
+
});
|
|
139
|
+
log.push({
|
|
140
|
+
kind: "request",
|
|
141
|
+
sessionId: session.id,
|
|
142
|
+
method
|
|
143
|
+
});
|
|
144
|
+
const handler = script.methods?.[method];
|
|
145
|
+
if (handler === void 0) return Promise.reject(new MethodUnsupportedError(`Method "${method}" is not advertised`, { sessionId: session.id }));
|
|
146
|
+
if (opts?.signal?.aborted === true) return Promise.reject(abortedError(opts.signal));
|
|
147
|
+
if (handler === "reject") return Promise.reject(new RequestRejectedError(`Request "${method}" rejected`, {
|
|
148
|
+
by: "user",
|
|
149
|
+
sessionId: session.id
|
|
150
|
+
}));
|
|
151
|
+
if (handler === "malformed") return Promise.reject(new InvalidWalletResponseError(`Wallet returned a malformed result for "${method}"`, { sessionId: session.id }));
|
|
152
|
+
if (handler === "hang") {
|
|
153
|
+
const held = hang(opts?.signal, () => {
|
|
154
|
+
const index = pending.indexOf(entry);
|
|
155
|
+
if (index !== -1) pending.splice(index, 1);
|
|
156
|
+
});
|
|
157
|
+
const entry = {
|
|
158
|
+
sessionId: session.id,
|
|
159
|
+
method,
|
|
160
|
+
params,
|
|
161
|
+
signal: opts?.signal,
|
|
162
|
+
resolve: held.resolve,
|
|
163
|
+
reject: held.reject
|
|
164
|
+
};
|
|
165
|
+
pending.push(entry);
|
|
166
|
+
return held.promise;
|
|
167
|
+
}
|
|
168
|
+
return handler(params, opts);
|
|
169
|
+
},
|
|
170
|
+
subscribe(session, event, listener) {
|
|
171
|
+
const key = listenerKey(session.id, event);
|
|
172
|
+
log.push({
|
|
173
|
+
kind: "subscribe",
|
|
174
|
+
sessionId: session.id,
|
|
175
|
+
event
|
|
176
|
+
});
|
|
177
|
+
const registered = listeners.get(key) ?? /* @__PURE__ */ new Set();
|
|
178
|
+
registered.add(listener);
|
|
179
|
+
listeners.set(key, registered);
|
|
180
|
+
let unsubscribed = false;
|
|
181
|
+
return () => {
|
|
182
|
+
if (unsubscribed) return;
|
|
183
|
+
unsubscribed = true;
|
|
184
|
+
log.push({
|
|
185
|
+
kind: "unsubscribe",
|
|
186
|
+
sessionId: session.id,
|
|
187
|
+
event
|
|
188
|
+
});
|
|
189
|
+
registered.delete(listener);
|
|
190
|
+
if (registered.size === 0) listeners.delete(key);
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
capabilitiesOf(session) {
|
|
194
|
+
const capabilities = typeof script.capabilities === "function" ? script.capabilities(session) : script.capabilities ?? [];
|
|
195
|
+
return new Set(capabilities);
|
|
196
|
+
},
|
|
197
|
+
async dispose() {
|
|
198
|
+
log.push({ kind: "dispose" });
|
|
199
|
+
if (script.dispose === "throw") throw new Error(`Fake connector "${script.protocol}" failed dispose.`);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/session.ts
|
|
205
|
+
/**
|
|
206
|
+
* Builds a `Session` for tests.
|
|
207
|
+
*
|
|
208
|
+
* Pass the result to `createFakeConnector` as a value for a session whose id
|
|
209
|
+
* the test pins, or as a function for a fresh id on every `connect()`.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const session = fakeSession<DemoProtocol>({
|
|
214
|
+
* id: "s1",
|
|
215
|
+
* protocol: "demo",
|
|
216
|
+
* data: {
|
|
217
|
+
* addresses: ["bitcoincash:qpea4gc3r589sdqdcprsu6uyxpugpqnshsa8v7vsxq"],
|
|
218
|
+
* xpubs: [],
|
|
219
|
+
* },
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @beta
|
|
224
|
+
*/
|
|
225
|
+
function fakeSession(init) {
|
|
226
|
+
return {
|
|
227
|
+
id: init.id ?? crypto.randomUUID(),
|
|
228
|
+
protocol: init.protocol,
|
|
229
|
+
wallet: init.wallet ?? { source: "protocol" },
|
|
230
|
+
data: init.data,
|
|
231
|
+
status: init.status ?? {
|
|
232
|
+
transport: "connected",
|
|
233
|
+
peer: "reachable"
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/protocols.ts
|
|
239
|
+
/**
|
|
240
|
+
* The runtime metadata of {@link DemoProtocol}'s methods, as its connector
|
|
241
|
+
* reports it: `get_balance` carries its own deadline, the signing methods
|
|
242
|
+
* wait on the user, and `get_addresses` is a plain read.
|
|
243
|
+
*
|
|
244
|
+
* @beta
|
|
245
|
+
*/
|
|
246
|
+
const demoMetadata = {
|
|
247
|
+
get_addresses: {},
|
|
248
|
+
get_balance: { timeoutMs: 5e3 },
|
|
249
|
+
sign_transaction: { userInteraction: true },
|
|
250
|
+
sign_message: { userInteraction: true }
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* The capability interfaces of a {@link DemoProtocol} session, as its
|
|
254
|
+
* connector builds them: `sign_transaction` wraps the request, and
|
|
255
|
+
* `sign_message` takes it as is.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* const connector = createFakeConnector<DemoProtocol>({
|
|
260
|
+
* protocol: "demo",
|
|
261
|
+
* capabilities: ["libauth-signing"],
|
|
262
|
+
* interfaces: demoCapabilities,
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @beta
|
|
267
|
+
*/
|
|
268
|
+
function demoCapabilities(_session, client) {
|
|
269
|
+
const { request } = client;
|
|
270
|
+
return {
|
|
271
|
+
"libauth-signing": { signTransaction: (transaction, opts) => request("sign_transaction", { transaction }, opts) },
|
|
272
|
+
"message-signing": { signMessage: (req, opts) => request("sign_message", req, opts) }
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Builds a {@link DemoProtocol} session with placeholder data.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* const session = demoSession({ id: "s1" });
|
|
281
|
+
* const other = demoSession({ data: { addresses: [], xpubs: [] } });
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @beta
|
|
285
|
+
*/
|
|
286
|
+
function demoSession(init = {}) {
|
|
287
|
+
return fakeSession({
|
|
288
|
+
...init,
|
|
289
|
+
protocol: "demo",
|
|
290
|
+
data: init.data ?? {
|
|
291
|
+
addresses: ["bitcoincash:qpea4gc3r589sdqdcprsu6uyxpugpqnshsa8v7vsxq"],
|
|
292
|
+
xpubs: [{
|
|
293
|
+
name: "receive",
|
|
294
|
+
xpub: "xpub6ByHsPNSQXTWZ7PLESMY2FufyYWtLXagSUpMQq7Un96SiThZH2iJB1X7pwviH1WtKVeDP6K8d6xxFzzoaFzF3s8BKCZx8oEDdDkNnp4owAZ"
|
|
295
|
+
}]
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Builds a {@link DemoAltProtocol} session with placeholder data.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const session = demoAltSession({ id: "s2" });
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @beta
|
|
308
|
+
*/
|
|
309
|
+
function demoAltSession(init = {}) {
|
|
310
|
+
return fakeSession({
|
|
311
|
+
...init,
|
|
312
|
+
protocol: "demo-alt",
|
|
313
|
+
data: init.data ?? { pubkey: new Uint8Array([
|
|
314
|
+
1,
|
|
315
|
+
2,
|
|
316
|
+
3
|
|
317
|
+
]) }
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
export { createFakeConnector, demoAltSession, demoCapabilities, demoMetadata, demoSession, fakeSession };
|
|
322
|
+
|
|
323
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/fake-connector.ts","../src/session.ts","../src/protocols.ts"],"sourcesContent":["import {\n\tAbortedError,\n\ttype CapabilityMap,\n\ttype Connector,\n\ttype ConnectorContext,\n\ttype EventName,\n\ttype EventPayload,\n\tInvalidWalletResponseError,\n\ttype MethodName,\n\ttype MethodParams,\n\ttype MethodResult,\n\tMethodUnsupportedError,\n\ttype Pairing,\n\ttype ProtocolDefinition,\n\ttype RequestOptions,\n\tRequestRejectedError,\n\ttype Session,\n\ttype SessionClient,\n} from \"@bchconnect/core\";\n\n/**\n * What a scripted method does when the client dispatches it: a handler, or one\n * of the canned outcomes.\n *\n * `\"reject\"` rejects `REJECTED` by the user, `\"malformed\"` rejects\n * `INVALID_WALLET_RESPONSE` the way a connector does when validation of the\n * wallet's reply fails, and `\"hang\"` never settles on its own — the call shows\n * up in {@link FakeConnectorHandle.pending} for the test to settle, and aborts\n * with `ABORTED` when its signal does.\n *\n * @beta\n */\nexport type FakeMethodScript<\n\tP extends ProtocolDefinition,\n\tM extends MethodName<P>,\n> =\n\t| ((\n\t\t\tparams: MethodParams<P, M>,\n\t\t\topts: RequestOptions | undefined,\n\t ) => Promise<MethodResult<P, M>>)\n\t| \"reject\"\n\t| \"hang\"\n\t| \"malformed\";\n\n/**\n * Scripted methods, by name. A method left out rejects\n * `METHOD_UNSUPPORTED`, the way a connector reports a method the session does\n * not advertise.\n *\n * @beta\n */\nexport type FakeMethodScripts<P extends ProtocolDefinition> = {\n\treadonly [M in MethodName<P>]?: FakeMethodScript<P, M>;\n};\n\n/**\n * Deadline and user-interaction metadata the connector reports, by method\n * name. Mirrors what a real connector would carry for its protocol.\n *\n * @beta\n */\nexport type FakeMethodMetadata<P extends ProtocolDefinition> = NonNullable<\n\tConnector<P>[\"methods\"]\n>;\n\n/**\n * What a {@link createFakeConnector} connector does, from `setup()` to\n * `dispose()`.\n *\n * @beta\n */\nexport interface FakeConnectorScript<P extends ProtocolDefinition> {\n\t/** Protocol id. Must equal `P[\"id\"]`. */\n\treadonly protocol: P[\"id\"];\n\t/**\n\t * The session `connect()` resolves with. A value is returned as written on\n\t * every call; a function is called once per `connect()`, so\n\t * `() => fakeSession(…)` gives a fresh id each time.\n\t */\n\treadonly session?: Session<P> | (() => Session<P>);\n\t/** Pairing material handed to `onPairing` at the start of `connect()`. */\n\treadonly pairing?: Pairing;\n\t/** How `connect()` behaves. Resolves with the scripted session by default. */\n\treadonly connect?:\n\t\t| \"reject\"\n\t\t| \"hang\"\n\t\t| ((opts: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonPairing?: (pairing: Pairing) => void;\n\t\t\t\ttimeoutMs?: number;\n\t\t }) => Promise<Session<P>>);\n\t/** What `restore()` returns, or `\"throw\"` to fail it. Defaults to `[]`. */\n\treadonly restore?:\n\t\t| readonly Session<P>[]\n\t\t| (() => Promise<readonly Session<P>[]>)\n\t\t| \"throw\";\n\t/** `\"throw\"` makes `setup()` fail, to exercise connector isolation. */\n\treadonly setup?: \"throw\";\n\t/** `\"throw\"` makes `disconnect()` fail, after its local cleanup ran. */\n\treadonly disconnect?: \"throw\";\n\t/** `\"throw\"` makes `dispose()` fail. */\n\treadonly dispose?: \"throw\";\n\t/** Scripted methods. */\n\treadonly methods?: FakeMethodScripts<P>;\n\t/** Metadata the connector reports for its methods. Defaults to none. */\n\treadonly metadata?: FakeMethodMetadata<P>;\n\t/** Capabilities of every session, or of one session. Defaults to none. */\n\treadonly capabilities?:\n\t\t| readonly P[\"capability\"][]\n\t\t| ((session: Session<P>) => readonly P[\"capability\"][]);\n\t/**\n\t * Builds the capability interfaces of one session, over the client bound\n\t * to it. Without it the connector supplies none.\n\t */\n\treadonly interfaces?: (\n\t\tsession: Session<P>,\n\t\tclient: SessionClient<P>,\n\t) => CapabilityMap<P>;\n\t/**\n\t * Whether `connect()` writes a marker to its storage namespace and\n\t * `disconnect()` removes it. On by default; `setup()` never writes.\n\t */\n\treadonly persist?: boolean;\n}\n\n/**\n * One recorded `request()` call.\n *\n * @beta\n */\nexport interface FakeRequestCall<P extends ProtocolDefinition> {\n\t/** The session the request was dispatched on. */\n\treadonly sessionId: string;\n\t/** Method name. */\n\treadonly method: MethodName<P>;\n\t/** Params, as the client passed them. */\n\treadonly params: unknown;\n\t/** Options, as the client passed them. */\n\treadonly opts: RequestOptions | undefined;\n\t/** The combined signal the client built, when there was one. */\n\treadonly signal: AbortSignal | undefined;\n}\n\n/**\n * One recorded call of any kind, in call order.\n *\n * @beta\n */\nexport type FakeLogEntry<P extends ProtocolDefinition> =\n\t| { readonly kind: \"setup\" }\n\t| { readonly kind: \"connect\"; readonly timeoutMs: number | undefined }\n\t| { readonly kind: \"restore\" }\n\t| { readonly kind: \"disconnect\"; readonly sessionId: string }\n\t| {\n\t\t\treadonly kind: \"request\";\n\t\t\treadonly sessionId: string;\n\t\t\treadonly method: MethodName<P>;\n\t }\n\t| {\n\t\t\treadonly kind: \"subscribe\";\n\t\t\treadonly sessionId: string;\n\t\t\treadonly event: EventName<P>;\n\t }\n\t| {\n\t\t\treadonly kind: \"unsubscribe\";\n\t\t\treadonly sessionId: string;\n\t\t\treadonly event: EventName<P>;\n\t }\n\t| { readonly kind: \"capabilities\"; readonly sessionId: string }\n\t| { readonly kind: \"dispose\" };\n\n/**\n * A `\"hang\"` call the test can settle whenever it likes.\n *\n * @beta\n */\nexport interface FakePendingRequest<P extends ProtocolDefinition> {\n\t/** The session the request was dispatched on. */\n\treadonly sessionId: string;\n\t/** Method name. */\n\treadonly method: MethodName<P>;\n\t/** Params, as the client passed them. */\n\treadonly params: unknown;\n\t/** The combined signal the client built, when there was one. */\n\treadonly signal: AbortSignal | undefined;\n\t/** Settles the call with a result. A second settlement does nothing. */\n\tresolve(result: unknown): void;\n\t/** Settles the call with an error. A second settlement does nothing. */\n\treject(error: unknown): void;\n}\n\n/**\n * What a fake connector exposes on top of\n * {@link @bchconnect/core#Connector | Connector}.\n *\n * @beta\n */\nexport interface FakeConnectorHandle<P extends ProtocolDefinition> {\n\t/** Every `request()` call, in order. */\n\treadonly calls: readonly FakeRequestCall<P>[];\n\t/** Every call of any kind, in order. */\n\treadonly log: readonly FakeLogEntry<P>[];\n\t/** Unsettled `\"hang\"` calls, in dispatch order. */\n\treadonly pending: readonly FakePendingRequest<P>[];\n\t/** Emits a session lifecycle event. Throws before `setup()` ran. */\n\temit: ConnectorContext[\"emit\"];\n\t/** Delivers a protocol event to the listeners of one session. */\n\temitProtocolEvent<E extends EventName<P>>(\n\t\tsession: Session<P>,\n\t\tevent: E,\n\t\tpayload: EventPayload<P, E>,\n\t): void;\n}\n\n/**\n * A connector whose every outcome is scripted, plus its recordings.\n *\n * @beta\n */\nexport type FakeConnector<P extends ProtocolDefinition> = Connector<P> &\n\tFakeConnectorHandle<P>;\n\n/** Key under which `connect()` records a session in its storage namespace. */\nfunction storageKey(sessionId: string): string {\n\treturn `session:${sessionId}`;\n}\n\n/** Key under which one session's listeners for one event are held. */\nfunction listenerKey(sessionId: string, event: string): string {\n\treturn `${sessionId}::${event}`;\n}\n\n/**\n * Builds a connector that does exactly what its script says, and records\n * everything the client asked of it.\n *\n * The protocol is passed explicitly: a partial method map and an optional\n * session give inference nothing reliable to work from.\n *\n * @example\n * ```ts\n * const connector = createFakeConnector<DemoProtocol>({\n * \tprotocol: \"demo\",\n * \tsession: demoSession({ id: \"s1\" }),\n * \tmethods: {\n * \t\tget_balance: async () => ({ sats: 1_000n }),\n * \t\tsign_message: \"hang\",\n * \t},\n * \tcapabilities: [\"message-signing\"],\n * });\n *\n * const session = await connector.connect({});\n * connector.emitProtocolEvent(session, \"wallet_ready\", { walletName: \"Fake\" });\n * ```\n *\n * @beta\n */\nexport function createFakeConnector<P extends ProtocolDefinition>(\n\tscript: FakeConnectorScript<P>,\n): FakeConnector<P> {\n\tconst calls: FakeRequestCall<P>[] = [];\n\tconst log: FakeLogEntry<P>[] = [];\n\tconst pending: FakePendingRequest<P>[] = [];\n\tconst listeners = new Map<string, Set<(payload: never) => void>>();\n\tconst persist = script.persist ?? true;\n\tconst { interfaces } = script;\n\tlet context: ConnectorContext | undefined;\n\n\tconst nextSession = (): Session<P> => {\n\t\tif (script.session === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Fake connector \"${script.protocol}\" has no session to connect with.`,\n\t\t\t);\n\t\t}\n\t\treturn typeof script.session === \"function\"\n\t\t\t? script.session()\n\t\t\t: script.session;\n\t};\n\n\tconst abortedError = (signal: AbortSignal): AbortedError =>\n\t\tnew AbortedError(\"Aborted by caller\", { cause: signal.reason });\n\n\t/** Never settles on its own; rejects when `signal` aborts. */\n\tconst hang = <T>(\n\t\tsignal: AbortSignal | undefined,\n\t\tonSettle?: () => void,\n\t): {\n\t\tpromise: Promise<T>;\n\t\tresolve: (value: unknown) => void;\n\t\treject: (error: unknown) => void;\n\t} => {\n\t\tlet settle: ((value: unknown) => void) | undefined;\n\t\tlet fail: ((error: unknown) => void) | undefined;\n\t\tconst promise = new Promise<T>((resolvePromise, rejectPromise) => {\n\t\t\t// The scripted value stands in for a wallet reply, which the client\n\t\t\t// treats as opaque until a connector validates it.\n\t\t\tsettle = (value) => resolvePromise(value as T);\n\t\t\tfail = rejectPromise;\n\t\t});\n\n\t\tconst done = (): void => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tonSettle?.();\n\t\t};\n\t\tconst onAbort = (): void => {\n\t\t\tif (signal !== undefined) fail?.(abortedError(signal));\n\t\t\tdone();\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\treturn {\n\t\t\tpromise,\n\t\t\tresolve: (value) => {\n\t\t\t\tsettle?.(value);\n\t\t\t\tdone();\n\t\t\t},\n\t\t\treject: (error) => {\n\t\t\t\tfail?.(error);\n\t\t\t\tdone();\n\t\t\t},\n\t\t};\n\t};\n\n\tconst connector: FakeConnector<P> = {\n\t\tprotocol: script.protocol,\n\t\t// Spread, not assigned: `methods: undefined` is not an absent map.\n\t\t...(script.metadata === undefined ? {} : { methods: script.metadata }),\n\t\t...(interfaces === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tcapabilities(session: Session<P>, client: SessionClient<P>) {\n\t\t\t\t\t\tlog.push({ kind: \"capabilities\", sessionId: session.id });\n\t\t\t\t\t\treturn interfaces(session, client);\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\tcalls,\n\t\tlog,\n\t\tpending,\n\n\t\temit(event, payload) {\n\t\t\tif (context === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Fake connector \"${script.protocol}\" cannot emit before setup().`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontext.emit(event, payload);\n\t\t},\n\n\t\temitProtocolEvent(session, event, payload) {\n\t\t\tconst registered = listeners.get(listenerKey(session.id, event));\n\t\t\tif (registered === undefined) return;\n\t\t\tfor (const listener of [...registered]) listener(payload as never);\n\t\t},\n\n\t\tsetup(ctx) {\n\t\t\tlog.push({ kind: \"setup\" });\n\t\t\tif (script.setup === \"throw\") {\n\t\t\t\tthrow new Error(`Fake connector \"${script.protocol}\" failed setup.`);\n\t\t\t}\n\t\t\tcontext = ctx;\n\t\t},\n\n\t\tasync connect(opts) {\n\t\t\tlog.push({ kind: \"connect\", timeoutMs: opts.timeoutMs });\n\t\t\tif (opts.signal?.aborted === true) throw abortedError(opts.signal);\n\t\t\tif (script.pairing !== undefined) opts.onPairing?.(script.pairing);\n\n\t\t\tif (script.connect === \"reject\") {\n\t\t\t\tthrow new RequestRejectedError(\"Connection rejected\", { by: \"user\" });\n\t\t\t}\n\n\t\t\tconst session =\n\t\t\t\tscript.connect === \"hang\"\n\t\t\t\t\t? await hang<Session<P>>(opts.signal).promise\n\t\t\t\t\t: typeof script.connect === \"function\"\n\t\t\t\t\t\t? await script.connect(opts)\n\t\t\t\t\t\t: nextSession();\n\n\t\t\tif (persist) await context?.storage.set(storageKey(session.id), \"1\");\n\t\t\treturn session;\n\t\t},\n\n\t\tasync restore() {\n\t\t\tlog.push({ kind: \"restore\" });\n\t\t\tif (script.restore === \"throw\") {\n\t\t\t\tthrow new Error(`Fake connector \"${script.protocol}\" failed restore.`);\n\t\t\t}\n\t\t\tif (typeof script.restore === \"function\")\n\t\t\t\treturn [...(await script.restore())];\n\t\t\treturn [...(script.restore ?? [])];\n\t\t},\n\n\t\tasync disconnect(session) {\n\t\t\tlog.push({ kind: \"disconnect\", sessionId: session.id });\n\t\t\tif (persist) await context?.storage.delete(storageKey(session.id));\n\t\t\tif (script.disconnect === \"throw\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Fake connector \"${script.protocol}\" failed to disconnect.`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\trequest(session, method, params, opts) {\n\t\t\tcalls.push({\n\t\t\t\tsessionId: session.id,\n\t\t\t\tmethod,\n\t\t\t\tparams,\n\t\t\t\topts,\n\t\t\t\tsignal: opts?.signal,\n\t\t\t});\n\t\t\tlog.push({ kind: \"request\", sessionId: session.id, method });\n\n\t\t\tconst handler = script.methods?.[method];\n\t\t\tif (handler === undefined) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew MethodUnsupportedError(`Method \"${method}\" is not advertised`, {\n\t\t\t\t\t\tsessionId: session.id,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (opts?.signal?.aborted === true) {\n\t\t\t\treturn Promise.reject(abortedError(opts.signal));\n\t\t\t}\n\t\t\tif (handler === \"reject\") {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew RequestRejectedError(`Request \"${method}\" rejected`, {\n\t\t\t\t\t\tby: \"user\",\n\t\t\t\t\t\tsessionId: session.id,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (handler === \"malformed\") {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew InvalidWalletResponseError(\n\t\t\t\t\t\t`Wallet returned a malformed result for \"${method}\"`,\n\t\t\t\t\t\t{ sessionId: session.id },\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (handler === \"hang\") {\n\t\t\t\tconst held = hang<MethodResult<P, typeof method>>(opts?.signal, () => {\n\t\t\t\t\tconst index = pending.indexOf(entry);\n\t\t\t\t\tif (index !== -1) pending.splice(index, 1);\n\t\t\t\t});\n\t\t\t\tconst entry: FakePendingRequest<P> = {\n\t\t\t\t\tsessionId: session.id,\n\t\t\t\t\tmethod,\n\t\t\t\t\tparams,\n\t\t\t\t\tsignal: opts?.signal,\n\t\t\t\t\tresolve: held.resolve,\n\t\t\t\t\treject: held.reject,\n\t\t\t\t};\n\t\t\t\tpending.push(entry);\n\t\t\t\treturn held.promise;\n\t\t\t}\n\t\t\treturn handler(params, opts);\n\t\t},\n\n\t\tsubscribe(session, event, listener) {\n\t\t\tconst key = listenerKey(session.id, event);\n\t\t\tlog.push({ kind: \"subscribe\", sessionId: session.id, event });\n\n\t\t\tconst registered =\n\t\t\t\tlisteners.get(key) ?? new Set<(payload: never) => void>();\n\t\t\tregistered.add(listener as (payload: never) => void);\n\t\t\tlisteners.set(key, registered);\n\n\t\t\tlet unsubscribed = false;\n\t\t\treturn () => {\n\t\t\t\tif (unsubscribed) return;\n\t\t\t\tunsubscribed = true;\n\t\t\t\tlog.push({ kind: \"unsubscribe\", sessionId: session.id, event });\n\t\t\t\tregistered.delete(listener as (payload: never) => void);\n\t\t\t\tif (registered.size === 0) listeners.delete(key);\n\t\t\t};\n\t\t},\n\n\t\tcapabilitiesOf(session) {\n\t\t\tconst capabilities =\n\t\t\t\ttypeof script.capabilities === \"function\"\n\t\t\t\t\t? script.capabilities(session)\n\t\t\t\t\t: (script.capabilities ?? []);\n\t\t\treturn new Set(capabilities);\n\t\t},\n\n\t\tasync dispose() {\n\t\t\tlog.push({ kind: \"dispose\" });\n\t\t\tif (script.dispose === \"throw\") {\n\t\t\t\tthrow new Error(`Fake connector \"${script.protocol}\" failed dispose.`);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn connector;\n}\n","import type {\n\tProtocolDefinition,\n\tSession,\n\tSessionStatus,\n\tWalletIdentity,\n} from \"@bchconnect/core\";\n\n/**\n * The parts of a {@link @bchconnect/core#Session | Session} a test cares\n * about. Everything else is filled with a plausible default.\n *\n * @beta\n */\nexport interface FakeSessionInit<P extends ProtocolDefinition> {\n\t/** Protocol id. Must match the connector the session belongs to. */\n\treadonly protocol: P[\"id\"];\n\t/** The protocol's handshake payload. */\n\treadonly data: P[\"session\"];\n\t/** Session id. Defaults to a fresh `crypto.randomUUID()`. */\n\treadonly id?: string;\n\t/** Wallet identity. Defaults to `{ source: \"protocol\" }`, with no name. */\n\treadonly wallet?: WalletIdentity;\n\t/** Session status. Defaults to connected and reachable. */\n\treadonly status?: SessionStatus;\n}\n\n/**\n * Builds a `Session` for tests.\n *\n * Pass the result to `createFakeConnector` as a value for a session whose id\n * the test pins, or as a function for a fresh id on every `connect()`.\n *\n * @example\n * ```ts\n * const session = fakeSession<DemoProtocol>({\n * \tid: \"s1\",\n * \tprotocol: \"demo\",\n * \tdata: {\n * \t\taddresses: [\"bitcoincash:qpea4gc3r589sdqdcprsu6uyxpugpqnshsa8v7vsxq\"],\n * \t\txpubs: [],\n * \t},\n * });\n * ```\n *\n * @beta\n */\nexport function fakeSession<P extends ProtocolDefinition>(\n\tinit: FakeSessionInit<P>,\n): Session<P> {\n\treturn {\n\t\tid: init.id ?? crypto.randomUUID(),\n\t\tprotocol: init.protocol,\n\t\twallet: init.wallet ?? { source: \"protocol\" },\n\t\tdata: init.data,\n\t\tstatus: init.status ?? { transport: \"connected\", peer: \"reachable\" },\n\t};\n}\n","import type {\n\tCapabilityMap,\n\tMethodMetadata,\n\tProtocolDefinition,\n\tSession,\n\tSessionClient,\n\tSignMessageRequest,\n\tSignMessageResponse,\n\tSignTransactionRequest,\n\tSignTransactionResponse,\n} from \"@bchconnect/core\";\nimport { type FakeSessionInit, fakeSession } from \"./session.js\";\n\n/**\n * Handshake payload of {@link DemoProtocol}: addresses, derivation paths and\n * the wallet's own name when it sent one.\n *\n * @beta\n */\nexport interface DemoSessionData {\n\t/** Addresses the wallet exposed, in wallet order. */\n\treadonly addresses: readonly string[];\n\t/** Named extended public keys. */\n\treadonly xpubs: readonly { readonly name: string; readonly xpub: string }[];\n\t/** Wallet name, when the protocol carries one. */\n\treadonly walletName?: string;\n}\n\n/**\n * A protocol definition for tests, shaped after a real wallet protocol.\n *\n * Its methods cover every branch of the timeout resolution order: a method\n * with no `timeoutMs` (the client's read default applies), one with its own\n * `timeoutMs`, and two `userInteraction` methods (no default deadline).\n *\n * @beta\n */\nexport interface DemoProtocol extends ProtocolDefinition {\n\t/** Protocol id. */\n\tid: \"demo\";\n\t/** Handshake payload. */\n\tsession: DemoSessionData;\n\t/** Request-shaped methods. */\n\tmethods: {\n\t\t/** A read with no parameters and no per-method deadline. */\n\t\tget_addresses: {\n\t\t\tparams: undefined;\n\t\t\tresult: { readonly addresses: readonly string[] };\n\t\t};\n\t\t/** A read carrying its own deadline. */\n\t\tget_balance: {\n\t\t\tparams: { readonly address: string };\n\t\t\tresult: { readonly sats: bigint };\n\t\t\ttimeoutMs: 5_000;\n\t\t};\n\t\t/** Signing, gated on the user. */\n\t\tsign_transaction: {\n\t\t\tparams: { readonly transaction: SignTransactionRequest };\n\t\t\tresult: SignTransactionResponse;\n\t\t\tuserInteraction: true;\n\t\t};\n\t\t/** Message signing, gated on the user. */\n\t\tsign_message: {\n\t\t\tparams: SignMessageRequest;\n\t\t\tresult: SignMessageResponse;\n\t\t\tuserInteraction: true;\n\t\t};\n\t};\n\t/** Wallet-initiated messages. */\n\tevents: {\n\t\t/** The wallet's address set changed. */\n\t\taddresses_changed: { readonly addresses: readonly string[] };\n\t\t/** The wallet finished loading and announced itself. */\n\t\twallet_ready: { readonly walletName?: string };\n\t};\n\t/** Capabilities sessions of this protocol may have. */\n\tcapability: \"libauth-signing\" | \"message-signing\";\n}\n\n/**\n * The runtime metadata of {@link DemoProtocol}'s methods, as its connector\n * reports it: `get_balance` carries its own deadline, the signing methods\n * wait on the user, and `get_addresses` is a plain read.\n *\n * @beta\n */\nexport const demoMetadata: {\n\treadonly [M in keyof DemoProtocol[\"methods\"]]: Pick<\n\t\tDemoProtocol[\"methods\"][M],\n\t\tkeyof DemoProtocol[\"methods\"][M] & keyof MethodMetadata\n\t> & {\n\t\treadonly [K in Exclude<\n\t\t\tkeyof MethodMetadata,\n\t\t\tkeyof DemoProtocol[\"methods\"][M]\n\t\t>]?: never;\n\t};\n} = {\n\tget_addresses: {},\n\tget_balance: { timeoutMs: 5_000 },\n\tsign_transaction: { userInteraction: true },\n\tsign_message: { userInteraction: true },\n};\n\n/**\n * The capability interfaces of a {@link DemoProtocol} session, as its\n * connector builds them: `sign_transaction` wraps the request, and\n * `sign_message` takes it as is.\n *\n * @example\n * ```ts\n * const connector = createFakeConnector<DemoProtocol>({\n * \tprotocol: \"demo\",\n * \tcapabilities: [\"libauth-signing\"],\n * \tinterfaces: demoCapabilities,\n * });\n * ```\n *\n * @beta\n */\nexport function demoCapabilities(\n\t_session: Session<DemoProtocol>,\n\tclient: SessionClient<DemoProtocol>,\n): CapabilityMap<DemoProtocol> {\n\tconst { request } = client;\n\treturn {\n\t\t\"libauth-signing\": {\n\t\t\tsignTransaction: (transaction, opts) =>\n\t\t\t\trequest(\"sign_transaction\", { transaction }, opts),\n\t\t},\n\t\t\"message-signing\": {\n\t\t\tsignMessage: (req, opts) => request(\"sign_message\", req, opts),\n\t\t},\n\t};\n}\n\n/**\n * Handshake payload of {@link DemoAltProtocol}.\n *\n * @beta\n */\nexport interface DemoAltSessionData {\n\t/** The wallet's public key, its only identity on the wire. */\n\treadonly pubkey: Uint8Array;\n}\n\n/**\n * A second protocol definition, for multi-protocol tests.\n *\n * It shares the method name `get_balance` with {@link DemoProtocol} under a\n * different result type, and declares no events, so narrowing by\n * `session.protocol` can be exercised.\n *\n * @beta\n */\nexport interface DemoAltProtocol extends ProtocolDefinition {\n\t/** Protocol id. */\n\tid: \"demo-alt\";\n\t/** Handshake payload. */\n\tsession: DemoAltSessionData;\n\t/** Request-shaped methods. */\n\tmethods: {\n\t\t/** Same name as {@link DemoProtocol}'s, different result. */\n\t\tget_balance: {\n\t\t\tparams: { readonly token?: string };\n\t\t\tresult: bigint;\n\t\t};\n\t};\n\t/** This protocol has no wallet-initiated messages. */\n\tevents: Record<never, never>;\n\t/** Capabilities sessions of this protocol may have. */\n\tcapability: \"message-signing\";\n}\n\n/**\n * Builds a {@link DemoProtocol} session with placeholder data.\n *\n * @example\n * ```ts\n * const session = demoSession({ id: \"s1\" });\n * const other = demoSession({ data: { addresses: [], xpubs: [] } });\n * ```\n *\n * @beta\n */\nexport function demoSession(\n\tinit: Partial<FakeSessionInit<DemoProtocol>> = {},\n): Session<DemoProtocol> {\n\treturn fakeSession<DemoProtocol>({\n\t\t...init,\n\t\tprotocol: \"demo\",\n\t\tdata: init.data ?? {\n\t\t\taddresses: [\"bitcoincash:qpea4gc3r589sdqdcprsu6uyxpugpqnshsa8v7vsxq\"],\n\t\t\t// Derived from the public BIP-39 test-vector mnemonic, at\n\t\t\t// m/44'/145'/0'. It holds nothing and belongs to nobody.\n\t\t\txpubs: [\n\t\t\t\t{\n\t\t\t\t\tname: \"receive\",\n\t\t\t\t\txpub: \"xpub6ByHsPNSQXTWZ7PLESMY2FufyYWtLXagSUpMQq7Un96SiThZH2iJB1X7pwviH1WtKVeDP6K8d6xxFzzoaFzF3s8BKCZx8oEDdDkNnp4owAZ\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t});\n}\n\n/**\n * Builds a {@link DemoAltProtocol} session with placeholder data.\n *\n * @example\n * ```ts\n * const session = demoAltSession({ id: \"s2\" });\n * ```\n *\n * @beta\n */\nexport function demoAltSession(\n\tinit: Partial<FakeSessionInit<DemoAltProtocol>> = {},\n): Session<DemoAltProtocol> {\n\treturn fakeSession<DemoAltProtocol>({\n\t\t...init,\n\t\tprotocol: \"demo-alt\",\n\t\tdata: init.data ?? { pubkey: new Uint8Array([1, 2, 3]) },\n\t});\n}\n"],"mappings":";;;AA+NA,SAAS,WAAW,WAA2B;CAC9C,OAAO,WAAW;AACnB;;AAGA,SAAS,YAAY,WAAmB,OAAuB;CAC9D,OAAO,GAAG,UAAU,IAAI;AACzB;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,oBACf,QACmB;CACnB,MAAM,QAA8B,CAAC;CACrC,MAAM,MAAyB,CAAC;CAChC,MAAM,UAAmC,CAAC;CAC1C,MAAM,4BAAY,IAAI,IAA2C;CACjE,MAAM,UAAU,OAAO,WAAW;CAClC,MAAM,EAAE,eAAe;CACvB,IAAI;CAEJ,MAAM,oBAAgC;EACrC,IAAI,OAAO,YAAY,KAAA,GACtB,MAAM,IAAI,MACT,mBAAmB,OAAO,SAAS,kCACpC;EAED,OAAO,OAAO,OAAO,YAAY,aAC9B,OAAO,QAAQ,IACf,OAAO;CACX;CAEA,MAAM,gBAAgB,WACrB,IAAI,aAAa,qBAAqB,EAAE,OAAO,OAAO,OAAO,CAAC;;CAG/D,MAAM,QACL,QACA,aAKI;EACJ,IAAI;EACJ,IAAI;EACJ,MAAM,UAAU,IAAI,SAAY,gBAAgB,kBAAkB;GAGjE,UAAU,UAAU,eAAe,KAAU;GAC7C,OAAO;EACR,CAAC;EAED,MAAM,aAAmB;GACxB,QAAQ,oBAAoB,SAAS,OAAO;GAC5C,WAAW;EACZ;EACA,MAAM,gBAAsB;GAC3B,IAAI,WAAW,KAAA,GAAW,OAAO,aAAa,MAAM,CAAC;GACrD,KAAK;EACN;EACA,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAEzD,OAAO;GACN;GACA,UAAU,UAAU;IACnB,SAAS,K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AAgB,YACf,MACa;CACb,OAAO;EACN,IAAI,KAAK,MAAM,OAAO,WAAW;EACjC,UAAU,KAAK;EACf,QAAQ,KAAK,UAAU,EAAE,QAAQ,WAAW;EAC5C,MAAM,KAAK;EACX,QAAQ,KAAK,UAAU;GAAE,WAAW;GAAa,MAAM;EAAY;CACpE;AACD;;;;;;;;;;AC8BA,MAAa,eAUT;CACH,eAAe,CAAC;CAChB,aAAa,EAAE,WAAW,IAAM;CAChC,kBAAkB,EAAE,iBAAiB,KAAK;CAC1C,cAAc,EAAE,iBAAiB,KAAK;AACvC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBACf,UACA,QAC8B;CAC9B,MAAM,EAAE,YAAY;CACpB,OAAO;EACN,mBAAmB,EAClB,kBAAkB,aAAa,SAC9B,QAAQ,oBAAoB,EAAE,YAAY,GAAG,IAAI,EACnD;EACA,mBAAmB,EAClB,cAAc,KAAK,SAAS,QAAQ,gBAAgB,KAAK,IAAI,EAC9D;CACD;AACD;;;;;;;;;;;;AAmDA,SAAgB,YACf,OAA+C,CAAC,GACxB;CACxB,OAAO,YAA0B;EAChC,GAAG;EACH,UAAU;EACV,MAAM,KAAK,QAAQ;GAClB,WAAW,CAAC,wDAAwD;GAGpE,OAAO,CACN;IACC,MAAM;IACN,MAAM;GACP,CACD;EACD;CACD,CAAC;AACF;;;;;;;;;;;AAYA,SAAgB,eACf,OAAkD,CAAC,GACxB;CAC3B,OAAO,YAA6B;EACnC,GAAG;EACH,UAAU;EACV,MAAM,KAAK,QAAQ,EAAE,QAAQ,IAAI,WAAW;GAAC;GAAG;GAAG;EAAC,CAAC,EAAE;CACxD,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bchconnect/test-utils",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/BCH-Connect/bchconnect.git",
|
|
8
|
+
"directory": "packages/test-utils"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"types": "./dist/index.d.cts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"provenance": true
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@bchconnect/core": "^0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@bchconnect/core": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown",
|
|
45
|
+
"api": "api-extractor run --local --verbose"
|
|
46
|
+
}
|
|
6
47
|
}
|
package/README.md
DELETED