@bililive-tools/douyu-recorder 1.0.1 → 1.0.2

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/lib/dy_api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import crypto from "node:crypto";
2
- import { v4 as uuid4 } from "uuid";
3
2
  import safeEval from "safe-eval";
3
+ import { uuid } from "./utils.js";
4
4
  import queryString from "query-string";
5
5
  import { requester } from "./requester.js";
6
6
  /**
@@ -8,7 +8,7 @@ import { requester } from "./requester.js";
8
8
  */
9
9
  export async function getLiveInfo(opts) {
10
10
  const sign = await getSignFn(opts.channelId, opts.rejectSignFnCache);
11
- const did = uuid4().replace(/-/g, "");
11
+ const did = uuid().replace(/-/g, "");
12
12
  const time = Math.ceil(Date.now() / 1000);
13
13
  const signedStr = String(sign(opts.channelId, did, time));
14
14
  // TODO: 这里类型处理的有点问题,先用 as 顶着
package/lib/utils.d.ts CHANGED
@@ -17,3 +17,4 @@
17
17
  export declare function getValuesFromArrayLikeFlexSpaceBetween<T>(array: T[], columnCount: number): T[];
18
18
  export declare function ensureFolderExist(fileOrFolderPath: string): void;
19
19
  export declare function assert(assertion: unknown, msg?: string): asserts assertion;
20
+ export declare const uuid: () => `${string}-${string}-${string}-${string}-${string}`;
package/lib/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import crypto from "node:crypto";
3
4
  import { range } from "lodash-es";
4
5
  /**
5
6
  * 从数组中按照特定算法提取一些值(允许同个索引重复提取)。
@@ -50,3 +51,6 @@ export function assert(assertion, msg) {
50
51
  throw new Error(msg);
51
52
  }
52
53
  }
54
+ export const uuid = () => {
55
+ return crypto.randomUUID();
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/douyu-recorder",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "bililive-tools douyu recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",