@4players/odin-common 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +11 -5
  2. package/mod.d.ts +4431 -0
  3. package/mod.js +1182 -0
  4. package/mod.mjs +1065 -0
  5. package/package.json +6 -30
  6. package/eslint.config.mjs +0 -30
  7. package/lib/cjs/index.js +0 -44
  8. package/lib/cjs/plugin/api.js +0 -19
  9. package/lib/cjs/rpc/commands.js +0 -96
  10. package/lib/cjs/rpc/notifications.js +0 -39
  11. package/lib/cjs/schema/channels.js +0 -44
  12. package/lib/cjs/schema/media.js +0 -25
  13. package/lib/cjs/schema/message.js +0 -10
  14. package/lib/cjs/schema/peer.js +0 -34
  15. package/lib/cjs/schema/room.js +0 -136
  16. package/lib/cjs/schema/serialization.js +0 -15
  17. package/lib/cjs/schema/token.js +0 -33
  18. package/lib/cjs/schema/webrtc.js +0 -23
  19. package/lib/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  20. package/lib/cjs/utility/base64.js +0 -29
  21. package/lib/cjs/utility/bytearray.js +0 -28
  22. package/lib/cjs/utility/codec.js +0 -89
  23. package/lib/cjs/utility/environment.js +0 -32
  24. package/lib/cjs/utility/iterable.js +0 -10
  25. package/lib/cjs/utility/json.js +0 -6
  26. package/lib/cjs/utility/log.js +0 -224
  27. package/lib/cjs/utility/msgpack.js +0 -11
  28. package/lib/cjs/utility/result.js +0 -31
  29. package/lib/cjs/utility/selector.js +0 -18
  30. package/lib/cjs/utility/sleep.js +0 -27
  31. package/lib/cjs/utility/strand.js +0 -38
  32. package/lib/cjs/utility/url.js +0 -27
  33. package/lib/cjs/utility/uuid.js +0 -11
  34. package/lib/cjs/utility/validation.js +0 -38
  35. package/lib/esm/index.js +0 -27
  36. package/lib/esm/plugin/api.js +0 -16
  37. package/lib/esm/rpc/commands.js +0 -93
  38. package/lib/esm/rpc/notifications.js +0 -36
  39. package/lib/esm/schema/channels.js +0 -40
  40. package/lib/esm/schema/media.js +0 -22
  41. package/lib/esm/schema/message.js +0 -7
  42. package/lib/esm/schema/peer.js +0 -31
  43. package/lib/esm/schema/room.js +0 -133
  44. package/lib/esm/schema/serialization.js +0 -12
  45. package/lib/esm/schema/token.js +0 -29
  46. package/lib/esm/schema/webrtc.js +0 -20
  47. package/lib/esm/tsconfig.esm.tsbuildinfo +0 -1
  48. package/lib/esm/utility/base64.js +0 -25
  49. package/lib/esm/utility/bytearray.js +0 -24
  50. package/lib/esm/utility/codec.js +0 -85
  51. package/lib/esm/utility/environment.js +0 -24
  52. package/lib/esm/utility/iterable.js +0 -7
  53. package/lib/esm/utility/json.js +0 -3
  54. package/lib/esm/utility/log.js +0 -210
  55. package/lib/esm/utility/msgpack.js +0 -7
  56. package/lib/esm/utility/result.js +0 -23
  57. package/lib/esm/utility/selector.js +0 -14
  58. package/lib/esm/utility/sleep.js +0 -22
  59. package/lib/esm/utility/strand.js +0 -34
  60. package/lib/esm/utility/url.js +0 -23
  61. package/lib/esm/utility/uuid.js +0 -7
  62. package/lib/esm/utility/validation.js +0 -27
  63. package/lib/index.d.ts +0 -27
  64. package/lib/plugin/api.d.ts +0 -159
  65. package/lib/rpc/commands.d.ts +0 -253
  66. package/lib/rpc/notifications.d.ts +0 -1626
  67. package/lib/schema/channels.d.ts +0 -11
  68. package/lib/schema/media.d.ts +0 -122
  69. package/lib/schema/message.d.ts +0 -12
  70. package/lib/schema/peer.d.ts +0 -226
  71. package/lib/schema/room.d.ts +0 -1673
  72. package/lib/schema/serialization.d.ts +0 -12
  73. package/lib/schema/token.d.ts +0 -58
  74. package/lib/schema/webrtc.d.ts +0 -42
  75. package/lib/utility/base64.d.ts +0 -3
  76. package/lib/utility/bytearray.d.ts +0 -4
  77. package/lib/utility/codec.d.ts +0 -15
  78. package/lib/utility/environment.d.ts +0 -6
  79. package/lib/utility/iterable.d.ts +0 -1
  80. package/lib/utility/json.d.ts +0 -4
  81. package/lib/utility/log.d.ts +0 -79
  82. package/lib/utility/msgpack.d.ts +0 -2
  83. package/lib/utility/result.d.ts +0 -18
  84. package/lib/utility/selector.d.ts +0 -7
  85. package/lib/utility/sleep.d.ts +0 -4
  86. package/lib/utility/strand.d.ts +0 -8
  87. package/lib/utility/url.d.ts +0 -3
  88. package/lib/utility/uuid.d.ts +0 -2
  89. package/lib/utility/validation.d.ts +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-common",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
