py-auth-client 0.0.1 → 0.1.3

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/client.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { AuthClientConfig, AuthResult, AuthorizationInfo } from "./types";
2
2
  export declare class AuthClient {
3
3
  private readonly serverUrl;
4
4
  private readonly softwareName;
5
+ private readonly softwareVersion;
5
6
  private readonly deviceId;
6
7
  private readonly deviceInfo;
7
8
  private readonly clientSecret;
package/dist/client.js CHANGED
@@ -9,6 +9,7 @@ const http_1 = require("./http");
9
9
  class AuthClient {
10
10
  serverUrl;
11
11
  softwareName;
12
+ softwareVersion;
12
13
  deviceId;
13
14
  deviceInfo;
14
15
  clientSecret;
@@ -25,10 +26,14 @@ class AuthClient {
25
26
  }
26
27
  this.serverUrl = config.serverUrl.replace(/\/+$/, "");
27
28
  this.softwareName = config.softwareName;
29
+ this.softwareVersion = config.softwareVersion ?? "0.0.0";
28
30
  this.clientSecret = secret;
29
31
  this.debug = !!config.debug;
30
32
  this.deviceId = (0, device_1.buildDeviceId)(this.serverUrl, config.deviceId, this.softwareName);
31
- this.deviceInfo = config.deviceInfo ?? (0, device_1.collectDeviceInfo)();
33
+ this.deviceInfo = {
34
+ ...(config.deviceInfo ?? (0, device_1.collectDeviceInfo)()),
35
+ software_version: this.softwareVersion,
36
+ };
32
37
  const enableCache = config.enableCache ?? true;
33
38
  const cacheValidityDays = config.cacheValidityDays ?? 7;
34
39
  const checkIntervalDays = config.checkIntervalDays ?? 2;
package/dist/device.js CHANGED
@@ -81,5 +81,84 @@ function collectDeviceInfo() {
81
81
  catch {
82
82
  // ignore
83
83
  }
84
+ // 收集CPU信息
85
+ try {
86
+ const cpus = node_os_1.default.cpus();
87
+ info.cpu_count = cpus.length;
88
+ if (cpus.length > 0) {
89
+ info.cpu_model = cpus[0].model;
90
+ }
91
+ }
92
+ catch {
93
+ // ignore
94
+ }
95
+ // 收集内存信息
96
+ try {
97
+ const totalMem = node_os_1.default.totalmem();
98
+ const freeMem = node_os_1.default.freemem();
99
+ info.memory_total_gb = Math.round((totalMem / (1024 ** 3)) * 100) / 100;
100
+ info.memory_free_gb = Math.round((freeMem / (1024 ** 3)) * 100) / 100;
101
+ }
102
+ catch {
103
+ // ignore
104
+ }
105
+ // 收集网络接口信息
106
+ try {
107
+ const interfaces = node_os_1.default.networkInterfaces();
108
+ const ips = [];
109
+ const macs = [];
110
+ for (const [, addrs] of Object.entries(interfaces)) {
111
+ if (!addrs)
112
+ continue;
113
+ for (const addr of addrs) {
114
+ if (addr.family === 'IPv4' && !addr.address.startsWith('127.') && !addr.address.startsWith('169.254.')) {
115
+ ips.push(addr.address);
116
+ }
117
+ if (addr.mac && addr.mac !== '00:00:00:00:00:00') {
118
+ macs.push(addr.mac);
119
+ }
120
+ }
121
+ }
122
+ if (ips.length > 0) {
123
+ info.ip_address = ips[0];
124
+ }
125
+ if (macs.length > 0) {
126
+ info.mac_address = macs[0];
127
+ }
128
+ }
129
+ catch {
130
+ // ignore
131
+ }
132
+ // 收集平台特定信息
133
+ try {
134
+ const platform = node_os_1.default.platform();
135
+ if (platform === 'win32') {
136
+ info.platform_version = node_os_1.default.release();
137
+ }
138
+ else if (platform === 'darwin') {
139
+ info.platform_version = node_os_1.default.release();
140
+ }
141
+ else if (platform === 'linux') {
142
+ info.platform_version = node_os_1.default.release();
143
+ }
144
+ }
145
+ catch {
146
+ // ignore
147
+ }
148
+ // 收集Node.js版本
149
+ try {
150
+ info.node_version = process.version;
151
+ }
152
+ catch {
153
+ // ignore
154
+ }
155
+ // 收集运行时信息
156
+ try {
157
+ const uptime = node_os_1.default.uptime();
158
+ info.system_uptime_seconds = Math.round(uptime);
159
+ }
160
+ catch {
161
+ // ignore
162
+ }
84
163
  return info;
85
164
  }
package/dist/types.d.ts CHANGED
@@ -8,10 +8,16 @@ export interface DeviceInfo {
8
8
  mac_address?: string;
9
9
  ip_address?: string;
10
10
  cpu_count?: number;
11
+ cpu_model?: string;
11
12
  cpu_freq_mhz?: number;
12
13
  memory_total_gb?: number;
14
+ memory_free_gb?: number;
13
15
  disk_total_gb?: number;
16
+ platform_version?: string;
17
+ node_version?: string;
18
+ system_uptime_seconds?: number;
14
19
  username?: string;
20
+ software_version?: string;
15
21
  }
16
22
  export interface AuthResult {
17
23
  authorized: boolean;
@@ -49,6 +55,7 @@ export interface CacheRecord {
49
55
  export interface AuthClientConfig {
50
56
  serverUrl: string;
51
57
  softwareName: string;
58
+ softwareVersion?: string;
52
59
  deviceId?: string;
53
60
  deviceInfo?: DeviceInfo;
54
61
  clientSecret?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "py-auth-client",
3
- "version": "0.0.1",
3
+ "version": "0.1.3",
4
4
  "description": "TypeScript/Node.js client for py-auth (compatible with Python/Go clients)",
5
5
  "keywords": [
6
6
  "auth",