diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index f992db1..c065cca 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -138,7 +138,7 @@ describe('printActionsRuntimeTokenACs', () => { }); it('malformed', async () => { process.env.ACTIONS_RUNTIME_TOKEN = 'foo'; - await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error("Cannot parse GitHub Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')")); + await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('Cannot parse GitHub Actions Runtime Token: Invalid token specified: missing part #2')); }); it('refs/heads/master', async () => { const infoSpy = jest.spyOn(core, 'info'); diff --git a/package.json b/package.json index 14ab703..fd809f2 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "csv-parse": "^5.5.2", "handlebars": "^4.7.8", "js-yaml": "^4.1.0", - "jwt-decode": "^3.1.2", + "jwt-decode": "^4.0.0", "semver": "^7.5.4", "tmp": "^0.2.1" }, diff --git a/src/github.ts b/src/github.ts index e7b8e1c..d49f0ac 100644 --- a/src/github.ts +++ b/src/github.ts @@ -18,7 +18,7 @@ import {GitHub as Octokit} from '@actions/github/lib/utils'; import * as core from '@actions/core'; import * as github from '@actions/github'; import {Context} from '@actions/github/lib/context'; -import jwt_decode from 'jwt-decode'; +import {jwtDecode, JwtPayload} from 'jwt-decode'; import {GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubRepo} from './types/github'; @@ -51,7 +51,7 @@ export class GitHub { static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined { const token = process.env['ACTIONS_RUNTIME_TOKEN'] || ''; - return token ? jwt_decode(token) : undefined; + return token ? (jwtDecode(token) as GitHubActionsRuntimeToken) : undefined; } public static async printActionsRuntimeTokenACs() { diff --git a/yarn.lock b/yarn.lock index cc87982..73ce51c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1066,7 +1066,7 @@ __metadata: handlebars: ^4.7.8 jest: ^29.6.4 js-yaml: ^4.1.0 - jwt-decode: ^3.1.2 + jwt-decode: ^4.0.0 prettier: ^3.0.3 rimraf: ^5.0.1 semver: ^7.5.4 @@ -5356,10 +5356,10 @@ __metadata: languageName: node linkType: hard -"jwt-decode@npm:^3.1.2": - version: 3.1.2 - resolution: "jwt-decode@npm:3.1.2" - checksum: 20a4b072d44ce3479f42d0d2c8d3dabeb353081ba4982e40b83a779f2459a70be26441be6c160bfc8c3c6eadf9f6380a036fbb06ac5406b5674e35d8c4205eeb +"jwt-decode@npm:^4.0.0": + version: 4.0.0 + resolution: "jwt-decode@npm:4.0.0" + checksum: 390e2edcb31a92e86c8cbdd1edeea4c0d62acd371f8a8f0a8878e499390c0ecf4c658b365c4e941e4ef37d0170e4ca650aaa49f99a45c0b9695a235b210154b0 languageName: node linkType: hard