@vizamodo/runtime-primitives 1.1.8 → 1.1.9

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,4 +1,4 @@
1
- export declare function getGithubInstallationToken(installationId: number, privateKey: string, appId: string): Promise<{
1
+ export declare function getGithubInstallationToken(installationId: number, privateKey: string, clientId: string): Promise<{
2
2
  token: string;
3
3
  expiresAt: string;
4
4
  }>;
@@ -1,4 +1,4 @@
1
- async function createGithubAppJwt(appId, privateKeyPem) {
1
+ async function createGithubAppJwt(clientId, privateKeyPem) {
2
2
  // Convert PEM → ArrayBuffer
3
3
  const pem = privateKeyPem
4
4
  .replace(/-----BEGIN [A-Z ]+-----/g, "")
@@ -23,7 +23,7 @@ async function createGithubAppJwt(appId, privateKeyPem) {
23
23
  const payload = {
24
24
  iat: now - 60,
25
25
  exp: now + 540,
26
- iss: appId,
26
+ iss: clientId,
27
27
  };
28
28
  const encode = (obj) => btoa(JSON.stringify(obj))
29
29
  .replace(/=/g, "")
@@ -43,8 +43,8 @@ async function createGithubAppJwt(appId, privateKeyPem) {
43
43
  .replace(/\//g, "_");
44
44
  return `${data}.${sigB64}`;
45
45
  }
46
- export async function getGithubInstallationToken(installationId, privateKey, appId) {
47
- const jwt = await createGithubAppJwt(appId, privateKey);
46
+ export async function getGithubInstallationToken(installationId, privateKey, clientId) {
47
+ const jwt = await createGithubAppJwt(clientId, privateKey);
48
48
  const res = await fetch(`https://api.github.com/app/installations/${installationId}/access_tokens`, {
49
49
  method: "POST",
50
50
  headers: {
@@ -1,6 +1,6 @@
1
1
  export declare function getInstallationTokenCached(params: {
2
2
  installationId: number;
3
3
  appPrivateKey: string;
4
- appId: string;
4
+ clientId: string;
5
5
  forceRefresh?: boolean;
6
6
  }): Promise<string>;
@@ -1,10 +1,10 @@
1
1
  import { getGithubInstallationToken } from "./github-app-token";
2
2
  import { getCachedOrFetch, wrapResult } from "@vizamodo/edge-cache-core";
3
3
  export async function getInstallationTokenCached(params) {
4
- const { installationId, appPrivateKey, appId, forceRefresh } = params;
5
- const key = `gh-token:${appId}:${installationId}`;
4
+ const { installationId, appPrivateKey, clientId, forceRefresh } = params;
5
+ const key = `gh-token:${clientId}:${installationId}`;
6
6
  const token = await getCachedOrFetch(key, async () => {
7
- const { token, expiresAt } = await getGithubInstallationToken(installationId, appPrivateKey, appId);
7
+ const { token, expiresAt } = await getGithubInstallationToken(installationId, appPrivateKey, clientId);
8
8
  // use wrapResult pattern to let cache derive TTL from expiresAt
9
9
  return wrapResult(token, expiresAt);
10
10
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/runtime-primitives",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
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",
@@ -28,7 +28,7 @@
28
28
  "tweetnacl-sealedbox-js": "^1.2.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^25.5.2",
31
+ "@types/node": "^25.6.0",
32
32
  "typescript": "^6.0.2"
33
33
  },
34
34
  "publishConfig": {