5
5
  "author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
6
6
  "homepage": "https://www.4players.io",
@@ -14,34 +14,10 @@
14
14
  ],
15
15
  "private": false,
16
16
  "license": "ISC",
17
- "main": "./lib/cjs/index.js",
18
- "module": "./lib/esm/index.js",
19
- "types": "./lib/index.d.ts",
20
- "scripts": {
21
- "clean": "rimraf lib",
22
- "build": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json",
23
- "format": "prettier 'src/**/*.ts' --write",
24
- "lint": "eslint .",
25
- "test": "testyts"
26
- },
17
+ "main": "mod.js",
18
+ "module": "mod.mjs",
19
+ "types": "mod.d.ts",
27
20
  "dependencies": {
28
- "@msgpack/msgpack": "3.1.1",
29
- "sdp-transform": "~2.15.0",
30
- "uuid": "~11.1.0",
31
- "zod": "~3.24.0"
32
- },
33
- "devDependencies": {
34
- "@types/node": "~22.13.0",
35
- "@types/sdp-transform": "~2.4.0",
36
- "@types/uuid": "~10.0.0",
37
- "eslint": "~9.20.0",
38
- "eslint-plugin-import": "~2.31.0",
39
- "eslint-plugin-node": "~11.1.0",
40
- "eslint-plugin-promise": "~7.2.0",
41
- "prettier": "~3.5.0",
42
- "rimraf": "~6.0.0",
43
- "testyts": "~1.5.0",
44
- "typescript": "~5.6.0",
45
- "typescript-eslint": "~8.24.0"
21
+ "zod": "^3.24.2"
46
22
  }
47
- }
23
+ }
package/eslint.config.mjs DELETED
@@ -1,30 +0,0 @@
1
- import tseslint from 'typescript-eslint';
2
-
3
- export default tseslint.config({
4
- plugins: { '@typescript-eslint': tseslint.plugin },
5
- languageOptions: {
6
- parser: tseslint.parser,
7
- parserOptions: { ecmaVersion: 12, sourceType: 'module' },
8
- },
9
- files: ['**/src/*.ts'],
10
- ignores: ['**/lib/*.ts', '**/lib/**/*.ts'],
11
- rules: {
12
- camelcase: 'off',
13
- 'comma-dangle': [
14
- 'error',
15
- {
16
- arrays: 'always-multiline',
17
- objects: 'always-multiline',
18
- imports: 'always-multiline',
19
- exports: 'always-multiline',
20
- functions: 'never',
21
- },
22
- ],
23
- 'no-unused-vars': 'off',
24
- 'no-use-before-define': 'off',
25
- 'space-before-function-paren': [
26
- 'error',
27
- { anonymous: 'always', named: 'never', asyncArrow: 'always' },
28
- ],
29
- },
30
- });
package/lib/cjs/index.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.zod = void 0;
18
- exports.zod = require("zod");
19
- __exportStar(require("./schema/serialization"), exports);
20
- __exportStar(require("./schema/token"), exports);
21
- __exportStar(require("./schema/room"), exports);
22
- __exportStar(require("./schema/peer"), exports);
23
- __exportStar(require("./schema/media"), exports);
24
- __exportStar(require("./schema/message"), exports);
25
- __exportStar(require("./schema/webrtc"), exports);
26
- __exportStar(require("./schema/channels"), exports);
27
- __exportStar(require("./rpc/commands"), exports);
28
- __exportStar(require("./rpc/notifications"), exports);
29
- __exportStar(require("./utility/base64"), exports);
30
- __exportStar(require("./utility/bytearray"), exports);
31
- __exportStar(require("./utility/codec"), exports);
32
- __exportStar(require("./utility/iterable"), exports);
33
- __exportStar(require("./utility/environment"), exports);
34
- __exportStar(require("./utility/json"), exports);
35
- __exportStar(require("./utility/msgpack"), exports);
36
- __exportStar(require("./utility/result"), exports);
37
- __exportStar(require("./utility/selector"), exports);
38
- __exportStar(require("./utility/sleep"), exports);
39
- __exportStar(require("./utility/strand"), exports);
40
- __exportStar(require("./utility/url"), exports);
41
- __exportStar(require("./utility/uuid"), exports);
42
- __exportStar(require("./utility/validation"), exports);
43
- __exportStar(require("./utility/log"), exports);
44
- __exportStar(require("./plugin/api"), exports);
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Backend = exports.MinDBFS = void 0;
4
- exports.MinDBFS = -758.596;
5
- var Backend;
6
- (function (Backend) {
7
- let Transport;
8
- (function (Transport) {
9
- Transport["H3"] = "h3";
10
- Transport["WebRTC"] = "webrtc";
11
- })(Transport = Backend.Transport || (Backend.Transport = {}));
12
- let PeerCipherStatus;
13
- (function (PeerCipherStatus) {
14
- PeerCipherStatus[PeerCipherStatus["InvalidPassword"] = -1] = "InvalidPassword";
15
- PeerCipherStatus[PeerCipherStatus["Unknown"] = 0] = "Unknown";
16
- PeerCipherStatus[PeerCipherStatus["Unencrypted"] = 1] = "Unencrypted";
17
- PeerCipherStatus[PeerCipherStatus["Encrypted"] = 2] = "Encrypted";
18
- })(PeerCipherStatus = Backend.PeerCipherStatus || (Backend.PeerCipherStatus = {}));
19
- })(Backend || (exports.Backend = Backend = {}));
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomCommandsRpc = exports.MainCommandsRpc = void 0;
4
- const zod_1 = require("zod");
5
- const serialization_1 = require("../schema/serialization");
6
- const room_1 = require("../schema/room");
7
- const peer_1 = require("../schema/peer");
8
- const media_1 = require("../schema/media");
9
- const webrtc_1 = require("../schema/webrtc");
10
- exports.MainCommandsRpc = {
11
- Hello: {
12
- request: zod_1.z.object({
13
- stream: zod_1.z.literal('main'),
14
- }),
15
- response: zod_1.z.null(),
16
- },
17
- JoinRoom: {
18
- request: zod_1.z.object({
19
- token: zod_1.z.string(),
20
- room_id: room_1.RoomV1.RoomIdSchema,
21
- user_data: serialization_1.ByteArraySchema,
22
- position: peer_1.PeerPositionSchema,
23
- }),
24
- response: zod_1.z.object({
25
- peer_id: peer_1.PeerIdSchema,
26
- stream_id: zod_1.z.optional(zod_1.z.number()),
27
- token: zod_1.z.optional(zod_1.z.string()),
28
- }),
29
- },
30
- WebRtcUpdate: {
31
- request: webrtc_1.WebRtcUpdateSchema,
32
- response: zod_1.z.null(),
33
- },
34
- RequestReconnectToken: {
35
- request: zod_1.z.object({ peer_id: zod_1.z.optional(peer_1.PeerIdSchema) }),
36
- response: zod_1.z.string(),
37
- },
38
- Ping: {
39
- request: zod_1.z.object({}),
40
- response: zod_1.z.null(),
41
- },
42
- };
43
- exports.RoomCommandsRpc = {
44
- Hello: {
45
- request: zod_1.z.object({
46
- stream: zod_1.z.literal('room'),
47
- token: zod_1.z.string(),
48
- room_id: zod_1.z.string(),
49
- user_data: serialization_1.ByteArraySchema,
50
- position: peer_1.PeerPositionSchema,
51
- }),
52
- response: zod_1.z.null(),
53
- },
54
- UpdatePeer: {
55
- request: zod_1.z.object({ user_data: serialization_1.ByteArraySchema }),
56
- response: zod_1.z.null(),
57
- },
58
- StartMedia: {
59
- request: zod_1.z.object({
60
- media_id: media_1.MediaIdSchema,
61
- properties: media_1.MediaPropertiesSchema,
62
- }),
63
- response: zod_1.z.null(),
64
- },
65
- StopMedia: {
66
- request: zod_1.z.object({
67
- media_id: media_1.MediaIdSchema,
68
- }),
69
- response: zod_1.z.null(),
70
- },
71
- PauseMedia: {
72
- request: zod_1.z.object({
73
- media_id: media_1.MediaIdSchema,
74
- }),
75
- response: zod_1.z.null(),
76
- },
77
- ResumeMedia: {
78
- request: zod_1.z.object({
79
- media_id: media_1.MediaIdSchema,
80
- }),
81
- response: zod_1.z.null(),
82
- },
83
- SetPeerPosition: {
84
- request: zod_1.z.object({
85
- position: peer_1.PeerPositionSchema,
86
- }),
87
- response: zod_1.z.null(),
88
- },
89
- SendMessage: {
90
- request: zod_1.z.object({
91
- target_peer_ids: zod_1.z.optional(zod_1.z.array(peer_1.PeerIdSchema)),
92
- message: serialization_1.ByteArraySchema,
93
- }),
94
- response: zod_1.z.null(),
95
- },
96
- };
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomNotificationsRpc = exports.RoomNotificationSchema = exports.MainNotificationsRpc = exports.MainNotificationSchema = void 0;
4
- const z = require("zod");
5
- const room_1 = require("../schema/room");
6
- const peer_1 = require("../schema/peer");
7
- const message_1 = require("../schema/message");
8
- const webrtc_1 = require("../schema/webrtc");
9
- exports.MainNotificationSchema = z.object({
10
- name: z.literal('WebRtcUpdate'),
11
- properties: webrtc_1.WebRtcUpdateSchema,
12
- });
13
- exports.MainNotificationsRpc = {
14
- WebRtcUpdate: webrtc_1.WebRtcUpdateSchema,
15
- };
16
- exports.RoomNotificationSchema = z.union([
17
- z.object({
18
- name: z.literal('RoomStatusChanged'),
19
- properties: room_1.RoomV1.RoomStatusChangedSchema,
20
- }),
21
- z.object({
22
- name: z.literal('RoomUpdated'),
23
- properties: room_1.RoomV1.RoomUpdatesSchema,
24
- }),
25
- z.object({
26
- name: z.literal('PeerUpdated'),
27
- properties: peer_1.PeerUpdateSchema,
28
- }),
29
- z.object({
30
- name: z.literal('MessageReceived'),
31
- properties: message_1.MessageReceivedSchema,
32
- }),
33
- ]);
34
- exports.RoomNotificationsRpc = {
35
- RoomStatusChanged: room_1.RoomV1.RoomStatusChangedSchema,
36
- RoomUpdated: room_1.RoomV1.RoomUpdatesSchema,
37
- PeerUpdated: peer_1.PeerUpdateSchema,
38
- MessageReceived: message_1.MessageReceivedSchema,
39
- };
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChannelSetSchema = exports.ChannelSet = void 0;
4
- const z = require("zod");
5
- class ChannelSet {
6
- constructor(value = BigInt(0)) {
7
- this.value = value;
8
- }
9
- from(...channels) {
10
- const value = channels.reduce((value, channel) => value | channel_mask(channel), BigInt(0));
11
- return new ChannelSet(value);
12
- }
13
- contains(channel) {
14
- return (this.value & channel_mask(channel)) !== BigInt(0);
15
- }
16
- insert(channel) {
17
- this.value |= channel_mask(channel);
18
- }
19
- remove(channel) {
20
- this.value &= ~channel_mask(channel);
21
- }
22
- [Symbol.iterator]() {
23
- let channel = -1;
24
- const self = new ChannelSet(this.value);
25
- return {
26
- next() {
27
- while (channel < 63) {
28
- channel += 1;
29
- if (self.contains(channel)) {
30
- return { value: channel, done: false };
31
- }
32
- }
33
- return { value: undefined, done: true };
34
- },
35
- };
36
- }
37
- }
38
- exports.ChannelSet = ChannelSet;
39
- exports.ChannelSetSchema = z
40
- .bigint()
41
- .transform((number) => new ChannelSet(number));
42
- function channel_mask(channel) {
43
- return BigInt(1) << BigInt(channel);
44
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MediaSchema = exports.MediaPropertiesSchema = exports.MediaVideoPropertiesSchema = exports.MediaAudioPropertiesSchema = exports.MediaIdSchema = void 0;
4
- const z = require("zod");
5
- exports.MediaIdSchema = z.number();
6
- exports.MediaAudioPropertiesSchema = z.object({
7
- kind: z.optional(z.literal('audio')),
8
- uid: z.optional(z.string()),
9
- customType: z.optional(z.string()),
10
- });
11
- exports.MediaVideoPropertiesSchema = z.object({
12
- kind: z.optional(z.literal('video')),
13
- codec: z.optional(z.string()),
14
- uid: z.optional(z.string()),
15
- customType: z.optional(z.string()),
16
- });
17
- exports.MediaPropertiesSchema = z.union([
18
- exports.MediaAudioPropertiesSchema,
19
- exports.MediaVideoPropertiesSchema,
20
- ]);
21
- exports.MediaSchema = z.object({
22
- id: exports.MediaIdSchema,
23
- properties: exports.MediaPropertiesSchema,
24
- paused: z.boolean(),
25
- });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageReceivedSchema = void 0;
4
- const zod_1 = require("zod");
5
- const peer_1 = require("./peer");
6
- const serialization_1 = require("./serialization");
7
- exports.MessageReceivedSchema = zod_1.z.object({
8
- sender_peer_id: peer_1.PeerIdSchema,
9
- message: serialization_1.ByteArraySchema,
10
- });
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PeerUpdateSchema = exports.PeerSchema = exports.PeerPositionSchema = exports.PeerIdSchema = void 0;
4
- const z = require("zod");
5
- const media_1 = require("./media");
6
- const serialization_1 = require("./serialization");
7
- exports.PeerIdSchema = z.number();
8
- exports.PeerPositionSchema = z.union([
9
- z.tuple([z.number(), z.number(), z.number()]),
10
- z.tuple([z.number(), z.number()]),
11
- ]);
12
- exports.PeerSchema = z.object({
13
- id: exports.PeerIdSchema,
14
- user_id: z.string(),
15
- user_data: serialization_1.ByteArraySchema,
16
- medias: z.array(media_1.MediaSchema),
17
- });
18
- exports.PeerUpdateSchema = z.discriminatedUnion('kind', [
19
- z.object({
20
- kind: z.literal('UserDataChanged'),
21
- peer_id: exports.PeerIdSchema,
22
- user_data: serialization_1.ByteArraySchema,
23
- }),
24
- z.object({
25
- kind: z.literal('MediaStarted'),
26
- peer_id: exports.PeerIdSchema,
27
- media: media_1.MediaSchema,
28
- }),
29
- z.object({
30
- kind: z.literal('MediaStopped'),
31
- peer_id: exports.PeerIdSchema,
32
- media_id: media_1.MediaIdSchema,
33
- }),
34
- ]);
@@ -1,136 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomV2 = exports.RoomV1 = void 0;
4
- const z = require("zod");
5
- const media_1 = require("./media");
6
- const peer_1 = require("./peer");
7
- const serialization_1 = require("./serialization");
8
- const channels_1 = require("./channels");
9
- var RoomV1;
10
- (function (RoomV1) {
11
- RoomV1.RoomIdSchema = z.string();
12
- RoomV1.RoomSchema = z.object({
13
- id: RoomV1.RoomIdSchema,
14
- customer: z.string(),
15
- user_data: serialization_1.ByteArraySchema,
16
- peers: z.array(peer_1.PeerSchema),
17
- });
18
- RoomV1.RoomUpdateSchema = z.discriminatedUnion('kind', [
19
- z.object({
20
- kind: z.literal('Joined'),
21
- room: RoomV1.RoomSchema,
22
- media_ids: z.array(media_1.MediaIdSchema),
23
- own_peer_id: peer_1.PeerIdSchema,
24
- }),
25
- z.object({
26
- kind: z.literal('Left'),
27
- reason: z.enum(['RoomClosing', 'ServerClosing', 'PeerKicked']),
28
- }),
29
- z.object({
30
- kind: z.literal('UserDataChanged'),
31
- user_data: z.optional(serialization_1.ByteArraySchema),
32
- }),
33
- z.object({
34
- kind: z.literal('PeerJoined'),
35
- peer: peer_1.PeerSchema,
36
- }),
37
- z.object({
38
- kind: z.literal('PeerLeft'),
39
- peer_id: peer_1.PeerIdSchema,
40
- }),
41
- ]);
42
- RoomV1.RoomUpdatesSchema = z.object({
43
- updates: z.array(RoomV1.RoomUpdateSchema),
44
- });
45
- RoomV1.RoomStatusSchema = z.enum(['Joining', 'Joined', 'Closed']);
46
- RoomV1.RoomStatusChangedSchema = z.object({
47
- status: RoomV1.RoomStatusSchema,
48
- message: z.optional(z.string()),
49
- });
50
- })(RoomV1 || (exports.RoomV1 = RoomV1 = {}));
51
- var RoomV2;
52
- (function (RoomV2) {
53
- RoomV2.ParametersSchema = z.record(serialization_1.JsonSchema);
54
- RoomV2.PeerProperties = z.object({
55
- user_data: serialization_1.ByteArraySchema.optional(),
56
- tags: z.array(z.string()).optional(),
57
- audio_parameters: RoomV2.ParametersSchema.optional(),
58
- video_parameters: RoomV2.ParametersSchema.optional(),
59
- });
60
- RoomV2.PingSchema = z.object({
61
- Ping: z.object({ id: z.number() }),
62
- });
63
- RoomV2.ChangeSelfSchema = z.object({
64
- ChangeSelf: RoomV2.PeerProperties.omit({ tags: true }),
65
- });
66
- RoomV2.SetAudioMaskSchema = z.object({
67
- SetAudioMask: z.object({
68
- peer_id: z.number(),
69
- mask: channels_1.ChannelSetSchema,
70
- }),
71
- });
72
- RoomV2.SendMessageSchema = z.object({
73
- SendMessage: z.object({
74
- peer_ids: z.number().array().default([]),
75
- message: serialization_1.ByteArraySchema,
76
- }),
77
- });
78
- RoomV2.CallSchema = RoomV2.PingSchema.or(RoomV2.ChangeSelfSchema)
79
- .or(RoomV2.SetAudioMaskSchema)
80
- .or(RoomV2.SendMessageSchema);
81
- RoomV2.PongSchema = z.object({
82
- Pong: z.object({ id: z.number() }),
83
- });
84
- RoomV2.JoinedSchema = z.object({
85
- Joined: z.object({
86
- own_peer_id: z.number(),
87
- room_id: z.string(),
88
- customer: z.string(),
89
- }),
90
- });
91
- RoomV2.LeftSchema = z.object({
92
- Left: z.object({
93
- reason: z.enum(['room_closing', 'server_closing', 'peer_kicked']),
94
- }),
95
- });
96
- RoomV2.PeerJoinedSchema = z.object({
97
- PeerJoined: RoomV2.PeerProperties.extend({
98
- peer_id: z.number(),
99
- user_id: z.string(),
100
- }),
101
- });
102
- RoomV2.PeerLeftSchema = z.object({
103
- PeerLeft: z.object({
104
- peer_id: z.number(),
105
- }),
106
- });
107
- RoomV2.PeerChangedSchema = z.object({
108
- PeerChanged: RoomV2.PeerProperties.extend({
109
- peer_id: z.number(),
110
- }),
111
- });
112
- RoomV2.NewReconnectTokenSchema = z.object({
113
- NewReconnectToken: z.object({
114
- token: z.string(),
115
- }),
116
- });
117
- RoomV2.MessageReceivedSchema = z.object({
118
- MessageReceived: z.object({
119
- sender_peer_id: z.number(),
120
- message: serialization_1.ByteArraySchema,
121
- }),
122
- });
123
- RoomV2.ErrorSchema = z.object({
124
- Error: z.object({
125
- message: serialization_1.ByteArraySchema,
126
- }),
127
- });
128
- RoomV2.EventSchema = RoomV2.PongSchema.or(RoomV2.JoinedSchema)
129
- .or(RoomV2.LeftSchema)
130
- .or(RoomV2.PeerJoinedSchema)
131
- .or(RoomV2.PeerLeftSchema)
132
- .or(RoomV2.PeerChangedSchema)
133
- .or(RoomV2.NewReconnectTokenSchema)
134
- .or(RoomV2.MessageReceivedSchema)
135
- .or(RoomV2.ErrorSchema);
136
- })(RoomV2 || (exports.RoomV2 = RoomV2 = {}));
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessagePackRpcSchema = exports.JsonSchema = exports.ByteArraySchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.ByteArraySchema = zod_1.z.custom((value) => value instanceof Uint8Array);
6
- const LiteralSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]);
7
- exports.JsonSchema = zod_1.z.lazy(() => zod_1.z.union([LiteralSchema, zod_1.z.array(exports.JsonSchema), zod_1.z.record(exports.JsonSchema)]));
8
- exports.MessagePackRpcSchema = zod_1.z.union([
9
- // request with method call
10
- zod_1.z.tuple([zod_1.z.literal(0), zod_1.z.number(), zod_1.z.string(), zod_1.z.unknown()]),
11
- // response
12
- zod_1.z.tuple([zod_1.z.literal(1), zod_1.z.number(), zod_1.z.nullable(zod_1.z.string()), zod_1.z.unknown()]),
13
- // notification
14
- zod_1.z.tuple([zod_1.z.literal(2), zod_1.z.string(), zod_1.z.unknown()]),
15
- ]);
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenClaimsSchema = exports.TokenSubjectSchema = exports.TokenAudienceSchema = void 0;
4
- exports.oneOrMany = oneOrMany;
5
- const zod_1 = require("zod");
6
- exports.TokenAudienceSchema = zod_1.z.enum(['sfu', 'gateway']);
7
- exports.TokenSubjectSchema = zod_1.z.enum([
8
- 'connect',
9
- 'roomclose',
10
- 'roomupdate',
11
- 'roombanclient',
12
- 'roomsendmessage',
13
- ]);
14
- exports.TokenClaimsSchema = zod_1.z.object({
15
- uid: zod_1.z.string(),
16
- cid: zod_1.z.optional(zod_1.z.string()),
17
- rid: oneOrMany(zod_1.z.string()),
18
- nsp: zod_1.z.optional(zod_1.z.string()),
19
- adr: zod_1.z.optional(zod_1.z.string()),
20
- aud: zod_1.z.optional(oneOrMany(exports.TokenAudienceSchema)),
21
- sub: zod_1.z.optional(oneOrMany(exports.TokenSubjectSchema)),
22
- exp: zod_1.z.optional(zod_1.z.number()),
23
- nbf: zod_1.z.optional(zod_1.z.number()),
24
- ups: zod_1.z.optional(zod_1.z.string()),
25
- tgs: zod_1.z.optional(oneOrMany(zod_1.z.string())),
26
- tsp: zod_1.z.optional(zod_1.z.number()),
27
- internal: zod_1.z.optional(zod_1.z.object({
28
- server: zod_1.z.optional(zod_1.z.string()),
29
- })),
30
- });
31
- function oneOrMany(type) {
32
- return zod_1.z.union([type, zod_1.z.array(type)]);
33
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebRtcUpdateSchema = void 0;
4
- const z = require("zod");
5
- const media_1 = require("./media");
6
- exports.WebRtcUpdateSchema = z.discriminatedUnion('kind', [
7
- z.object({
8
- kind: z.literal('Sdp'),
9
- type: z.enum(['Answer', 'Offer']),
10
- sdp: z.string(),
11
- media_map: z.array(z.tuple([media_1.MediaIdSchema, z.string()])),
12
- }),
13
- z.object({
14
- kind: z.literal('Trickle'),
15
- candidate: z.string(),
16
- spd_mid: z.optional(z.string()),
17
- spd_mline_index: z.optional(z.number()),
18
- username_fragment: z.optional(z.union([z.string(), z.null()])),
19
- }),
20
- z.object({
21
- kind: z.literal('TrickleFinished'),
22
- }),
23
- ]);
@@ -1 +0,0 @@
1
- {"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/channels.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.6.3"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromBase64 = fromBase64;
4
- exports.fromBase64Url = fromBase64Url;
5
- const result_1 = require("./result");
6
- function fromBase64(base64) {
7
- try {
8
- const binString = atob(base64);
9
- /* @ts-ignore: strings are array-like */
10
- const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));
11
- const decoder = new TextDecoder('utf8');
12
- return (0, result_1.success)(decoder.decode(bytes));
13
- }
14
- catch (error) {
15
- return (0, result_1.failure)(String(error));
16
- }
17
- }
18
- function fromBase64Url(base64uri) {
19
- try {
20
- const binString = atob(base64uri.replace(/-/g, '+').replace(/_/g, '/'));
21
- /* @ts-ignore: strings are array-like */
22
- const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));
23
- const decoder = new TextDecoder('utf8');
24
- return (0, result_1.success)(decoder.decode(bytes));
25
- }
26
- catch (error) {
27
- return (0, result_1.failure)(String(error));
28
- }
29
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBytes = toBytes;
4
- exports.fromBytes = fromBytes;
5
- const result_1 = require("./result");
6
- function toBytes(value) {
7
- try {
8
- (0, result_1.assert)(value !== undefined, 'undefined cannot be converted to byte array');
9
- (0, result_1.assert)(value !== null, 'null cannot be converted to byte array');
10
- const json = JSON.stringify(value);
11
- const decoder = new TextEncoder();
12
- return (0, result_1.success)(decoder.encode(json));
13
- }
14
- catch (error) {
15
- return (0, result_1.failure)(String(error));
16
- }
17
- }
18
- function fromBytes(bytes) {
19
- try {
20
- (0, result_1.assert)(bytes.length > 0, 'empty byte array cannot be converted to value');
21
- const json = new TextDecoder().decode(bytes);
22
- const text = JSON.parse(json);
23
- return (0, result_1.success)(text);
24
- }
25
- catch (error) {
26
- return (0, result_1.failure)(String(error));
27
- }
28
- }