diff --git a/package-lock.json b/package-lock.json index c1394fdec..84d7b2bfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2108,9 +2108,9 @@ } }, "@octokit/auth-action": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-1.2.2.tgz", - "integrity": "sha512-G3xcXQI+TRlvkcCe3uN7heklS0sDbHosbStkcoCBzuOQxDSuOB5nGIjJcWCnp4YO7/L9hKDwsC6ct/6eR9GcnQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-1.3.0.tgz", + "integrity": "sha512-PLC7cQsFJIVnfhvV2QTbwzEO6GBxWpWxxxOroN5Z+g3maMpuTZIexBMLBE6iq94mlFN7AzI349L0HjbMFt/6NQ==", "dev": true, "requires": { "@octokit/auth-token": "^2.4.0", @@ -2118,35 +2118,41 @@ } }, "@octokit/auth-app": { - "version": "2.4.7", - "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-2.4.7.tgz", - "integrity": "sha512-qCHtVsrbk1SeokGWv6jeVkkpjqSBwAoor2VymBlETzrJgvM4I69sp8Zf8c/sAY8qf4/VLzK0/Ql1kJx0pb3CAg==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-2.7.0.tgz", + "integrity": "sha512-znx092EpYmtEr5UjRXrFGGinA3jWJNriKT/N3CZFbx53JfXNsHqKW8UogyuJwob55JAgEzwhRTra/yy6e+AcfQ==", "dev": true, "requires": { "@octokit/request": "^5.3.0", "@octokit/request-error": "^2.0.0", "@octokit/types": "^5.0.0", "@types/lru-cache": "^5.1.0", - "lru-cache": "^5.1.1", + "lru-cache": "^6.0.0", "universal-github-app-jwt": "^1.0.1", - "universal-user-agent": "^5.0.0" + "universal-user-agent": "^6.0.0" }, "dependencies": { - "universal-user-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", - "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "requires": { - "os-name": "^3.1.0" + "yallist": "^4.0.0" } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } }, "@octokit/auth-basic": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/@octokit/auth-basic/-/auth-basic-1.4.5.tgz", - "integrity": "sha512-J4ttlZuKhQGJEFuXY15k5elpmFDQHMvNEfFJTZy5RLarmLhsrxMugqr2zKsrYSL3xB9NeFsxf1ZlBWCkEyZuzQ==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/@octokit/auth-basic/-/auth-basic-1.4.7.tgz", + "integrity": "sha512-ZVTTH6TeyGkXWe7nuFZY6z6aNxDbQjAbt7hEvtOupvGGuFDdYRBG5sHRLezJYQliBEbNbdnLFtMdyxwIbxJBoA==", "dev": true, "requires": { "@octokit/request": "^5.4.2", @@ -2154,24 +2160,13 @@ "@octokit/types": "^5.0.0", "@types/btoa-lite": "^1.0.0", "btoa-lite": "^1.0.0", - "universal-user-agent": "^5.0.0" - }, - "dependencies": { - "universal-user-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", - "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", - "dev": true, - "requires": { - "os-name": "^3.1.0" - } - } + "universal-user-agent": "^6.0.0" } }, "@octokit/auth-oauth-app": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-3.0.4.tgz", - "integrity": "sha512-zf7RzZv6uD1ZZrK+4v/aQQvXxP6SIYIpHzwjAPpPq0yc9Ux8kxng07nmZXIpSsm76sTyZZ3aqQqcwPW2M5I8aA==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-3.0.5.tgz", + "integrity": "sha512-py5clDH1sGxsznHiKWW/RPVuHLp6d1PUevDUPGw9QsIA93iFSS1oMO0rRziOeIcyt/tpweTANPPlM97WYWepeg==", "dev": true, "requires": { "@octokit/request": "^5.3.0", @@ -2179,18 +2174,7 @@ "@octokit/types": "^5.0.0", "@types/btoa-lite": "^1.0.0", "btoa-lite": "^1.0.0", - "universal-user-agent": "^5.0.0" - }, - "dependencies": { - "universal-user-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", - "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", - "dev": true, - "requires": { - "os-name": "^3.1.0" - } - } + "universal-user-agent": "^6.0.0" } }, "@octokit/auth-token": { @@ -16663,9 +16647,9 @@ } }, "universal-github-app-jwt": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.0.2.tgz", - "integrity": "sha512-bJ3hVBdPREry3vob+JBOjXkO76QAQkYTIJvQ62Ja7XBSrKv6v6gHaRBWADddvS0HiLF0Q6lCK1kg4ZJrj/Kl9g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.1.0.tgz", + "integrity": "sha512-3b+ocAjjz4JTyqaOT+NNBd5BtTuvJTxWElIoeHSVelUV9J3Jp7avmQTdLKCaoqi/5Ox2o/q+VK19TJ233rVXVQ==", "dev": true, "requires": { "@types/jsonwebtoken": "^8.3.3", diff --git a/src/index.ts b/src/index.ts index 1cc99f6f3..a604554d6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -139,6 +139,7 @@ export class Octokit { Object.assign( { request: this.request, + log: this.log, }, options.auth ) diff --git a/test/auth.test.ts b/test/auth.test.ts index 516adcb6e..1c87e9791 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -353,4 +353,46 @@ describe("Authentication", () => { expect(mock.done()).toBe(true); }); + + it("should pass through the logger (#1277)", async () => { + const mock = fetchMock + .sandbox() + .postOnce("https://api.github.com/app/installations/2/access_tokens", { + token: "installation-token-123", + permissions: {}, + }) + .getOnce("https://api.github.com/repos/octokit/core.js", 401) + .getOnce( + "https://api.github.com/repos/octokit/core.js", + { ok: true }, + { overwriteRoutes: false } + ); + + const mockWarnLogger = jest.fn(); + + const octokit = new Octokit({ + log: { + debug: jest.fn(), + info: jest.fn(), + warn: mockWarnLogger, + error: jest.fn(), + }, + authStrategy: createAppAuth, + auth: { + id: 1, + privateKey: PRIVATE_KEY, + installationId: 2, + }, + request: { + fetch: mock, + }, + }); + + await octokit.request("GET /repos/octokit/core.js"); + + expect(mockWarnLogger.mock.calls.length).toBe(1); + expect(mockWarnLogger.mock.calls[0][0]).toBe( + "[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s)" + ); + }); });