@omujs/omu 0.9.47 → 0.9.49
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/dts/api/asset/extension.d.ts +25 -0
- package/dist/dts/api/asset/index.d.ts +2 -0
- package/dist/dts/api/dashboard/extension.d.ts +183 -0
- package/{src/api/dashboard/handler.ts → dist/dts/api/dashboard/handler.d.ts} +0 -2
- package/dist/dts/api/dashboard/index.d.ts +3 -0
- package/dist/dts/api/dashboard/packets.d.ts +73 -0
- package/dist/dts/api/endpoint/endpoint.d.ts +21 -0
- package/dist/dts/api/endpoint/extension.d.ts +17 -0
- package/{src/api/endpoint/index.ts → dist/dts/api/endpoint/index.d.ts} +0 -1
- package/dist/dts/api/endpoint/packets.d.ts +51 -0
- package/dist/dts/api/extension-registry.d.ts +8 -0
- package/dist/dts/api/extension.d.ts +11 -0
- package/dist/dts/api/http/extension.d.ts +41 -0
- package/dist/dts/api/http/http.d.ts +36 -0
- package/{src/api/http/index.ts → dist/dts/api/http/index.d.ts} +0 -1
- package/dist/dts/api/http/websocket.d.ts +125 -0
- package/dist/dts/api/i18n/extension.d.ts +19 -0
- package/{src/api/i18n/index.ts → dist/dts/api/i18n/index.d.ts} +0 -1
- package/{src/api/index.ts → dist/dts/api/index.d.ts} +0 -1
- package/dist/dts/api/logger/extension.d.ts +25 -0
- package/dist/dts/api/logger/index.d.ts +1 -0
- package/dist/dts/api/logger/packets.d.ts +18 -0
- package/dist/dts/api/permission/extension.d.ts +19 -0
- package/{src/api/permission/index.ts → dist/dts/api/permission/index.d.ts} +0 -1
- package/dist/dts/api/permission/permission.d.ts +25 -0
- package/dist/dts/api/plugin/extension.d.ts +43 -0
- package/{src/api/plugin/index.ts → dist/dts/api/plugin/index.d.ts} +0 -1
- package/{src/api/plugin/package-info.ts → dist/dts/api/plugin/package-info.d.ts} +0 -7
- package/dist/dts/api/registry/extension.d.ts +23 -0
- package/{src/api/registry/index.ts → dist/dts/api/registry/index.d.ts} +0 -1
- package/dist/dts/api/registry/packets.d.ts +20 -0
- package/{src/api/registry/registry.ts → dist/dts/api/registry/registry.d.ts} +11 -53
- package/dist/dts/api/server/extension.d.ts +61 -0
- package/dist/dts/api/server/index.d.ts +1 -0
- package/dist/dts/api/session/extension.d.ts +52 -0
- package/dist/dts/api/session/index.d.ts +1 -0
- package/dist/dts/api/signal/extension.d.ts +19 -0
- package/dist/dts/api/signal/packets.d.ts +21 -0
- package/dist/dts/api/signal/signal.d.ts +33 -0
- package/dist/dts/api/table/extension.d.ts +26 -0
- package/{src/api/table/index.ts → dist/dts/api/table/index.d.ts} +0 -1
- package/dist/dts/api/table/packets.d.ts +65 -0
- package/dist/dts/api/table/table.d.ts +75 -0
- package/dist/dts/app.d.ts +49 -0
- package/dist/dts/const.d.ts +2 -0
- package/dist/dts/errors.d.ts +36 -0
- package/dist/dts/event/index.d.ts +6 -0
- package/dist/dts/helper.d.ts +10 -0
- package/dist/dts/identifier.d.ts +51 -0
- package/dist/dts/index.d.ts +36 -0
- package/{src/localization/index.ts → dist/dts/localization/index.d.ts} +0 -1
- package/dist/dts/localization/locale.d.ts +735 -0
- package/{src/localization/localization.ts → dist/dts/localization/localization.d.ts} +0 -2
- package/dist/dts/lock.d.ts +6 -0
- package/dist/dts/network/connection.d.ts +17 -0
- package/dist/dts/network/encryption.d.ts +38 -0
- package/dist/dts/network/frame-transport.d.ts +22 -0
- package/{src/network/index.ts → dist/dts/network/index.d.ts} +0 -1
- package/dist/dts/network/network.d.ts +59 -0
- package/{src/network/packet/index.ts → dist/dts/network/packet/index.d.ts} +0 -1
- package/dist/dts/network/packet/packet-types.d.ts +84 -0
- package/dist/dts/network/packet/packet.d.ts +25 -0
- package/dist/dts/network/websocket-transport.d.ts +24 -0
- package/dist/dts/omu.d.ts +61 -0
- package/dist/dts/result.d.ts +26 -0
- package/dist/dts/serialize/bytebuffer.d.ts +73 -0
- package/dist/dts/serialize/serializer.d.ts +26 -0
- package/dist/dts/token.d.ts +14 -0
- package/dist/dts/version.d.ts +2 -0
- package/dist/esm/address.js +4 -0
- package/dist/esm/api/asset/extension.js +911 -0
- package/dist/esm/api/asset/index.js +909 -0
- package/dist/esm/api/dashboard/extension.js +1362 -0
- package/dist/esm/api/dashboard/handler.js +4 -0
- package/dist/esm/api/dashboard/index.js +1361 -0
- package/dist/esm/api/dashboard/packets.js +419 -0
- package/dist/esm/api/endpoint/endpoint.js +383 -0
- package/dist/esm/api/endpoint/extension.js +1096 -0
- package/dist/esm/api/endpoint/index.js +383 -0
- package/dist/esm/api/endpoint/packets.js +799 -0
- package/dist/esm/api/extension-registry.js +23 -0
- package/dist/esm/api/extension.js +278 -0
- package/dist/esm/api/http/extension.js +1420 -0
- package/dist/esm/api/http/http.js +448 -0
- package/dist/esm/api/http/index.js +1419 -0
- package/dist/esm/api/http/websocket.js +220 -0
- package/dist/esm/api/i18n/extension.js +1339 -0
- package/dist/esm/api/i18n/index.js +1337 -0
- package/dist/esm/api/index.js +295 -0
- package/dist/esm/api/logger/extension.js +856 -0
- package/dist/esm/api/logger/index.js +852 -0
- package/dist/esm/api/logger/packets.js +673 -0
- package/dist/esm/api/permission/extension.js +535 -0
- package/dist/esm/api/permission/index.js +294 -0
- package/dist/esm/api/permission/permission.js +294 -0
- package/dist/esm/api/plugin/extension.js +531 -0
- package/dist/esm/api/plugin/index.js +529 -0
- package/dist/esm/api/plugin/package-info.js +4 -0
- package/dist/esm/api/registry/extension.js +1286 -0
- package/dist/esm/api/registry/index.js +1285 -0
- package/dist/esm/api/registry/packets.js +694 -0
- package/dist/esm/api/registry/registry.js +383 -0
- package/dist/esm/api/server/extension.js +2140 -0
- package/dist/esm/api/server/index.js +2118 -0
- package/dist/esm/api/session/extension.js +2235 -0
- package/dist/esm/api/session/index.js +2235 -0
- package/dist/esm/api/signal/extension.js +1031 -0
- package/dist/esm/api/signal/index.js +379 -0
- package/dist/esm/api/signal/packets.js +690 -0
- package/dist/esm/api/signal/signal.js +379 -0
- package/dist/esm/api/table/extension.js +1553 -0
- package/dist/esm/api/table/index.js +1552 -0
- package/dist/esm/api/table/packets.js +904 -0
- package/dist/esm/api/table/table.js +383 -0
- package/dist/esm/app.js +264 -0
- package/dist/esm/const.js +11 -0
- package/dist/esm/errors.js +548 -0
- package/dist/esm/event/index.js +22 -0
- package/dist/esm/helper.js +15 -0
- package/dist/esm/identifier.js +266 -0
- package/dist/esm/index.js +5186 -0
- package/dist/esm/localization/index.js +742 -0
- package/dist/esm/localization/locale.js +742 -0
- package/dist/esm/localization/localization.js +4 -0
- package/dist/esm/lock.js +46 -0
- package/dist/esm/network/connection.js +293 -0
- package/dist/esm/network/encryption.js +986 -0
- package/dist/esm/network/frame-transport.js +531 -0
- package/dist/esm/network/index.js +1627 -0
- package/dist/esm/network/network.js +1368 -0
- package/dist/esm/network/packet/index.js +485 -0
- package/dist/esm/network/packet/packet-types.js +486 -0
- package/dist/esm/network/packet/packet.js +126 -0
- package/dist/esm/network/websocket-transport.js +493 -0
- package/dist/esm/omu.js +4945 -0
- package/dist/esm/result.js +68 -0
- package/dist/esm/serialize/bytebuffer.js +384 -0
- package/dist/esm/serialize/index.js +471 -0
- package/dist/esm/serialize/serializer.js +97 -0
- package/dist/esm/token.js +42 -0
- package/dist/esm/version.js +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -1
- package/CHANGELOG.md +0 -1837
- package/src/api/asset/extension.ts +0 -193
- package/src/api/asset/index.ts +0 -5
- package/src/api/dashboard/extension.ts +0 -651
- package/src/api/dashboard/index.ts +0 -38
- package/src/api/dashboard/packets.ts +0 -126
- package/src/api/endpoint/endpoint.ts +0 -56
- package/src/api/endpoint/extension.ts +0 -133
- package/src/api/endpoint/packets.ts +0 -176
- package/src/api/extension-registry.ts +0 -17
- package/src/api/extension.ts +0 -19
- package/src/api/http/extension.ts +0 -401
- package/src/api/http/http.ts +0 -79
- package/src/api/http/websocket.ts +0 -283
- package/src/api/i18n/extension.ts +0 -65
- package/src/api/logger/extension.ts +0 -75
- package/src/api/logger/index.ts +0 -4
- package/src/api/logger/packets.ts +0 -38
- package/src/api/permission/extension.ts +0 -107
- package/src/api/permission/permission.ts +0 -53
- package/src/api/plugin/extension.ts +0 -100
- package/src/api/registry/extension.ts +0 -326
- package/src/api/registry/packets.ts +0 -64
- package/src/api/server/extension.ts +0 -155
- package/src/api/server/index.ts +0 -11
- package/src/api/session/extension.ts +0 -205
- package/src/api/session/index.ts +0 -7
- package/src/api/signal/extension.ts +0 -125
- package/src/api/signal/packets.ts +0 -61
- package/src/api/signal/signal.ts +0 -67
- package/src/api/table/extension.ts +0 -554
- package/src/api/table/packets.ts +0 -252
- package/src/api/table/table.ts +0 -113
- package/src/app.ts +0 -95
- package/src/const.ts +0 -2
- package/src/errors.ts +0 -70
- package/src/event/index.ts +0 -18
- package/src/helper.ts +0 -16
- package/src/identifier.ts +0 -256
- package/src/index.ts +0 -87
- package/src/localization/locale.ts +0 -737
- package/src/lock.ts +0 -43
- package/src/network/connection.ts +0 -45
- package/src/network/encryption.ts +0 -221
- package/src/network/frame-transport.ts +0 -186
- package/src/network/network.ts +0 -322
- package/src/network/packet/packet-types.ts +0 -164
- package/src/network/packet/packet.ts +0 -55
- package/src/network/websocket-transport.ts +0 -123
- package/src/omu.ts +0 -156
- package/src/result.ts +0 -78
- package/src/serialize/bytebuffer.ts +0 -432
- package/src/serialize/serializer.ts +0 -149
- package/src/token.ts +0 -39
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -18
- /package/{src/address.ts → dist/dts/address.d.ts} +0 -0
- /package/{src/api/signal/index.ts → dist/dts/api/signal/index.d.ts} +0 -0
- /package/{src/serialize/index.ts → dist/dts/serialize/index.d.ts} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Serializable } from '../serialize';
|
|
2
|
+
import type { Packet, PacketData, PacketType } from './packet';
|
|
3
|
+
export declare class PacketMapper implements Serializable<Packet, PacketData> {
|
|
4
|
+
private readonly packetMap;
|
|
5
|
+
register(...packetTypes: PacketType<unknown>[]): void;
|
|
6
|
+
serialize(packet: Packet): PacketData;
|
|
7
|
+
deserialize(data: PacketData): Packet;
|
|
8
|
+
}
|
|
9
|
+
export interface Transport {
|
|
10
|
+
connect(): Promise<Connection>;
|
|
11
|
+
}
|
|
12
|
+
export interface Connection {
|
|
13
|
+
send(packet: Packet, serializer: Serializable<Packet, PacketData>): void;
|
|
14
|
+
receive(serializer: Serializable<Packet, PacketData>): Promise<Packet | null>;
|
|
15
|
+
close(): void;
|
|
16
|
+
closed: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Packet, PacketData } from './packet';
|
|
2
|
+
type RSANumbers = {
|
|
3
|
+
e: string;
|
|
4
|
+
n: string;
|
|
5
|
+
};
|
|
6
|
+
export type EncryptionResponse = {
|
|
7
|
+
kind: 'v1';
|
|
8
|
+
rsa: RSANumbers;
|
|
9
|
+
aes: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ENCRYPTION_AVAILABLE: boolean;
|
|
12
|
+
export declare class Decryptor {
|
|
13
|
+
private readonly privateKey;
|
|
14
|
+
private readonly publicKey;
|
|
15
|
+
private constructor();
|
|
16
|
+
static new(): Promise<Decryptor>;
|
|
17
|
+
toRequest(): Promise<RSANumbers>;
|
|
18
|
+
decrypt(data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
19
|
+
decryptString(data: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
export declare class Encryptor {
|
|
22
|
+
private readonly publicKey;
|
|
23
|
+
private constructor();
|
|
24
|
+
static new(request: RSANumbers): Promise<Encryptor>;
|
|
25
|
+
encrypt(data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
26
|
+
encryptString(data: string): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
export declare class AES {
|
|
29
|
+
private readonly key;
|
|
30
|
+
private readonly iv;
|
|
31
|
+
private constructor();
|
|
32
|
+
static new(): Promise<AES>;
|
|
33
|
+
static deserialize(aes: string, decryptor: Decryptor): Promise<AES>;
|
|
34
|
+
serialize(encryptor: Encryptor): Promise<string>;
|
|
35
|
+
encrypt(data: PacketData): Promise<Packet>;
|
|
36
|
+
decrypt(packet: Packet<Uint8Array>): Promise<PacketData>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Serializable } from '../serialize';
|
|
2
|
+
import type { Connection, Transport } from './connection.js';
|
|
3
|
+
import type { Packet, PacketData } from './packet/packet.js';
|
|
4
|
+
export declare class FrameTransport implements Transport {
|
|
5
|
+
connect(): Promise<FrameConnection>;
|
|
6
|
+
}
|
|
7
|
+
export declare class FrameConnection implements Connection {
|
|
8
|
+
private connectedWaiter;
|
|
9
|
+
connected: boolean;
|
|
10
|
+
private origin;
|
|
11
|
+
private readonly packetQueue;
|
|
12
|
+
private readonly sendQueue;
|
|
13
|
+
private receiveWaiter;
|
|
14
|
+
constructor(connectedWaiter: (() => void) | null);
|
|
15
|
+
static create(): Promise<FrameConnection>;
|
|
16
|
+
private handleCommand;
|
|
17
|
+
private postCommand;
|
|
18
|
+
receive(serializer: Serializable<Packet<unknown>, PacketData>): Promise<Packet | null>;
|
|
19
|
+
get closed(): boolean;
|
|
20
|
+
close(): void;
|
|
21
|
+
send(packet: Packet, serializer: Serializable<Packet<unknown>, PacketData>): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Address } from '../address.js';
|
|
2
|
+
import { DisconnectReason } from '../errors.js';
|
|
3
|
+
import { EventEmitter } from '../event';
|
|
4
|
+
import { Omu } from '../omu.js';
|
|
5
|
+
import type { SessioTokenProvider } from '../token.js';
|
|
6
|
+
import type { Connection, Transport } from './connection.js';
|
|
7
|
+
import { AES } from './encryption.js';
|
|
8
|
+
import type { Packet, PacketType } from './packet/packet.js';
|
|
9
|
+
type StatusType<T> = {
|
|
10
|
+
type: T;
|
|
11
|
+
};
|
|
12
|
+
export type NetworkStatus = StatusType<'connecting'> | StatusType<'connected'> | StatusType<'ready'> | {
|
|
13
|
+
type: 'disconnected';
|
|
14
|
+
attempt?: number;
|
|
15
|
+
reason?: DisconnectReason;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'reconnecting';
|
|
18
|
+
attempt: number;
|
|
19
|
+
timeout: number;
|
|
20
|
+
date: Date;
|
|
21
|
+
cancel: () => void;
|
|
22
|
+
};
|
|
23
|
+
export declare class Network {
|
|
24
|
+
private readonly omu;
|
|
25
|
+
address: Address;
|
|
26
|
+
private readonly tokenProvider;
|
|
27
|
+
private transport;
|
|
28
|
+
private connection?;
|
|
29
|
+
private aes?;
|
|
30
|
+
status: NetworkStatus;
|
|
31
|
+
readonly event: {
|
|
32
|
+
connected: EventEmitter<[]>;
|
|
33
|
+
disconnected: EventEmitter<[DisconnectReason | undefined]>;
|
|
34
|
+
packet: EventEmitter<[Packet<unknown>]>;
|
|
35
|
+
status: EventEmitter<[NetworkStatus]>;
|
|
36
|
+
};
|
|
37
|
+
private readonly tasks;
|
|
38
|
+
private readonly packetMapper;
|
|
39
|
+
private readonly packetHandlers;
|
|
40
|
+
private listenTask;
|
|
41
|
+
reason: DisconnectReason | undefined;
|
|
42
|
+
private attempt;
|
|
43
|
+
constructor(omu: Omu, address: Address, tokenProvider: SessioTokenProvider, transport: Transport, connection?: Connection | undefined, aes?: AES | undefined);
|
|
44
|
+
setConnection(connection: Connection): void;
|
|
45
|
+
registerPacket(...packetTypes: PacketType<unknown>[]): void;
|
|
46
|
+
addPacketHandler<T>(type: PacketType<T>, handler: (packet: T) => void): void;
|
|
47
|
+
private scheduleReconnect;
|
|
48
|
+
connect(reconnect?: boolean): Promise<void>;
|
|
49
|
+
private isState;
|
|
50
|
+
send(packet: Packet): Promise<void>;
|
|
51
|
+
private listen;
|
|
52
|
+
private dispatchPacket;
|
|
53
|
+
addTask(task: () => Promise<void> | void): void;
|
|
54
|
+
removeTask(task: () => Promise<void> | void): void;
|
|
55
|
+
private dispatchTasks;
|
|
56
|
+
private setStatus;
|
|
57
|
+
close(): void;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AppJson } from '../../app.js';
|
|
2
|
+
import { App } from '../../app.js';
|
|
3
|
+
import { PacketType } from './packet.js';
|
|
4
|
+
type ProtocolInfo = {
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
type RSANumbers = {
|
|
8
|
+
e: string;
|
|
9
|
+
n: string;
|
|
10
|
+
};
|
|
11
|
+
type EncryptionRequest = {
|
|
12
|
+
kind: 'v1';
|
|
13
|
+
rsa: RSANumbers;
|
|
14
|
+
};
|
|
15
|
+
type EncryptionResponse = {
|
|
16
|
+
kind: 'v1';
|
|
17
|
+
rsa: RSANumbers;
|
|
18
|
+
aes: string;
|
|
19
|
+
};
|
|
20
|
+
export type ServerMeta = {
|
|
21
|
+
protocol: ProtocolInfo;
|
|
22
|
+
encryption: EncryptionRequest | null;
|
|
23
|
+
hash: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
type ConnectPacketJson = {
|
|
26
|
+
protocol: ProtocolInfo;
|
|
27
|
+
app: AppJson;
|
|
28
|
+
token: string;
|
|
29
|
+
encryption: EncryptionResponse | null;
|
|
30
|
+
};
|
|
31
|
+
export declare class ConnectPacket {
|
|
32
|
+
readonly protocol: ProtocolInfo;
|
|
33
|
+
readonly app: App;
|
|
34
|
+
readonly token: string;
|
|
35
|
+
readonly encryption: EncryptionResponse | null;
|
|
36
|
+
constructor(options: {
|
|
37
|
+
protocol: ProtocolInfo;
|
|
38
|
+
app: App;
|
|
39
|
+
token: string;
|
|
40
|
+
encryption?: EncryptionResponse | null;
|
|
41
|
+
});
|
|
42
|
+
static deserialize(data: ConnectPacketJson): ConnectPacket;
|
|
43
|
+
static serialize(data: ConnectPacket): ConnectPacketJson;
|
|
44
|
+
}
|
|
45
|
+
export declare enum DisconnectType {
|
|
46
|
+
INVALID_TOKEN = "invalid_token",
|
|
47
|
+
INVALID_ORIGIN = "invalid_origin",
|
|
48
|
+
INVALID_VERSION = "invalid_version",
|
|
49
|
+
INVALID_PACKET_TYPE = "invalid_packet_type",
|
|
50
|
+
INVALID_PACKET_DATA = "invalid_packet_data",
|
|
51
|
+
INVALID_PACKET = "invalid_packet",
|
|
52
|
+
INTERNAL_ERROR = "internal_error",
|
|
53
|
+
ANOTHER_CONNECTION = "another_connection",
|
|
54
|
+
PERMISSION_DENIED = "permission_denied",
|
|
55
|
+
APP_REMOVED = "app_removed",
|
|
56
|
+
SERVER_RESTART = "server_restart",
|
|
57
|
+
SHUTDOWN = "shutdown",
|
|
58
|
+
CLOSE = "close"
|
|
59
|
+
}
|
|
60
|
+
type DisconnectPacketJson = {
|
|
61
|
+
type: DisconnectType;
|
|
62
|
+
message: string | null;
|
|
63
|
+
};
|
|
64
|
+
export declare class DisconnectPacket {
|
|
65
|
+
readonly type: DisconnectType;
|
|
66
|
+
readonly message: string | null;
|
|
67
|
+
constructor(options: {
|
|
68
|
+
type: DisconnectType;
|
|
69
|
+
message?: string | null;
|
|
70
|
+
});
|
|
71
|
+
static serialize(data: DisconnectPacket): DisconnectPacketJson;
|
|
72
|
+
static deserialize(data: DisconnectPacketJson): DisconnectPacket;
|
|
73
|
+
static fromJson(data: DisconnectPacketJson): DisconnectPacket;
|
|
74
|
+
toJson(): DisconnectPacketJson;
|
|
75
|
+
}
|
|
76
|
+
export declare const PACKET_TYPES: {
|
|
77
|
+
SERVER_META: PacketType<ServerMeta>;
|
|
78
|
+
CONNECT: PacketType<ConnectPacket>;
|
|
79
|
+
DISCONNECT: PacketType<DisconnectPacket>;
|
|
80
|
+
TOKEN: PacketType<string>;
|
|
81
|
+
READY: PacketType<undefined>;
|
|
82
|
+
ENCRYPTED_PACKET: PacketType<Uint8Array>;
|
|
83
|
+
};
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Identifier } from '../../identifier';
|
|
2
|
+
import { JsonType, type Serializable } from '../../serialize';
|
|
3
|
+
export type PacketData = {
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly data: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
export type Packet<T = unknown> = {
|
|
8
|
+
readonly type: PacketType<T>;
|
|
9
|
+
readonly data: T;
|
|
10
|
+
};
|
|
11
|
+
export declare class PacketType<T> {
|
|
12
|
+
readonly id: Identifier;
|
|
13
|
+
readonly serializer: Serializable<T, Uint8Array>;
|
|
14
|
+
constructor(id: Identifier, serializer: Serializable<T, Uint8Array>);
|
|
15
|
+
new(data: T): Packet<T>;
|
|
16
|
+
match(packet: Packet): packet is Packet<T>;
|
|
17
|
+
static createJson<T, D extends JsonType = JsonType>(identifier: Identifier, { name, serializer, }: {
|
|
18
|
+
name: string;
|
|
19
|
+
serializer?: Serializable<T, D>;
|
|
20
|
+
}): PacketType<T>;
|
|
21
|
+
static createSerialized<T>(identifier: Identifier, { name, serializer, }: {
|
|
22
|
+
name: string;
|
|
23
|
+
serializer: Serializable<T, Uint8Array>;
|
|
24
|
+
}): PacketType<T>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Address } from '../address.js';
|
|
2
|
+
import type { Serializable } from '../serialize';
|
|
3
|
+
import type { Connection, Transport } from './connection.js';
|
|
4
|
+
import type { Packet, PacketData } from './packet/packet.js';
|
|
5
|
+
export declare class WebsocketTransport implements Transport {
|
|
6
|
+
private readonly address;
|
|
7
|
+
constructor(address: Address);
|
|
8
|
+
private get wsEndpoint();
|
|
9
|
+
connect(): Promise<Connection>;
|
|
10
|
+
}
|
|
11
|
+
export declare class WebsocketConnection implements Connection {
|
|
12
|
+
private socket;
|
|
13
|
+
private readonly packetQueue;
|
|
14
|
+
private receiveWaiter;
|
|
15
|
+
private readingPromise;
|
|
16
|
+
private beingClosed;
|
|
17
|
+
constructor(socket: WebSocket);
|
|
18
|
+
static fromSocket(socket: WebSocket): Promise<WebsocketConnection>;
|
|
19
|
+
private onMessage;
|
|
20
|
+
receive(serializer: Serializable<Packet<unknown>, PacketData>): Promise<Packet | null>;
|
|
21
|
+
get closed(): boolean;
|
|
22
|
+
close(): void;
|
|
23
|
+
send(packet: Packet, serializer: Serializable<Packet<unknown>, PacketData>): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ExtensionRegistry } from './api';
|
|
2
|
+
import { type AssetExtension } from './api/asset/extension';
|
|
3
|
+
import { type DashboardExtension } from './api/dashboard/extension';
|
|
4
|
+
import { type EndpointExtension } from './api/endpoint/extension';
|
|
5
|
+
import { HttpExtension } from './api/http/extension';
|
|
6
|
+
import { type I18nExtension } from './api/i18n/extension';
|
|
7
|
+
import { type LoggerExtension } from './api/logger/extension.js';
|
|
8
|
+
import { type PermissionExtension } from './api/permission/extension';
|
|
9
|
+
import { type PluginExtension } from './api/plugin/extension';
|
|
10
|
+
import { type RegistryExtension } from './api/registry/extension';
|
|
11
|
+
import { type ServerExtension } from './api/server/extension';
|
|
12
|
+
import { SessionExtension } from './api/session';
|
|
13
|
+
import { type SignalExtension } from './api/signal/extension';
|
|
14
|
+
import { type TableExtension } from './api/table/extension';
|
|
15
|
+
import type { App } from './app.js';
|
|
16
|
+
import type { Unlisten } from './event';
|
|
17
|
+
import { EventEmitter } from './event';
|
|
18
|
+
import type { Address, Connection } from './network';
|
|
19
|
+
import { Network } from './network';
|
|
20
|
+
import { Transport } from './network/connection.js';
|
|
21
|
+
import type { PacketType } from './network/packet/packet.js';
|
|
22
|
+
import { type SessioTokenProvider } from './token.js';
|
|
23
|
+
export type ClientEvents = {
|
|
24
|
+
started: EventEmitter<[]>;
|
|
25
|
+
stopped: EventEmitter<[]>;
|
|
26
|
+
ready: EventEmitter<[]>;
|
|
27
|
+
};
|
|
28
|
+
export declare class Omu {
|
|
29
|
+
readonly app: App;
|
|
30
|
+
ready: boolean;
|
|
31
|
+
running: boolean;
|
|
32
|
+
readonly event: ClientEvents;
|
|
33
|
+
readonly token: SessioTokenProvider;
|
|
34
|
+
readonly address: Address;
|
|
35
|
+
readonly sessions: SessionExtension;
|
|
36
|
+
readonly network: Network;
|
|
37
|
+
readonly endpoints: EndpointExtension;
|
|
38
|
+
readonly permissions: PermissionExtension;
|
|
39
|
+
readonly plugins: PluginExtension;
|
|
40
|
+
readonly dashboard: DashboardExtension;
|
|
41
|
+
readonly extensions: ExtensionRegistry;
|
|
42
|
+
readonly tables: TableExtension;
|
|
43
|
+
readonly registries: RegistryExtension;
|
|
44
|
+
readonly signals: SignalExtension;
|
|
45
|
+
readonly assets: AssetExtension;
|
|
46
|
+
readonly i18n: I18nExtension;
|
|
47
|
+
readonly server: ServerExtension;
|
|
48
|
+
readonly logger: LoggerExtension;
|
|
49
|
+
readonly http: HttpExtension;
|
|
50
|
+
constructor(app: App, options?: {
|
|
51
|
+
address?: Address;
|
|
52
|
+
token?: SessioTokenProvider | string;
|
|
53
|
+
transport?: Transport;
|
|
54
|
+
connection?: Connection;
|
|
55
|
+
});
|
|
56
|
+
send<T>(packetType: PacketType<T>, data: T): void;
|
|
57
|
+
start(): Promise<void>;
|
|
58
|
+
stop(): void;
|
|
59
|
+
onReady(callback: () => void): Unlisten;
|
|
60
|
+
waitForReady(): Promise<void>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Success<T> = {
|
|
2
|
+
data: T;
|
|
3
|
+
error: null;
|
|
4
|
+
};
|
|
5
|
+
export type Failure<E> = {
|
|
6
|
+
data: null;
|
|
7
|
+
error: E;
|
|
8
|
+
};
|
|
9
|
+
export type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
10
|
+
export declare function tryCatch<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>>;
|
|
11
|
+
export declare function success<T>(data: T): Result<T>;
|
|
12
|
+
export declare function failure<E>(error: E): Result<null, E>;
|
|
13
|
+
export declare class PromiseResult<T, E = Error> implements Promise<T> {
|
|
14
|
+
private readonly promise;
|
|
15
|
+
private constructor();
|
|
16
|
+
static create<T, E = Error>(): {
|
|
17
|
+
promise: PromiseResult<T, E>;
|
|
18
|
+
resolve: (value: T) => void;
|
|
19
|
+
reject: (error: E) => void;
|
|
20
|
+
};
|
|
21
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: E) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
22
|
+
catch<TResult = never>(onrejected?: ((reason: E) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
|
|
23
|
+
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
|
|
24
|
+
[Symbol.toStringTag]: string;
|
|
25
|
+
toResult(): Promise<Result<T, E>>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { JsonType } from './serializer.js';
|
|
2
|
+
export declare class Flags {
|
|
3
|
+
private value;
|
|
4
|
+
private length;
|
|
5
|
+
constructor(options: {
|
|
6
|
+
value?: number;
|
|
7
|
+
length?: number;
|
|
8
|
+
});
|
|
9
|
+
has(position: number): boolean;
|
|
10
|
+
get(position: number): boolean;
|
|
11
|
+
ifSet<T>(position: number, callback: () => T): T | undefined;
|
|
12
|
+
set(position: number, value: boolean): void;
|
|
13
|
+
write(writer: ByteWriter): void;
|
|
14
|
+
static read(reader: ByteReader, length: number): Flags;
|
|
15
|
+
}
|
|
16
|
+
export declare class ByteWriter {
|
|
17
|
+
private dataView;
|
|
18
|
+
private buffer;
|
|
19
|
+
private offset;
|
|
20
|
+
private finished;
|
|
21
|
+
constructor(init?: ArrayBuffer, offset?: number);
|
|
22
|
+
static fromUint8Array(buffer: Uint8Array): ByteWriter;
|
|
23
|
+
private allocate;
|
|
24
|
+
write(data: Uint8Array): ByteWriter;
|
|
25
|
+
writeBoolean(value: boolean): ByteWriter;
|
|
26
|
+
writeInt8(value: number): ByteWriter;
|
|
27
|
+
writeUint8(value: number): ByteWriter;
|
|
28
|
+
writeInt16(value: number): ByteWriter;
|
|
29
|
+
writeUint16(value: number): ByteWriter;
|
|
30
|
+
writeInt32(value: number): ByteWriter;
|
|
31
|
+
writeUint32(value: number): ByteWriter;
|
|
32
|
+
writeInt64(value: bigint): ByteWriter;
|
|
33
|
+
writeUint64(value: bigint): ByteWriter;
|
|
34
|
+
writeULEB128(value: number): ByteWriter;
|
|
35
|
+
writeFloat16(value: number): ByteWriter;
|
|
36
|
+
writeFloat32(value: number): ByteWriter;
|
|
37
|
+
writeFloat64(value: number): ByteWriter;
|
|
38
|
+
writeUint8Array(value: Uint8Array): ByteWriter;
|
|
39
|
+
writeString(value: string): ByteWriter;
|
|
40
|
+
writeJSON(value: JsonType): ByteWriter;
|
|
41
|
+
writeFlags(flags: Flags): ByteWriter;
|
|
42
|
+
finish(): Uint8Array;
|
|
43
|
+
toUint8Array(): Uint8Array;
|
|
44
|
+
toArrayBuffer(): ArrayBuffer;
|
|
45
|
+
}
|
|
46
|
+
export declare class ByteReader {
|
|
47
|
+
private dataView;
|
|
48
|
+
private offset;
|
|
49
|
+
private finished;
|
|
50
|
+
private constructor();
|
|
51
|
+
static fromUint8Array(buffer: Uint8Array): ByteReader;
|
|
52
|
+
static fromArrayBuffer(buffer: ArrayBuffer): ByteReader;
|
|
53
|
+
static fromBlob(blob: Blob): Promise<ByteReader>;
|
|
54
|
+
read(size: number): Uint8Array;
|
|
55
|
+
readBoolean(): boolean;
|
|
56
|
+
readInt8(): number;
|
|
57
|
+
readUint8(): number;
|
|
58
|
+
readInt16(): number;
|
|
59
|
+
readUint16(): number;
|
|
60
|
+
readInt32(): number;
|
|
61
|
+
readUint32(): number;
|
|
62
|
+
readInt64(): bigint;
|
|
63
|
+
readUint64(): bigint;
|
|
64
|
+
readULEB128(): number;
|
|
65
|
+
readFloat16(): number;
|
|
66
|
+
readFloat32(): number;
|
|
67
|
+
readFloat64(): number;
|
|
68
|
+
readUint8Array(): Uint8Array;
|
|
69
|
+
readString(): string;
|
|
70
|
+
readJSON<T extends JsonType>(): T;
|
|
71
|
+
readFlags(length: number): Flags;
|
|
72
|
+
finish(): void;
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type JsonType = string | number | boolean | null | undefined | {
|
|
2
|
+
[key in never]?: JsonType;
|
|
3
|
+
} | JsonType[];
|
|
4
|
+
export interface Serializable<T, D> {
|
|
5
|
+
serialize(data: T): D;
|
|
6
|
+
deserialize(data: D): T;
|
|
7
|
+
}
|
|
8
|
+
export declare class Serializer<T, D> {
|
|
9
|
+
serialize: (data: T) => D;
|
|
10
|
+
deserialize: (data: D) => T;
|
|
11
|
+
constructor(serialize: (data: T) => D, deserialize: (data: D) => T);
|
|
12
|
+
static of<T, D>(serializer: Serializable<T, D>): Serializer<T, D>;
|
|
13
|
+
static pipe<T, R, D>(ser1: Serializable<T, R>, ser2: Serializable<R, D>): Serializable<T, D>;
|
|
14
|
+
static transform<T>(func: (value: T) => T): Serializer<T, T>;
|
|
15
|
+
static noop<T>(): Serializer<T, T>;
|
|
16
|
+
field<K extends keyof D, R>(key: K, serializer: Serializable<D[K], R>): Serializer<T, {
|
|
17
|
+
[P in keyof D]: P extends K ? R : D[P];
|
|
18
|
+
}>;
|
|
19
|
+
static json<T extends JsonType>(): Serializer<T, Uint8Array>;
|
|
20
|
+
toJson(): Serializer<T, Uint8Array>;
|
|
21
|
+
toArray(): Serializer<T[], D[]>;
|
|
22
|
+
toMap(): Serializer<Map<string, T>, Map<string, D>>;
|
|
23
|
+
fallback(fallback: T): Serializer<T, D>;
|
|
24
|
+
fallbackMap(fallback: (data: D, error: unknown) => T): Serializer<T, D>;
|
|
25
|
+
pipe<E>(serializer: Serializable<D, E>): Serializer<T, E>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from './address.js';
|
|
2
|
+
import type { App } from './app.js';
|
|
3
|
+
export interface SessioTokenProvider {
|
|
4
|
+
get(serverAddress: Address, app: App): Promise<string | undefined>;
|
|
5
|
+
}
|
|
6
|
+
export type SessionParam = {
|
|
7
|
+
address: Address;
|
|
8
|
+
token: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class BrowserSession implements SessioTokenProvider {
|
|
11
|
+
static readonly PARAM_NAME = "_omu_session";
|
|
12
|
+
get(address: Address): Promise<string | undefined>;
|
|
13
|
+
private parseParamSession;
|
|
14
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
|
|
3
|
+
//# debugId=EED7009B9B6A303464756E2164756E21
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICBdLAogICJtYXBwaW5ncyI6ICIiLAogICJkZWJ1Z0lkIjogIkVFRDcwMDlCOUI2QTMwMzQ2NDc1NkUyMTY0NzU2RTIxIiwKICAibmFtZXMiOiBbXQp9
|