@q9labsai/chalk-client 4.1.17 → 5.0.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/README.md +60 -42
- package/dist/access/grant.d.ts +0 -10
- package/dist/access/grant.d.ts.map +1 -1
- package/dist/access/manager.d.ts.map +1 -1
- package/dist/{chunk-ZRMGKMX4.js → chunk-2HJIJVE2.js} +552 -3651
- package/dist/{chunk-CZUJNAUI.js → chunk-AVXJ4HQU.js} +142 -49
- package/dist/{chunk-A7BVZEFM.js → chunk-CMVO7USN.js} +2 -8
- package/dist/{chunk-AUQTQOLR.js → chunk-IPAN4LUZ.js} +627 -2434
- package/dist/{chunk-2DZUHV6I.js → chunk-O2NOZKJP.js} +129 -721
- package/dist/client.d.ts +2559 -5303
- package/dist/client.d.ts.map +1 -1
- package/dist/collaboration/types.d.ts +21 -1
- package/dist/collaboration/types.d.ts.map +1 -1
- package/dist/collaboration/wire.d.ts +8 -1
- package/dist/collaboration/wire.d.ts.map +1 -1
- package/dist/connection/dependencies.d.ts +7 -13
- package/dist/connection/dependencies.d.ts.map +1 -1
- package/dist/connection/index.d.ts +1 -6
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/lifecycle.d.ts.map +1 -1
- package/dist/connection/media-devices.d.ts +11 -0
- package/dist/connection/media-devices.d.ts.map +1 -1
- package/dist/connection/production.d.ts +1 -1
- package/dist/connection/production.d.ts.map +1 -1
- package/dist/connection/types.d.ts +4 -4
- package/dist/connection/types.d.ts.map +1 -1
- package/dist/effect.d.ts +0 -4
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +53 -776
- package/dist/generated/http-api.d.ts +2603 -5293
- package/dist/generated/http-api.d.ts.map +1 -1
- package/dist/generated/schemas.d.ts +1893 -6870
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/sync.d.ts +191 -28
- package/dist/generated/sync.d.ts.map +1 -1
- package/dist/generated/whiteboard-v1.d.ts +0 -7
- package/dist/generated/whiteboard-v1.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -119
- package/dist/media/client.d.ts +6 -5
- package/dist/media/client.d.ts.map +1 -1
- package/dist/media/index.d.ts +1 -2
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -7
- package/dist/media/plane.d.ts +12 -1
- package/dist/media/plane.d.ts.map +1 -1
- package/dist/media/target.d.ts +4 -2
- package/dist/media/target.d.ts.map +1 -1
- package/dist/media/tracks.d.ts +2 -2
- package/dist/media/tracks.d.ts.map +1 -1
- package/dist/media/transport.d.ts.map +1 -1
- package/dist/media/types.d.ts +4 -11
- package/dist/media/types.d.ts.map +1 -1
- package/dist/public-invites/client.d.ts.map +1 -1
- package/dist/public-invites/index.d.ts +2 -2
- package/dist/public-invites/index.d.ts.map +1 -1
- package/dist/public-invites/index.js +2 -5
- package/dist/public-invites/types.d.ts +2 -6
- package/dist/public-invites/types.d.ts.map +1 -1
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/index.cjs +12 -112
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +9 -109
- package/dist/server/types.d.cts +0 -7
- package/dist/server/types.d.ts +0 -7
- package/dist/server/types.d.ts.map +1 -1
- package/dist/space-client/chat-controller-helpers.d.ts.map +1 -1
- package/dist/space-client/chat-controller.d.ts +2 -3
- package/dist/space-client/chat-controller.d.ts.map +1 -1
- package/dist/space-client/controller-effects.d.ts +0 -3
- package/dist/space-client/controller-effects.d.ts.map +1 -1
- package/dist/space-client/core.d.ts +3 -18
- package/dist/space-client/core.d.ts.map +1 -1
- package/dist/space-client/core.test.helpers.d.ts.map +1 -1
- package/dist/space-client/effect.d.ts +0 -2
- package/dist/space-client/effect.d.ts.map +1 -1
- package/dist/space-client/index.d.ts +1 -2
- package/dist/space-client/index.d.ts.map +1 -1
- package/dist/space-client/media-controller.d.ts +4 -4
- package/dist/space-client/media-controller.d.ts.map +1 -1
- package/dist/space-client/offline-actions-storage.d.ts +18 -3
- package/dist/space-client/offline-actions-storage.d.ts.map +1 -1
- package/dist/space-client/offline-actions.d.ts +1 -0
- package/dist/space-client/offline-actions.d.ts.map +1 -1
- package/dist/space-client/participants-controller.d.ts +2 -3
- package/dist/space-client/participants-controller.d.ts.map +1 -1
- package/dist/space-client/reactions-controller.d.ts +2 -3
- package/dist/space-client/reactions-controller.d.ts.map +1 -1
- package/dist/space-client/recording-controller.d.ts +2 -3
- package/dist/space-client/recording-controller.d.ts.map +1 -1
- package/dist/space-client/space-client.d.ts.map +1 -1
- package/dist/space-client/store.d.ts.map +1 -1
- package/dist/space-client/terminal.test.helpers.d.ts +33 -12
- package/dist/space-client/terminal.test.helpers.d.ts.map +1 -1
- package/dist/space-client/types.d.ts +15 -8
- package/dist/space-client/types.d.ts.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -3
- package/dist/sync/v1-client.d.ts +4 -3
- package/dist/sync/v1-client.d.ts.map +1 -1
- package/dist/sync/v1-collaboration-state.d.ts +10 -3
- package/dist/sync/v1-collaboration-state.d.ts.map +1 -1
- package/dist/sync/v1-types.d.ts +10 -9
- package/dist/sync/v1-types.d.ts.map +1 -1
- package/dist/whiteboard/file-download-transport.d.ts +8 -0
- package/dist/whiteboard/file-download-transport.d.ts.map +1 -0
- package/dist/whiteboard/index.d.ts +1 -1
- package/dist/whiteboard/index.d.ts.map +1 -1
- package/dist/whiteboard/types.d.ts +12 -15
- package/dist/whiteboard/types.d.ts.map +1 -1
- package/dist/whiteboard/v1-client.d.ts.map +1 -1
- package/package.json +4 -16
- package/dist/access/episode-diagnostic-credential.d.ts +0 -11
- package/dist/access/episode-diagnostic-credential.d.ts.map +0 -1
- package/dist/chunk-EWTITNJ3.js +0 -1163
- package/dist/chunk-HW5TTZL2.js +0 -99
- package/dist/chunk-PBSYXPNJ.js +0 -23
- package/dist/chunk-RCDXIDCN.js +0 -33
- package/dist/connection/snapshot.d.ts +0 -23
- package/dist/connection/snapshot.d.ts.map +0 -1
- package/dist/feedback/collector.d.ts +0 -14
- package/dist/feedback/collector.d.ts.map +0 -1
- package/dist/feedback/context.d.ts +0 -38
- package/dist/feedback/context.d.ts.map +0 -1
- package/dist/feedback/controller.d.ts +0 -4
- package/dist/feedback/controller.d.ts.map +0 -1
- package/dist/feedback/index.d.ts +0 -7
- package/dist/feedback/index.d.ts.map +0 -1
- package/dist/feedback/transport.d.ts +0 -29
- package/dist/feedback/transport.d.ts.map +0 -1
- package/dist/feedback/types.d.ts +0 -202
- package/dist/feedback/types.d.ts.map +0 -1
- package/dist/feedback/validation.d.ts +0 -30
- package/dist/feedback/validation.d.ts.map +0 -1
- package/dist/media/rtk.d.ts +0 -101
- package/dist/media/rtk.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-registry.d.ts +0 -13
- package/dist/space-client/episode-diagnostic-registry.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-render-registry.d.ts +0 -4
- package/dist/space-client/episode-diagnostic-render-registry.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-runtime.d.ts +0 -105
- package/dist/space-client/episode-diagnostic-runtime.d.ts.map +0 -1
- package/dist/telemetry/attributes.d.ts +0 -7
- package/dist/telemetry/attributes.d.ts.map +0 -1
- package/dist/telemetry/client.d.ts +0 -44
- package/dist/telemetry/client.d.ts.map +0 -1
- package/dist/telemetry/delivery.d.ts +0 -107
- package/dist/telemetry/delivery.d.ts.map +0 -1
- package/dist/telemetry/exporter.d.ts +0 -38
- package/dist/telemetry/exporter.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts +0 -7
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -50
- package/dist/telemetry/journey.d.ts +0 -52
- package/dist/telemetry/journey.d.ts.map +0 -1
- package/dist/telemetry/random.d.ts +0 -18
- package/dist/telemetry/random.d.ts.map +0 -1
- package/dist/telemetry/reconnect.d.ts +0 -7
- package/dist/telemetry/reconnect.d.ts.map +0 -1
- package/dist/telemetry/rtc.d.ts +0 -41
- package/dist/telemetry/rtc.d.ts.map +0 -1
- package/dist/telemetry/storage.d.ts +0 -22
- package/dist/telemetry/storage.d.ts.map +0 -1
- package/dist/telemetry/sync.d.ts +0 -10
- package/dist/telemetry/sync.d.ts.map +0 -1
- package/dist/telemetry/test-support.d.ts +0 -51
- package/dist/telemetry/test-support.d.ts.map +0 -1
- package/dist/telemetry/trace.d.ts +0 -18
- package/dist/telemetry/trace.d.ts.map +0 -1
- package/dist/telemetry/types.d.ts +0 -109
- package/dist/telemetry/types.d.ts.map +0 -1
- package/dist/whiteboard/file-http-transport.d.ts +0 -9
- package/dist/whiteboard/file-http-transport.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/public-invites/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/public-invites/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAkC,iBAAiB,EAAE,wBAAwB,EAA6L,MAAM,YAAY,CAAC;AACzS,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAoF5F;AACD,eAAO,MAAM,6BAA6B,gCAA0B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createChalkPublicClient, createChalkPublicInviteClient } from "./client.js";
|
|
2
|
-
export type { ArriveBySpacePublicInviteInput, ChalkPublicClient, ChalkPublicClientOptions, ChalkPublicClientRuntime, ChalkPublicIdempotencyOptions, ChalkPublicInviteError, CreatePublicSpace, CreatePublicSpaceInput, ArriveBySpacePublicInvite, GetSpacePublicInviteArrival, LeaveSpacePublicInviteArrival, PublicArrivalOptions, PublicArrivalReference, PublicRefreshAccessInput, PublicLeaveOptions, PublicSpaceArrival, PublicSpaceArrivalAccess, PublicSpaceCreated,
|
|
2
|
+
export type { ArriveBySpacePublicInviteInput, ChalkPublicClient, ChalkPublicClientOptions, ChalkPublicClientRuntime, ChalkPublicIdempotencyOptions, ChalkPublicInviteError, CreatePublicSpace, CreatePublicSpaceInput, ArriveBySpacePublicInvite, GetSpacePublicInviteArrival, LeaveSpacePublicInviteArrival, PublicArrivalOptions, PublicArrivalReference, PublicRefreshAccessInput, PublicLeaveOptions, PublicSpaceArrival, PublicSpaceArrivalAccess, PublicSpaceCreated, RefreshSpacePublicInviteAccess, } from "./types.js";
|
|
3
3
|
export { ArrivalInvalidHandleError, ArrivalUnavailableError, SpacePublicInviteUnavailableError } from "../generated/schemas.js";
|
|
4
|
-
export type { ApproveSpacePublicAdmissionRequestError, ArriveBySpacePublicInviteError, CreatePublicSpaceError, DenySpacePublicAdmissionRequestError,
|
|
4
|
+
export type { ApproveSpacePublicAdmissionRequestError, ArriveBySpacePublicInviteError, CreatePublicSpaceError, DenySpacePublicAdmissionRequestError, GetSpacePublicInviteArrivalError, LeaveSpacePublicInviteArrivalError, RefreshSpacePublicInviteAccessError } from "../generated/schemas.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/public-invites/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACrF,YAAY,EACV,8BAA8B,EAC9B,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,EAC7B,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/public-invites/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACrF,YAAY,EACV,8BAA8B,EAC9B,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,EAC7B,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAChI,YAAY,EAAE,uCAAuC,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createChalkPublicClient,
|
|
3
3
|
createChalkPublicInviteClient
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-CMVO7USN.js";
|
|
5
5
|
import {
|
|
6
6
|
ArrivalInvalidHandleError,
|
|
7
7
|
ArrivalUnavailableError,
|
|
8
8
|
SpacePublicInviteUnavailableError
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-EWTITNJ3.js";
|
|
11
|
-
import "../chunk-HW5TTZL2.js";
|
|
12
|
-
import "../chunk-PBSYXPNJ.js";
|
|
9
|
+
} from "../chunk-2HJIJVE2.js";
|
|
13
10
|
export {
|
|
14
11
|
ArrivalInvalidHandleError,
|
|
15
12
|
ArrivalUnavailableError,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AccessGrant } from "../access/grant.js";
|
|
2
|
-
import type {
|
|
3
|
-
import type { ApproveSpacePublicAdmissionRequestError, ArriveBySpacePublicInviteError, ArrivalInvalidHandleError, ArrivalUnavailableError, CreatePublicSpaceError, DenySpacePublicAdmissionRequestError, GetPublicStatusError, GetPublicStatusResponse, GetSpacePublicInviteArrivalError, LeaveSpacePublicInviteArrivalError, PublicSpaceArrival as GeneratedPublicSpaceArrival, PublicSpaceCreated as GeneratedPublicSpaceCreated, PreparePublicSpaceEntranceError, RefreshSpacePublicInviteAccessError, SpacePublicInviteUnavailableError } from "../generated/schemas.js";
|
|
2
|
+
import type { ApproveSpacePublicAdmissionRequestError, ArriveBySpacePublicInviteError, ArrivalInvalidHandleError, ArrivalUnavailableError, CreatePublicSpaceError, DenySpacePublicAdmissionRequestError, GetSpacePublicInviteArrivalError, LeaveSpacePublicInviteArrivalError, PublicSpaceArrival as GeneratedPublicSpaceArrival, PublicSpaceCreated as GeneratedPublicSpaceCreated, PreparePublicSpaceEntranceError, RefreshSpacePublicInviteAccessError, SpacePublicInviteUnavailableError } from "../generated/schemas.js";
|
|
4
3
|
export type ChalkPublicClientRuntime = "browser" | "react-native";
|
|
5
4
|
export type ChalkPublicClientOptions = {
|
|
6
5
|
readonly baseUrl: string | URL;
|
|
@@ -9,7 +8,6 @@ export type ChalkPublicClientOptions = {
|
|
|
9
8
|
readonly headers?: Readonly<Record<string, string>>;
|
|
10
9
|
readonly guestCredential?: string;
|
|
11
10
|
readonly runtime?: ChalkPublicClientRuntime;
|
|
12
|
-
readonly telemetry?: JourneyTelemetryContext;
|
|
13
11
|
};
|
|
14
12
|
export type ChalkPublicIdempotencyOptions = {
|
|
15
13
|
readonly idempotencyKey?: string;
|
|
@@ -45,7 +43,6 @@ export type PublicSpaceArrival = Omit<GeneratedPublicSpaceArrival, "access"> & {
|
|
|
45
43
|
export type PublicSpaceCreated = Omit<GeneratedPublicSpaceCreated, "arrival"> & {
|
|
46
44
|
readonly arrival: PublicSpaceArrival;
|
|
47
45
|
};
|
|
48
|
-
export type PublicStatus = GetPublicStatusResponse;
|
|
49
46
|
export type CreatePublicSpace = (input: CreatePublicSpaceInput, options?: ChalkPublicIdempotencyOptions) => Promise<PublicSpaceCreated>;
|
|
50
47
|
export type ArriveBySpacePublicInvite = (input: ArriveBySpacePublicInviteInput, options?: PublicArrivalOptions) => Promise<PublicSpaceArrival>;
|
|
51
48
|
export type GetSpacePublicInviteArrival = (reference: PublicArrivalReference | string) => Promise<PublicSpaceArrival>;
|
|
@@ -57,7 +54,6 @@ export type ChalkPublicClient = {
|
|
|
57
54
|
readonly arriveBySpacePublicInvite: ArriveBySpacePublicInvite;
|
|
58
55
|
readonly create: CreatePublicSpace;
|
|
59
56
|
readonly createPublicSpace: CreatePublicSpace;
|
|
60
|
-
readonly getPublicStatus: () => Promise<PublicStatus>;
|
|
61
57
|
readonly getSpacePublicInviteArrival: GetSpacePublicInviteArrival;
|
|
62
58
|
readonly leave: LeaveSpacePublicInviteArrival;
|
|
63
59
|
readonly leaveSpacePublicInviteArrival: LeaveSpacePublicInviteArrival;
|
|
@@ -65,6 +61,6 @@ export type ChalkPublicClient = {
|
|
|
65
61
|
readonly refreshSpacePublicInviteAccess: RefreshSpacePublicInviteAccess;
|
|
66
62
|
readonly status: GetSpacePublicInviteArrival;
|
|
67
63
|
};
|
|
68
|
-
export type ChalkPublicInviteError = PreparePublicSpaceEntranceError | ApproveSpacePublicAdmissionRequestError | ArriveBySpacePublicInviteError | DenySpacePublicAdmissionRequestError | CreatePublicSpaceError |
|
|
64
|
+
export type ChalkPublicInviteError = PreparePublicSpaceEntranceError | ApproveSpacePublicAdmissionRequestError | ArriveBySpacePublicInviteError | DenySpacePublicAdmissionRequestError | CreatePublicSpaceError | GetSpacePublicInviteArrivalError | LeaveSpacePublicInviteArrivalError | RefreshSpacePublicInviteAccessError | ArrivalInvalidHandleError | ArrivalUnavailableError | SpacePublicInviteUnavailableError;
|
|
69
65
|
export type PublicSpaceArrivalAccess = PublicSpaceArrival["access"];
|
|
70
66
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/public-invites/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/public-invites/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAKV,iBAAiB,EACjB,wBAAwB,EAyBzB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAKV,iBAAiB,EACjB,wBAAwB,EAyBzB,MAAM,YAAY,CAAC;AACpB,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAkO5F"}
|
package/dist/server/index.cjs
CHANGED
|
@@ -34,71 +34,6 @@ function decodeBase64Url(value) {
|
|
|
34
34
|
return new TextDecoder().decode(bytes);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// src/access/episode-diagnostic-credential.ts
|
|
38
|
-
var INTAKE_PATH = "/_internal/episode-diagnostic-events";
|
|
39
|
-
var RFC3339_ZONED = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
40
|
-
function parseEpisodeDiagnosticCredential(value) {
|
|
41
|
-
if (!isRecord(value)) return null;
|
|
42
|
-
const token = value.token;
|
|
43
|
-
const expiresAt = value.expires_at;
|
|
44
|
-
const generation = value.generation;
|
|
45
|
-
const intakePath = value.intake_path;
|
|
46
|
-
if (typeof token !== "string" || !validDiagnosticCredential(token)) return null;
|
|
47
|
-
if (!isRFC3339Zoned(expiresAt)) return null;
|
|
48
|
-
if (!Number.isSafeInteger(generation) || generation < 1) return null;
|
|
49
|
-
if (intakePath !== INTAKE_PATH) return null;
|
|
50
|
-
return Object.freeze({ token, expiresAt, generation, intakePath });
|
|
51
|
-
}
|
|
52
|
-
function validDiagnosticCredential(token) {
|
|
53
|
-
const segments = token.split(".");
|
|
54
|
-
if (segments.length !== 3) return false;
|
|
55
|
-
try {
|
|
56
|
-
const payload = JSON.parse(decodeBase64Url(segments[1] ?? ""));
|
|
57
|
-
return isRecord(payload) && payload.aud === "chalk-diagnostics";
|
|
58
|
-
} catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function isRFC3339Zoned(value) {
|
|
63
|
-
if (typeof value !== "string") return false;
|
|
64
|
-
const match = RFC3339_ZONED.exec(value);
|
|
65
|
-
if (!match) return false;
|
|
66
|
-
return validTimestampFields(match) && Number.isFinite(Date.parse(value));
|
|
67
|
-
}
|
|
68
|
-
function validTimestampFields(match) {
|
|
69
|
-
const year = Number(match[1]);
|
|
70
|
-
const month = Number(match[2]);
|
|
71
|
-
const day = Number(match[3]);
|
|
72
|
-
const hour = Number(match[4]);
|
|
73
|
-
const minute = Number(match[5]);
|
|
74
|
-
const second = Number(match[6]);
|
|
75
|
-
const zone = match[7] ?? "";
|
|
76
|
-
return validCalendarDate(year, month, day) && validClockTime(hour, minute, second) && validZoneOffset(zone);
|
|
77
|
-
}
|
|
78
|
-
function inRange(value, min, max) {
|
|
79
|
-
return value >= min && value <= max;
|
|
80
|
-
}
|
|
81
|
-
function validCalendarDate(year, month, day) {
|
|
82
|
-
return inRange(month, 1, 12) && inRange(day, 1, daysInMonth(year, month));
|
|
83
|
-
}
|
|
84
|
-
function validClockTime(hour, minute, second) {
|
|
85
|
-
return inRange(hour, 0, 23) && inRange(minute, 0, 59) && inRange(second, 0, 59);
|
|
86
|
-
}
|
|
87
|
-
function validZoneOffset(zone) {
|
|
88
|
-
if (zone === "Z") return true;
|
|
89
|
-
return inRange(Number(zone.slice(1, 3)), 0, 23) && inRange(Number(zone.slice(4, 6)), 0, 59);
|
|
90
|
-
}
|
|
91
|
-
function daysInMonth(year, month) {
|
|
92
|
-
if (month === 2) return isLeapYear(year) ? 29 : 28;
|
|
93
|
-
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
94
|
-
}
|
|
95
|
-
function isLeapYear(year) {
|
|
96
|
-
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
97
|
-
}
|
|
98
|
-
function isRecord(value) {
|
|
99
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
37
|
// src/access/grant.ts
|
|
103
38
|
var accessGrantBrand = /* @__PURE__ */ Symbol("AccessGrant");
|
|
104
39
|
var AccessGrantError = class extends TypeError {
|
|
@@ -109,16 +44,14 @@ var AccessGrantError = class extends TypeError {
|
|
|
109
44
|
}
|
|
110
45
|
};
|
|
111
46
|
function parseParsedAccessGrant(value) {
|
|
112
|
-
if (!
|
|
47
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
113
48
|
const subject = parseSubject(value.subject);
|
|
114
49
|
const episodeStartedAt = parseOptionalDateTime(value.episode_started_at);
|
|
115
|
-
const diagnostics = parseEpisodeDiagnosticCredential(value.diagnostics);
|
|
116
50
|
return {
|
|
117
51
|
subject,
|
|
118
52
|
episodeStartedAt,
|
|
119
53
|
sync: parseSyncAccess(value.sync),
|
|
120
|
-
media: parseMediaAccess(value.media)
|
|
121
|
-
diagnostics: diagnostics?.generation === subject.participantGeneration ? diagnostics : null
|
|
54
|
+
media: parseMediaAccess(value.media)
|
|
122
55
|
};
|
|
123
56
|
}
|
|
124
57
|
function parseAccessGrant(value) {
|
|
@@ -141,19 +74,11 @@ function accessGrantFromParsed(value) {
|
|
|
141
74
|
provider: value.media.provider,
|
|
142
75
|
client_payload: mediaClientPayload(value.media)
|
|
143
76
|
},
|
|
144
|
-
...value.diagnostics ? {
|
|
145
|
-
diagnostics: {
|
|
146
|
-
token: value.diagnostics.token,
|
|
147
|
-
expires_at: value.diagnostics.expiresAt,
|
|
148
|
-
generation: value.diagnostics.generation,
|
|
149
|
-
intake_path: value.diagnostics.intakePath
|
|
150
|
-
}
|
|
151
|
-
} : {},
|
|
152
77
|
[accessGrantBrand]: "AccessGrant"
|
|
153
78
|
});
|
|
154
79
|
}
|
|
155
80
|
function parseSubject(value) {
|
|
156
|
-
if (!
|
|
81
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
157
82
|
return {
|
|
158
83
|
tenantId: requireNonEmptyString(value.tenant_id),
|
|
159
84
|
spaceId: requireNonEmptyString(value.space_id),
|
|
@@ -167,16 +92,16 @@ function requirePositiveInteger(value) {
|
|
|
167
92
|
return value;
|
|
168
93
|
}
|
|
169
94
|
function parseSyncAccess(value) {
|
|
170
|
-
if (!
|
|
95
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
171
96
|
return {
|
|
172
97
|
token: requireCredential(value.token, "chalk-sync"),
|
|
173
98
|
expiresAt: requireDateTime(value.expires_at ?? value.expiresAt)
|
|
174
99
|
};
|
|
175
100
|
}
|
|
176
101
|
function parseMediaAccess(value) {
|
|
177
|
-
if (!
|
|
102
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
178
103
|
const payload = value.client_payload ?? value.clientPayload;
|
|
179
|
-
if (!
|
|
104
|
+
if (!isRecord(payload)) throw new AccessGrantError();
|
|
180
105
|
const token = requireCredential(value.token, "chalk-media");
|
|
181
106
|
const expiresAt = requireDateTime(value.expires_at ?? value.expiresAt);
|
|
182
107
|
switch (value.provider) {
|
|
@@ -190,16 +115,6 @@ function parseMediaAccess(value) {
|
|
|
190
115
|
stunServer: requireNonEmptyString(payload.stunServer)
|
|
191
116
|
}
|
|
192
117
|
};
|
|
193
|
-
case "cloudflare_rtk":
|
|
194
|
-
return {
|
|
195
|
-
token,
|
|
196
|
-
expiresAt,
|
|
197
|
-
provider: value.provider,
|
|
198
|
-
clientPayload: {
|
|
199
|
-
providerSubject: requireNonEmptyString(payload.provider_subject ?? payload.providerSubject),
|
|
200
|
-
token: requireNonEmptyString(payload.token)
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
118
|
default:
|
|
204
119
|
throw new AccessGrantError();
|
|
205
120
|
}
|
|
@@ -208,8 +123,6 @@ function mediaClientPayload(value) {
|
|
|
208
123
|
switch (value.provider) {
|
|
209
124
|
case "cloudflare_sfu":
|
|
210
125
|
return { connectionId: value.clientPayload.connectionId, stunServer: value.clientPayload.stunServer };
|
|
211
|
-
case "cloudflare_rtk":
|
|
212
|
-
return { provider_subject: value.clientPayload.providerSubject, token: value.clientPayload.token };
|
|
213
126
|
}
|
|
214
127
|
}
|
|
215
128
|
function requireCredential(value, audience) {
|
|
@@ -222,7 +135,7 @@ function requireCredential(value, audience) {
|
|
|
222
135
|
} catch {
|
|
223
136
|
throw new AccessGrantError();
|
|
224
137
|
}
|
|
225
|
-
if (!
|
|
138
|
+
if (!isRecord(payload) || payload.aud !== audience) throw new AccessGrantError();
|
|
226
139
|
return token;
|
|
227
140
|
}
|
|
228
141
|
function requireDateTime(value) {
|
|
@@ -238,7 +151,7 @@ function requireNonEmptyString(value) {
|
|
|
238
151
|
if (typeof value !== "string" || value.trim().length === 0) throw new AccessGrantError();
|
|
239
152
|
return value;
|
|
240
153
|
}
|
|
241
|
-
function
|
|
154
|
+
function isRecord(value) {
|
|
242
155
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
243
156
|
}
|
|
244
157
|
|
|
@@ -285,8 +198,8 @@ function requestId(headers) {
|
|
|
285
198
|
return safeRequestId(headers.get("x-request-id") ?? headers.get("x-chalk-request-id"));
|
|
286
199
|
}
|
|
287
200
|
function errorCodeValue(value) {
|
|
288
|
-
if (!
|
|
289
|
-
if (!
|
|
201
|
+
if (!isRecord2(value)) return void 0;
|
|
202
|
+
if (!isRecord2(value.error)) return void 0;
|
|
290
203
|
return value.error.code;
|
|
291
204
|
}
|
|
292
205
|
function safeErrorCode(value) {
|
|
@@ -304,7 +217,7 @@ function messageFor(code, status) {
|
|
|
304
217
|
if (code === "invalid_response") return "The Chalk API returned an invalid response.";
|
|
305
218
|
return status > 0 ? `The Chalk API request failed with HTTP ${status}.` : "The Chalk API request failed.";
|
|
306
219
|
}
|
|
307
|
-
function
|
|
220
|
+
function isRecord2(value) {
|
|
308
221
|
if (typeof value !== "object") return false;
|
|
309
222
|
if (value === null) return false;
|
|
310
223
|
return !Array.isArray(value);
|
|
@@ -380,7 +293,6 @@ function serializedBody(body) {
|
|
|
380
293
|
function requestHeaders(options, apiKey, hasBody, idempotencyKeyValue) {
|
|
381
294
|
const headers = new Headers(options.headers);
|
|
382
295
|
setContentType(headers, hasBody);
|
|
383
|
-
setTelemetryHeaders(headers, options);
|
|
384
296
|
setOptionalHeader(headers, "idempotency-key", idempotencyKeyValue);
|
|
385
297
|
headers.set("authorization", `Bearer ${apiKey}`);
|
|
386
298
|
return headers;
|
|
@@ -388,12 +300,6 @@ function requestHeaders(options, apiKey, hasBody, idempotencyKeyValue) {
|
|
|
388
300
|
function setContentType(headers, hasBody) {
|
|
389
301
|
if (hasBody) headers.set("content-type", "application/json");
|
|
390
302
|
}
|
|
391
|
-
function setTelemetryHeaders(headers, options) {
|
|
392
|
-
if (!options.telemetry) return;
|
|
393
|
-
headers.set("x-chalk-journey-id", options.telemetry.journeyId);
|
|
394
|
-
headers.set("traceparent", options.telemetry.traceparent);
|
|
395
|
-
setOptionalHeader(headers, "tracestate", options.telemetry.tracestate);
|
|
396
|
-
}
|
|
397
303
|
function setOptionalHeader(headers, name, value) {
|
|
398
304
|
if (value !== void 0) headers.set(name, value);
|
|
399
305
|
}
|
|
@@ -754,8 +660,7 @@ function accessGrant(value) {
|
|
|
754
660
|
expires_at: value.media.expires_at,
|
|
755
661
|
provider: value.media.provider,
|
|
756
662
|
client_payload: payload
|
|
757
|
-
}
|
|
758
|
-
diagnostics: value.diagnostics
|
|
663
|
+
}
|
|
759
664
|
});
|
|
760
665
|
}
|
|
761
666
|
function mediaClientPayload2(media) {
|
|
@@ -765,11 +670,6 @@ function mediaClientPayload2(media) {
|
|
|
765
670
|
if (typeof connectionId !== "string" || typeof stunServer !== "string") throw invalidResponse(201);
|
|
766
671
|
return { connectionId, stunServer };
|
|
767
672
|
}
|
|
768
|
-
case "cloudflare_rtk": {
|
|
769
|
-
const { provider_subject, token } = media.client_payload;
|
|
770
|
-
if (typeof provider_subject !== "string" || typeof token !== "string") throw invalidResponse(201);
|
|
771
|
-
return { provider_subject, token };
|
|
772
|
-
}
|
|
773
673
|
default:
|
|
774
674
|
throw invalidResponse(201);
|
|
775
675
|
}
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { getAccessRefreshState, type AccessRefreshRequest, type AccessRefreshState } from "./access-refresh.cjs";
|
|
2
2
|
export { createChalkServerClient } from "./client.cjs";
|
|
3
3
|
export { ChalkAPIError, ChalkServerOnlyError } from "./errors.cjs";
|
|
4
|
-
export type { APIKey, APIKeyList, APIKeyWithSecret, AdmitParticipantInput, ChalkIdempotencyOptions, ChalkServerClient, ChalkServerClientOptions, ChalkServerHeaders,
|
|
4
|
+
export type { APIKey, APIKeyList, APIKeyWithSecret, AdmitParticipantInput, ChalkIdempotencyOptions, ChalkServerClient, ChalkServerClientOptions, ChalkServerHeaders, CreateAPIKeyInput, CreateEpisodeInput, CreateRecordingDownloadURLInput, CreateSpaceInput, Episode, EpisodeEnd, IssueAccessGrantInput, ListPublicAdmissionRequestsInput, ListRecordingsInput, ListAPIKeysInput, ListSpacesInput, AccessGrant, ParticipantLifecycle, ParticipantRemoval, PublicAdmissionRequest, PublicAdmissionRequestPage, Recording, RecordingDownloadURL, RecordingExport, RecordingExportRequestAcceptedResponse, RecordingExportStatus, RecordingList, RecordingSource, RecordingSourceStatus, RecordingPolicy, RemoveParticipantInput, RotateAPIKeyInput, Space, SpacePublicInvite, SpaceList, TranscriptionPolicy, UpdateSpaceInput, UpdateSpacePublicInviteInput, } from "./types.cjs";
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getAccessRefreshState, type AccessRefreshRequest, type AccessRefreshState } from "./access-refresh.js";
|
|
2
2
|
export { createChalkServerClient } from "./client.js";
|
|
3
3
|
export { ChalkAPIError, ChalkServerOnlyError } from "./errors.js";
|
|
4
|
-
export type { APIKey, APIKeyList, APIKeyWithSecret, AdmitParticipantInput, ChalkIdempotencyOptions, ChalkServerClient, ChalkServerClientOptions, ChalkServerHeaders,
|
|
4
|
+
export type { APIKey, APIKeyList, APIKeyWithSecret, AdmitParticipantInput, ChalkIdempotencyOptions, ChalkServerClient, ChalkServerClientOptions, ChalkServerHeaders, CreateAPIKeyInput, CreateEpisodeInput, CreateRecordingDownloadURLInput, CreateSpaceInput, Episode, EpisodeEnd, IssueAccessGrantInput, ListPublicAdmissionRequestsInput, ListRecordingsInput, ListAPIKeysInput, ListSpacesInput, AccessGrant, ParticipantLifecycle, ParticipantRemoval, PublicAdmissionRequest, PublicAdmissionRequestPage, Recording, RecordingDownloadURL, RecordingExport, RecordingExportRequestAcceptedResponse, RecordingExportStatus, RecordingList, RecordingSource, RecordingSourceStatus, RecordingPolicy, RemoveParticipantInput, RotateAPIKeyInput, Space, SpacePublicInvite, SpaceList, TranscriptionPolicy, UpdateSpaceInput, UpdateSpacePublicInviteInput, } from "./types.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EACV,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EACV,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,gCAAgC,EAChC,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,sCAAsC,EACtC,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,YAAY,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -12,71 +12,6 @@ function decodeBase64Url(value) {
|
|
|
12
12
|
return new TextDecoder().decode(bytes);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// src/access/episode-diagnostic-credential.ts
|
|
16
|
-
var INTAKE_PATH = "/_internal/episode-diagnostic-events";
|
|
17
|
-
var RFC3339_ZONED = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
18
|
-
function parseEpisodeDiagnosticCredential(value) {
|
|
19
|
-
if (!isRecord(value)) return null;
|
|
20
|
-
const token = value.token;
|
|
21
|
-
const expiresAt = value.expires_at;
|
|
22
|
-
const generation = value.generation;
|
|
23
|
-
const intakePath = value.intake_path;
|
|
24
|
-
if (typeof token !== "string" || !validDiagnosticCredential(token)) return null;
|
|
25
|
-
if (!isRFC3339Zoned(expiresAt)) return null;
|
|
26
|
-
if (!Number.isSafeInteger(generation) || generation < 1) return null;
|
|
27
|
-
if (intakePath !== INTAKE_PATH) return null;
|
|
28
|
-
return Object.freeze({ token, expiresAt, generation, intakePath });
|
|
29
|
-
}
|
|
30
|
-
function validDiagnosticCredential(token) {
|
|
31
|
-
const segments = token.split(".");
|
|
32
|
-
if (segments.length !== 3) return false;
|
|
33
|
-
try {
|
|
34
|
-
const payload = JSON.parse(decodeBase64Url(segments[1] ?? ""));
|
|
35
|
-
return isRecord(payload) && payload.aud === "chalk-diagnostics";
|
|
36
|
-
} catch {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function isRFC3339Zoned(value) {
|
|
41
|
-
if (typeof value !== "string") return false;
|
|
42
|
-
const match = RFC3339_ZONED.exec(value);
|
|
43
|
-
if (!match) return false;
|
|
44
|
-
return validTimestampFields(match) && Number.isFinite(Date.parse(value));
|
|
45
|
-
}
|
|
46
|
-
function validTimestampFields(match) {
|
|
47
|
-
const year = Number(match[1]);
|
|
48
|
-
const month = Number(match[2]);
|
|
49
|
-
const day = Number(match[3]);
|
|
50
|
-
const hour = Number(match[4]);
|
|
51
|
-
const minute = Number(match[5]);
|
|
52
|
-
const second = Number(match[6]);
|
|
53
|
-
const zone = match[7] ?? "";
|
|
54
|
-
return validCalendarDate(year, month, day) && validClockTime(hour, minute, second) && validZoneOffset(zone);
|
|
55
|
-
}
|
|
56
|
-
function inRange(value, min, max) {
|
|
57
|
-
return value >= min && value <= max;
|
|
58
|
-
}
|
|
59
|
-
function validCalendarDate(year, month, day) {
|
|
60
|
-
return inRange(month, 1, 12) && inRange(day, 1, daysInMonth(year, month));
|
|
61
|
-
}
|
|
62
|
-
function validClockTime(hour, minute, second) {
|
|
63
|
-
return inRange(hour, 0, 23) && inRange(minute, 0, 59) && inRange(second, 0, 59);
|
|
64
|
-
}
|
|
65
|
-
function validZoneOffset(zone) {
|
|
66
|
-
if (zone === "Z") return true;
|
|
67
|
-
return inRange(Number(zone.slice(1, 3)), 0, 23) && inRange(Number(zone.slice(4, 6)), 0, 59);
|
|
68
|
-
}
|
|
69
|
-
function daysInMonth(year, month) {
|
|
70
|
-
if (month === 2) return isLeapYear(year) ? 29 : 28;
|
|
71
|
-
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
72
|
-
}
|
|
73
|
-
function isLeapYear(year) {
|
|
74
|
-
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
75
|
-
}
|
|
76
|
-
function isRecord(value) {
|
|
77
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
15
|
// src/access/grant.ts
|
|
81
16
|
var accessGrantBrand = /* @__PURE__ */ Symbol("AccessGrant");
|
|
82
17
|
var AccessGrantError = class extends TypeError {
|
|
@@ -87,16 +22,14 @@ var AccessGrantError = class extends TypeError {
|
|
|
87
22
|
}
|
|
88
23
|
};
|
|
89
24
|
function parseParsedAccessGrant(value) {
|
|
90
|
-
if (!
|
|
25
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
91
26
|
const subject = parseSubject(value.subject);
|
|
92
27
|
const episodeStartedAt = parseOptionalDateTime(value.episode_started_at);
|
|
93
|
-
const diagnostics = parseEpisodeDiagnosticCredential(value.diagnostics);
|
|
94
28
|
return {
|
|
95
29
|
subject,
|
|
96
30
|
episodeStartedAt,
|
|
97
31
|
sync: parseSyncAccess(value.sync),
|
|
98
|
-
media: parseMediaAccess(value.media)
|
|
99
|
-
diagnostics: diagnostics?.generation === subject.participantGeneration ? diagnostics : null
|
|
32
|
+
media: parseMediaAccess(value.media)
|
|
100
33
|
};
|
|
101
34
|
}
|
|
102
35
|
function parseAccessGrant(value) {
|
|
@@ -119,19 +52,11 @@ function accessGrantFromParsed(value) {
|
|
|
119
52
|
provider: value.media.provider,
|
|
120
53
|
client_payload: mediaClientPayload(value.media)
|
|
121
54
|
},
|
|
122
|
-
...value.diagnostics ? {
|
|
123
|
-
diagnostics: {
|
|
124
|
-
token: value.diagnostics.token,
|
|
125
|
-
expires_at: value.diagnostics.expiresAt,
|
|
126
|
-
generation: value.diagnostics.generation,
|
|
127
|
-
intake_path: value.diagnostics.intakePath
|
|
128
|
-
}
|
|
129
|
-
} : {},
|
|
130
55
|
[accessGrantBrand]: "AccessGrant"
|
|
131
56
|
});
|
|
132
57
|
}
|
|
133
58
|
function parseSubject(value) {
|
|
134
|
-
if (!
|
|
59
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
135
60
|
return {
|
|
136
61
|
tenantId: requireNonEmptyString(value.tenant_id),
|
|
137
62
|
spaceId: requireNonEmptyString(value.space_id),
|
|
@@ -145,16 +70,16 @@ function requirePositiveInteger(value) {
|
|
|
145
70
|
return value;
|
|
146
71
|
}
|
|
147
72
|
function parseSyncAccess(value) {
|
|
148
|
-
if (!
|
|
73
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
149
74
|
return {
|
|
150
75
|
token: requireCredential(value.token, "chalk-sync"),
|
|
151
76
|
expiresAt: requireDateTime(value.expires_at ?? value.expiresAt)
|
|
152
77
|
};
|
|
153
78
|
}
|
|
154
79
|
function parseMediaAccess(value) {
|
|
155
|
-
if (!
|
|
80
|
+
if (!isRecord(value)) throw new AccessGrantError();
|
|
156
81
|
const payload = value.client_payload ?? value.clientPayload;
|
|
157
|
-
if (!
|
|
82
|
+
if (!isRecord(payload)) throw new AccessGrantError();
|
|
158
83
|
const token = requireCredential(value.token, "chalk-media");
|
|
159
84
|
const expiresAt = requireDateTime(value.expires_at ?? value.expiresAt);
|
|
160
85
|
switch (value.provider) {
|
|
@@ -168,16 +93,6 @@ function parseMediaAccess(value) {
|
|
|
168
93
|
stunServer: requireNonEmptyString(payload.stunServer)
|
|
169
94
|
}
|
|
170
95
|
};
|
|
171
|
-
case "cloudflare_rtk":
|
|
172
|
-
return {
|
|
173
|
-
token,
|
|
174
|
-
expiresAt,
|
|
175
|
-
provider: value.provider,
|
|
176
|
-
clientPayload: {
|
|
177
|
-
providerSubject: requireNonEmptyString(payload.provider_subject ?? payload.providerSubject),
|
|
178
|
-
token: requireNonEmptyString(payload.token)
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
96
|
default:
|
|
182
97
|
throw new AccessGrantError();
|
|
183
98
|
}
|
|
@@ -186,8 +101,6 @@ function mediaClientPayload(value) {
|
|
|
186
101
|
switch (value.provider) {
|
|
187
102
|
case "cloudflare_sfu":
|
|
188
103
|
return { connectionId: value.clientPayload.connectionId, stunServer: value.clientPayload.stunServer };
|
|
189
|
-
case "cloudflare_rtk":
|
|
190
|
-
return { provider_subject: value.clientPayload.providerSubject, token: value.clientPayload.token };
|
|
191
104
|
}
|
|
192
105
|
}
|
|
193
106
|
function requireCredential(value, audience) {
|
|
@@ -200,7 +113,7 @@ function requireCredential(value, audience) {
|
|
|
200
113
|
} catch {
|
|
201
114
|
throw new AccessGrantError();
|
|
202
115
|
}
|
|
203
|
-
if (!
|
|
116
|
+
if (!isRecord(payload) || payload.aud !== audience) throw new AccessGrantError();
|
|
204
117
|
return token;
|
|
205
118
|
}
|
|
206
119
|
function requireDateTime(value) {
|
|
@@ -216,7 +129,7 @@ function requireNonEmptyString(value) {
|
|
|
216
129
|
if (typeof value !== "string" || value.trim().length === 0) throw new AccessGrantError();
|
|
217
130
|
return value;
|
|
218
131
|
}
|
|
219
|
-
function
|
|
132
|
+
function isRecord(value) {
|
|
220
133
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
221
134
|
}
|
|
222
135
|
|
|
@@ -303,7 +216,6 @@ function serializedBody(body) {
|
|
|
303
216
|
function requestHeaders(options, apiKey, hasBody, idempotencyKeyValue) {
|
|
304
217
|
const headers = new Headers(options.headers);
|
|
305
218
|
setContentType(headers, hasBody);
|
|
306
|
-
setTelemetryHeaders(headers, options);
|
|
307
219
|
setOptionalHeader(headers, "idempotency-key", idempotencyKeyValue);
|
|
308
220
|
headers.set("authorization", `Bearer ${apiKey}`);
|
|
309
221
|
return headers;
|
|
@@ -311,12 +223,6 @@ function requestHeaders(options, apiKey, hasBody, idempotencyKeyValue) {
|
|
|
311
223
|
function setContentType(headers, hasBody) {
|
|
312
224
|
if (hasBody) headers.set("content-type", "application/json");
|
|
313
225
|
}
|
|
314
|
-
function setTelemetryHeaders(headers, options) {
|
|
315
|
-
if (!options.telemetry) return;
|
|
316
|
-
headers.set("x-chalk-journey-id", options.telemetry.journeyId);
|
|
317
|
-
headers.set("traceparent", options.telemetry.traceparent);
|
|
318
|
-
setOptionalHeader(headers, "tracestate", options.telemetry.tracestate);
|
|
319
|
-
}
|
|
320
226
|
function setOptionalHeader(headers, name, value) {
|
|
321
227
|
if (value !== void 0) headers.set(name, value);
|
|
322
228
|
}
|
|
@@ -677,8 +583,7 @@ function accessGrant(value) {
|
|
|
677
583
|
expires_at: value.media.expires_at,
|
|
678
584
|
provider: value.media.provider,
|
|
679
585
|
client_payload: payload
|
|
680
|
-
}
|
|
681
|
-
diagnostics: value.diagnostics
|
|
586
|
+
}
|
|
682
587
|
});
|
|
683
588
|
}
|
|
684
589
|
function mediaClientPayload2(media) {
|
|
@@ -688,11 +593,6 @@ function mediaClientPayload2(media) {
|
|
|
688
593
|
if (typeof connectionId !== "string" || typeof stunServer !== "string") throw invalidResponse(201);
|
|
689
594
|
return { connectionId, stunServer };
|
|
690
595
|
}
|
|
691
|
-
case "cloudflare_rtk": {
|
|
692
|
-
const { provider_subject, token } = media.client_payload;
|
|
693
|
-
if (typeof provider_subject !== "string" || typeof token !== "string") throw invalidResponse(201);
|
|
694
|
-
return { provider_subject, token };
|
|
695
|
-
}
|
|
696
596
|
default:
|
|
697
597
|
throw invalidResponse(201);
|
|
698
598
|
}
|
package/dist/server/types.d.cts
CHANGED
|
@@ -2,19 +2,12 @@ import type { AccessRefreshRequest } from "./access-refresh.cjs";
|
|
|
2
2
|
import type { AccessGrant } from "../access/grant.cjs";
|
|
3
3
|
export type { AccessGrant } from "../access/grant.cjs";
|
|
4
4
|
export type ChalkServerHeaders = Readonly<Record<string, string>>;
|
|
5
|
-
export type ChalkServerTelemetry = {
|
|
6
|
-
readonly journeyId: string;
|
|
7
|
-
readonly rootJourneyId: string;
|
|
8
|
-
readonly traceparent: string;
|
|
9
|
-
readonly tracestate?: string;
|
|
10
|
-
};
|
|
11
5
|
export type ChalkServerClientOptions = {
|
|
12
6
|
readonly apiKey: string;
|
|
13
7
|
readonly tenantId: string;
|
|
14
8
|
readonly apiBaseURL: string | URL;
|
|
15
9
|
readonly fetch?: typeof globalThis.fetch;
|
|
16
10
|
readonly headers?: ChalkServerHeaders;
|
|
17
|
-
readonly telemetry?: ChalkServerTelemetry;
|
|
18
11
|
};
|
|
19
12
|
export type ChalkIdempotencyOptions = {
|
|
20
13
|
readonly idempotencyKey?: string;
|
package/dist/server/types.d.ts
CHANGED
|
@@ -2,19 +2,12 @@ import type { AccessRefreshRequest } from "./access-refresh.js";
|
|
|
2
2
|
import type { AccessGrant } from "../access/grant.js";
|
|
3
3
|
export type { AccessGrant } from "../access/grant.js";
|
|
4
4
|
export type ChalkServerHeaders = Readonly<Record<string, string>>;
|
|
5
|
-
export type ChalkServerTelemetry = {
|
|
6
|
-
readonly journeyId: string;
|
|
7
|
-
readonly rootJourneyId: string;
|
|
8
|
-
readonly traceparent: string;
|
|
9
|
-
readonly tracestate?: string;
|
|
10
|
-
};
|
|
11
5
|
export type ChalkServerClientOptions = {
|
|
12
6
|
readonly apiKey: string;
|
|
13
7
|
readonly tenantId: string;
|
|
14
8
|
readonly apiBaseURL: string | URL;
|
|
15
9
|
readonly fetch?: typeof globalThis.fetch;
|
|
16
10
|
readonly headers?: ChalkServerHeaders;
|
|
17
|
-
readonly telemetry?: ChalkServerTelemetry;
|
|
18
11
|
};
|
|
19
12
|
export type ChalkIdempotencyOptions = {
|
|
20
13
|
readonly idempotencyKey?: string;
|