@simplito/privmx-webendpoint 2.6.5 → 2.7.1
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/CONTRIBUTING.md +86 -0
- package/README.md +97 -7
- package/assets/driver-web-context.js +1 -1
- package/assets/e2ee-worker.js +1 -1
- package/assets/endpoint-wasm-module.js +2 -2
- package/assets/endpoint-wasm-module.wasm +0 -0
- package/assets/rms-processor.js +1 -0
- package/build-manifest.sh +6 -0
- package/{FinalizationHelper.js → dist/FinalizationHelper.js} +1 -1
- package/dist/ServerTypes.d.ts +7 -0
- package/{Types.d.ts → dist/Types.d.ts} +97 -10
- package/{Types.js → dist/Types.js} +17 -32
- package/{api → dist/api}/Api.d.ts +2 -0
- package/{api → dist/api}/Api.js +18 -1
- package/{api → dist/api}/ConnectionNative.js +1 -1
- package/{api → dist/api}/CryptoApiNative.js +1 -2
- package/{api → dist/api}/InboxApiNative.d.ts +21 -2
- package/{api → dist/api}/KvdbApiNative.d.ts +19 -2
- package/dist/api/NativeError.d.ts +13 -0
- package/dist/api/NativeError.js +20 -0
- package/{api → dist/api}/StoreApiNative.d.ts +19 -2
- package/dist/api/StreamApiNative.d.ts +72 -0
- package/dist/api/StreamApiNative.js +142 -0
- package/{api → dist/api}/ThreadApiNative.d.ts +19 -2
- package/dist/assets/e2ee-worker.js +1 -0
- package/dist/bundle/privmx-endpoint-web.js +2 -0
- package/dist/bundle/privmx-endpoint-web.js.LICENSE.txt +30 -0
- package/dist/bundle/rms-processor.js +1 -0
- package/{extra → dist/extra}/PrivmxClient.d.ts +9 -9
- package/{extra → dist/extra}/PrivmxClient.js +12 -12
- package/{extra → dist/extra}/PublicConnection.d.ts +2 -2
- package/{extra → dist/extra}/PublicConnection.js +2 -2
- package/{extra → dist/extra}/__tests__/connectionEventManager.test.js +1 -3
- package/{extra → dist/extra}/__tests__/customEventManager.test.js +1 -3
- package/{extra → dist/extra}/__tests__/userEventManager.test.js +2 -6
- package/{extra → dist/extra}/__tests__/utils.test.js +18 -18
- package/{extra → dist/extra}/events.js +32 -12
- package/{extra → dist/extra}/files.d.ts +5 -5
- package/{extra → dist/extra}/files.js +11 -11
- package/{extra → dist/extra}/generics.d.ts +1 -1
- package/{extra → dist/extra}/inbox.d.ts +1 -1
- package/{extra → dist/extra}/inbox.js +2 -2
- package/{extra → dist/extra}/index.d.ts +7 -7
- package/{extra → dist/extra}/managers.js +1 -1
- package/{extra → dist/extra}/utils.js +9 -9
- package/{index.d.ts → dist/index.d.ts} +3 -2
- package/{index.js → dist/index.js} +4 -1
- package/{service → dist/service}/Connection.js +13 -6
- package/{service → dist/service}/CryptoApi.js +2 -8
- package/{service → dist/service}/EndpointFactory.d.ts +11 -0
- package/{service → dist/service}/EndpointFactory.js +45 -10
- package/{service → dist/service}/EventApi.js +9 -5
- package/dist/service/EventDispatcher.d.ts +15 -0
- package/dist/service/EventDispatcher.js +25 -0
- package/{service → dist/service}/EventQueue.d.ts +4 -4
- package/{service → dist/service}/EventQueue.js +5 -9
- package/{service → dist/service}/ExtKey.d.ts +10 -10
- package/{service → dist/service}/ExtKey.js +10 -10
- package/{service → dist/service}/InboxApi.js +7 -11
- package/{service → dist/service}/KvdbApi.js +12 -7
- package/{service → dist/service}/StoreApi.js +10 -15
- package/dist/service/StreamApi.d.ts +237 -0
- package/dist/service/StreamApi.js +442 -0
- package/{service → dist/service}/ThreadApi.js +6 -7
- package/{service → dist/service}/UserVerifierInterface.d.ts +2 -2
- package/dist/service/UserVerifierInterface.js +2 -0
- package/dist/service/WebRtcInterface.d.ts +58 -0
- package/dist/service/WebRtcInterface.js +8 -0
- package/{service → dist/service}/index.d.ts +3 -2
- package/{service → dist/service}/index.js +5 -3
- package/dist/webStreams/CryptoUtils.d.ts +24 -0
- package/dist/webStreams/CryptoUtils.js +58 -0
- package/dist/webStreams/KeyStore.d.ts +9 -0
- package/dist/webStreams/KeyStore.js +29 -0
- package/dist/webStreams/Logger.d.ts +7 -0
- package/dist/webStreams/Logger.js +25 -0
- package/dist/webStreams/PeerConnectionsManager.d.ts +20 -0
- package/dist/webStreams/PeerConnectionsManager.js +92 -0
- package/dist/webStreams/Queue.d.ts +19 -0
- package/dist/webStreams/Queue.js +70 -0
- package/dist/webStreams/Utils.d.ts +20 -0
- package/dist/webStreams/Utils.js +211 -0
- package/dist/webStreams/WebRtcClient.d.ts +85 -0
- package/dist/webStreams/WebRtcClient.js +437 -0
- package/dist/webStreams/WebRtcClientTypes.d.ts +64 -0
- package/dist/webStreams/WebRtcClientTypes.js +2 -0
- package/dist/webStreams/WebRtcConfig.d.ts +20 -0
- package/dist/webStreams/WebRtcConfig.js +53 -0
- package/dist/webStreams/WebRtcInterfaceImpl.d.ts +28 -0
- package/dist/webStreams/WebRtcInterfaceImpl.js +85 -0
- package/dist/webStreams/WebWorkerHelper copy.d.ts +0 -0
- package/dist/webStreams/WebWorkerHelper copy.js +17 -0
- package/dist/webStreams/WebWorkerHelper.d.ts +18 -0
- package/dist/webStreams/WebWorkerHelper.js +69 -0
- package/dist/webStreams/audio/ActiveSpeakerDetector.d.ts +38 -0
- package/dist/webStreams/audio/ActiveSpeakerDetector.js +64 -0
- package/dist/webStreams/audio/LocalAudioLevelMeter.d.ts +12 -0
- package/dist/webStreams/audio/LocalAudioLevelMeter.js +101 -0
- package/dist/webStreams/types/ApiTypes.d.ts +74 -0
- package/dist/webStreams/types/ApiTypes.js +2 -0
- package/dist/webStreams/types/BaseServerTypes.d.ts +10 -0
- package/dist/webStreams/types/BaseServerTypes.js +2 -0
- package/dist/webStreams/types/MediaServerWebSocketApiTypes.d.ts +255 -0
- package/dist/webStreams/types/MediaServerWebSocketApiTypes.js +2 -0
- package/dist/webStreams/types/SignalingReceiverTypes.d.ts +13 -0
- package/dist/webStreams/types/SignalingReceiverTypes.js +2 -0
- package/dist/webStreams/types/SignalingSenderTypes.d.ts +24 -0
- package/dist/webStreams/types/SignalingSenderTypes.js +2 -0
- package/dist/webStreams/types/StreamsApiTypes.d.ts +144 -0
- package/dist/webStreams/types/StreamsApiTypes.js +2 -0
- package/dist/webStreams/worker/WorkerEvents.d.ts +11 -0
- package/dist/webStreams/worker/WorkerEvents.js +2 -0
- package/dist/webStreams/worker/worker.d.ts +13 -0
- package/dist/webStreams/worker/worker.js +202 -0
- package/package.json +46 -15
- package/assets/endpoint-wasm-module.worker.js +0 -1
- package/assets/privmx-endpoint-web.js +0 -2
- package/bundle/privmx-endpoint-web.js +0 -2
- package/bundle/privmx-endpoint-web.js.LICENSE.txt +0 -10
- /package/{FinalizationHelper.d.ts → dist/FinalizationHelper.d.ts} +0 -0
- /package/{extra/generics.js → dist/ServerTypes.js} +0 -0
- /package/{api → dist/api}/ApiStatic.d.ts +0 -0
- /package/{api → dist/api}/ApiStatic.js +0 -0
- /package/{api → dist/api}/BaseNative.d.ts +0 -0
- /package/{api → dist/api}/BaseNative.js +0 -0
- /package/{api → dist/api}/ConnectionNative.d.ts +0 -0
- /package/{api → dist/api}/CryptoApiNative.d.ts +0 -0
- /package/{api → dist/api}/EventApiNative.d.ts +0 -0
- /package/{api → dist/api}/EventApiNative.js +0 -0
- /package/{api → dist/api}/EventQueueNative.d.ts +0 -0
- /package/{api → dist/api}/EventQueueNative.js +0 -0
- /package/{api → dist/api}/ExtKeyNative.d.ts +0 -0
- /package/{api → dist/api}/ExtKeyNative.js +0 -0
- /package/{api → dist/api}/IdGenerator.d.ts +0 -0
- /package/{api → dist/api}/IdGenerator.js +0 -0
- /package/{api → dist/api}/InboxApiNative.js +0 -0
- /package/{api → dist/api}/KvdbApiNative.js +0 -0
- /package/{api → dist/api}/StoreApiNative.js +0 -0
- /package/{api → dist/api}/ThreadApiNative.js +0 -0
- /package/{bundle.d.ts → dist/bundle.d.ts} +0 -0
- /package/{bundle.js → dist/bundle.js} +0 -0
- /package/{extra → dist/extra}/__mocks__/constants.d.ts +0 -0
- /package/{extra → dist/extra}/__mocks__/constants.js +0 -0
- /package/{extra → dist/extra}/__mocks__/mockContainerSubscriber.d.ts +0 -0
- /package/{extra → dist/extra}/__mocks__/mockContainerSubscriber.js +0 -0
- /package/{extra → dist/extra}/__mocks__/mockEventQueue.d.ts +0 -0
- /package/{extra → dist/extra}/__mocks__/mockEventQueue.js +0 -0
- /package/{extra → dist/extra}/__mocks__/utils.d.ts +0 -0
- /package/{extra → dist/extra}/__mocks__/utils.js +0 -0
- /package/{extra → dist/extra}/__tests__/connectionEventManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/customEventManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/eventsManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/eventsManager.test.js +0 -0
- /package/{extra → dist/extra}/__tests__/inboxEventManager.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/inboxEventManager.js +0 -0
- /package/{extra → dist/extra}/__tests__/storeEventManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/storeEventManager.test.js +0 -0
- /package/{extra → dist/extra}/__tests__/threadEventManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/threadEventManager.test.js +0 -0
- /package/{extra → dist/extra}/__tests__/userEventManager.test.d.ts +0 -0
- /package/{extra → dist/extra}/__tests__/utils.test.d.ts +0 -0
- /package/{extra → dist/extra}/events.d.ts +0 -0
- /package/{service/UserVerifierInterface.js → dist/extra/generics.js} +0 -0
- /package/{extra → dist/extra}/index.js +0 -0
- /package/{extra → dist/extra}/managers.d.ts +0 -0
- /package/{extra → dist/extra}/subscriptions.d.ts +0 -0
- /package/{extra → dist/extra}/subscriptions.js +0 -0
- /package/{extra → dist/extra}/utils.d.ts +0 -0
- /package/{service → dist/service}/BaseApi.d.ts +0 -0
- /package/{service → dist/service}/BaseApi.js +0 -0
- /package/{service → dist/service}/Connection.d.ts +0 -0
- /package/{service → dist/service}/CryptoApi.d.ts +0 -0
- /package/{service → dist/service}/EventApi.d.ts +0 -0
- /package/{service → dist/service}/InboxApi.d.ts +0 -0
- /package/{service → dist/service}/KvdbApi.d.ts +0 -0
- /package/{service → dist/service}/StoreApi.d.ts +0 -0
- /package/{service → dist/service}/ThreadApi.d.ts +0 -0
|
@@ -22,9 +22,7 @@ describe("User event manager", () => {
|
|
|
22
22
|
id: "ctx-1",
|
|
23
23
|
callbacks: [callback],
|
|
24
24
|
});
|
|
25
|
-
const [subscriptionId] = await userEventsManager.subscribeFor([
|
|
26
|
-
subscription,
|
|
27
|
-
]);
|
|
25
|
+
const [subscriptionId] = await userEventsManager.subscribeFor([subscription]);
|
|
28
26
|
q.dispatchEvent((0, constants_1.MOCK_CONNECTION_USER_ADDED_EVENT)(subscriptionId));
|
|
29
27
|
await (0, utils_1.waitForNextTick)();
|
|
30
28
|
expect(callback).toHaveBeenCalledTimes(1);
|
|
@@ -41,9 +39,7 @@ describe("User event manager", () => {
|
|
|
41
39
|
id: "ctx-1",
|
|
42
40
|
callbacks: [callback],
|
|
43
41
|
});
|
|
44
|
-
const [subscriptionId] = await userEventsManager.subscribeFor([
|
|
45
|
-
subscription,
|
|
46
|
-
]);
|
|
42
|
+
const [subscriptionId] = await userEventsManager.subscribeFor([subscription]);
|
|
47
43
|
await userEventsManager.unsubscribeFrom([subscriptionId]);
|
|
48
44
|
q.dispatchEvent((0, constants_1.MOCK_CONNECTION_USER_STATUS_EVENT)(subscriptionId));
|
|
49
45
|
await (0, utils_1.waitForNextTick)();
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
describe(
|
|
5
|
-
test(
|
|
6
|
-
const obj = { key:
|
|
4
|
+
describe("Serialization Helpers", () => {
|
|
5
|
+
test("serializeObject should correctly serialize objects", () => {
|
|
6
|
+
const obj = { key: "value", num: 42 };
|
|
7
7
|
const result = (0, utils_1.serializeObject)(obj);
|
|
8
8
|
expect(result).toBeInstanceOf(Uint8Array);
|
|
9
9
|
expect((0, utils_1.uint8ToStr)(result)).toBe(JSON.stringify(obj));
|
|
10
10
|
});
|
|
11
|
-
test(
|
|
11
|
+
test("serializeObject should throw an error for invalid inputs", () => {
|
|
12
12
|
expect(() => (0, utils_1.serializeObject)(null)).toThrow(TypeError);
|
|
13
|
-
expect(() => (0, utils_1.serializeObject)(
|
|
13
|
+
expect(() => (0, utils_1.serializeObject)("string")).toThrow(TypeError);
|
|
14
14
|
});
|
|
15
|
-
test(
|
|
16
|
-
const obj = { key:
|
|
15
|
+
test("deserializeObject should correctly deserialize Uint8Array", () => {
|
|
16
|
+
const obj = { key: "value", num: 42 };
|
|
17
17
|
const serialized = (0, utils_1.strToUint8)(JSON.stringify(obj));
|
|
18
18
|
const result = (0, utils_1.deserializeObject)(serialized);
|
|
19
19
|
expect(result).toEqual(obj);
|
|
20
20
|
});
|
|
21
|
-
test(
|
|
21
|
+
test("deserializeObject should handle empty input gracefully", () => {
|
|
22
22
|
const empty = new Uint8Array();
|
|
23
23
|
const result = (0, utils_1.deserializeObject)(empty);
|
|
24
24
|
expect(result).toEqual({});
|
|
25
25
|
});
|
|
26
|
-
test(
|
|
26
|
+
test("deserializeObject should throw an error for invalid inputs", () => {
|
|
27
27
|
expect(() => (0, utils_1.deserializeObject)(null)).toThrow(TypeError);
|
|
28
|
-
expect(() => (0, utils_1.deserializeObject)(
|
|
29
|
-
const invalidJson = (0, utils_1.strToUint8)(
|
|
28
|
+
expect(() => (0, utils_1.deserializeObject)("string")).toThrow(TypeError);
|
|
29
|
+
const invalidJson = (0, utils_1.strToUint8)("{ key: value }");
|
|
30
30
|
expect(() => (0, utils_1.deserializeObject)(invalidJson)).toThrow(SyntaxError);
|
|
31
31
|
});
|
|
32
|
-
test(
|
|
33
|
-
const str =
|
|
32
|
+
test("uint8ToStr should correctly convert Uint8Array to string", () => {
|
|
33
|
+
const str = "Hello, world!";
|
|
34
34
|
const arr = (0, utils_1.strToUint8)(str);
|
|
35
35
|
const result = (0, utils_1.uint8ToStr)(arr);
|
|
36
36
|
expect(result).toBe(str);
|
|
37
37
|
});
|
|
38
|
-
test(
|
|
38
|
+
test("uint8ToStr should throw an error for invalid inputs", () => {
|
|
39
39
|
expect(() => (0, utils_1.uint8ToStr)(null)).toThrow(TypeError);
|
|
40
|
-
expect(() => (0, utils_1.uint8ToStr)(
|
|
40
|
+
expect(() => (0, utils_1.uint8ToStr)("string")).toThrow(TypeError);
|
|
41
41
|
});
|
|
42
|
-
test(
|
|
43
|
-
const str =
|
|
42
|
+
test("strToUint8 should correctly convert string to Uint8Array", () => {
|
|
43
|
+
const str = "Hello, world!";
|
|
44
44
|
const result = (0, utils_1.strToUint8)(str);
|
|
45
45
|
expect(result).toBeInstanceOf(Uint8Array);
|
|
46
46
|
expect((0, utils_1.uint8ToStr)(result)).toBe(str);
|
|
47
47
|
});
|
|
48
|
-
test(
|
|
48
|
+
test("strToUint8 should throw an error for invalid inputs", () => {
|
|
49
49
|
expect(() => (0, utils_1.strToUint8)(null)).toThrow(TypeError);
|
|
50
50
|
expect(() => (0, utils_1.strToUint8)(42)).toThrow(TypeError);
|
|
51
51
|
});
|
|
@@ -5,12 +5,27 @@ const subscriptions_1 = require("./subscriptions");
|
|
|
5
5
|
const managers_1 = require("./managers");
|
|
6
6
|
function normalizeConnectionEvent(e) {
|
|
7
7
|
switch (e.type) {
|
|
8
|
-
case
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
case "libDisconnected":
|
|
9
|
+
return {
|
|
10
|
+
...e,
|
|
11
|
+
subscriptions: [
|
|
12
|
+
`${e.connectionId}/${managers_1.ConnectionChannels[subscriptions_1.ConnectionStatusEventType.LIB_DISCONNECTED]}`,
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
case "libPlatformDisconnected":
|
|
16
|
+
return {
|
|
17
|
+
...e,
|
|
18
|
+
subscriptions: [
|
|
19
|
+
`${e.connectionId}/${managers_1.ConnectionChannels[subscriptions_1.ConnectionStatusEventType.LIB_PLATFORM_DISCONNECTED]}`,
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
case "libConnected":
|
|
23
|
+
return {
|
|
24
|
+
...e,
|
|
25
|
+
subscriptions: [
|
|
26
|
+
`${e.connectionId}/${managers_1.ConnectionChannels[subscriptions_1.ConnectionStatusEventType.LIB_CONNECTED]}`,
|
|
27
|
+
],
|
|
28
|
+
};
|
|
14
29
|
default:
|
|
15
30
|
return e;
|
|
16
31
|
}
|
|
@@ -19,14 +34,16 @@ class EventManager {
|
|
|
19
34
|
_isEventLoopRunning = false;
|
|
20
35
|
dispatchers = [];
|
|
21
36
|
eventsQueue = null;
|
|
22
|
-
constructor() {
|
|
23
|
-
}
|
|
37
|
+
constructor() { }
|
|
24
38
|
listenForEvents() {
|
|
25
39
|
if (this.eventsQueue) {
|
|
26
|
-
this.eventsQueue
|
|
40
|
+
this.eventsQueue
|
|
41
|
+
.waitEvent()
|
|
42
|
+
.then((event) => {
|
|
27
43
|
this.onEvent(event);
|
|
28
44
|
this.listenForEvents();
|
|
29
|
-
})
|
|
45
|
+
})
|
|
46
|
+
.catch(() => {
|
|
30
47
|
this.listenForEvents();
|
|
31
48
|
});
|
|
32
49
|
}
|
|
@@ -35,12 +52,15 @@ class EventManager {
|
|
|
35
52
|
const manager = new EventManager();
|
|
36
53
|
manager.eventsQueue = eventQueue;
|
|
37
54
|
manager._isEventLoopRunning = true;
|
|
38
|
-
manager.eventsQueue
|
|
55
|
+
manager.eventsQueue
|
|
56
|
+
.waitEvent()
|
|
57
|
+
.then((event) => {
|
|
39
58
|
if (!manager._isEventLoopRunning)
|
|
40
59
|
return;
|
|
41
60
|
manager.onEvent(event);
|
|
42
61
|
manager.listenForEvents();
|
|
43
|
-
})
|
|
62
|
+
})
|
|
63
|
+
.catch(() => {
|
|
44
64
|
manager.listenForEvents();
|
|
45
65
|
});
|
|
46
66
|
return manager;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Represents a stream reader for reading a file in chunks.
|
|
3
3
|
*/
|
|
4
|
-
import { InboxApi, StoreApi } from
|
|
4
|
+
import { InboxApi, StoreApi } from "..";
|
|
5
5
|
export declare const FILE_DEFAULT_CHUNK_SIZE = 1048576;
|
|
6
6
|
export declare class StreamReader {
|
|
7
7
|
private _handle;
|
|
@@ -24,7 +24,7 @@ export declare class StreamReader {
|
|
|
24
24
|
*/
|
|
25
25
|
[Symbol.asyncIterator](): AsyncGenerator<readonly [Uint8Array<ArrayBufferLike>, number], void, unknown>;
|
|
26
26
|
readNextChunk(): Promise<Uint8Array>;
|
|
27
|
-
getFileContent(): Promise<Uint8Array
|
|
27
|
+
getFileContent(): Promise<Uint8Array>;
|
|
28
28
|
/**
|
|
29
29
|
* Aborts the reading process and closes the file handle.
|
|
30
30
|
*
|
|
@@ -58,14 +58,14 @@ export declare class FileUploader {
|
|
|
58
58
|
* @param {StoreApi} api {@link StoreApi `StoreApi`} instance
|
|
59
59
|
*/
|
|
60
60
|
constructor(file: File, api: FileContainerApi);
|
|
61
|
-
static uploadStoreFile({ storeApi, storeId, file, privateMeta, publicMeta }: {
|
|
61
|
+
static uploadStoreFile({ storeApi, storeId, file, privateMeta, publicMeta, }: {
|
|
62
62
|
storeId: string;
|
|
63
63
|
file: File;
|
|
64
64
|
storeApi: StoreApi;
|
|
65
65
|
publicMeta?: Uint8Array;
|
|
66
66
|
privateMeta?: Uint8Array;
|
|
67
67
|
}): Promise<FileUploader>;
|
|
68
|
-
static uploadInboxFile({ inboxApi, inboxHandle, preparedFileUpload }: {
|
|
68
|
+
static uploadInboxFile({ inboxApi, inboxHandle, preparedFileUpload, }: {
|
|
69
69
|
inboxHandle: number;
|
|
70
70
|
preparedFileUpload: {
|
|
71
71
|
file: File;
|
|
@@ -73,7 +73,7 @@ export declare class FileUploader {
|
|
|
73
73
|
};
|
|
74
74
|
inboxApi: InboxApi;
|
|
75
75
|
}): Promise<FileUploader>;
|
|
76
|
-
static prepareInboxUpload({ inboxApi, file, privateMeta, publicMeta }: {
|
|
76
|
+
static prepareInboxUpload({ inboxApi, file, privateMeta, publicMeta, }: {
|
|
77
77
|
inboxApi: InboxApi;
|
|
78
78
|
file: File;
|
|
79
79
|
publicMeta?: Uint8Array;
|
|
@@ -94,10 +94,10 @@ class FileUploader {
|
|
|
94
94
|
this._api = api;
|
|
95
95
|
this._reader = file.stream().getReader();
|
|
96
96
|
}
|
|
97
|
-
static async uploadStoreFile({ storeApi, storeId, file, privateMeta, publicMeta }) {
|
|
97
|
+
static async uploadStoreFile({ storeApi, storeId, file, privateMeta, publicMeta, }) {
|
|
98
98
|
const meta = {
|
|
99
99
|
publicMeta: publicMeta || new Uint8Array(),
|
|
100
|
-
privateMeta: privateMeta || new Uint8Array()
|
|
100
|
+
privateMeta: privateMeta || new Uint8Array(),
|
|
101
101
|
};
|
|
102
102
|
const handle = await storeApi.createFile(storeId, meta.publicMeta, meta.privateMeta, file.size);
|
|
103
103
|
const streamer = new FileUploader(file, {
|
|
@@ -106,25 +106,25 @@ class FileUploader {
|
|
|
106
106
|
},
|
|
107
107
|
writeToFile(chunk) {
|
|
108
108
|
return storeApi.writeToFile(handle, chunk);
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
110
|
});
|
|
111
111
|
return streamer;
|
|
112
112
|
}
|
|
113
|
-
static async uploadInboxFile({ inboxApi, inboxHandle, preparedFileUpload }) {
|
|
113
|
+
static async uploadInboxFile({ inboxApi, inboxHandle, preparedFileUpload, }) {
|
|
114
114
|
const streamer = new FileUploader(preparedFileUpload.file, {
|
|
115
115
|
closeFile() {
|
|
116
|
-
return Promise.resolve(
|
|
116
|
+
return Promise.resolve("");
|
|
117
117
|
},
|
|
118
118
|
writeToFile(chunk) {
|
|
119
119
|
return inboxApi.writeToFile(inboxHandle, preparedFileUpload.handle, chunk);
|
|
120
|
-
}
|
|
120
|
+
},
|
|
121
121
|
});
|
|
122
122
|
return streamer;
|
|
123
123
|
}
|
|
124
|
-
static async prepareInboxUpload({ inboxApi, file, privateMeta, publicMeta }) {
|
|
124
|
+
static async prepareInboxUpload({ inboxApi, file, privateMeta, publicMeta, }) {
|
|
125
125
|
const meta = {
|
|
126
126
|
publicMeta: publicMeta || new Uint8Array(),
|
|
127
|
-
privateMeta: privateMeta || new Uint8Array()
|
|
127
|
+
privateMeta: privateMeta || new Uint8Array(),
|
|
128
128
|
};
|
|
129
129
|
const handle = await inboxApi.createFileHandle(meta.publicMeta, meta.privateMeta, file.size);
|
|
130
130
|
return { file: file, handle };
|
|
@@ -187,12 +187,12 @@ exports.FileUploader = FileUploader;
|
|
|
187
187
|
async function downloadFile(api, fileId, targetFileName) {
|
|
188
188
|
const filename = targetFileName || fileId;
|
|
189
189
|
const apiReader = await StreamReader.readFile(api, fileId);
|
|
190
|
-
if (
|
|
190
|
+
if ("showSaveFilePicker" in window && window.isSecureContext) {
|
|
191
191
|
//@ts-ignore
|
|
192
192
|
const systemHandle = (await window.showSaveFilePicker({
|
|
193
193
|
id: 0,
|
|
194
194
|
suggestedName: filename,
|
|
195
|
-
startIn:
|
|
195
|
+
startIn: "downloads",
|
|
196
196
|
}));
|
|
197
197
|
const accessHandle = await systemHandle.createWritable();
|
|
198
198
|
for await (const [file] of apiReader) {
|
|
@@ -202,7 +202,7 @@ async function downloadFile(api, fileId, targetFileName) {
|
|
|
202
202
|
}
|
|
203
203
|
else {
|
|
204
204
|
const fileBuffer = await apiReader.getFileContent();
|
|
205
|
-
const anchor = document.createElement(
|
|
205
|
+
const anchor = document.createElement("a");
|
|
206
206
|
const reader = new FileReader();
|
|
207
207
|
reader.onload = (e) => {
|
|
208
208
|
if (!e.target)
|
|
@@ -19,7 +19,7 @@ async function sendEntry(inboxApi, inboxId, payload) {
|
|
|
19
19
|
inboxApi,
|
|
20
20
|
file: file.content,
|
|
21
21
|
privateMeta: file.privateMeta,
|
|
22
|
-
publicMeta: file.publicMeta
|
|
22
|
+
publicMeta: file.publicMeta,
|
|
23
23
|
});
|
|
24
24
|
}))
|
|
25
25
|
: [];
|
|
@@ -27,7 +27,7 @@ async function sendEntry(inboxApi, inboxId, payload) {
|
|
|
27
27
|
const uploaders = await Promise.all(preparedFiles.map((file) => files_1.FileUploader.uploadInboxFile({
|
|
28
28
|
inboxApi,
|
|
29
29
|
inboxHandle: inboxEntryHandle,
|
|
30
|
-
preparedFileUpload: file
|
|
30
|
+
preparedFileUpload: file,
|
|
31
31
|
})));
|
|
32
32
|
await Promise.all(uploaders.map((uploader) => uploader.uploadFileContent()));
|
|
33
33
|
await inboxApi.sendEntry(inboxEntryHandle);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as Files from
|
|
2
|
-
import * as Utils from
|
|
3
|
-
import * as Generics from
|
|
4
|
-
import * as Inboxes from
|
|
5
|
-
import { FileUploader, StreamReader, downloadFile } from
|
|
6
|
-
import { PrivmxClient } from
|
|
7
|
-
import { PublicConnection } from
|
|
1
|
+
import * as Files from "./files";
|
|
2
|
+
import * as Utils from "./utils";
|
|
3
|
+
import * as Generics from "./generics";
|
|
4
|
+
import * as Inboxes from "./inbox";
|
|
5
|
+
import { FileUploader, StreamReader, downloadFile } from "./files";
|
|
6
|
+
import { PrivmxClient } from "./PrivmxClient";
|
|
7
|
+
import { PublicConnection } from "./PublicConnection";
|
|
8
8
|
export { EventManager } from "./events";
|
|
9
9
|
export { createInboxSubscription, createThreadSubscription, createConnectionSubscription, createUserEventSubscription, createKvdbSubscription, createStoreSubscription, createEventSubscription, EventCallback, Subscription, ConnectionStatusEventType, ConnectionSubscription, } from "./subscriptions";
|
|
10
10
|
export { Files, Inboxes, Utils, Generics, FileUploader, downloadFile, StreamReader, PrivmxClient, PublicConnection, };
|
|
@@ -44,7 +44,7 @@ class BaseEventDispatcherManager {
|
|
|
44
44
|
async unsubscribeFrom(subscriptionsId) {
|
|
45
45
|
const knownIds = [];
|
|
46
46
|
for (const subscriptionId of subscriptionsId) {
|
|
47
|
-
for (const [key, callbackSubscription
|
|
47
|
+
for (const [key, callbackSubscription] of this._listenersSymbols.entries()) {
|
|
48
48
|
if (callbackSubscription === subscriptionId) {
|
|
49
49
|
knownIds.push(subscriptionId);
|
|
50
50
|
this.unregisterCallback(key);
|
|
@@ -10,8 +10,8 @@ exports.strToUint8 = strToUint8;
|
|
|
10
10
|
* @returns {Uint8Array} object serialized to `Uint8Array`
|
|
11
11
|
*/
|
|
12
12
|
function serializeObject(object) {
|
|
13
|
-
if (object === null || typeof object !==
|
|
14
|
-
throw new TypeError(
|
|
13
|
+
if (object === null || typeof object !== "object") {
|
|
14
|
+
throw new TypeError("Input must be a non-null object.");
|
|
15
15
|
}
|
|
16
16
|
const encoder = new TextEncoder();
|
|
17
17
|
const parsed = JSON.stringify(object);
|
|
@@ -24,11 +24,11 @@ function serializeObject(object) {
|
|
|
24
24
|
*/
|
|
25
25
|
function deserializeObject(data) {
|
|
26
26
|
if (!(data instanceof Uint8Array)) {
|
|
27
|
-
throw new TypeError(
|
|
27
|
+
throw new TypeError("Input must be a Uint8Array.");
|
|
28
28
|
}
|
|
29
29
|
const decoder = new TextDecoder();
|
|
30
30
|
const decodedData = decoder.decode(data);
|
|
31
|
-
if (decodedData.trim() ===
|
|
31
|
+
if (decodedData.trim() === "") {
|
|
32
32
|
return {};
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
@@ -36,10 +36,10 @@ function deserializeObject(data) {
|
|
|
36
36
|
}
|
|
37
37
|
catch (error) {
|
|
38
38
|
if (error instanceof SyntaxError) {
|
|
39
|
-
throw new SyntaxError(
|
|
39
|
+
throw new SyntaxError("Failed to parse JSON: " + error.message);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
throw new Error(
|
|
42
|
+
throw new Error("An unexpected error occurred: " + String(error));
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ function deserializeObject(data) {
|
|
|
50
50
|
*/
|
|
51
51
|
function uint8ToStr(arr) {
|
|
52
52
|
if (!(arr instanceof Uint8Array)) {
|
|
53
|
-
throw new TypeError(
|
|
53
|
+
throw new TypeError("Input must be a Uint8Array.");
|
|
54
54
|
}
|
|
55
55
|
return new TextDecoder().decode(arr);
|
|
56
56
|
}
|
|
@@ -60,8 +60,8 @@ function uint8ToStr(arr) {
|
|
|
60
60
|
* @returns {Uint8Array} The resulting Uint8Array
|
|
61
61
|
*/
|
|
62
62
|
function strToUint8(text) {
|
|
63
|
-
if (typeof text !==
|
|
64
|
-
throw new TypeError(
|
|
63
|
+
if (typeof text !== "string") {
|
|
64
|
+
throw new TypeError("Input must be a string.");
|
|
65
65
|
}
|
|
66
66
|
return new TextEncoder().encode(text);
|
|
67
67
|
}
|
|
@@ -9,6 +9,7 @@ See the License for the specific language governing permissions and
|
|
|
9
9
|
limitations under the License.
|
|
10
10
|
*/
|
|
11
11
|
import { EndpointFactory } from "./service/EndpointFactory";
|
|
12
|
-
import {
|
|
12
|
+
import { NativeError } from "./api/NativeError";
|
|
13
|
+
import { EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, Connection, CryptoApi, BaseApi, StreamApi, ExtKey, EventApi } from "./service";
|
|
13
14
|
import * as Types from "./Types";
|
|
14
|
-
export { EndpointFactory as Endpoint, Types, EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, CryptoApi, Connection, BaseApi, ExtKey, EventApi };
|
|
15
|
+
export { EndpointFactory as Endpoint, NativeError, Types, EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, CryptoApi, StreamApi, Connection, BaseApi, ExtKey, EventApi, };
|
|
@@ -10,9 +10,11 @@ See the License for the specific language governing permissions and
|
|
|
10
10
|
limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.EventApi = exports.ExtKey = exports.BaseApi = exports.Connection = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.ThreadApi = exports.StoreApi = exports.EventQueue = exports.Types = exports.Endpoint = void 0;
|
|
13
|
+
exports.EventApi = exports.ExtKey = exports.BaseApi = exports.Connection = exports.StreamApi = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.ThreadApi = exports.StoreApi = exports.EventQueue = exports.Types = exports.NativeError = exports.Endpoint = void 0;
|
|
14
14
|
const EndpointFactory_1 = require("./service/EndpointFactory");
|
|
15
15
|
Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return EndpointFactory_1.EndpointFactory; } });
|
|
16
|
+
const NativeError_1 = require("./api/NativeError");
|
|
17
|
+
Object.defineProperty(exports, "NativeError", { enumerable: true, get: function () { return NativeError_1.NativeError; } });
|
|
16
18
|
const service_1 = require("./service");
|
|
17
19
|
Object.defineProperty(exports, "EventQueue", { enumerable: true, get: function () { return service_1.EventQueue; } });
|
|
18
20
|
Object.defineProperty(exports, "StoreApi", { enumerable: true, get: function () { return service_1.StoreApi; } });
|
|
@@ -22,6 +24,7 @@ Object.defineProperty(exports, "KvdbApi", { enumerable: true, get: function () {
|
|
|
22
24
|
Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return service_1.Connection; } });
|
|
23
25
|
Object.defineProperty(exports, "CryptoApi", { enumerable: true, get: function () { return service_1.CryptoApi; } });
|
|
24
26
|
Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return service_1.BaseApi; } });
|
|
27
|
+
Object.defineProperty(exports, "StreamApi", { enumerable: true, get: function () { return service_1.StreamApi; } });
|
|
25
28
|
Object.defineProperty(exports, "ExtKey", { enumerable: true, get: function () { return service_1.ExtKey; } });
|
|
26
29
|
Object.defineProperty(exports, "EventApi", { enumerable: true, get: function () { return service_1.EventApi; } });
|
|
27
30
|
const Types = require("./Types");
|
|
@@ -76,7 +76,11 @@ class Connection extends BaseApi_1.BaseApi {
|
|
|
76
76
|
* @param {string} selectorId ID of the selector
|
|
77
77
|
*/
|
|
78
78
|
async buildSubscriptionQuery(eventType, selectorType, selectorId) {
|
|
79
|
-
return this.native.buildSubscriptionQuery(this.servicePtr, [
|
|
79
|
+
return this.native.buildSubscriptionQuery(this.servicePtr, [
|
|
80
|
+
eventType,
|
|
81
|
+
selectorType,
|
|
82
|
+
selectorId,
|
|
83
|
+
]);
|
|
80
84
|
}
|
|
81
85
|
/**
|
|
82
86
|
* Disconnects from the Platform backend.
|
|
@@ -101,11 +105,14 @@ class Connection extends BaseApi_1.BaseApi {
|
|
|
101
105
|
return this.native.setUserVerifier(this.servicePtr, [this.servicePtr, verifier]);
|
|
102
106
|
}
|
|
103
107
|
async freeApis() {
|
|
104
|
-
for
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
console.warn("freeApis disabled for debugging purposes. Please re-enable");
|
|
109
|
+
// for (const apiId in this.apisRefs) {
|
|
110
|
+
// if (this.nativeApisDeps[apiId]) {
|
|
111
|
+
// await this.nativeApisDeps[apiId].deleteApi(
|
|
112
|
+
// this.apisRefs[apiId]._apiServicePtr
|
|
113
|
+
// );
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
exports.Connection = Connection;
|
|
@@ -93,10 +93,7 @@ class CryptoApi extends BaseApi_1.BaseApi {
|
|
|
93
93
|
* @returns {Uint8Array} encrypted data buffer
|
|
94
94
|
*/
|
|
95
95
|
async encryptDataSymmetric(data, symmetricKey) {
|
|
96
|
-
return this.native.encryptDataSymmetric(this.servicePtr, [
|
|
97
|
-
data,
|
|
98
|
-
symmetricKey,
|
|
99
|
-
]);
|
|
96
|
+
return this.native.encryptDataSymmetric(this.servicePtr, [data, symmetricKey]);
|
|
100
97
|
}
|
|
101
98
|
/**
|
|
102
99
|
* Decrypts buffer with a given key using AES.
|
|
@@ -106,10 +103,7 @@ class CryptoApi extends BaseApi_1.BaseApi {
|
|
|
106
103
|
* @returns {Uint8Array} plain (decrypted) data buffer
|
|
107
104
|
*/
|
|
108
105
|
async decryptDataSymmetric(data, symmetricKey) {
|
|
109
|
-
return this.native.decryptDataSymmetric(this.servicePtr, [
|
|
110
|
-
data,
|
|
111
|
-
symmetricKey,
|
|
112
|
-
]);
|
|
106
|
+
return this.native.decryptDataSymmetric(this.servicePtr, [data, symmetricKey]);
|
|
113
107
|
}
|
|
114
108
|
/**
|
|
115
109
|
* Converts given private key in PEM format to its WIF format.
|
|
@@ -16,6 +16,7 @@ import { EventQueue } from "./EventQueue";
|
|
|
16
16
|
import { InboxApi } from "./InboxApi";
|
|
17
17
|
import { KvdbApi } from "./KvdbApi";
|
|
18
18
|
import { StoreApi } from "./StoreApi";
|
|
19
|
+
import { StreamApi } from "./StreamApi";
|
|
19
20
|
import { ThreadApi } from "./ThreadApi";
|
|
20
21
|
/**
|
|
21
22
|
* Contains static factory methods - generators for Connection and APIs.
|
|
@@ -23,6 +24,7 @@ import { ThreadApi } from "./ThreadApi";
|
|
|
23
24
|
export declare class EndpointFactory {
|
|
24
25
|
private static api;
|
|
25
26
|
private static eventQueueInstance;
|
|
27
|
+
private static assetsBasePath;
|
|
26
28
|
/**
|
|
27
29
|
* Load the Endpoint's WASM assets and initialize the Endpoint library.
|
|
28
30
|
*
|
|
@@ -107,4 +109,13 @@ export declare class EndpointFactory {
|
|
|
107
109
|
* @returns {EventApi} instance of EventApi
|
|
108
110
|
*/
|
|
109
111
|
static createEventApi(connection: Connection): Promise<EventApi>;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an instance of the Stream API.
|
|
114
|
+
*
|
|
115
|
+
* @param {Connection} connection instance of Connection
|
|
116
|
+
* @param {EventApi} eventApi instance of EventApi
|
|
117
|
+
* @param {StoreApi} storeApi instance of StoreApi
|
|
118
|
+
* @returns {StreamApi} instance of StreamApi
|
|
119
|
+
*/
|
|
120
|
+
static createStreamApi(connection: Connection, eventApi: EventApi): Promise<StreamApi>;
|
|
110
121
|
}
|
|
@@ -20,8 +20,10 @@ const EventQueueNative_1 = require("../api/EventQueueNative");
|
|
|
20
20
|
const InboxApiNative_1 = require("../api/InboxApiNative");
|
|
21
21
|
const KvdbApiNative_1 = require("../api/KvdbApiNative");
|
|
22
22
|
const StoreApiNative_1 = require("../api/StoreApiNative");
|
|
23
|
+
const StreamApiNative_1 = require("../api/StreamApiNative");
|
|
23
24
|
const ThreadApiNative_1 = require("../api/ThreadApiNative");
|
|
24
25
|
const FinalizationHelper_1 = require("../FinalizationHelper");
|
|
26
|
+
const WebRtcClient_1 = require("../webStreams/WebRtcClient");
|
|
25
27
|
const Connection_1 = require("./Connection");
|
|
26
28
|
const CryptoApi_1 = require("./CryptoApi");
|
|
27
29
|
const EventApi_1 = require("./EventApi");
|
|
@@ -29,6 +31,7 @@ const EventQueue_1 = require("./EventQueue");
|
|
|
29
31
|
const InboxApi_1 = require("./InboxApi");
|
|
30
32
|
const KvdbApi_1 = require("./KvdbApi");
|
|
31
33
|
const StoreApi_1 = require("./StoreApi");
|
|
34
|
+
const StreamApi_1 = require("./StreamApi");
|
|
32
35
|
const ThreadApi_1 = require("./ThreadApi");
|
|
33
36
|
/**
|
|
34
37
|
* Contains static factory methods - generators for Connection and APIs.
|
|
@@ -36,13 +39,16 @@ const ThreadApi_1 = require("./ThreadApi");
|
|
|
36
39
|
class EndpointFactory {
|
|
37
40
|
static api;
|
|
38
41
|
static eventQueueInstance;
|
|
42
|
+
static assetsBasePath;
|
|
39
43
|
/**
|
|
40
44
|
* Load the Endpoint's WASM assets and initialize the Endpoint library.
|
|
41
45
|
*
|
|
42
46
|
* @param {string} [assetsBasePath] base path/url to the Endpoint's WebAssembly assets (like: endpoint-wasm-module.js, driver-web-context.js and others)
|
|
43
47
|
*/
|
|
44
48
|
static async setup(assetsBasePath) {
|
|
45
|
-
const basePath = assetsBasePath ||
|
|
49
|
+
const basePath = assetsBasePath ||
|
|
50
|
+
document.currentScript.src.split("/").slice(0, -1).join("/");
|
|
51
|
+
this.assetsBasePath = basePath;
|
|
46
52
|
const assets = ["driver-web-context.js", "endpoint-wasm-module.js"];
|
|
47
53
|
for (const asset of assets) {
|
|
48
54
|
await this.loadScript(basePath + "/" + asset);
|
|
@@ -51,10 +57,10 @@ class EndpointFactory {
|
|
|
51
57
|
EndpointFactory.init(lib);
|
|
52
58
|
}
|
|
53
59
|
static async loadScript(url) {
|
|
54
|
-
return new Promise(resolve => {
|
|
55
|
-
const head = document.getElementsByTagName(
|
|
56
|
-
const script = document.createElement(
|
|
57
|
-
script.type =
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
const head = document.getElementsByTagName("head")[0];
|
|
62
|
+
const script = document.createElement("script");
|
|
63
|
+
script.type = "text/javascript";
|
|
58
64
|
script.src = url;
|
|
59
65
|
script.onload = () => {
|
|
60
66
|
resolve();
|
|
@@ -86,7 +92,7 @@ class EndpointFactory {
|
|
|
86
92
|
static generateDefaultPKIVerificationOptions() {
|
|
87
93
|
return {
|
|
88
94
|
bridgeInstanceId: undefined,
|
|
89
|
-
bridgePubKey: undefined
|
|
95
|
+
bridgePubKey: undefined,
|
|
90
96
|
};
|
|
91
97
|
}
|
|
92
98
|
/**
|
|
@@ -101,7 +107,12 @@ class EndpointFactory {
|
|
|
101
107
|
static async connect(userPrivKey, solutionId, bridgeUrl, verificationOptions) {
|
|
102
108
|
const nativeApi = new ConnectionNative_1.ConnectionNative(this.api);
|
|
103
109
|
const ptr = await nativeApi.newConnection();
|
|
104
|
-
await nativeApi.connect(ptr, [
|
|
110
|
+
await nativeApi.connect(ptr, [
|
|
111
|
+
userPrivKey,
|
|
112
|
+
solutionId,
|
|
113
|
+
bridgeUrl,
|
|
114
|
+
verificationOptions || this.generateDefaultPKIVerificationOptions(),
|
|
115
|
+
]);
|
|
105
116
|
return new Connection_1.Connection(nativeApi, ptr);
|
|
106
117
|
}
|
|
107
118
|
/**
|
|
@@ -115,7 +126,11 @@ class EndpointFactory {
|
|
|
115
126
|
static async connectPublic(solutionId, bridgeUrl, verificationOptions) {
|
|
116
127
|
const nativeApi = new ConnectionNative_1.ConnectionNative(this.api);
|
|
117
128
|
const ptr = await nativeApi.newConnection();
|
|
118
|
-
await nativeApi.connectPublic(ptr, [
|
|
129
|
+
await nativeApi.connectPublic(ptr, [
|
|
130
|
+
solutionId,
|
|
131
|
+
bridgeUrl,
|
|
132
|
+
verificationOptions || this.generateDefaultPKIVerificationOptions(),
|
|
133
|
+
]);
|
|
119
134
|
return new Connection_1.Connection(nativeApi, ptr);
|
|
120
135
|
}
|
|
121
136
|
/**
|
|
@@ -168,9 +183,9 @@ class EndpointFactory {
|
|
|
168
183
|
}
|
|
169
184
|
const nativeApi = new InboxApiNative_1.InboxApiNative(this.api);
|
|
170
185
|
const ptr = await nativeApi.newApi(connection.servicePtr, threadApi.servicePtr, storeApi.servicePtr);
|
|
186
|
+
await nativeApi.create(ptr, []);
|
|
171
187
|
connection.apisRefs["inboxes"] = { _apiServicePtr: ptr };
|
|
172
188
|
connection.nativeApisDeps["inboxes"] = nativeApi;
|
|
173
|
-
await nativeApi.create(ptr, []);
|
|
174
189
|
return new InboxApi_1.InboxApi(nativeApi, ptr);
|
|
175
190
|
}
|
|
176
191
|
/**
|
|
@@ -215,10 +230,30 @@ class EndpointFactory {
|
|
|
215
230
|
}
|
|
216
231
|
const nativeApi = new EventApiNative_1.EventApiNative(this.api);
|
|
217
232
|
const ptr = await nativeApi.newApi(connection.servicePtr);
|
|
233
|
+
await nativeApi.create(ptr, []);
|
|
218
234
|
connection.apisRefs["events"] = { _apiServicePtr: ptr };
|
|
219
235
|
connection.nativeApisDeps["events"] = nativeApi;
|
|
220
|
-
await nativeApi.create(ptr, []);
|
|
221
236
|
return new EventApi_1.EventApi(nativeApi, ptr);
|
|
222
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Creates an instance of the Stream API.
|
|
240
|
+
*
|
|
241
|
+
* @param {Connection} connection instance of Connection
|
|
242
|
+
* @param {EventApi} eventApi instance of EventApi
|
|
243
|
+
* @param {StoreApi} storeApi instance of StoreApi
|
|
244
|
+
* @returns {StreamApi} instance of StreamApi
|
|
245
|
+
*/
|
|
246
|
+
static async createStreamApi(connection, eventApi) {
|
|
247
|
+
if ("streams" in connection.apisRefs) {
|
|
248
|
+
throw new Error("StreamApi already registered for given connection.");
|
|
249
|
+
}
|
|
250
|
+
const webRtcClient = new WebRtcClient_1.WebRtcClient(this.assetsBasePath);
|
|
251
|
+
const nativeApi = new StreamApiNative_1.StreamApiNative(this.api, webRtcClient);
|
|
252
|
+
const ptr = await nativeApi.newApi(connection.servicePtr, eventApi.servicePtr);
|
|
253
|
+
await nativeApi.create(ptr, []);
|
|
254
|
+
connection.apisRefs["streams"] = { _apiServicePtr: ptr };
|
|
255
|
+
connection.nativeApisDeps["streams"] = nativeApi;
|
|
256
|
+
return new StreamApi_1.StreamApi(nativeApi, ptr, webRtcClient);
|
|
257
|
+
}
|
|
223
258
|
}
|
|
224
259
|
exports.EndpointFactory = EndpointFactory;
|