@openlv/transport 0.0.1-beta.4 → 0.0.1-beta.6
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/dist/base.d.ts +37 -4
- package/dist/base.js +64 -5
- package/dist/base.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +72 -2
- package/dist/index.test.js.map +1 -1
- package/dist/layer.d.ts +20 -0
- package/dist/layer.js +8 -0
- package/dist/layer.js.map +1 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +6 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/webrtc/index.d.ts +6 -1
- package/dist/webrtc/index.js +137 -66
- package/dist/webrtc/index.js.map +1 -1
- package/package.json +12 -3
package/dist/base.d.ts
CHANGED
|
@@ -1,16 +1,49 @@
|
|
|
1
|
+
import { EventEmitter } from "eventemitter3";
|
|
1
2
|
import type { MaybePromise } from "viem";
|
|
2
|
-
|
|
3
|
+
import { type TLayerEventMap, type TransportLayerParameters, type TransportState } from "./layer.js";
|
|
4
|
+
export type TransportMessage = {
|
|
5
|
+
type: "offer";
|
|
6
|
+
payload: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "answer";
|
|
9
|
+
payload: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: "candidate";
|
|
12
|
+
payload: string;
|
|
13
|
+
};
|
|
14
|
+
export type TransportLayer = {
|
|
3
15
|
type: string;
|
|
4
16
|
setup: () => MaybePromise<void>;
|
|
5
17
|
teardown: () => MaybePromise<void>;
|
|
18
|
+
send: (message: object) => Promise<void>;
|
|
19
|
+
handle: (message: TransportMessage) => Promise<void>;
|
|
20
|
+
waitFor: (state: TransportState) => Promise<void>;
|
|
21
|
+
emitter: EventEmitter<TLayerEventMap>;
|
|
6
22
|
};
|
|
7
|
-
export type
|
|
23
|
+
export type TLayer = (parameters: TransportLayerParameters) => TransportLayer;
|
|
24
|
+
export type TransportLayerBase = {
|
|
8
25
|
type: string;
|
|
9
|
-
|
|
26
|
+
setup: () => MaybePromise<void>;
|
|
27
|
+
teardown: () => MaybePromise<void>;
|
|
28
|
+
handle: (message: TransportMessage) => Promise<void>;
|
|
29
|
+
send: (message: string) => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
export type TransportLayerBaseEventMap = {
|
|
32
|
+
offer: (offer: string) => void;
|
|
33
|
+
answer: (answer: string) => void;
|
|
34
|
+
candidate: (candidate: string) => void;
|
|
35
|
+
connected: () => void;
|
|
36
|
+
message: (message: string) => void;
|
|
37
|
+
};
|
|
38
|
+
export type TransportLayerBaseEmitter = EventEmitter<TransportLayerBaseEventMap>;
|
|
39
|
+
export type TransportLayerBaseParameters = {
|
|
40
|
+
emitter: TransportLayerBaseEmitter;
|
|
41
|
+
isHost: boolean;
|
|
10
42
|
};
|
|
43
|
+
export type TransportLayerBaseInit = (parameters: TransportLayerBaseParameters) => TransportLayerBase;
|
|
11
44
|
/**
|
|
12
45
|
* Base Transport Layer implementation
|
|
13
46
|
*
|
|
14
47
|
* https://openlv.sh/api/transport
|
|
15
48
|
*/
|
|
16
|
-
export declare const
|
|
49
|
+
export declare const createTransportBase: (init: TransportLayerBaseInit) => TLayer;
|
package/dist/base.js
CHANGED
|
@@ -1,13 +1,72 @@
|
|
|
1
|
+
import { EventEmitter } from "eventemitter3";
|
|
2
|
+
import { TRANSPORT_STATE, } from "./layer.js";
|
|
1
3
|
/**
|
|
2
4
|
* Base Transport Layer implementation
|
|
3
5
|
*
|
|
4
6
|
* https://openlv.sh/api/transport
|
|
5
7
|
*/
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export const createTransportBase = (init) => {
|
|
9
|
+
return ({ encrypt, decrypt, subsend, isHost, onmessage }) => {
|
|
10
|
+
const emitter = new EventEmitter();
|
|
11
|
+
const internalEmitter = new EventEmitter();
|
|
12
|
+
let state = TRANSPORT_STATE.STANDBY;
|
|
13
|
+
const setState = (newState) => {
|
|
14
|
+
state = newState;
|
|
15
|
+
emitter.emit("state_change", newState);
|
|
16
|
+
};
|
|
17
|
+
internalEmitter.on("offer", (offer) => {
|
|
18
|
+
console.log("onOffer", offer);
|
|
19
|
+
subsend({ type: "offer", payload: offer });
|
|
20
|
+
});
|
|
21
|
+
internalEmitter.on("answer", (answer) => {
|
|
22
|
+
console.log("onAnswer", answer);
|
|
23
|
+
subsend({ type: "answer", payload: answer });
|
|
24
|
+
});
|
|
25
|
+
internalEmitter.on("candidate", (candidate) => {
|
|
26
|
+
console.log("onCandidate", candidate);
|
|
27
|
+
subsend({ type: "candidate", payload: candidate });
|
|
28
|
+
});
|
|
29
|
+
internalEmitter.on("connected", () => {
|
|
30
|
+
console.log("onConnected");
|
|
31
|
+
setState(TRANSPORT_STATE.CONNECTED);
|
|
32
|
+
});
|
|
33
|
+
internalEmitter.on("message", async (message) => {
|
|
34
|
+
console.log("onMessage", message);
|
|
35
|
+
const data = await decrypt(message);
|
|
36
|
+
onmessage(JSON.parse(data));
|
|
37
|
+
});
|
|
38
|
+
const { setup, teardown, type, send: sendLayer, handle, } = init({
|
|
39
|
+
emitter: internalEmitter,
|
|
40
|
+
isHost,
|
|
41
|
+
});
|
|
42
|
+
const send = async (message) => {
|
|
43
|
+
if (state !== TRANSPORT_STATE.CONNECTED)
|
|
44
|
+
throw new Error("Transport not connected");
|
|
45
|
+
const payload = await encrypt(JSON.stringify(message));
|
|
46
|
+
await sendLayer(payload);
|
|
47
|
+
};
|
|
48
|
+
const waitFor = async (state) => {
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
emitter.on("state_change", (newState) => {
|
|
51
|
+
if (newState === state) {
|
|
52
|
+
resolve();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
type,
|
|
59
|
+
async setup() {
|
|
60
|
+
setState(TRANSPORT_STATE.CONNECTING);
|
|
61
|
+
await setup();
|
|
62
|
+
setState(TRANSPORT_STATE.READY);
|
|
63
|
+
},
|
|
64
|
+
teardown,
|
|
65
|
+
handle,
|
|
66
|
+
send,
|
|
67
|
+
waitFor,
|
|
68
|
+
emitter,
|
|
69
|
+
};
|
|
11
70
|
};
|
|
12
71
|
};
|
|
13
72
|
//# sourceMappingURL=base.js.map
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAEL,eAAe,GAGhB,MAAM,YAAY,CAAC;AAiDpB;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAA4B,EAAU,EAAE;IAC1E,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE;QAC1D,MAAM,OAAO,GAAG,IAAI,YAAY,EAAkB,CAAC;QACnD,MAAM,eAAe,GAAG,IAAI,YAAY,EAA8B,CAAC;QACvE,IAAI,KAAK,GAAmB,eAAe,CAAC,OAAO,CAAC;QAEpD,MAAM,QAAQ,GAAG,CAAC,QAAwB,EAAE,EAAE;YAC5C,KAAK,GAAG,QAAQ,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC9B,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC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AAC,CAAC;YAE7C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAEvD,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,EAAE,KAAqB,EAAE,EAAE;YAC9C,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBACnC,OAAO,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,EAAE;oBACtC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;wBACvB,OAAO,EAAE,CAAC;oBACZ,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO;YACL,IAAI;YACJ,KAAK,CAAC,KAAK;gBACT,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;gBACrC,MAAM,KAAK,EAAE,CAAC;gBACd,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;YACD,QAAQ;YACR,MAAM;YACN,IAAI;YACJ,OAAO;YACP,OAAO;SACR,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: package entrypoint */
|
|
2
|
+
/** biome-ignore-all lint/performance/noReExportAll: package entrypoint */
|
|
1
3
|
/**
|
|
2
4
|
* Open Lavatory Protocol - Decentralized Wallet Connection Library
|
|
3
5
|
*
|
|
@@ -5,3 +7,4 @@
|
|
|
5
7
|
* without relying on centralized infrastructure.
|
|
6
8
|
*/
|
|
7
9
|
export * from "./base.js";
|
|
10
|
+
export * from "./layer.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: package entrypoint */
|
|
2
|
+
/** biome-ignore-all lint/performance/noReExportAll: package entrypoint */
|
|
1
3
|
/**
|
|
2
4
|
* Open Lavatory Protocol - Decentralized Wallet Connection Library
|
|
3
5
|
*
|
|
@@ -5,4 +7,5 @@
|
|
|
5
7
|
* without relying on centralized infrastructure.
|
|
6
8
|
*/
|
|
7
9
|
export * from "./base.js";
|
|
10
|
+
export * from "./layer.js";
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,0EAA0E;AAE1E;;;;;GAKG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
package/dist/index.test.js
CHANGED
|
@@ -1,7 +1,77 @@
|
|
|
1
|
+
import { generateKeyPair } from "@openlv/core/encryption";
|
|
2
|
+
import { EventEmitter } from "eventemitter3";
|
|
1
3
|
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { TRANSPORT_STATE } from "./layer.js";
|
|
5
|
+
import { webrtc } from "./webrtc/index.js";
|
|
2
6
|
describe("Transport", () => {
|
|
3
|
-
it("should be able to create a transport", () => {
|
|
4
|
-
|
|
7
|
+
it("should be able to create a transport", async () => {
|
|
8
|
+
const { encryptionKey: publicKey, decryptionKey } = await generateKeyPair();
|
|
9
|
+
const { encrypt } = publicKey;
|
|
10
|
+
const { decrypt } = decryptionKey;
|
|
11
|
+
const signalA = new EventEmitter();
|
|
12
|
+
const signalB = new EventEmitter();
|
|
13
|
+
const transportA = webrtc({ isHost: true })({
|
|
14
|
+
encrypt,
|
|
15
|
+
decrypt,
|
|
16
|
+
subsend: async (m) => {
|
|
17
|
+
signalA.emit("signal", m);
|
|
18
|
+
},
|
|
19
|
+
isHost: true,
|
|
20
|
+
onmessage: (m) => {
|
|
21
|
+
signalA.emit("message", m);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const transportB = webrtc({ isHost: false })({
|
|
25
|
+
encrypt,
|
|
26
|
+
decrypt,
|
|
27
|
+
subsend: async (m) => {
|
|
28
|
+
signalB.emit("signal", m);
|
|
29
|
+
},
|
|
30
|
+
isHost: false,
|
|
31
|
+
onmessage: (m) => {
|
|
32
|
+
signalB.emit("message", m);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
signalA.on("signal", (m) => {
|
|
36
|
+
console.log("messageA", m);
|
|
37
|
+
transportB.handle(m);
|
|
38
|
+
});
|
|
39
|
+
signalB.on("signal", (m) => {
|
|
40
|
+
console.log("messageB", m);
|
|
41
|
+
transportA.handle(m);
|
|
42
|
+
});
|
|
43
|
+
console.log("test: setup");
|
|
44
|
+
await Promise.all([transportA.setup(), transportB.setup()]);
|
|
45
|
+
console.log("test: waitFor connected");
|
|
46
|
+
await Promise.all([
|
|
47
|
+
transportA.waitFor(TRANSPORT_STATE.CONNECTED),
|
|
48
|
+
transportB.waitFor(TRANSPORT_STATE.CONNECTED),
|
|
49
|
+
]);
|
|
50
|
+
console.log("test: connected");
|
|
51
|
+
const awaitedMessageAtB = new Promise((resolve) => {
|
|
52
|
+
signalB.on("message", (m) => {
|
|
53
|
+
console.log("messageB", m);
|
|
54
|
+
resolve(m);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
console.log("test: send message to A");
|
|
58
|
+
await transportA.send({ data: "test_123" });
|
|
59
|
+
console.log("test: await message at B");
|
|
60
|
+
const messageAtB = await awaitedMessageAtB;
|
|
61
|
+
expect(messageAtB).toEqual({ data: "test_123" });
|
|
62
|
+
console.log("test: message at B", messageAtB);
|
|
63
|
+
const awaitedMessageAtA = new Promise((resolve) => {
|
|
64
|
+
signalA.on("message", (m) => {
|
|
65
|
+
console.log("messageA", m);
|
|
66
|
+
resolve(m);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
await transportB.send({ data: "test_456" });
|
|
70
|
+
const messageAtA = await awaitedMessageAtA;
|
|
71
|
+
expect(messageAtA).toEqual({ data: "test_456" });
|
|
72
|
+
await Promise.all([transportA.teardown(), transportB.teardown()]);
|
|
73
|
+
expect(transportA).toBeDefined();
|
|
74
|
+
expect(transportB).toBeDefined();
|
|
5
75
|
});
|
|
6
76
|
});
|
|
7
77
|
//# sourceMappingURL=index.test.js.map
|
package/dist/index.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,eAAe,EAAE,CAAC;QAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;QAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;QAClC,MAA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,EAAE,EAAE;gBAC1B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;gBAC3B,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC;QAE3C,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAEjD,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAElE,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/layer.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DecryptionKey, EncryptionKey } from "@openlv/core/encryption";
|
|
2
|
+
import type { TransportMessage } from "./base.js";
|
|
3
|
+
export declare const TRANSPORT_STATE: {
|
|
4
|
+
readonly STANDBY: "standby";
|
|
5
|
+
readonly CONNECTING: "connecting";
|
|
6
|
+
readonly READY: "ready";
|
|
7
|
+
readonly CONNECTED: "connected";
|
|
8
|
+
readonly ERROR: "error";
|
|
9
|
+
};
|
|
10
|
+
export type TransportState = (typeof TRANSPORT_STATE)[keyof typeof TRANSPORT_STATE];
|
|
11
|
+
export type TLayerEventMap = {
|
|
12
|
+
state_change: (state: TransportState) => void;
|
|
13
|
+
};
|
|
14
|
+
export type TransportLayerParameters = {
|
|
15
|
+
isHost: boolean;
|
|
16
|
+
encrypt: EncryptionKey["encrypt"];
|
|
17
|
+
decrypt: DecryptionKey["decrypt"];
|
|
18
|
+
subsend: (message: TransportMessage) => Promise<void>;
|
|
19
|
+
onmessage: (message: object) => void;
|
|
20
|
+
};
|
package/dist/layer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer.js","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;CACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const log: (...x: Parameters<typeof console.log>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAiC,EAAE,EAAE,CAC1D,OAAO,CAAC,GAAG;AACT,qBAAqB;AACrB,sCAAsC;AACtC,yCAAyC;AACzC,GAAG,CAAC,CACL,CAAC"}
|
package/dist/webrtc/index.d.ts
CHANGED
package/dist/webrtc/index.js
CHANGED
|
@@ -1,70 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// },
|
|
16
|
-
// ];
|
|
17
|
-
// this.peerConnection = new RTCPeerConnection({
|
|
18
|
-
// iceServers,
|
|
19
|
-
// iceCandidatePoolSize: 10,
|
|
20
|
-
// iceTransportPolicy: 'all',
|
|
21
|
-
// bundlePolicy: 'max-bundle',
|
|
22
|
-
// rtcpMuxPolicy: 'require',
|
|
23
|
-
// });
|
|
24
|
-
// // Connection state handlers
|
|
25
|
-
// this.peerConnection.onconnectionstatechange = () => {
|
|
26
|
-
// const state = this.peerConnection!.connectionState;
|
|
27
|
-
// console.log('WebRTC connection state:', state);
|
|
28
|
-
// if (state === 'connected') {
|
|
29
|
-
// this.updateConnectionState('webrtc-connected', 'Direct P2P connection established');
|
|
30
|
-
// } else if (state === 'failed') {
|
|
31
|
-
// this.retryWebRTC();
|
|
32
|
-
// } else if (state === 'connecting') {
|
|
33
|
-
// this.updateConnectionState('webrtc-negotiating', 'Establishing P2P connection...');
|
|
34
|
-
// }
|
|
35
|
-
// };
|
|
36
|
-
// // ICE candidate handler
|
|
37
|
-
// this.peerConnection.onicecandidate = async (event) => {
|
|
38
|
-
// if (event.candidate && this.peerPublicKey) {
|
|
39
|
-
// const encryptedCandidate = await EncryptionUtils.encryptMessage(
|
|
40
|
-
// event.candidate,
|
|
41
|
-
// this.peerPublicKey,
|
|
42
|
-
// this.privateKey!,
|
|
43
|
-
// this.publicKey!
|
|
44
|
-
// );
|
|
45
|
-
// await this.signaling.publish({
|
|
46
|
-
// type: 'ice-candidate',
|
|
47
|
-
// payload: encryptedCandidate,
|
|
48
|
-
// sessionId: this.sessionId!,
|
|
49
|
-
// timestamp: Date.now(),
|
|
50
|
-
// senderId: this.peerId,
|
|
51
|
-
// });
|
|
52
|
-
// }
|
|
53
|
-
// };
|
|
54
|
-
// // Data channel setup
|
|
55
|
-
// if (this.isInitiator) {
|
|
56
|
-
// this.dataChannel = this.peerConnection.createDataChannel('openlv-data');
|
|
57
|
-
// this.setupDataChannel();
|
|
58
|
-
// } else {
|
|
59
|
-
// this.peerConnection.ondatachannel = (event) => {
|
|
60
|
-
// this.dataChannel = event.channel;
|
|
61
|
-
// this.setupDataChannel();
|
|
62
|
-
// };
|
|
63
|
-
// }
|
|
64
|
-
},
|
|
65
|
-
teardown() {
|
|
66
|
-
//
|
|
1
|
+
/* eslint-disable sonarjs/no-duplicate-string */
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
import { createTransportBase } from "../base.js";
|
|
4
|
+
import { log } from "../utils/log.js";
|
|
5
|
+
// TODO: decide wether we want defaults, and if so what defaults
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
iceServers: [
|
|
8
|
+
{ urls: "stun:stun.l.google.com:19302" },
|
|
9
|
+
{ urls: "stun:stun1.l.google.com:19302" },
|
|
10
|
+
{ urls: "stun:stun.services.mozilla.com:3478" },
|
|
11
|
+
{
|
|
12
|
+
urls: ["turn:openrelay.metered.ca:80", "turn:openrelay.metered.ca:443"],
|
|
13
|
+
username: "openrelayproject",
|
|
14
|
+
credential: "openrelayproject",
|
|
67
15
|
},
|
|
16
|
+
],
|
|
17
|
+
isHost: true,
|
|
18
|
+
};
|
|
19
|
+
export const webrtc = (config = defaultConfig) => {
|
|
20
|
+
const { iceServers = defaultConfig.iceServers } = config;
|
|
21
|
+
const ident = Math.random().toString(36).substring(2, 4) + "#";
|
|
22
|
+
return createTransportBase(({ emitter, isHost }) => {
|
|
23
|
+
const rtcConfig = { iceServers };
|
|
24
|
+
let connection;
|
|
25
|
+
let channel;
|
|
26
|
+
const onConnectionStateChange = () => {
|
|
27
|
+
log(ident, "onConnectionStateChange", connection?.connectionState);
|
|
28
|
+
const state = connection?.connectionState;
|
|
29
|
+
match(state)
|
|
30
|
+
.with("disconnected", () => {
|
|
31
|
+
// TODO: implement
|
|
32
|
+
})
|
|
33
|
+
.with("failed", () => { })
|
|
34
|
+
.otherwise(() => {
|
|
35
|
+
log(ident, "onConnectionStateChangeUnknown", state);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const onIceCandidate = (c) => {
|
|
39
|
+
if (channel?.readyState === "open")
|
|
40
|
+
return;
|
|
41
|
+
log(ident, "onIceCandidate", c.candidate);
|
|
42
|
+
emitter.emit("candidate", JSON.stringify(c.candidate?.toJSON()));
|
|
43
|
+
};
|
|
44
|
+
const onDataChannel = (e) => {
|
|
45
|
+
// eslint-disable-next-line prefer-destructuring
|
|
46
|
+
channel = e.channel;
|
|
47
|
+
hookChannel(channel);
|
|
48
|
+
log(ident, "onDataChannel", channel);
|
|
49
|
+
};
|
|
50
|
+
const onDataChannelOpen = () => {
|
|
51
|
+
log(ident, "onDataChannelOpen");
|
|
52
|
+
emitter.emit("connected");
|
|
53
|
+
};
|
|
54
|
+
const onDataChannelMessage = (e) => {
|
|
55
|
+
log(ident, "onDataChannelMessage", e.data);
|
|
56
|
+
emitter.emit("message", e.data);
|
|
57
|
+
};
|
|
58
|
+
const onNegotiationNeeded = async () => {
|
|
59
|
+
log(ident, "onNegotiationNeeded");
|
|
60
|
+
if (isHost && connection) {
|
|
61
|
+
await connection.setLocalDescription();
|
|
62
|
+
if (connection.localDescription)
|
|
63
|
+
emitter.emit("offer", JSON.stringify(connection.localDescription));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const hookChannel = (channel) => {
|
|
67
|
+
channel.onopen = onDataChannelOpen;
|
|
68
|
+
channel.onmessage = onDataChannelMessage;
|
|
69
|
+
};
|
|
70
|
+
const handle = async (message) => {
|
|
71
|
+
console.log(ident, "webrtc handle", message);
|
|
72
|
+
if (!connection)
|
|
73
|
+
throw new Error("Connection not found");
|
|
74
|
+
match(message)
|
|
75
|
+
.with({ type: "offer" }, async ({ payload }) => {
|
|
76
|
+
console.log("offer", payload);
|
|
77
|
+
// TODO: add zon schema?
|
|
78
|
+
const offer = JSON.parse(payload);
|
|
79
|
+
await connection.setRemoteDescription(new RTCSessionDescription(offer));
|
|
80
|
+
console.log(ident, "setRemoteDescriptionran", connection.remoteDescription);
|
|
81
|
+
const answer = await connection.createAnswer();
|
|
82
|
+
await connection.setLocalDescription(answer);
|
|
83
|
+
emitter.emit("answer", JSON.stringify(answer));
|
|
84
|
+
})
|
|
85
|
+
.with({ type: "answer" }, async ({ payload }) => {
|
|
86
|
+
if (!connection)
|
|
87
|
+
throw new Error("Connection not found");
|
|
88
|
+
console.log(ident, "answer", payload);
|
|
89
|
+
const answer = JSON.parse(payload);
|
|
90
|
+
await connection.setRemoteDescription(new RTCSessionDescription(answer));
|
|
91
|
+
})
|
|
92
|
+
.with({ type: "candidate" }, async ({ payload }) => {
|
|
93
|
+
if (!connection)
|
|
94
|
+
throw new Error("Connection not found");
|
|
95
|
+
if (!payload)
|
|
96
|
+
return;
|
|
97
|
+
console.log(ident, "candidate", payload);
|
|
98
|
+
const candidate = JSON.parse(payload);
|
|
99
|
+
await connection.addIceCandidate(new RTCIceCandidate(candidate));
|
|
100
|
+
})
|
|
101
|
+
.otherwise(() => {
|
|
102
|
+
// biome-ignore lint/suspicious/noConsole: <x>
|
|
103
|
+
console.warn("invalid message", message);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const send = async (message) => {
|
|
107
|
+
if (!channel)
|
|
108
|
+
throw new Error("Channel not found");
|
|
109
|
+
channel.send(message);
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
type: "webrtc",
|
|
113
|
+
async setup() {
|
|
114
|
+
log("webrtc setup");
|
|
115
|
+
connection = new RTCPeerConnection(rtcConfig);
|
|
116
|
+
connection.onconnectionstatechange = onConnectionStateChange;
|
|
117
|
+
connection.onicecandidate = onIceCandidate;
|
|
118
|
+
connection.ondatachannel = onDataChannel;
|
|
119
|
+
connection.onnegotiationneeded = onNegotiationNeeded;
|
|
120
|
+
if (isHost) {
|
|
121
|
+
channel = connection.createDataChannel("openlv-data");
|
|
122
|
+
hookChannel(channel);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
teardown() {
|
|
126
|
+
log("webrtc teardown");
|
|
127
|
+
if (channel) {
|
|
128
|
+
channel.close();
|
|
129
|
+
channel = undefined;
|
|
130
|
+
}
|
|
131
|
+
if (connection) {
|
|
132
|
+
connection.close();
|
|
133
|
+
connection = undefined;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
handle,
|
|
137
|
+
send,
|
|
138
|
+
};
|
|
68
139
|
});
|
|
69
140
|
};
|
|
70
141
|
//# sourceMappingURL=index.js.map
|
package/dist/webrtc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webrtc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webrtc/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAyB,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAOtC,gEAAgE;AAChE,MAAM,aAAa,GAAiB;IAClC,UAAU,EAAE;QACV,EAAE,IAAI,EAAE,8BAA8B,EAAE;QACxC,EAAE,IAAI,EAAE,+BAA+B,EAAE;QACzC,EAAE,IAAI,EAAE,qCAAqC,EAAE;QAC/C;YACE,IAAI,EAAE,CAAC,8BAA8B,EAAE,+BAA+B,CAAC;YACvE,QAAQ,EAAE,kBAAkB;YAC5B,UAAU,EAAE,kBAAkB;SAC/B;KACF;IACD,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,SAAuB,aAAa,EAAE,EAAE;IAC7D,MAAM,EAAE,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACjD,MAAM,SAAS,GAAqB,EAAE,UAAU,EAAE,CAAC;QACnD,IAAI,UAAyC,CAAC;QAC9C,IAAI,OAAmC,CAAC;QAExC,MAAM,uBAAuB,GAAG,GAAG,EAAE;YACnC,GAAG,CAAC,KAAK,EAAE,yBAAyB,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
4
4
|
"keywords": [
|
|
5
5
|
"open-lavatory"
|
|
6
6
|
],
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"import": "./dist/index.js",
|
|
27
27
|
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./webrtc": {
|
|
30
|
+
"types": "./dist/webrtc/index.d.ts",
|
|
31
|
+
"import": "./dist/webrtc/index.js",
|
|
32
|
+
"default": "./dist/webrtc/index.js"
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
"main": "./dist/index.js",
|
|
@@ -36,9 +41,12 @@
|
|
|
36
41
|
"dependencies": {
|
|
37
42
|
"eventemitter3": "^5.0.1",
|
|
38
43
|
"globals": "^16.2.0",
|
|
39
|
-
"ts-pattern": "^5"
|
|
44
|
+
"ts-pattern": "^5",
|
|
45
|
+
"@openlv/core": "0.0.1-beta.8"
|
|
40
46
|
},
|
|
41
47
|
"devDependencies": {
|
|
48
|
+
"@vitest/browser-playwright": "^4.0.8",
|
|
49
|
+
"playwright": "^1.56.1",
|
|
42
50
|
"typescript": "^5",
|
|
43
51
|
"vitest": "^4"
|
|
44
52
|
},
|
|
@@ -53,6 +61,7 @@
|
|
|
53
61
|
},
|
|
54
62
|
"scripts": {
|
|
55
63
|
"build": "tsc",
|
|
56
|
-
"test": "vitest"
|
|
64
|
+
"test": "vitest",
|
|
65
|
+
"test:install": "playwright install --with-deps"
|
|
57
66
|
}
|
|
58
67
|
}
|