@kevisual/cnb 0.0.72 → 0.0.73

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/cli.js CHANGED
@@ -40372,6 +40372,7 @@ class Repo extends CNBCore {
40372
40372
  }
40373
40373
 
40374
40374
  // src/user/index.ts
40375
+ var import_dayjs2 = __toESM(require_dayjs_min(), 1);
40375
40376
  class User extends CNBCore {
40376
40377
  constructor(options) {
40377
40378
  super(options);
@@ -40386,11 +40387,26 @@ class User extends CNBCore {
40386
40387
  async checkCookieValid() {
40387
40388
  const user = await this.getCurrentUser();
40388
40389
  if (user.code === 200) {
40389
- return { code: 200, message: "cookie valid" };
40390
+ const cookieInfo = await this.getCookieInfo();
40391
+ const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
40392
+ return { code: 200, message: "cookie valid", data: { expiredAt } };
40390
40393
  } else {
40391
40394
  return { code: 401, message: "cookie invalid" };
40392
40395
  }
40393
40396
  }
40397
+ async getCookieInfo() {
40398
+ const cookie = this.cookie;
40399
+ const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
40400
+ const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
40401
+ const firstPart = cnbSession?.split("=")[1].split(".")[0];
40402
+ const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
40403
+ return {
40404
+ cnbSession,
40405
+ csrfKey,
40406
+ firstPart,
40407
+ expiredAt
40408
+ };
40409
+ }
40394
40410
  getUser() {
40395
40411
  const url3 = "/user";
40396
40412
  return this.get({ url: url3 });
@@ -64542,7 +64558,7 @@ app.route({
64542
64558
  }).addTo(app);
64543
64559
 
64544
64560
  // agent/routes/cnb-board/live/live-content.ts
64545
- var import_dayjs2 = __toESM(require_dayjs_min(), 1);
64561
+ var import_dayjs3 = __toESM(require_dayjs_min(), 1);
64546
64562
  import os2 from "node:os";
64547
64563
  import { execSync as execSync2 } from "node:child_process";
64548
64564
  var getLiveMdContent = (opts) => {
@@ -64756,8 +64772,8 @@ var createOSInfo = (more = false) => {
64756
64772
  description: "当前目录磁盘使用情况"
64757
64773
  });
64758
64774
  if (startTimer) {
64759
- const buildStartTime = import_dayjs2.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
64760
- const buildStartTimestamp = import_dayjs2.default(startTimer).valueOf();
64775
+ const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
64776
+ const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
64761
64777
  const buildUptime = Date.now() - buildStartTimestamp;
64762
64778
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
64763
64779
  const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
@@ -64773,7 +64789,7 @@ var createOSInfo = (more = false) => {
64773
64789
  description: `构建已运行时间: ${buildUptimeStr}`
64774
64790
  });
64775
64791
  if (maxRunTime > 0) {
64776
- const now = import_dayjs2.default();
64792
+ const now = import_dayjs3.default();
64777
64793
  const today4am = now.hour(4).minute(0).second(0).millisecond(0);
64778
64794
  let timeTo4 = today4am.valueOf() - now.valueOf();
64779
64795
  if (timeTo4 < 0) {
@@ -72229,7 +72245,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
72229
72245
  import fs4 from "node:fs";
72230
72246
 
72231
72247
  // src/release/upload-release.ts
72232
- var import_dayjs3 = __toESM(require_dayjs_min(), 1);
72248
+ var import_dayjs4 = __toESM(require_dayjs_min(), 1);
72233
72249
  import fs3 from "node:fs";
72234
72250
 
72235
72251
  // src/upload/upload-base.ts
@@ -72314,7 +72330,7 @@ var getFileSize = (file3) => {
72314
72330
 
72315
72331
  // src/release/upload-release.ts
72316
72332
  var createBodyByFileItem = (files) => {
72317
- const createdAt = import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss");
72333
+ const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
72318
72334
  const summary = `创建时间:${createdAt},文件数量:${files.length}`;
72319
72335
  const header = `| name | type |
72320
72336
  | --- | --- |`;
package/dist/npc.js CHANGED
@@ -38279,6 +38279,7 @@ class Repo extends CNBCore {
38279
38279
  }
38280
38280
 
38281
38281
  // src/user/index.ts
38282
+ var import_dayjs2 = __toESM(require_dayjs_min(), 1);
38282
38283
  class User extends CNBCore {
38283
38284
  constructor(options) {
38284
38285
  super(options);
@@ -38293,11 +38294,26 @@ class User extends CNBCore {
38293
38294
  async checkCookieValid() {
38294
38295
  const user = await this.getCurrentUser();
38295
38296
  if (user.code === 200) {
38296
- return { code: 200, message: "cookie valid" };
38297
+ const cookieInfo = await this.getCookieInfo();
38298
+ const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
38299
+ return { code: 200, message: "cookie valid", data: { expiredAt } };
38297
38300
  } else {
38298
38301
  return { code: 401, message: "cookie invalid" };
38299
38302
  }
38300
38303
  }
38304
+ async getCookieInfo() {
38305
+ const cookie = this.cookie;
38306
+ const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
38307
+ const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
38308
+ const firstPart = cnbSession?.split("=")[1].split(".")[0];
38309
+ const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
38310
+ return {
38311
+ cnbSession,
38312
+ csrfKey,
38313
+ firstPart,
38314
+ expiredAt
38315
+ };
38316
+ }
38301
38317
  getUser() {
38302
38318
  const url3 = "/user";
38303
38319
  return this.get({ url: url3 });
@@ -62483,7 +62499,7 @@ app.route({
62483
62499
  }).addTo(app);
62484
62500
 
62485
62501
  // agent/routes/cnb-board/live/live-content.ts
62486
- var import_dayjs2 = __toESM(require_dayjs_min(), 1);
62502
+ var import_dayjs3 = __toESM(require_dayjs_min(), 1);
62487
62503
  import os2 from "node:os";
62488
62504
  import { execSync as execSync2 } from "node:child_process";
62489
62505
  var getLiveMdContent = (opts) => {
@@ -62697,8 +62713,8 @@ var createOSInfo = (more = false) => {
62697
62713
  description: "当前目录磁盘使用情况"
62698
62714
  });
62699
62715
  if (startTimer) {
62700
- const buildStartTime = import_dayjs2.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62701
- const buildStartTimestamp = import_dayjs2.default(startTimer).valueOf();
62716
+ const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62717
+ const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
62702
62718
  const buildUptime = Date.now() - buildStartTimestamp;
62703
62719
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
62704
62720
  const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
@@ -62714,7 +62730,7 @@ var createOSInfo = (more = false) => {
62714
62730
  description: `构建已运行时间: ${buildUptimeStr}`
62715
62731
  });
62716
62732
  if (maxRunTime > 0) {
62717
- const now = import_dayjs2.default();
62733
+ const now = import_dayjs3.default();
62718
62734
  const today4am = now.hour(4).minute(0).second(0).millisecond(0);
62719
62735
  let timeTo4 = today4am.valueOf() - now.valueOf();
62720
62736
  if (timeTo4 < 0) {
@@ -70170,7 +70186,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
70170
70186
  import fs4 from "node:fs";
70171
70187
 
70172
70188
  // src/release/upload-release.ts
70173
- var import_dayjs3 = __toESM(require_dayjs_min(), 1);
70189
+ var import_dayjs4 = __toESM(require_dayjs_min(), 1);
70174
70190
  import fs3 from "node:fs";
70175
70191
 
70176
70192
  // src/upload/upload-base.ts
@@ -70255,7 +70271,7 @@ var getFileSize = (file3) => {
70255
70271
 
70256
70272
  // src/release/upload-release.ts
70257
70273
  var createBodyByFileItem = (files) => {
70258
- const createdAt = import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss");
70274
+ const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
70259
70275
  const summary = `创建时间:${createdAt},文件数量:${files.length}`;
70260
70276
  const header = `| name | type |
70261
70277
  | --- | --- |`;
package/dist/opencode.js CHANGED
@@ -38279,6 +38279,7 @@ class Repo extends CNBCore {
38279
38279
  }
38280
38280
 
38281
38281
  // src/user/index.ts
38282
+ var import_dayjs2 = __toESM(require_dayjs_min(), 1);
38282
38283
  class User extends CNBCore {
38283
38284
  constructor(options) {
38284
38285
  super(options);
@@ -38293,11 +38294,26 @@ class User extends CNBCore {
38293
38294
  async checkCookieValid() {
38294
38295
  const user = await this.getCurrentUser();
38295
38296
  if (user.code === 200) {
38296
- return { code: 200, message: "cookie valid" };
38297
+ const cookieInfo = await this.getCookieInfo();
38298
+ const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
38299
+ return { code: 200, message: "cookie valid", data: { expiredAt } };
38297
38300
  } else {
38298
38301
  return { code: 401, message: "cookie invalid" };
38299
38302
  }
38300
38303
  }
38304
+ async getCookieInfo() {
38305
+ const cookie = this.cookie;
38306
+ const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
38307
+ const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
38308
+ const firstPart = cnbSession?.split("=")[1].split(".")[0];
38309
+ const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
38310
+ return {
38311
+ cnbSession,
38312
+ csrfKey,
38313
+ firstPart,
38314
+ expiredAt
38315
+ };
38316
+ }
38301
38317
  getUser() {
38302
38318
  const url3 = "/user";
38303
38319
  return this.get({ url: url3 });
@@ -62449,7 +62465,7 @@ app.route({
62449
62465
  }).addTo(app);
62450
62466
 
62451
62467
  // agent/routes/cnb-board/live/live-content.ts
62452
- var import_dayjs2 = __toESM(require_dayjs_min(), 1);
62468
+ var import_dayjs3 = __toESM(require_dayjs_min(), 1);
62453
62469
  import os2 from "node:os";
62454
62470
  import { execSync as execSync2 } from "node:child_process";
62455
62471
  var getLiveMdContent = (opts) => {
@@ -62663,8 +62679,8 @@ var createOSInfo = (more = false) => {
62663
62679
  description: "当前目录磁盘使用情况"
62664
62680
  });
62665
62681
  if (startTimer) {
62666
- const buildStartTime = import_dayjs2.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62667
- const buildStartTimestamp = import_dayjs2.default(startTimer).valueOf();
62682
+ const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62683
+ const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
62668
62684
  const buildUptime = Date.now() - buildStartTimestamp;
62669
62685
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
62670
62686
  const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
@@ -62680,7 +62696,7 @@ var createOSInfo = (more = false) => {
62680
62696
  description: `构建已运行时间: ${buildUptimeStr}`
62681
62697
  });
62682
62698
  if (maxRunTime > 0) {
62683
- const now = import_dayjs2.default();
62699
+ const now = import_dayjs3.default();
62684
62700
  const today4am = now.hour(4).minute(0).second(0).millisecond(0);
62685
62701
  let timeTo4 = today4am.valueOf() - now.valueOf();
62686
62702
  if (timeTo4 < 0) {
@@ -70136,7 +70152,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
70136
70152
  import fs4 from "node:fs";
70137
70153
 
70138
70154
  // src/release/upload-release.ts
70139
- var import_dayjs3 = __toESM(require_dayjs_min(), 1);
70155
+ var import_dayjs4 = __toESM(require_dayjs_min(), 1);
70140
70156
  import fs3 from "node:fs";
70141
70157
 
70142
70158
  // src/upload/upload-base.ts
@@ -70221,7 +70237,7 @@ var getFileSize = (file3) => {
70221
70237
 
70222
70238
  // src/release/upload-release.ts
70223
70239
  var createBodyByFileItem = (files) => {
70224
- const createdAt = import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss");
70240
+ const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
70225
70241
  const summary = `创建时间:${createdAt},文件数量:${files.length}`;
70226
70242
  const header = `| name | type |
70227
70243
  | --- | --- |`;
package/dist/routes.d.ts CHANGED
@@ -514,6 +514,12 @@ declare class User extends CNBCore {
514
514
  * @returns
515
515
  */
516
516
  checkCookieValid(): Promise<Result$2>;
517
+ getCookieInfo(): Promise<{
518
+ cnbSession: string;
519
+ csrfKey: string;
520
+ firstPart: string;
521
+ expiredAt: number;
522
+ }>;
517
523
  /**
518
524
  * 使用 Token 获取用户信息
519
525
  * @returns
package/dist/routes.js CHANGED
@@ -38279,6 +38279,7 @@ class Repo extends CNBCore {
38279
38279
  }
38280
38280
 
38281
38281
  // src/user/index.ts
38282
+ var import_dayjs2 = __toESM(require_dayjs_min(), 1);
38282
38283
  class User extends CNBCore {
38283
38284
  constructor(options) {
38284
38285
  super(options);
@@ -38293,11 +38294,26 @@ class User extends CNBCore {
38293
38294
  async checkCookieValid() {
38294
38295
  const user = await this.getCurrentUser();
38295
38296
  if (user.code === 200) {
38296
- return { code: 200, message: "cookie valid" };
38297
+ const cookieInfo = await this.getCookieInfo();
38298
+ const expiredAt = import_dayjs2.default(cookieInfo.expiredAt * 1000).format("YYYY-MM-DD HH:mm:ss");
38299
+ return { code: 200, message: "cookie valid", data: { expiredAt } };
38297
38300
  } else {
38298
38301
  return { code: 401, message: "cookie invalid" };
38299
38302
  }
38300
38303
  }
38304
+ async getCookieInfo() {
38305
+ const cookie = this.cookie;
38306
+ const cnbSession = cookie?.split(";").find((item) => item.trim().startsWith("CNBSESSION="));
38307
+ const csrfKey = cookie?.split(";").find((item) => item.trim().startsWith("csrfkey="));
38308
+ const firstPart = cnbSession?.split("=")[1].split(".")[0];
38309
+ const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60;
38310
+ return {
38311
+ cnbSession,
38312
+ csrfKey,
38313
+ firstPart,
38314
+ expiredAt
38315
+ };
38316
+ }
38301
38317
  getUser() {
38302
38318
  const url3 = "/user";
38303
38319
  return this.get({ url: url3 });
@@ -62449,7 +62465,7 @@ app.route({
62449
62465
  }).addTo(app);
62450
62466
 
62451
62467
  // agent/routes/cnb-board/live/live-content.ts
62452
- var import_dayjs2 = __toESM(require_dayjs_min(), 1);
62468
+ var import_dayjs3 = __toESM(require_dayjs_min(), 1);
62453
62469
  import os2 from "node:os";
62454
62470
  import { execSync as execSync2 } from "node:child_process";
62455
62471
  var getLiveMdContent = (opts) => {
@@ -62663,8 +62679,8 @@ var createOSInfo = (more = false) => {
62663
62679
  description: "当前目录磁盘使用情况"
62664
62680
  });
62665
62681
  if (startTimer) {
62666
- const buildStartTime = import_dayjs2.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62667
- const buildStartTimestamp = import_dayjs2.default(startTimer).valueOf();
62682
+ const buildStartTime = import_dayjs3.default(startTimer).format("YYYY-MM-DD HH:mm:ss");
62683
+ const buildStartTimestamp = import_dayjs3.default(startTimer).valueOf();
62668
62684
  const buildUptime = Date.now() - buildStartTimestamp;
62669
62685
  const buildUptimeStr = formatUptime(Math.floor(buildUptime / 1000));
62670
62686
  const maxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME") || 0;
@@ -62680,7 +62696,7 @@ var createOSInfo = (more = false) => {
62680
62696
  description: `构建已运行时间: ${buildUptimeStr}`
62681
62697
  });
62682
62698
  if (maxRunTime > 0) {
62683
- const now = import_dayjs2.default();
62699
+ const now = import_dayjs3.default();
62684
62700
  const today4am = now.hour(4).minute(0).second(0).millisecond(0);
62685
62701
  let timeTo4 = today4am.valueOf() - now.valueOf();
62686
62702
  if (timeTo4 < 0) {
@@ -70136,7 +70152,7 @@ var import_fast_glob = __toESM(require_out4(), 1);
70136
70152
  import fs4 from "node:fs";
70137
70153
 
70138
70154
  // src/release/upload-release.ts
70139
- var import_dayjs3 = __toESM(require_dayjs_min(), 1);
70155
+ var import_dayjs4 = __toESM(require_dayjs_min(), 1);
70140
70156
  import fs3 from "node:fs";
70141
70157
 
70142
70158
  // src/upload/upload-base.ts
@@ -70221,7 +70237,7 @@ var getFileSize = (file3) => {
70221
70237
 
70222
70238
  // src/release/upload-release.ts
70223
70239
  var createBodyByFileItem = (files) => {
70224
- const createdAt = import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss");
70240
+ const createdAt = import_dayjs4.default().format("YYYY-MM-DD HH:mm:ss");
70225
70241
  const summary = `创建时间:${createdAt},文件数量:${files.length}`;
70226
70242
  const header = `| name | type |
70227
70243
  | --- | --- |`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.72",
3
+ "version": "0.0.73",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "basename": "/root/cnb",
package/src/user/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import dayjs from "dayjs";
1
2
  import { CNBCore, CNBCoreOptions } from "../cnb-core.ts";
2
3
  import { Result } from "@kevisual/query";
3
4
  export class User extends CNBCore {
@@ -23,11 +24,28 @@ export class User extends CNBCore {
23
24
  async checkCookieValid(): Promise<Result> {
24
25
  const user = await this.getCurrentUser();
25
26
  if (user.code === 200) {
26
- return { code: 200, message: 'cookie valid' };
27
+ const cookieInfo = await this.getCookieInfo();
28
+ const expiredAt = dayjs(cookieInfo.expiredAt * 1000).format('YYYY-MM-DD HH:mm:ss');
29
+ return { code: 200, message: 'cookie valid', data: { expiredAt: expiredAt } };
27
30
  } else {
28
31
  return { code: 401, message: 'cookie invalid' };
29
32
  }
30
33
  }
34
+ async getCookieInfo() {
35
+ // CNBSESSION=1775638499.1935321989751226368.23c2313b832a6ca869c15e5257d6b16deb341dea4633bbd76c8d91c77d65fda5; csrfkey=1619226679
36
+ const cookie = this.cookie;
37
+ // 解析 CNBSESSION
38
+ const cnbSession = cookie?.split(';').find(item => item.trim().startsWith('CNBSESSION='));
39
+ const csrfKey = cookie?.split(';').find(item => item.trim().startsWith('csrfkey='));
40
+ const firstPart = cnbSession?.split('=')[1].split('.')[0];
41
+ const expiredAt = Number(firstPart) + 7 * 24 * 60 * 60; // CNBSESSION 的过期时间为7* 24 小时
42
+ return {
43
+ cnbSession,
44
+ csrfKey,
45
+ firstPart,
46
+ expiredAt,
47
+ }
48
+ }
31
49
  /**
32
50
  * 使用 Token 获取用户信息
33
51
  * @returns