@tourmind-frontend/monitor-plugin-vite 1.2.0 → 1.4.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.
package/dist/index.cjs CHANGED
@@ -77,7 +77,10 @@ async function uploadFiles({ url, query, files }) {
77
77
  function uploadSourceMapPlugin(options) {
78
78
  var _a;
79
79
  if (!options.url) throw new Error(`${LOG_PREFIX} "url" is required`);
80
- if (!options.token) throw new Error(`${LOG_PREFIX} "token" is required`);
80
+ if (!options.authToken) throw new Error(`${LOG_PREFIX} "authToken" is required`);
81
+ if (!options.authToken.startsWith("fm_at_")) {
82
+ throw new Error(`${LOG_PREFIX} "authToken" must start with "fm_at_"; do not use the client key here`);
83
+ }
81
84
  if (!options.commit) throw new Error(`${LOG_PREFIX} "commit" is required`);
82
85
  const log = (_a = options.logger) != null ? _a : defaultLogger;
83
86
  const uploadUrl = `${options.url.replace(/\/+$/, "")}/api/upload`;
@@ -102,7 +105,7 @@ function uploadSourceMapPlugin(options) {
102
105
  const commit = (_a2 = options.commit) != null ? _a2 : "";
103
106
  const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
104
107
  const query = {
105
- token: options.token,
108
+ token: options.authToken,
106
109
  timestamp: String(timestamp)
107
110
  };
108
111
  if (commit) query.commit = commit;
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import { Plugin } from "vite";
2
2
  export interface UploadSourceMapOptions {
3
3
  /** monitor 服务的 base URL,例如 `https://monitor.example.com`。内部拼接 `/api/upload`。 */
4
4
  url: string;
5
- /** monitor 项目 token,从 web 控制台创建项目后获取,内部已绑定仓库 + 分支。 */
6
- token: string;
5
+ /** monitor 项目 auth token(前缀 `fm_at_`),仅供 CI / 构建机使用,从 web 控制台「项目」页获取。 */
6
+ authToken: string;
7
7
  /** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
8
8
  commit: string;
9
9
  /** 构建时间戳(毫秒),未设置时取上传时刻的 `Date.now()`。 */
package/dist/index.js CHANGED
@@ -43,7 +43,10 @@ async function uploadFiles({ url, query, files }) {
43
43
  function uploadSourceMapPlugin(options) {
44
44
  var _a;
45
45
  if (!options.url) throw new Error(`${LOG_PREFIX} "url" is required`);
46
- if (!options.token) throw new Error(`${LOG_PREFIX} "token" is required`);
46
+ if (!options.authToken) throw new Error(`${LOG_PREFIX} "authToken" is required`);
47
+ if (!options.authToken.startsWith("fm_at_")) {
48
+ throw new Error(`${LOG_PREFIX} "authToken" must start with "fm_at_"; do not use the client key here`);
49
+ }
47
50
  if (!options.commit) throw new Error(`${LOG_PREFIX} "commit" is required`);
48
51
  const log = (_a = options.logger) != null ? _a : defaultLogger;
49
52
  const uploadUrl = `${options.url.replace(/\/+$/, "")}/api/upload`;
@@ -68,7 +71,7 @@ function uploadSourceMapPlugin(options) {
68
71
  const commit = (_a2 = options.commit) != null ? _a2 : "";
69
72
  const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
70
73
  const query = {
71
- token: options.token,
74
+ token: options.authToken,
72
75
  timestamp: String(timestamp)
73
76
  };
74
77
  if (commit) query.commit = commit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tourmind-frontend/monitor-plugin-vite",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Vite plugin that uploads sourcemaps to a frontend-monitor server.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",