Skip to content

Commit

Permalink
Created service token for stitcher
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Oct 29, 2024
1 parent cb8059b commit 0611458
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/stitcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dom-parser": "^1.1.5",
"elysia": "^1.1.20",
"hh-mm-ss": "^1.2.0",
"jose": "^5.9.6",
"lru-cache": "^11.0.1",
"luxon": "^3.5.0",
"redis": "^4.7.0",
Expand Down
10 changes: 8 additions & 2 deletions packages/stitcher/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { SignJWT } from "jose";
import { env } from "./env";
import { createApiClient } from "@superstreamer/api/client";

export const api = createApiClient(env.PUBLIC_API_ENDPOINT);
const jwt = new SignJWT({
type: "service",
}).setProtectedHeader({ alg: "HS256" });

export type * from "@superstreamer/api/client";
const secret = new TextEncoder().encode(env.JWT_SECRET);
const token = await jwt.sign(secret);

export const api = createApiClient(env.PUBLIC_API_ENDPOINT, token);
2 changes: 2 additions & 0 deletions packages/stitcher/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export const env = parseEnv((t) => ({
PUBLIC_S3_ENDPOINT: t.String(),
PUBLIC_STITCHER_ENDPOINT: t.String(),
PUBLIC_API_ENDPOINT: t.String(),

JWT_SECRET: t.String(),
}));
1 change: 0 additions & 1 deletion packages/stitcher/src/vast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export async function getAdMediasFromVast(adBreak: VmapAdBreak) {
}
result.push(adMedia);
}

return result;
}

Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0611458

Please sign in to comment.