@tribe-nest/media-protocol 1.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.
- package/build/_fixtures/joinTokenVectors.json +103 -0
- package/build/claims.d.ts +327 -0
- package/build/claims.d.ts.map +1 -0
- package/build/claims.js +91 -0
- package/build/claims.js.map +1 -0
- package/build/codecs.d.ts +102 -0
- package/build/codecs.d.ts.map +1 -0
- package/build/codecs.js +138 -0
- package/build/codecs.js.map +1 -0
- package/build/errorSchema.d.ts +8 -0
- package/build/errorSchema.d.ts.map +1 -0
- package/build/errorSchema.js +12 -0
- package/build/errorSchema.js.map +1 -0
- package/build/errors.d.ts +18 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +47 -0
- package/build/errors.js.map +1 -0
- package/build/frames.d.ts +1291 -0
- package/build/frames.d.ts.map +1 -0
- package/build/frames.js +222 -0
- package/build/frames.js.map +1 -0
- package/build/grants.d.ts +307 -0
- package/build/grants.d.ts.map +1 -0
- package/build/grants.js +228 -0
- package/build/grants.js.map +1 -0
- package/build/index.d.ts +24 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +40 -0
- package/build/index.js.map +1 -0
- package/build/mp-build/_fixtures/joinTokenVectors.json +103 -0
- package/build/mp-build/claims.d.ts +299 -0
- package/build/mp-build/claims.d.ts.map +1 -0
- package/build/mp-build/claims.js +60 -0
- package/build/mp-build/claims.js.map +1 -0
- package/build/mp-build/errorSchema.d.ts +8 -0
- package/build/mp-build/errorSchema.d.ts.map +1 -0
- package/build/mp-build/errorSchema.js +12 -0
- package/build/mp-build/errorSchema.js.map +1 -0
- package/build/mp-build/errors.d.ts +18 -0
- package/build/mp-build/errors.d.ts.map +1 -0
- package/build/mp-build/errors.js +47 -0
- package/build/mp-build/errors.js.map +1 -0
- package/build/mp-build/frames.d.ts +786 -0
- package/build/mp-build/frames.d.ts.map +1 -0
- package/build/mp-build/frames.js +153 -0
- package/build/mp-build/frames.js.map +1 -0
- package/build/mp-build/grants.d.ts +245 -0
- package/build/mp-build/grants.d.ts.map +1 -0
- package/build/mp-build/grants.js +135 -0
- package/build/mp-build/grants.js.map +1 -0
- package/build/mp-build/index.d.ts +23 -0
- package/build/mp-build/index.d.ts.map +1 -0
- package/build/mp-build/index.js +39 -0
- package/build/mp-build/index.js.map +1 -0
- package/build/mp-build/token.d.ts +66 -0
- package/build/mp-build/token.d.ts.map +1 -0
- package/build/mp-build/token.js +208 -0
- package/build/mp-build/token.js.map +1 -0
- package/build/mp-build/version.d.ts +9 -0
- package/build/mp-build/version.d.ts.map +1 -0
- package/build/mp-build/version.js +12 -0
- package/build/mp-build/version.js.map +1 -0
- package/build/token.d.ts +66 -0
- package/build/token.d.ts.map +1 -0
- package/build/token.js +208 -0
- package/build/token.js.map +1 -0
- package/build/version.d.ts +9 -0
- package/build/version.d.ts.map +1 -0
- package/build/version.js +12 -0
- package/build/version.js.map +1 -0
- package/package.json +53 -0
- package/src/_fixtures/joinTokenVectors.json +103 -0
- package/src/_tests/codecs.spec.ts +66 -0
- package/src/_tests/publishGrants.spec.ts +109 -0
- package/src/_tests/token.spec.ts +272 -0
- package/src/claims.ts +116 -0
- package/src/codecs.ts +165 -0
- package/src/errorSchema.ts +9 -0
- package/src/errors.ts +44 -0
- package/src/frames.ts +234 -0
- package/src/grants.ts +248 -0
- package/src/index.ts +23 -0
- package/src/token.ts +237 -0
- package/src/version.ts +8 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The join token's claims: the whole authorization decision, made once by the
|
|
4
|
+
* backend and carried to a media plane that never asks it anything.
|
|
5
|
+
*
|
|
6
|
+
* Names here were contested by the parallel phase plans; each disagreement is
|
|
7
|
+
* resolved once, in this file, and everything else imports it.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `iss` IS the instance id (`legal-de`, `main`), not a service name.
|
|
11
|
+
*
|
|
12
|
+
* One plan proposed `iss: "tribenest-backend"` with the instance in a separate
|
|
13
|
+
* `inst` claim. That displaces the one value a verifier actually checks, and a
|
|
14
|
+
* legal-de token would then verify happily on the main instance - which is the
|
|
15
|
+
* whole reason instances are separate.
|
|
16
|
+
*/
|
|
17
|
+
export declare const mediaJoinClaimsSchema: z.ZodObject<{
|
|
18
|
+
v: z.ZodLiteral<1>;
|
|
19
|
+
iss: z.ZodString;
|
|
20
|
+
aud: z.ZodLiteral<"media">;
|
|
21
|
+
room: z.ZodString;
|
|
22
|
+
/** `identity`, not `sub`: it is a first-class concept the barrier rules name. */
|
|
23
|
+
identity: z.ZodString;
|
|
24
|
+
name: z.ZodOptional<z.ZodString>;
|
|
25
|
+
/** Top level, NOT inside grants - it decides what may be minted at all. */
|
|
26
|
+
kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
|
|
27
|
+
/** Top level. Transport authority is not media authority. */
|
|
28
|
+
transport: z.ZodEnum<["webrtc", "plain", "pipe"]>;
|
|
29
|
+
grants: z.ZodObject<{
|
|
30
|
+
canPublish: z.ZodBoolean;
|
|
31
|
+
canSubscribe: z.ZodBoolean;
|
|
32
|
+
canPublishData: z.ZodBoolean;
|
|
33
|
+
subscribe: z.ZodOptional<z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
|
|
34
|
+
mode: z.ZodLiteral<"all">;
|
|
35
|
+
}, "strict", z.ZodTypeAny, {
|
|
36
|
+
mode: "all";
|
|
37
|
+
}, {
|
|
38
|
+
mode: "all";
|
|
39
|
+
}>, z.ZodObject<{
|
|
40
|
+
mode: z.ZodLiteral<"none">;
|
|
41
|
+
}, "strict", z.ZodTypeAny, {
|
|
42
|
+
mode: "none";
|
|
43
|
+
}, {
|
|
44
|
+
mode: "none";
|
|
45
|
+
}>, z.ZodObject<{
|
|
46
|
+
mode: z.ZodLiteral<"allow">;
|
|
47
|
+
identities: z.ZodArray<z.ZodString, "many">;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
mode: "allow";
|
|
50
|
+
identities: string[];
|
|
51
|
+
}, {
|
|
52
|
+
mode: "allow";
|
|
53
|
+
identities: string[];
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
mode: z.ZodLiteral<"deny">;
|
|
56
|
+
identities: z.ZodArray<z.ZodString, "many">;
|
|
57
|
+
}, "strict", z.ZodTypeAny, {
|
|
58
|
+
mode: "deny";
|
|
59
|
+
identities: string[];
|
|
60
|
+
}, {
|
|
61
|
+
mode: "deny";
|
|
62
|
+
identities: string[];
|
|
63
|
+
}>]>>;
|
|
64
|
+
visibleTo: z.ZodOptional<z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
|
|
65
|
+
mode: z.ZodLiteral<"all">;
|
|
66
|
+
}, "strict", z.ZodTypeAny, {
|
|
67
|
+
mode: "all";
|
|
68
|
+
}, {
|
|
69
|
+
mode: "all";
|
|
70
|
+
}>, z.ZodObject<{
|
|
71
|
+
mode: z.ZodLiteral<"none">;
|
|
72
|
+
}, "strict", z.ZodTypeAny, {
|
|
73
|
+
mode: "none";
|
|
74
|
+
}, {
|
|
75
|
+
mode: "none";
|
|
76
|
+
}>, z.ZodObject<{
|
|
77
|
+
mode: z.ZodLiteral<"allow">;
|
|
78
|
+
identities: z.ZodArray<z.ZodString, "many">;
|
|
79
|
+
}, "strict", z.ZodTypeAny, {
|
|
80
|
+
mode: "allow";
|
|
81
|
+
identities: string[];
|
|
82
|
+
}, {
|
|
83
|
+
mode: "allow";
|
|
84
|
+
identities: string[];
|
|
85
|
+
}>, z.ZodObject<{
|
|
86
|
+
mode: z.ZodLiteral<"deny">;
|
|
87
|
+
identities: z.ZodArray<z.ZodString, "many">;
|
|
88
|
+
}, "strict", z.ZodTypeAny, {
|
|
89
|
+
mode: "deny";
|
|
90
|
+
identities: string[];
|
|
91
|
+
}, {
|
|
92
|
+
mode: "deny";
|
|
93
|
+
identities: string[];
|
|
94
|
+
}>]>>;
|
|
95
|
+
publishKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<["audio", "video", "screen"]>, "many">>;
|
|
96
|
+
subscribeExempt: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
maxSubscriptions: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, "strict", z.ZodTypeAny, {
|
|
99
|
+
canPublish: boolean;
|
|
100
|
+
canSubscribe: boolean;
|
|
101
|
+
canPublishData: boolean;
|
|
102
|
+
subscribe?: {
|
|
103
|
+
mode: "all";
|
|
104
|
+
} | {
|
|
105
|
+
mode: "none";
|
|
106
|
+
} | {
|
|
107
|
+
mode: "allow";
|
|
108
|
+
identities: string[];
|
|
109
|
+
} | {
|
|
110
|
+
mode: "deny";
|
|
111
|
+
identities: string[];
|
|
112
|
+
} | undefined;
|
|
113
|
+
visibleTo?: {
|
|
114
|
+
mode: "all";
|
|
115
|
+
} | {
|
|
116
|
+
mode: "none";
|
|
117
|
+
} | {
|
|
118
|
+
mode: "allow";
|
|
119
|
+
identities: string[];
|
|
120
|
+
} | {
|
|
121
|
+
mode: "deny";
|
|
122
|
+
identities: string[];
|
|
123
|
+
} | undefined;
|
|
124
|
+
publishKinds?: ("audio" | "video" | "screen")[] | undefined;
|
|
125
|
+
subscribeExempt?: boolean | undefined;
|
|
126
|
+
maxSubscriptions?: number | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
canPublish: boolean;
|
|
129
|
+
canSubscribe: boolean;
|
|
130
|
+
canPublishData: boolean;
|
|
131
|
+
subscribe?: {
|
|
132
|
+
mode: "all";
|
|
133
|
+
} | {
|
|
134
|
+
mode: "none";
|
|
135
|
+
} | {
|
|
136
|
+
mode: "allow";
|
|
137
|
+
identities: string[];
|
|
138
|
+
} | {
|
|
139
|
+
mode: "deny";
|
|
140
|
+
identities: string[];
|
|
141
|
+
} | undefined;
|
|
142
|
+
visibleTo?: {
|
|
143
|
+
mode: "all";
|
|
144
|
+
} | {
|
|
145
|
+
mode: "none";
|
|
146
|
+
} | {
|
|
147
|
+
mode: "allow";
|
|
148
|
+
identities: string[];
|
|
149
|
+
} | {
|
|
150
|
+
mode: "deny";
|
|
151
|
+
identities: string[];
|
|
152
|
+
} | undefined;
|
|
153
|
+
publishKinds?: ("audio" | "video" | "screen")[] | undefined;
|
|
154
|
+
subscribeExempt?: boolean | undefined;
|
|
155
|
+
maxSubscriptions?: number | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
jti: z.ZodString;
|
|
158
|
+
iat: z.ZodNumber;
|
|
159
|
+
nbf: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
exp: z.ZodNumber;
|
|
161
|
+
}, "strict", z.ZodTypeAny, {
|
|
162
|
+
v: 1;
|
|
163
|
+
iss: string;
|
|
164
|
+
aud: "media";
|
|
165
|
+
room: string;
|
|
166
|
+
identity: string;
|
|
167
|
+
kind: "human" | "agent" | "egress" | "sip" | "ingress";
|
|
168
|
+
transport: "webrtc" | "plain" | "pipe";
|
|
169
|
+
grants: {
|
|
170
|
+
canPublish: boolean;
|
|
171
|
+
canSubscribe: boolean;
|
|
172
|
+
canPublishData: boolean;
|
|
173
|
+
subscribe?: {
|
|
174
|
+
mode: "all";
|
|
175
|
+
} | {
|
|
176
|
+
mode: "none";
|
|
177
|
+
} | {
|
|
178
|
+
mode: "allow";
|
|
179
|
+
identities: string[];
|
|
180
|
+
} | {
|
|
181
|
+
mode: "deny";
|
|
182
|
+
identities: string[];
|
|
183
|
+
} | undefined;
|
|
184
|
+
visibleTo?: {
|
|
185
|
+
mode: "all";
|
|
186
|
+
} | {
|
|
187
|
+
mode: "none";
|
|
188
|
+
} | {
|
|
189
|
+
mode: "allow";
|
|
190
|
+
identities: string[];
|
|
191
|
+
} | {
|
|
192
|
+
mode: "deny";
|
|
193
|
+
identities: string[];
|
|
194
|
+
} | undefined;
|
|
195
|
+
publishKinds?: ("audio" | "video" | "screen")[] | undefined;
|
|
196
|
+
subscribeExempt?: boolean | undefined;
|
|
197
|
+
maxSubscriptions?: number | undefined;
|
|
198
|
+
};
|
|
199
|
+
jti: string;
|
|
200
|
+
iat: number;
|
|
201
|
+
exp: number;
|
|
202
|
+
name?: string | undefined;
|
|
203
|
+
nbf?: number | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
v: 1;
|
|
206
|
+
iss: string;
|
|
207
|
+
aud: "media";
|
|
208
|
+
room: string;
|
|
209
|
+
identity: string;
|
|
210
|
+
kind: "human" | "agent" | "egress" | "sip" | "ingress";
|
|
211
|
+
transport: "webrtc" | "plain" | "pipe";
|
|
212
|
+
grants: {
|
|
213
|
+
canPublish: boolean;
|
|
214
|
+
canSubscribe: boolean;
|
|
215
|
+
canPublishData: boolean;
|
|
216
|
+
subscribe?: {
|
|
217
|
+
mode: "all";
|
|
218
|
+
} | {
|
|
219
|
+
mode: "none";
|
|
220
|
+
} | {
|
|
221
|
+
mode: "allow";
|
|
222
|
+
identities: string[];
|
|
223
|
+
} | {
|
|
224
|
+
mode: "deny";
|
|
225
|
+
identities: string[];
|
|
226
|
+
} | undefined;
|
|
227
|
+
visibleTo?: {
|
|
228
|
+
mode: "all";
|
|
229
|
+
} | {
|
|
230
|
+
mode: "none";
|
|
231
|
+
} | {
|
|
232
|
+
mode: "allow";
|
|
233
|
+
identities: string[];
|
|
234
|
+
} | {
|
|
235
|
+
mode: "deny";
|
|
236
|
+
identities: string[];
|
|
237
|
+
} | undefined;
|
|
238
|
+
publishKinds?: ("audio" | "video" | "screen")[] | undefined;
|
|
239
|
+
subscribeExempt?: boolean | undefined;
|
|
240
|
+
maxSubscriptions?: number | undefined;
|
|
241
|
+
};
|
|
242
|
+
jti: string;
|
|
243
|
+
iat: number;
|
|
244
|
+
exp: number;
|
|
245
|
+
name?: string | undefined;
|
|
246
|
+
nbf?: number | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
export type MediaJoinClaims = z.infer<typeof mediaJoinClaimsSchema>;
|
|
249
|
+
/**
|
|
250
|
+
* Server-to-server control calls (create room, end room, attach an agent).
|
|
251
|
+
*
|
|
252
|
+
* A separate audience so a join token can never be replayed as a control call.
|
|
253
|
+
* It carries no room, identity, kind, transport or grants: a control caller is
|
|
254
|
+
* not a participant, and giving it participant-shaped claims invites code that
|
|
255
|
+
* treats it as one.
|
|
256
|
+
*/
|
|
257
|
+
export declare const mediaControlClaimsSchema: z.ZodObject<{
|
|
258
|
+
v: z.ZodLiteral<1>;
|
|
259
|
+
iss: z.ZodString;
|
|
260
|
+
aud: z.ZodLiteral<"control">;
|
|
261
|
+
jti: z.ZodString;
|
|
262
|
+
iat: z.ZodNumber;
|
|
263
|
+
nbf: z.ZodOptional<z.ZodNumber>;
|
|
264
|
+
exp: z.ZodNumber;
|
|
265
|
+
}, "strict", z.ZodTypeAny, {
|
|
266
|
+
v: 1;
|
|
267
|
+
iss: string;
|
|
268
|
+
aud: "control";
|
|
269
|
+
jti: string;
|
|
270
|
+
iat: number;
|
|
271
|
+
exp: number;
|
|
272
|
+
nbf?: number | undefined;
|
|
273
|
+
}, {
|
|
274
|
+
v: 1;
|
|
275
|
+
iss: string;
|
|
276
|
+
aud: "control";
|
|
277
|
+
jti: string;
|
|
278
|
+
iat: number;
|
|
279
|
+
exp: number;
|
|
280
|
+
nbf?: number | undefined;
|
|
281
|
+
}>;
|
|
282
|
+
export type MediaControlClaims = z.infer<typeof mediaControlClaimsSchema>;
|
|
283
|
+
/**
|
|
284
|
+
* Why a token was refused.
|
|
285
|
+
*
|
|
286
|
+
* Deliberately granular for the SERVER's logs and deliberately NOT returned to
|
|
287
|
+
* the client, which gets `unauthorized` and nothing else. Telling a caller
|
|
288
|
+
* whether the signature or the room was wrong is an oracle.
|
|
289
|
+
*/
|
|
290
|
+
export type JoinTokenRejection = "malformed" | "unknown_kid" | "bad_signature" | "expired" | "not_yet_valid" | "ttl_too_long" | "wrong_audience" | "wrong_issuer" | "wrong_room" | "bad_claims";
|
|
291
|
+
export type VerifyResult<T> = {
|
|
292
|
+
ok: true;
|
|
293
|
+
claims: T;
|
|
294
|
+
kid: string;
|
|
295
|
+
} | {
|
|
296
|
+
ok: false;
|
|
297
|
+
re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AAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mediaControlClaimsSchema = exports.mediaJoinClaimsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const grants_1 = require("./grants");
|
|
6
|
+
/**
|
|
7
|
+
* The join token's claims: the whole authorization decision, made once by the
|
|
8
|
+
* backend and carried to a media plane that never asks it anything.
|
|
9
|
+
*
|
|
10
|
+
* Names here were contested by the parallel phase plans; each disagreement is
|
|
11
|
+
* resolved once, in this file, and everything else imports it.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* `iss` IS the instance id (`legal-de`, `main`), not a service name.
|
|
15
|
+
*
|
|
16
|
+
* One plan proposed `iss: "tribenest-backend"` with the instance in a separate
|
|
17
|
+
* `inst` claim. That displaces the one value a verifier actually checks, and a
|
|
18
|
+
* legal-de token would then verify happily on the main instance - which is the
|
|
19
|
+
* whole reason instances are separate.
|
|
20
|
+
*/
|
|
21
|
+
exports.mediaJoinClaimsSchema = zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
v: zod_1.z.literal(1),
|
|
24
|
+
iss: zod_1.z.string().min(1),
|
|
25
|
+
aud: zod_1.z.literal("media"),
|
|
26
|
+
room: zod_1.z.string().min(1).max(200),
|
|
27
|
+
/** `identity`, not `sub`: it is a first-class concept the barrier rules name. */
|
|
28
|
+
identity: zod_1.z.string().min(1).max(200),
|
|
29
|
+
name: zod_1.z.string().max(200).optional(),
|
|
30
|
+
/** Top level, NOT inside grants - it decides what may be minted at all. */
|
|
31
|
+
kind: grants_1.participantKindSchema,
|
|
32
|
+
/** Top level. Transport authority is not media authority. */
|
|
33
|
+
transport: grants_1.transportKindSchema,
|
|
34
|
+
grants: grants_1.mediaGrantsSchema,
|
|
35
|
+
jti: zod_1.z.string().min(8),
|
|
36
|
+
iat: zod_1.z.number().int().positive(),
|
|
37
|
+
nbf: zod_1.z.number().int().positive().optional(),
|
|
38
|
+
exp: zod_1.z.number().int().positive(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
/**
|
|
42
|
+
* Server-to-server control calls (create room, end room, attach an agent).
|
|
43
|
+
*
|
|
44
|
+
* A separate audience so a join token can never be replayed as a control call.
|
|
45
|
+
* It carries no room, identity, kind, transport or grants: a control caller is
|
|
46
|
+
* not a participant, and giving it participant-shaped claims invites code that
|
|
47
|
+
* treats it as one.
|
|
48
|
+
*/
|
|
49
|
+
exports.mediaControlClaimsSchema = zod_1.z
|
|
50
|
+
.object({
|
|
51
|
+
v: zod_1.z.literal(1),
|
|
52
|
+
iss: zod_1.z.string().min(1),
|
|
53
|
+
aud: zod_1.z.literal("control"),
|
|
54
|
+
jti: zod_1.z.string().min(8),
|
|
55
|
+
iat: zod_1.z.number().int().positive(),
|
|
56
|
+
nbf: zod_1.z.number().int().positive().optional(),
|
|
57
|
+
exp: zod_1.z.number().int().positive(),
|
|
58
|
+
})
|
|
59
|
+
.strict();
|
|
60
|
+
//# sourceMappingURL=claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.js","sourceRoot":"","sources":["../src/claims.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,qCAAyF;AAEzF;;;;;;GAMG;AAEH;;;;;;;GAOG;AACU,QAAA,qBAAqB,GAAG,OAAC;KACnC,MAAM,CAAC;IACN,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACf,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,GAAG,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACvB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,iFAAiF;IACjF,QAAQ,EAAE,OAAC,CAAC,MA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ACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Separate from `errors.ts` so that file stays a plain union with no zod
|
|
4
|
+
* import, and so `frames.ts` can validate a code without a circular import
|
|
5
|
+
* through the error class.
|
|
6
|
+
*/
|
|
7
|
+
export declare const mediaErrorCodeSchema: z.ZodEnum<["unauthorized", "replayed", "protocol_version", "forbidden_transport", "forbidden", "not_subscribable", "subscription_limit", "room_closed", "no_such_room", "no_such_producer", "no_such_transport", "duplicate_identity", "node_draining", "capacity", "bad_request", "internal"]>;
|
|
8
|
+
//# sourceMappingURL=errorSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorSchema.d.ts","sourceRoot":"","sources":["../src/errorSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,iSAA4B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mediaErrorCodeSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
/**
|
|
7
|
+
* Separate from `errors.ts` so that file stays a plain union with no zod
|
|
8
|
+
* import, and so `frames.ts` can validate a code without a circular import
|
|
9
|
+
* through the error class.
|
|
10
|
+
*/
|
|
11
|
+
exports.mediaErrorCodeSchema = zod_1.z.enum(errors_1.MEDIA_ERROR_CODES);
|
|
12
|
+
//# sourceMappingURL=errorSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorSchema.js","sourceRoot":"","sources":["../src/errorSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,qCAA6C;AAE7C;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,OAAC,CAAC,IAAI,CAAC,0BAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every way the media plane refuses, named once.
|
|
3
|
+
*
|
|
4
|
+
* A closed union rather than free-text messages, because three surfaces (the
|
|
5
|
+
* SDK, the harness, the egress client) branch on these, and a string compare
|
|
6
|
+
* against prose drifts the moment someone improves the wording.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MEDIA_ERROR_CODES: readonly ["unauthorized", "replayed", "protocol_version", "forbidden_transport", "forbidden", "not_subscribable", "subscription_limit", "room_closed", "no_such_room", "no_such_producer", "no_such_transport", "duplicate_identity", "node_draining", "capacity", "bad_request", "internal"];
|
|
9
|
+
export type MediaErrorCode = (typeof MEDIA_ERROR_CODES)[number];
|
|
10
|
+
export declare class MediaError extends Error {
|
|
11
|
+
readonly code: MediaErrorCode;
|
|
12
|
+
/** Safe to show a user? Most of these are not. */
|
|
13
|
+
readonly retryable: boolean;
|
|
14
|
+
constructor(code: MediaErrorCode, message?: string,
|
|
15
|
+
/** Safe to show a user? Most of these are not. */
|
|
16
|
+
retryable?: boolean);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,+RAsBpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,qBAAa,UAAW,SAAQ,KAAK;aAEjB,IAAI,EAAE,cAAc;IAEpC,kDAAkD;aAClC,SAAS;gBAHT,IAAI,EAAE,cAAc,EACpC,OAAO,CAAC,EAAE,MAAM;IAChB,kDAAkD;IAClC,SAAS,UAAQ;CAKpC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaError = exports.MEDIA_ERROR_CODES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Every way the media plane refuses, named once.
|
|
6
|
+
*
|
|
7
|
+
* A closed union rather than free-text messages, because three surfaces (the
|
|
8
|
+
* SDK, the harness, the egress client) branch on these, and a string compare
|
|
9
|
+
* against prose drifts the moment someone improves the wording.
|
|
10
|
+
*/
|
|
11
|
+
exports.MEDIA_ERROR_CODES = [
|
|
12
|
+
// token / session
|
|
13
|
+
"unauthorized", // token missing, malformed, or rejected
|
|
14
|
+
"replayed", // jti already consumed (a session concern, not a verifier one)
|
|
15
|
+
"protocol_version", // client and node disagree on MEDIA_PROTOCOL_VERSION
|
|
16
|
+
"forbidden_transport", // token's `transport` claim does not permit this transport kind
|
|
17
|
+
// authorization
|
|
18
|
+
"forbidden", // grants do not permit this operation
|
|
19
|
+
"not_subscribable", // maySubscribe said no - an information barrier, not an error
|
|
20
|
+
"subscription_limit", // maxSubscriptions or the active-set ceiling
|
|
21
|
+
// state
|
|
22
|
+
"room_closed",
|
|
23
|
+
"no_such_room",
|
|
24
|
+
"no_such_producer",
|
|
25
|
+
"no_such_transport",
|
|
26
|
+
"duplicate_identity", // that identity is already connected to this room
|
|
27
|
+
// capacity / lifecycle
|
|
28
|
+
"node_draining", // reconnect via the URL; the LB or a redirect will place you
|
|
29
|
+
"capacity",
|
|
30
|
+
// catch-alls
|
|
31
|
+
"bad_request",
|
|
32
|
+
"internal",
|
|
33
|
+
];
|
|
34
|
+
class MediaError extends Error {
|
|
35
|
+
code;
|
|
36
|
+
retryable;
|
|
37
|
+
constructor(code, message,
|
|
38
|
+
/** Safe to show a user? Most of these are not. */
|
|
39
|
+
retryable = false) {
|
|
40
|
+
super(message ?? code);
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.retryable = retryable;
|
|
43
|
+
this.name = "MediaError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MediaError = MediaError;
|
|
47
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,iBAAiB,GAAG;IAC/B,kBAAkB;IAClB,cAAc,EAAW,wCAAwC;IACjE,UAAU,EAAe,+DAA+D;IACxF,kBAAkB,EAAO,qDAAqD;IAC9E,qBAAqB,EAAI,gEAAgE;IACzF,gBAAgB;IAChB,WAAW,EAAc,sCAAsC;IAC/D,kBAAkB,EAAO,8DAA8D;IACvF,oBAAoB,EAAK,6CAA6C;IACtE,QAAQ;IACR,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,mBAAmB;IACnB,oBAAoB,EAAK,kDAAkD;IAC3E,uBAAuB;IACvB,eAAe,EAAU,6DAA6D;IACtF,UAAU;IACV,aAAa;IACb,aAAa;IACb,UAAU;CACF,CAAC;AAIX,MAAa,UAAW,SAAQ,KAAK;IAEjB;IAGA;IAJlB,YACkB,IAAoB,EACpC,OAAgB;IAChB,kDAAkD;IAClC,YAAY,KAAK;QAEjC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QALP,SAAI,GAAJ,IAAI,CAAgB;QAGpB,cAAS,GAAT,SAAS,CAAQ;QAGjC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAVD,gCAUC"}
|