@allurereport/service 3.7.0 → 3.8.0

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.
@@ -13,6 +13,7 @@ var _AllureLegacyServiceClient_client, _AllureLegacyServiceClient_url, _AllureLe
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { join as joinPosix } from "node:path/posix";
15
15
  import { createServiceHttpClient } from "./utils/http.js";
16
+ import { parseServiceToken } from "./utils/token.js";
16
17
  const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
17
18
  const UPLOAD_CONTENT_TYPE = "application/octet-stream";
18
19
  const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
@@ -37,9 +38,9 @@ export class AllureLegacyServiceClient {
37
38
  if (!config?.accessToken) {
38
39
  throw new Error("Allure service access token is required");
39
40
  }
40
- const { url } = JSON.parse(atob(config.accessToken.split(".")[1]));
41
+ const { accessToken, url } = parseServiceToken(config.accessToken);
41
42
  __classPrivateFieldSet(this, _AllureLegacyServiceClient_url, url.replace(/\/$/, ""), "f");
42
- __classPrivateFieldSet(this, _AllureLegacyServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), config.accessToken), "f");
43
+ __classPrivateFieldSet(this, _AllureLegacyServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), accessToken), "f");
43
44
  }
44
45
  async downloadHistory(payload) {
45
46
  const { branch, limit } = payload ?? {};
package/dist/service.js CHANGED
@@ -13,6 +13,7 @@ var _AllureServiceClient_client, _AllureServiceClient_url;
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { join as joinPosix } from "node:path/posix";
15
15
  import { createServiceHttpClient } from "./utils/http.js";
16
+ import { parseServiceToken } from "./utils/token.js";
16
17
  const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
17
18
  const UPLOAD_CONTENT_TYPE = "application/octet-stream";
18
19
  const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
@@ -23,13 +24,11 @@ export class AllureServiceClient {
23
24
  this.config = config;
24
25
  _AllureServiceClient_client.set(this, void 0);
25
26
  _AllureServiceClient_url.set(this, void 0);
26
- if (!config?.url) {
27
- throw new Error("Allure service URL is required");
28
- }
29
27
  if (!config?.accessToken) {
30
28
  throw new Error("Allure service access token is required");
31
29
  }
32
- __classPrivateFieldSet(this, _AllureServiceClient_url, config.url.replace(/\/$/, ""), "f");
30
+ const { url } = parseServiceToken(config.accessToken);
31
+ __classPrivateFieldSet(this, _AllureServiceClient_url, url.replace(/\/$/, ""), "f");
33
32
  __classPrivateFieldSet(this, _AllureServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), config.accessToken), "f");
34
33
  }
35
34
  async downloadHistory(payload) {
@@ -0,0 +1,4 @@
1
+ export declare const parseServiceToken: (token: string) => {
2
+ accessToken: string;
3
+ url: string;
4
+ };
@@ -0,0 +1,22 @@
1
+ export const parseServiceToken = (token) => {
2
+ try {
3
+ const encodedPayload = token.split(".")[1];
4
+ if (!encodedPayload) {
5
+ throw new Error("missing payload");
6
+ }
7
+ const payload = JSON.parse(Buffer.from(encodedPayload, "base64url").toString("utf-8"));
8
+ if (!payload.accessToken) {
9
+ throw new Error("missing access token");
10
+ }
11
+ if (!payload.url) {
12
+ throw new Error("missing url");
13
+ }
14
+ return {
15
+ accessToken: payload.accessToken,
16
+ url: payload.url,
17
+ };
18
+ }
19
+ catch {
20
+ throw new Error("Allure service access token is invalid");
21
+ }
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/service",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "Allure Service API",
5
5
  "keywords": [
6
6
  "allure",
@@ -30,9 +30,9 @@
30
30
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
31
31
  },
32
32
  "dependencies": {
33
- "@allurereport/core-api": "3.7.0",
34
- "@allurereport/plugin-api": "3.7.0",
35
- "axios": "^1.15.0",
33
+ "@allurereport/core-api": "3.8.0",
34
+ "@allurereport/plugin-api": "3.8.0",
35
+ "axios": "^1.15.2",
36
36
  "open": "^10.1.0"
37
37
  },
38
38
  "devDependencies": {