diff --git a/packages/js/api-client/package.json b/packages/js/api-client/package.json index 403da4f08d3..7c1ea7c943d 100644 --- a/packages/js/api-client/package.json +++ b/packages/js/api-client/package.json @@ -49,6 +49,6 @@ "vitest": "^2.1.4" }, "dependencies": { - "openapi-fetch": "^0.11.2" + "openapi-fetch": "^0.13.0" } } diff --git a/packages/js/api-client/src/auth.ts b/packages/js/api-client/src/auth.ts index c142dd53698..95b8ccd51af 100644 --- a/packages/js/api-client/src/auth.ts +++ b/packages/js/api-client/src/auth.ts @@ -1,4 +1,4 @@ -import type { Middleware } from "openapi-fetch" +import type { MiddlewareCallbackParams } from "openapi-fetch" import type { components } from "./generated/openverse" import type { OpenverseClient, ClientCredentials } from "./types" @@ -11,7 +11,15 @@ type OAuth2Token = components["schemas"]["OAuth2Token"] const currTimestamp = (): number => Math.floor(Date.now() / 1e3) export const EXPIRY_THRESHOLD = 5 // seconds -export class OpenverseAuthMiddleware implements Middleware { +type MiddlewareOnRequest = ( + options: MiddlewareCallbackParams +) => void | Request | undefined | Promise + +interface OpenverseMiddleware { + onRequest: MiddlewareOnRequest +} + +export class OpenverseAuthMiddleware implements OpenverseMiddleware { /** * An Openverse REST API client. * @@ -57,7 +65,10 @@ export class OpenverseAuthMiddleware implements Middleware { this.credentials = credentials } - onRequest: Middleware["onRequest"] = async ({ schemaPath, request }) => { + onRequest: OpenverseMiddleware["onRequest"] = async ({ + schemaPath, + request, + }) => { if (schemaPath == "/v1/auth_tokens/token/") { // Do not send auth headers for token generation requests return request diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 433a708412f..aeb4b0a120a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -254,8 +254,8 @@ importers: packages/js/api-client: dependencies: openapi-fetch: - specifier: ^0.11.2 - version: 0.11.2 + specifier: ^0.13.0 + version: 0.13.3 devDependencies: '@rollup/plugin-typescript': specifier: ^12.0.0 @@ -5452,11 +5452,11 @@ packages: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} - openapi-fetch@0.11.2: - resolution: {integrity: sha512-zc37VvX9vHJjJxNY3JLhg5Ks3J3KSL56NJrIAp2QRt/fdkOhGQHBTVY+Zz7tEOdqocS/1xfRTzWC6NguCGjUnA==} + openapi-fetch@0.13.3: + resolution: {integrity: sha512-M1THnPkNOXUPsQKZfqunhW/wqH8l3/W3Vlj4lemQynf4mTaTwBTvL2pgjBe0zerL/GFT5ttCHu9fYvanUI3tOw==} - openapi-typescript-helpers@0.0.12: - resolution: {integrity: sha512-FO+5kTWO6KDutigamr2MRwciYkAUYhqdctlyVRrQOe2uxif2/O2+GcS07jNnP36AUK6ubSsGu3GeBiYIc6eQzA==} + openapi-typescript-helpers@0.0.15: + resolution: {integrity: sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==} openapi-typescript@7.4.3: resolution: {integrity: sha512-xTIjMIIOv9kNhsr8JxaC00ucbIY/6ZwuJPJBZMSh5FA2dicZN5uM805DWVJojXdom8YI4AQTavPDPHMx/3g0vQ==} @@ -13768,11 +13768,11 @@ snapshots: is-docker: 2.2.1 is-wsl: 2.2.0 - openapi-fetch@0.11.2: + openapi-fetch@0.13.3: dependencies: - openapi-typescript-helpers: 0.0.12 + openapi-typescript-helpers: 0.0.15 - openapi-typescript-helpers@0.0.12: {} + openapi-typescript-helpers@0.0.15: {} openapi-typescript@7.4.3(encoding@0.1.13)(typescript@5.6.3): dependencies: