diff --git a/src/bbstd/client.ts b/src/bbstd/client.ts index 96f782f..a2f6d38 100644 --- a/src/bbstd/client.ts +++ b/src/bbstd/client.ts @@ -74,15 +74,14 @@ export class BitBucket { async apiCall( path: string, - method: "GET" | "POST" | "DELETE" = "GET", - // eslint-disable-next-line @typescript-eslint/no-explicit-any - data: any = {}, + method: "GET" | "POST" | "PUT" | "DELETE" = "GET", + data?: atlassianjwt.Params, ): Promise { // ensure there's a slash prior to path const url = `${this.#baseURL.replace(/\/$/, "")}/${path}`; // eslint-disable-next-line @typescript-eslint/no-explicit-any let body: any = undefined; - if (method === "POST") { + if (method === "POST" || method === "PUT") { body = JSON.stringify(data); } @@ -94,6 +93,7 @@ export class BitBucket { this.#securityContext, method, url, + data, ); headers.Authorization = `JWT ${token}`; } @@ -116,13 +116,18 @@ export class BitBucket { */ async function generateSessionToken( sctx: BitBucketSecurityContext, - method: "GET" | "POST" | "DELETE", + method: "GET" | "POST" | "PUT" | "DELETE", urlRaw: string, + body?: atlassianjwt.Params, ): Promise { - const req: atlassianjwt.Request = atlassianjwt.fromMethodAndUrl( - method, - urlRaw, - ); + let req: atlassianjwt.Request; + if (body && method === "POST") { + req = atlassianjwt.fromMethodAndPathAndBody("post", urlRaw, body); + } else if (body && method === "PUT") { + req = atlassianjwt.fromMethodAndPathAndBody("put", urlRaw, body); + } else { + req = atlassianjwt.fromMethodAndUrl(method, urlRaw); + } const qsh = atlassianjwt.createQueryStringHash(req); const customClaims = { qsh }; diff --git a/src/sourcer/index.ts b/src/sourcer/index.ts index 1e0380c..1724db9 100644 --- a/src/sourcer/index.ts +++ b/src/sourcer/index.ts @@ -8,3 +8,4 @@ export * from "./from.ts"; export * from "./from_github.ts"; +export * from "./from_bitbucket.ts";