@4players/odin-common 1.6.1 → 1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.1
4
+
5
+ - Update `TokenSubjectSchema` with additional subjects for gateway management apis
6
+
7
+ ## 1.7.0
8
+
9
+ - Added `MinDBFS`
10
+ - Renamed `MainNotificationsSchema` to `MainNotificationSchema`
11
+ - Renamed `RoomNotificationsSchema` to `RoomNotificationSchema`
12
+
3
13
  ## 1.6.1
4
14
 
5
15
  - Re-added `msgpackEncode` and `msgpackDecode`
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MinDBFS = void 0;
4
+ exports.MinDBFS = -758.596;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RoomCommandsRpc = exports.MainCommandsRpc = void 0;
4
- const z = require("zod");
4
+ const zod_1 = require("zod");
5
5
  const serialization_1 = require("../schema/serialization");
6
6
  const room_1 = require("../schema/room");
7
7
  const peer_1 = require("../schema/peer");
@@ -9,72 +9,72 @@ const media_1 = require("../schema/media");
9
9
  const webrtc_1 = require("../schema/webrtc");
10
10
  exports.MainCommandsRpc = {
11
11
  JoinRoom: {
12
- request: z.object({
13
- token: z.string(),
12
+ request: zod_1.z.object({
13
+ token: zod_1.z.string(),
14
14
  room_id: room_1.RoomIdSchema,
15
15
  user_data: serialization_1.ByteArraySchema,
16
16
  position: peer_1.PeerPositionSchema,
17
17
  }),
18
- response: z.object({
18
+ response: zod_1.z.object({
19
19
  peer_id: peer_1.PeerIdSchema,
20
- stream_id: z.optional(z.number()),
21
- token: z.optional(z.string()),
20
+ stream_id: zod_1.z.optional(zod_1.z.number()),
21
+ token: zod_1.z.optional(zod_1.z.string()),
22
22
  }),
23
23
  },
24
24
  WebRtcUpdate: {
25
25
  request: webrtc_1.WebRtcUpdateSchema,
26
- response: z.null(),
26
+ response: zod_1.z.null(),
27
27
  },
28
28
  RequestReconnectToken: {
29
- request: z.object({ peer_id: z.optional(peer_1.PeerIdSchema) }),
30
- response: z.string(),
29
+ request: zod_1.z.object({ peer_id: zod_1.z.optional(peer_1.PeerIdSchema) }),
30
+ response: zod_1.z.string(),
31
31
  },
32
32
  Ping: {
33
- request: z.object({}),
34
- response: z.null(),
33
+ request: zod_1.z.object({}),
34
+ response: zod_1.z.null(),
35
35
  },
36
36
  };
37
37
  exports.RoomCommandsRpc = {
38
38
  UpdatePeer: {
39
- request: z.object({ user_data: serialization_1.ByteArraySchema }),
40
- response: z.null(),
39
+ request: zod_1.z.object({ user_data: serialization_1.ByteArraySchema }),
40
+ response: zod_1.z.null(),
41
41
  },
42
42
  StartMedia: {
43
- request: z.object({
43
+ request: zod_1.z.object({
44
44
  media_id: media_1.MediaIdSchema,
45
45
  properties: media_1.MediaPropertiesSchema,
46
46
  }),
47
- response: z.null(),
47
+ response: zod_1.z.null(),
48
48
  },
49
49
  StopMedia: {
50
- request: z.object({
50
+ request: zod_1.z.object({
51
51
  media_id: media_1.MediaIdSchema,
52
52
  }),
53
- response: z.null(),
53
+ response: zod_1.z.null(),
54
54
  },
55
55
  PauseMedia: {
56
- request: z.object({
56
+ request: zod_1.z.object({
57
57
  media_id: media_1.MediaIdSchema,
58
58
  }),
59
- response: z.null(),
59
+ response: zod_1.z.null(),
60
60
  },
61
61
  ResumeMedia: {
62
- request: z.object({
62
+ request: zod_1.z.object({
63
63
  media_id: media_1.MediaIdSchema,
64
64
  }),
65
- response: z.null(),
65
+ response: zod_1.z.null(),
66
66
  },
67
67
  SetPeerPosition: {
68
- request: z.object({
68
+ request: zod_1.z.object({
69
69
  position: peer_1.PeerPositionSchema,
70
70
  }),
71
- response: z.null(),
71
+ response: zod_1.z.null(),
72
72
  },
73
73
  SendMessage: {
74
- request: z.object({
75
- target_peer_ids: z.optional(z.array(peer_1.PeerIdSchema)),
74
+ request: zod_1.z.object({
75
+ target_peer_ids: zod_1.z.optional(zod_1.z.array(peer_1.PeerIdSchema)),
76
76
  message: serialization_1.ByteArraySchema,
77
77
  }),
78
- response: z.null(),
78
+ response: zod_1.z.null(),
79
79
  },
80
80
  };
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomNotificationsRpc = exports.RoomNotificationsSchema = exports.MainNotificationsRpc = exports.MainNotificationsSchema = void 0;
3
+ exports.RoomNotificationsRpc = exports.RoomNotificationSchema = exports.MainNotificationsRpc = exports.MainNotificationSchema = void 0;
4
4
  const z = require("zod");
5
5
  const room_1 = require("../schema/room");
6
6
  const peer_1 = require("../schema/peer");
7
7
  const message_1 = require("../schema/message");
8
8
  const webrtc_1 = require("../schema/webrtc");
9
- exports.MainNotificationsSchema = z.object({
9
+ exports.MainNotificationSchema = z.object({
10
10
  name: z.literal('WebRtcUpdate'),
11
11
  properties: webrtc_1.WebRtcUpdateSchema,
12
12
  });
13
13
  exports.MainNotificationsRpc = {
14
14
  WebRtcUpdate: webrtc_1.WebRtcUpdateSchema,
15
15
  };
16
- exports.RoomNotificationsSchema = z.union([
16
+ exports.RoomNotificationSchema = z.union([
17
17
  z.object({
18
18
  name: z.literal('RoomStatusChanged'),
19
19
  properties: room_1.RoomStatusChangedSchema,
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.oneOrMany = exports.TokenClaimsSchema = exports.TokenAudienceSchema = exports.TokenSubjectSchema = void 0;
3
+ exports.oneOrMany = exports.TokenClaimsSchema = exports.TokenSubjectSchema = exports.TokenAudienceSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.TokenSubjectSchema = zod_1.z.enum(['connect']);
6
5
  exports.TokenAudienceSchema = zod_1.z.enum(['sfu', 'gateway']);
6
+ exports.TokenSubjectSchema = zod_1.z.enum([
7
+ 'connect',
8
+ 'roomclose',
9
+ 'roomupdate',
10
+ 'roombanclient',
11
+ 'roomsendmessage',
12
+ ]);
7
13
  exports.TokenClaimsSchema = zod_1.z.object({
8
14
  uid: zod_1.z.string(),
9
15
  cid: zod_1.z.optional(zod_1.z.string()),
10
16
  rid: oneOrMany(zod_1.z.string()),
11
17
  nsp: zod_1.z.optional(zod_1.z.string()),
12
18
  adr: zod_1.z.optional(zod_1.z.string()),
13
- sub: zod_1.z.optional(oneOrMany(exports.TokenSubjectSchema)),
14
19
  aud: zod_1.z.optional(oneOrMany(exports.TokenAudienceSchema)),
20
+ sub: zod_1.z.optional(oneOrMany(exports.TokenSubjectSchema)),
15
21
  exp: zod_1.z.optional(zod_1.z.number()),
16
22
  nbf: zod_1.z.optional(zod_1.z.number()),
17
23
  ups: zod_1.z.optional(zod_1.z.string()),
@@ -1 +1 @@
1
- export {};
1
+ export const MinDBFS = -758.596;
@@ -1,4 +1,4 @@
1
- import * as z from 'zod';
1
+ import { z } from 'zod';
2
2
  import { ByteArraySchema } from '../schema/serialization';
3
3
  import { RoomIdSchema } from '../schema/room';
4
4
  import { PeerIdSchema, PeerPositionSchema } from '../schema/peer';
@@ -3,14 +3,14 @@ import { RoomStatusChangedSchema, RoomUpdatesSchema } from '../schema/room';
3
3
  import { PeerUpdateSchema } from '../schema/peer';
4
4
  import { MessageReceivedSchema } from '../schema/message';
5
5
  import { WebRtcUpdateSchema } from '../schema/webrtc';
6
- export const MainNotificationsSchema = z.object({
6
+ export const MainNotificationSchema = z.object({
7
7
  name: z.literal('WebRtcUpdate'),
8
8
  properties: WebRtcUpdateSchema,
9
9
  });
10
10
  export const MainNotificationsRpc = {
11
11
  WebRtcUpdate: WebRtcUpdateSchema,
12
12
  };
13
- export const RoomNotificationsSchema = z.union([
13
+ export const RoomNotificationSchema = z.union([
14
14
  z.object({
15
15
  name: z.literal('RoomStatusChanged'),
16
16
  properties: RoomStatusChangedSchema,
@@ -1,14 +1,20 @@
1
1
  import { z } from 'zod';
2
- export const TokenSubjectSchema = z.enum(['connect']);
3
2
  export const TokenAudienceSchema = z.enum(['sfu', 'gateway']);
3
+ export const TokenSubjectSchema = z.enum([
4
+ 'connect',
5
+ 'roomclose',
6
+ 'roomupdate',
7
+ 'roombanclient',
8
+ 'roomsendmessage',
9
+ ]);
4
10
  export const TokenClaimsSchema = z.object({
5
11
  uid: z.string(),
6
12
  cid: z.optional(z.string()),
7
13
  rid: oneOrMany(z.string()),
8
14
  nsp: z.optional(z.string()),
9
15
  adr: z.optional(z.string()),
10
- sub: z.optional(oneOrMany(TokenSubjectSchema)),
11
16
  aud: z.optional(oneOrMany(TokenAudienceSchema)),
17
+ sub: z.optional(oneOrMany(TokenSubjectSchema)),
12
18
  exp: z.optional(z.number()),
13
19
  nbf: z.optional(z.number()),
14
20
  ups: z.optional(z.string()),
@@ -1,3 +1,4 @@
1
+ export declare const MinDBFS = -758.596;
1
2
  export declare namespace Backend {
2
3
  type UID = string;
3
4
  type OnStatusChanged = (status: 'started' | 'stopped') => void;
@@ -1,4 +1,5 @@
1
- import * as z from 'zod';
1
+ import { z, infer } from 'zod';
2
+ export type { infer as Infer };
2
3
  export type Commands = Record<string, {
3
4
  request: z.ZodTypeAny;
4
5
  response: z.ZodTypeAny;
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod';
2
2
  export type Notifications = Record<string, z.ZodTypeAny>;
3
- export declare const MainNotificationsSchema: z.ZodObject<{
3
+ export declare const MainNotificationSchema: z.ZodObject<{
4
4
  name: z.ZodLiteral<"WebRtcUpdate">;
5
5
  properties: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
6
6
  kind: z.ZodLiteral<"Sdp">;
@@ -75,6 +75,7 @@ export declare const MainNotificationsSchema: z.ZodObject<{
75
75
  };
76
76
  name: "WebRtcUpdate";
77
77
  }>;
78
+ export type MainNotification = z.infer<typeof MainNotificationSchema>;
78
79
  export declare const MainNotificationsRpc: {
79
80
  WebRtcUpdate: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
80
81
  kind: z.ZodLiteral<"Sdp">;
@@ -118,7 +119,7 @@ export declare const MainNotificationsRpc: {
118
119
  }>]>;
119
120
  };
120
121
  export type MainNotifications = typeof MainNotificationsRpc;
121
- export declare const RoomNotificationsSchema: z.ZodUnion<[z.ZodObject<{
122
+ export declare const RoomNotificationSchema: z.ZodUnion<[z.ZodObject<{
122
123
  name: z.ZodLiteral<"RoomStatusChanged">;
123
124
  properties: z.ZodObject<{
124
125
  status: z.ZodEnum<["Joining", "Joined", "Closed"]>;
@@ -1098,6 +1099,7 @@ export declare const RoomNotificationsSchema: z.ZodUnion<[z.ZodObject<{
1098
1099
  };
1099
1100
  name: "MessageReceived";
1100
1101
  }>]>;
1102
+ export type RoomNotification = z.infer<typeof RoomNotificationSchema>;
1101
1103
  export declare const RoomNotificationsRpc: {
1102
1104
  RoomStatusChanged: z.ZodObject<{
1103
1105
  status: z.ZodEnum<["Joining", "Joined", "Closed"]>;
@@ -1,14 +1,14 @@
1
1
  import { z } from 'zod';
2
- export declare const TokenSubjectSchema: z.ZodEnum<["connect"]>;
3
2
  export declare const TokenAudienceSchema: z.ZodEnum<["sfu", "gateway"]>;
3
+ export declare const TokenSubjectSchema: z.ZodEnum<["connect", "roomclose", "roomupdate", "roombanclient", "roomsendmessage"]>;
4
4
  export declare const TokenClaimsSchema: z.ZodObject<{
5
5
  uid: z.ZodString;
6
6
  cid: z.ZodOptional<z.ZodString>;
7
7
  rid: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
8
8
  nsp: z.ZodOptional<z.ZodString>;
9
9
  adr: z.ZodOptional<z.ZodString>;
10
- sub: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["connect"]>, z.ZodArray<z.ZodEnum<["connect"]>, "many">]>>;
11
10
  aud: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["sfu", "gateway"]>, z.ZodArray<z.ZodEnum<["sfu", "gateway"]>, "many">]>>;
11
+ sub: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["connect", "roomclose", "roomupdate", "roombanclient", "roomsendmessage"]>, z.ZodArray<z.ZodEnum<["connect", "roomclose", "roomupdate", "roombanclient", "roomsendmessage"]>, "many">]>>;
12
12
  exp: z.ZodOptional<z.ZodNumber>;
13
13
  nbf: z.ZodOptional<z.ZodNumber>;
14
14
  ups: z.ZodOptional<z.ZodString>;
@@ -25,8 +25,8 @@ export declare const TokenClaimsSchema: z.ZodObject<{
25
25
  cid?: string | undefined;
26
26
  nsp?: string | undefined;
27
27
  adr?: string | undefined;
28
- sub?: "connect" | "connect"[] | undefined;
29
28
  aud?: "sfu" | "gateway" | ("sfu" | "gateway")[] | undefined;
29
+ sub?: "connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage" | ("connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage")[] | undefined;
30
30
  exp?: number | undefined;
31
31
  nbf?: number | undefined;
32
32
  ups?: string | undefined;
@@ -39,8 +39,8 @@ export declare const TokenClaimsSchema: z.ZodObject<{
39
39
  cid?: string | undefined;
40
40
  nsp?: string | undefined;
41
41
  adr?: string | undefined;
42
- sub?: "connect" | "connect"[] | undefined;
43
42
  aud?: "sfu" | "gateway" | ("sfu" | "gateway")[] | undefined;
43
+ sub?: "connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage" | ("connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage")[] | undefined;
44
44
  exp?: number | undefined;
45
45
  nbf?: number | undefined;
46
46
  ups?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-common",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
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",
@@ -32,8 +32,8 @@
32
32
  "devDependencies": {
33
33
  "@types/node": "~20.11.0",
34
34
  "@types/uuid": "~9.0.0",
35
- "@typescript-eslint/eslint-plugin": "~7.1.0",
36
- "@typescript-eslint/parser": "~7.1.0",
35
+ "@typescript-eslint/eslint-plugin": "~7.3.0",
36
+ "@typescript-eslint/parser": "~7.3.0",
37
37
  "eslint": "~8.57.0",
38
38
  "eslint-config-semistandard": "~17.0.0",
39
39
  "eslint-plugin-import": "~2.29.0",