@vizamodo/pkg-runtime-primitives 1.1.3 → 1.1.4

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.
@@ -1,5 +1,4 @@
1
- export declare function getTokenForRepo(params: {
2
- repo: string;
1
+ export declare function getInstallationTokenCached(params: {
3
2
  installationId: number;
4
3
  appPrivateKey: string;
5
4
  appId: string;
@@ -1,12 +1,8 @@
1
1
  import { getGithubInstallationToken } from "./github-app-token";
2
2
  import { getCachedOrFetch, wrapResult } from "@vizamodo/edge-cache-core";
3
- export async function getTokenForRepo(params) {
4
- const { repo, installationId, appPrivateKey, appId, forceRefresh } = params;
5
- const [owner] = repo.split("/");
6
- if (!owner) {
7
- throw new Error(`invalid_repo_format: ${repo}`);
8
- }
9
- const key = `gh-token:${owner}`;
3
+ export async function getInstallationTokenCached(params) {
4
+ const { installationId, appPrivateKey, appId, forceRefresh } = params;
5
+ const key = `gh-token:${appId}:${installationId}`;
10
6
  const token = await getCachedOrFetch(key, async () => {
11
7
  const { token, expiresAt } = await getGithubInstallationToken(installationId, appPrivateKey, appId);
12
8
  // use wrapResult pattern to let cache derive TTL from expiresAt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/pkg-runtime-primitives",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Edge-compatible runtime primitives for AWS, GitHub, crypto, and caching used across Viza services",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",